Ver Fonte

fix: 优化优惠券相关逻辑,更新优惠券状态显示,移除冗余代码

laiqi há 1 ano atrás
pai
commit
f0f23dd8d2

+ 3 - 1
src/hooks/useRequest.ts

@@ -37,8 +37,10 @@ export default function useRequest<T>(
             return data.value
 
           case -1:
+            data.value = res as UnwrapRef<T>
             error.value = true
-            throw new Error(res.Message)
+            return data.value
+          // throw new Error(res.Message)
 
           default:
             break

+ 2 - 2
src/pages-sub/user/index.vue

@@ -191,7 +191,7 @@ import { useToast } from 'wot-design-uni'
 // CREATE TABLE `users` (
 //   `usersid` varchar(50) NOT NULL COMMENT '用户id',
 //   `usersname` varchar(50) DEFAULT NULL COMMENT '用户名称',
-//   `usersnature` varchar(50) DEFAULT NULL COMMENT '用户性质(用户/渠道)',
+//   `usersnature` varchar(50) DEFAULT NULL COMMENT '用户性质(购机者/经销商)',
 //   `userssuperiorid` varchar(50) DEFAULT NULL COMMENT '用户关联上级id',
 
 //   `usersidcardnumber` varchar(50) DEFAULT NULL COMMENT '用户证件号码',
@@ -222,7 +222,7 @@ import { useToast } from 'wot-design-uni'
 // ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户信息';
 
 const model = reactive({
-  usersnature: '用户',
+  usersnature: '购机者',
   usersname: '',
   userstype: '个人',
   usersidcardnumber: '',

+ 68 - 6
src/pages/coupon/index.vue

@@ -14,12 +14,41 @@
       <view class="sticky-box-content w-100vw" v-if="couponList.length">
         <view class="coupon-list">
           <view class="coupon-item" v-for="item in couponList" :key="item.coupon2id">
+            <!-- 优惠劵标题 -->
             <view class="coupon-header">
               <text class="coupon-code">券码: {{ item.coupon2code }}</text>
-              <wd-tag :type="item.coupon2isused ? 'primary' : 'success'" custom-class="status-tag">
-                {{ item.coupon2isused ? '已使用' : '未使用' }}
-              </wd-tag>
+              <view class="flex items-center gap-2">
+                <wd-tag
+                  :type="
+                    item.coupon2sype === 0
+                      ? 'warning'
+                      : item.coupon2sype === 1
+                        ? 'success'
+                        : item.coupon2sype === 2
+                          ? 'danger'
+                          : 'default'
+                  "
+                  custom-class="status-tag"
+                >
+                  {{
+                    item.coupon2sype === 0
+                      ? '审核中'
+                      : item.coupon2sype === 1
+                        ? '审核通过'
+                        : item.coupon2sype === 2
+                          ? '审核失败'
+                          : '未知状态'
+                  }}
+                </wd-tag>
+                <wd-tag
+                  :type="item.coupon2isused ? 'primary' : 'success'"
+                  custom-class="status-tag"
+                >
+                  {{ item.coupon2isused ? '已使用' : '未使用' }}
+                </wd-tag>
+              </view>
             </view>
+            <!-- 优惠劵信息 -->
             <view class="coupon-content">
               <view class="coupon-info">
                 <text>券名: {{ item.coupon2mc || '暂无券名' }}</text>
@@ -28,7 +57,21 @@
                 <text>产品: {{ item.productsname || '暂无产品信息' }}</text>
               </view>
               <view class="coupon-info">
-                <text>添加时间: {{ formatDate(item.coupon2adddatetime) }}</text>
+                <text>领劵时间: {{ formatDate(item.coupon2adddatetime) }}</text>
+              </view>
+              <view class="coupon-info" v-if="item.coupon2sype === 2">
+                <text>审核备注: {{ item.coupon2shbz || '暂无审核备注' }}</text>
+              </view>
+            </view>
+            <!-- 优惠劵下单 -->
+            <view
+              class="coupon-footer flex justify-end"
+              v-if="item.coupon2sype === 1 && !item.coupon2isused"
+            >
+              <view>
+                <wd-button type="primary" size="small" @click="handleCouponOrder(item)">
+                  优惠劵下单
+                </wd-button>
               </view>
             </view>
           </view>
@@ -57,17 +100,19 @@
 import { ref } from 'vue'
 import { useCouponStore } from '@/store/coupon'
 import { useAppStore } from '@/store/app'
+import { useMessage } from 'wot-design-uni'
+import dayjs from 'dayjs'
 
 const appStore = useAppStore()
 const couponStore = useCouponStore()
 const couponList = ref([])
 const overlayShow = ref(false)
+const message = useMessage()
 
 // 格式化日期
 function formatDate(dateStr) {
   if (!dateStr) return '--'
-  const date = new Date(dateStr)
-  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
+  return dayjs(dateStr).format('YYYY-MM-DD HH:mm:ss')
 }
 
 function handleBack() {
@@ -90,6 +135,23 @@ onLoad(() => {
       overlayShow.value = false
     })
 })
+
+// 优惠劵下单
+function handleCouponOrder(item) {
+  if (item.coupon2sype !== 1) {
+    message.alert({
+      title: '提示',
+      msg: '优惠券未审核通过',
+    })
+    return
+  }
+
+  console.log(item)
+
+  uni.navigateTo({
+    url: `/pages/form/formStep4?productsid=${item.coupon2productids}&couponcode=${item.coupon2code}&usersid=${item.coupon2merchantid}`,
+  })
+}
 </script>
 
 <style lang="scss" scoped>

+ 43 - 40
src/pages/form/formStep3.vue

@@ -82,10 +82,10 @@
     </view>
 
     <!-- 下单 -->
-    <!-- 立即下单按钮 -->
-    <view class="fixed-bottom bg-white p-4 border-t border-gray-100">
+    <!-- 立即下单按钮 2025-05-20 16:38:45 要求取消-->
+    <!-- <view class="fixed-bottom bg-white p-4 border-t border-gray-100">
       <wd-button type="primary" block size="large" @tap="handleOrder">立即下单</wd-button>
-    </view>
+    </view> -->
 
     <!-- 手机号输入弹窗 (已移除) -->
 
@@ -114,10 +114,10 @@ const productInfo = ref<any>(null) // 产品详情
 const overlayShow = ref(false) // 加载状态
 const coupons = ref<any[]>([]) // 可用优惠券列表
 const couponChoose = ref('') // 选择的优惠券ID
-const submitLoading = ref(false) // 提交订单loading
+// const submitLoading = ref(false) // 提交订单loading
 
 // 跳转到领取优惠券页面
-function navigateToReceiveCoupon() {
+async function navigateToReceiveCoupon() {
   if (!coupons.value || coupons.value.length === 0) {
     message.alert({
       msg: '暂无可用优惠券可领取',
@@ -134,9 +134,12 @@ function navigateToReceiveCoupon() {
     return
   }
 
+  // 获取token
+  await appStore.getTokenSilently()
+
   // 跳转到 formStep3a.vue 页面
   uni.navigateTo({
-    url: `/pages/form/formStep3a?productsid=${productsid.value}&couponid=${couponChoose.value}`,
+    url: `/pages/form/formStep3a?productsid=${productsid.value}&couponid=${couponChoose.value}&usersid=${usersid.value}`,
   })
 }
 
@@ -161,39 +164,39 @@ async function getCouponList() {
   }
 }
 
-// 立即下单
-function handleOrder() {
-  // 检查登录状态
-  if (!appStore.isLoginState) {
-    // 未登录状态,显示确认框
-    message
-      .confirm({
-        title: '提示',
-        msg: '请先登录后再进行下单操作',
-        confirmButtonText: '去登录',
-        cancelButtonText: '取消',
-      })
-      .then(() => {
-        // 用户点击确认,跳转到登录页面
-        // 保存当前页面路径用于登录后回跳
-        const currentPage = getCurrentPages()[getCurrentPages().length - 1].route
-        const queryParams = `?usersid=${usersid.value}&productsid=${productsid.value}`
-        const redirectPath = `/${currentPage}${queryParams}`
-
-        uni.navigateTo({
-          url: `/pages-sub/auth/index?redirect=${encodeURIComponent(redirectPath)}`,
-        })
-      })
-      .catch(() => {
-        // 取消操作,不做任何处理
-      })
-  } else {
-    // 已登录状态,跳转到订单确认页面
-    uni.navigateTo({
-      url: `/pages/form/formStep4?usersid=${usersid.value}&productsid=${productsid.value}`,
-    })
-  }
-}
+// // 立即下单
+// function handleOrder() {
+//   // 检查登录状态
+//   if (!appStore.isLoginState) {
+//     // 未登录状态,显示确认框
+//     message
+//       .confirm({
+//         title: '提示',
+//         msg: '请先登录后再进行下单操作',
+//         confirmButtonText: '去登录',
+//         cancelButtonText: '取消',
+//       })
+//       .then(() => {
+//         // 用户点击确认,跳转到登录页面
+//         // 保存当前页面路径用于登录后回跳
+//         const currentPage = getCurrentPages()[getCurrentPages().length - 1].route
+//         const queryParams = `?usersid=${usersid.value}&productsid=${productsid.value}`
+//         const redirectPath = `/${currentPage}${queryParams}`
+
+//         uni.navigateTo({
+//           url: `/pages-sub/auth/index?redirect=${encodeURIComponent(redirectPath)}`,
+//         })
+//       })
+//       .catch(() => {
+//         // 取消操作,不做任何处理
+//       })
+//   } else {
+//     // 已登录状态,跳转到订单确认页面
+//     uni.navigateTo({
+//       url: `/pages/form/formStep4?usersid=${usersid.value}&productsid=${productsid.value}`,
+//     })
+//   }
+// }
 
 onLoad(async (query) => {
   usersid.value = query.usersid
@@ -218,7 +221,7 @@ onLoad(async (query) => {
   }
 
   :deep(.wd-cell__value) {
-    @apply text-gray-800 text-sm whitespace-nowrap;
+    @apply text-gray-800 text-sm;
   }
 }
 

+ 32 - 123
src/pages/form/formStep3a.vue

@@ -15,7 +15,7 @@
         <view class="ml-2 flex-1 h-px bg-gray-100"></view>
       </view>
       <view class="rules-text text-sm text-gray-600 space-y-1">
-        <view>1. 优惠券发放后,有效期为1个月,过期作废;</view>
+        <view>1. 优惠券审核后,有效期为30天,过期作废;</view>
         <view>2. 个人购买者:享受消费优惠券同类型农机不超过2台;</view>
         <view>3. 组织购买者:享受消费优惠券同类型农机不超过10台。</view>
       </view>
@@ -129,37 +129,6 @@
             ]"
             @blur="validatePhone"
           />
-
-          <!-- 验证码 -->
-          <wd-cell
-            title="验证码"
-            title-width="100px"
-            prop="smsCode"
-            required
-            custom-class="custom-cell"
-            vertical-align="center"
-          >
-            <view class="flex items-center flex-1">
-              <wd-input
-                v-model="formData.smsCode"
-                placeholder="请输入验证码"
-                clearable
-                no-border
-                custom-style="flex:1;"
-                :rules="[{ required: true, message: '请输入验证码' }]"
-              />
-              <wd-button
-                size="small"
-                type="primary"
-                plain
-                @click="getSmsCode"
-                :disabled="smsCodeDisabled || !isPhoneValid"
-                custom-style="margin-left: 10px;"
-              >
-                {{ smsCodeButtonText }}
-              </wd-button>
-            </view>
-          </wd-cell>
         </wd-cell-group>
       </wd-form>
     </view>
@@ -190,8 +159,9 @@ import UploadComponent from '@/components/UploadComponent.vue'
 const couponStore = useCouponStore()
 const message = useMessage()
 
-const productsid = ref('')
-const couponid = ref('')
+const productsid = ref('') // 产品id
+const couponid = ref('') // 优惠券(主劵)id
+const usersid = ref('') // 用户id(销售点userid)
 
 const formRef = ref<any>()
 const formData = reactive({
@@ -199,9 +169,6 @@ const formData = reactive({
   usersname: '', // 姓名或企业名称
   idNumber: '', // 证件号
 
-  // 移除旧的idPhoto字段,替换为文件上传相关字段
-  // idPhoto: '', // 证件照片
-
   // 身份证照片(个人用户)
   idCardFiles: [], // 身份证照片文件列表
   idCardIds: [], // 身份证照片ID列表
@@ -211,7 +178,6 @@ const formData = reactive({
   businessLicenseIds: [], // 营业执照照片ID列表
 
   phone: '', // 手机号
-  smsCode: '', // 短信验证码
 })
 
 const usersnameLabel = computed(() => (formData.userstype === '个人' ? '姓名' : '企业名称'))
@@ -238,35 +204,6 @@ function validatePhone() {
   }
 }
 
-// 短信验证码相关
-const smsCodeButtonText = ref('获取验证码')
-const smsCodeDisabled = ref(false)
-let countdownTimer: number | null = null
-
-async function getSmsCode() {
-  validatePhone()
-  if (!isPhoneValid.value) {
-    uni.showToast({ title: '请输入正确的手机号码', icon: 'none' })
-    return
-  }
-
-  uni.showToast({ title: '验证码已发送', icon: 'none' })
-  smsCodeDisabled.value = true
-  let countdown = 60
-  smsCodeButtonText.value = `${countdown}s后重试`
-
-  countdownTimer = setInterval(() => {
-    countdown--
-    if (countdown <= 0) {
-      if (countdownTimer) clearInterval(countdownTimer)
-      smsCodeButtonText.value = '获取验证码'
-      smsCodeDisabled.value = false
-    } else {
-      smsCodeButtonText.value = `${countdown}s后重试`
-    }
-  }, 1000)
-}
-
 // 用户类型切换
 function handleUserTypeChange() {
   // 清空相关字段以便用户重新输入和校验
@@ -324,39 +261,44 @@ async function handleSubmit() {
         ? formData.idCardIds.map((item) => item.id).join(',')
         : formData.businessLicenseIds.map((item) => item.id).join(',')
 
-    // 模拟API调用
-    await new Promise((resolve) => setTimeout(resolve, 1500))
-
-    // 调用领取优惠券API - 注意:这里的API参数需要根据您的实际接口调整
-    // await couponStore.receiveCoupon({
-    //   couponid: couponid.value,
-    //   coupon2phone: formData.phone,
-    //   coupon2productids: productsid.value,
-    //   userstype: formData.userstype,
-    //   usersname: formData.usersname,
-    //   idNumber: formData.idNumber,
-    //   fileIds: fileIds, // 上传的文件ID字符串
-    //   smsCode: formData.smsCode,
-    //   // ... 其他可能需要的参数
-    // })
+    // 调用领取优惠券API
+    const res = await couponStore.receiveCouponNew({
+      couponid: couponid.value,
+      userstype: formData.userstype,
+      usersshtyxydm: formData.userstype === '企业' ? formData.idNumber : '',
+      usersidcardnumber: formData.userstype === '个人' ? formData.idNumber : '',
+      usersname: formData.usersname,
+      coupon2productids: productsid.value,
+      coupon2phone: formData.phone,
+      filesid: fileIds, // 上传的文件ID字符串
+      coupon2merchantid: usersid.value,
+      // smsCode: formData.smsCode,
+      // ... 其他可能需要的参数
+    })
+
+    // console.log('领取优惠券API成功', res)  领取优惠券API成功 2025052017584880465552
 
     message
-      .alert({
+      .confirm({
         msg: '优惠券领取成功!',
         title: '提示',
-        confirmButtonText: '确定',
+        confirmButtonText: '使用优惠劵下单',
+        cancelButtonText: '返回到产品页',
       })
       .then(() => {
         // 跳转回formStep3页面
         // 注意:需要确保formStep3页面能够正确处理返回逻辑,比如刷新优惠券列表
+        uni.navigateTo({
+          // url: `/pages/form/formStep4?usersid=${usersid.value}&productsid=${productsid.value}&couponcode=${res}`,  // 跳转到formStep4 下单页面
+          url: `/pages/coupon/index`, // 跳转到优惠劵列表
+        })
+      })
+      .catch(() => {
+        // 取消操作,不做任何处理
         uni.navigateBack()
       })
   } catch (error) {
     console.error('领取优惠券出错:', error)
-    message.alert({
-      msg: '操作失败,请稍后重试',
-      title: '提示',
-    })
   } finally {
     submitLoading.value = false
     overlayShow.value = false
@@ -366,46 +308,13 @@ async function handleSubmit() {
 onLoad(async (query: any) => {
   productsid.value = query.productsid || ''
   couponid.value = query.couponid || ''
+  usersid.value = query.usersid || ''
   // 可以根据 query 中的参数做一些初始化操作
 })
 onUnmounted(() => {
-  if (countdownTimer) {
-    clearInterval(countdownTimer)
-  }
+  // 如果需要清理任何资源,可以在这里添加清理逻辑
 })
 
-// 表单校验规则
-const rules = {
-  userstype: [{ required: true, message: '请选择用户类型' }],
-  usersname: [{ required: true, message: '请输入名称/企业名称' }],
-  idNumber: [{ required: true, message: '请输入证件号' }],
-
-  // 移除旧的idPhoto验证规则
-  // idPhoto: [{ required: true, message: '请上传证件照片' }],
-
-  // 根据用户类型添加自定义验证规则
-  idCardIds: [
-    {
-      required: true,
-      validator: (val) => formData.userstype !== '个人' || (val && val.length > 0),
-      message: '请上传身份证照片',
-    },
-  ],
-  businessLicenseIds: [
-    {
-      required: true,
-      validator: (val) => formData.userstype !== '企业' || (val && val.length > 0),
-      message: '请上传营业执照照片',
-    },
-  ],
-
-  phone: [
-    { required: true, message: '请输入手机号码' },
-    { required: false, pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' },
-  ],
-  smsCode: [{ required: true, message: '请输入验证码' }],
-}
-
 // 将校验规则绑定到form
 onMounted(() => {
   // 初始化其他必要的操作

+ 10 - 1
src/pages/form/formStep4.vue

@@ -199,6 +199,8 @@ const couponStore = useCouponStore()
 // 页面参数
 const usersid = ref('') // 销售网点用户id(渠道id)
 const productsid = ref('') // 产品id
+const couponCode = ref('') // 优惠码
+
 const productInfo = ref<any>(null) // 产品详情
 const overlayShow = ref(false) // 加载状态
 const submitLoading = ref(false) // 提交订单loading
@@ -429,7 +431,14 @@ async function getProductDetail() {
 
 // 页面加载
 onLoad(async (query) => {
-  usersid.value = query.usersid || ''
+  usersid.value = query.usersid || '' // 销售网点id(渠道id)
+  couponCode.value = query.couponcode || '' // 优惠码
+  formData.couponCode = couponCode.value
+
+  // 如果优惠码不为空,触发验证优惠码
+  if (couponCode.value) {
+    await verifyCouponCode()
+  }
 })
 </script>
 

+ 1 - 1
src/pages/index/index.vue

@@ -179,7 +179,7 @@ function handleSwiperChange(e: any) {
 // 网点数据
 const locationList = ref([])
 
-// 获取销售点列表(users表,usersnature=渠道
+// 获取销售点列表(users表,usersnature=经销商
 const getUserList = async () => {
   const userList = await userStore.getSellUserList()
 

+ 2 - 2
src/pages/mine/index.vue

@@ -80,13 +80,13 @@
       </view>
 
       <!-- 设置 -->
-      <view class="menu-item" @click="handleNavigate('/pages/settings/index')">
+      <!-- <view class="menu-item" @click="handleNavigate('/pages/settings/index')">
         <view class="flex items-center">
           <wd-icon name="setting1" class="text-gray-500" />
           <text class="ml-3">设置</text>
         </view>
         <wd-icon name="arrow-right" size="18" class="text-gray-400" />
-      </view>
+      </view> -->
 
       <!-- 关于 -->
       <view class="menu-item" @click="handleNavigate('/pages/about/index')">

+ 34 - 1
src/service/coupon1/index.ts

@@ -13,7 +13,7 @@ export const getCouponListApi = (params: Partial<Coupon1Type>, page: Partial<Lis
   })
 }
 
-/** 领取优惠券 */
+/** 领取优惠券下单tel 旧 已弃用 */
 export const receiveCouponApi = (params: {
   couponid: string
   coupon2phone: string
@@ -26,6 +26,39 @@ export const receiveCouponApi = (params: {
   })
 }
 
+/** 领取优惠券下单tel new */
+export const receiveCouponApiNew = (params: {
+  // smscode: string  // 2025-05-20 16:14:54 要求去掉验证码
+  couponid: string // 优惠券id
+  userstype: string // 个人,企业
+  usersidcardnumber: string // 身份证号
+  usersshtyxydm: string // 企业统一吗
+  usersname: string // 姓名
+  coupon2productids: string // 产品id
+  coupon2phone: string // 手机号
+  filesid: string // 图片id
+  coupon2merchantid: string // 商家id
+}) => {
+  return http.get<any>('/api/nlua/call?pagevalue=98', {
+    couponid: params.couponid,
+    userstype: params.userstype,
+    usersidcardnumber: params.usersidcardnumber,
+    usersshtyxydm: params.usersshtyxydm,
+    usersname: params.usersname,
+    coupon2productids: params.coupon2productids,
+    coupon2phone: params.coupon2phone,
+    filesid: params.filesid,
+    coupon2merchantid: params.coupon2merchantid,
+  })
+}
+
+/** 领取优惠劵,获取验证码 */
+export const getCoupon2smsApi = (params: { coupon2phone: string }) => {
+  return http.get<any>('/api/nlua/call?pagevalue=103', {
+    phone: params.coupon2phone, // 手机号
+  })
+}
+
 /** 获取该用户下,已领取的优惠劵id,用于判断是否可以领取 */
 export const getCoupon2idApi = (
   params: Partial<Coupon2Type> & {

+ 27 - 0
src/store/app.ts

@@ -1,6 +1,7 @@
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
 import dayjs from 'dayjs'
+import { getAuthCode } from '@/service/auth'
 
 const initState = {
   token: '', // 登录token
@@ -53,6 +54,31 @@ export const useAppStore = defineStore(
       }
     }
 
+    /**
+     * 静默获取用户code,然后获取token
+     *
+     */
+    const getTokenSilently = async () => {
+      return new Promise((resolve, reject) => {
+        // 获取code
+        uni.login().then(async ({ errMsg, code }) => {
+          if (errMsg !== 'login:ok') {
+            uni.showToast({ title: '获取code失败', icon: 'none' })
+            return
+          }
+          // 获取token
+          const { Data, Status } = await getAuthCode(code)
+          if (Status === 0) {
+            const { token, userid, openid } = Data as any
+            setAppInfo({ token, userid, openid })
+            resolve(true)
+          } else {
+            reject(new Error('获取token失败'))
+          }
+        })
+      })
+    }
+
     return {
       appInfo,
       setAppInfo,
@@ -63,6 +89,7 @@ export const useAppStore = defineStore(
       alertCompleteInfo,
       setAlertCompleteInfo,
       needAlertCompleteInDays,
+      getTokenSilently,
     }
   },
   {

+ 48 - 1
src/store/coupon.ts

@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
 import {
   getCouponListApi,
   receiveCouponApi,
+  receiveCouponApiNew,
   getCoupon2idApi,
   getCoupon2ListApi,
 } from '@/service/coupon1'
@@ -24,7 +25,7 @@ export const useCouponStore = defineStore(
       return couponList.value.Data
     }
 
-    // 领取优惠券
+    // 领取优惠券 旧 已弃用
     const receiveCoupon = async ({ couponid, coupon2phone, coupon2productids }) => {
       const { data: couponList, loading } = useRequest(
         () => receiveCouponApi({ couponid, coupon2phone, coupon2productids }),
@@ -37,6 +38,51 @@ export const useCouponStore = defineStore(
       return couponList.value
     }
 
+    // 领取优惠券 new
+    const receiveCouponNew = ({
+      couponid,
+      userstype,
+      usersidcardnumber,
+      usersshtyxydm,
+      usersname,
+      coupon2productids,
+      coupon2phone,
+      filesid,
+      coupon2merchantid,
+    }) => {
+      // eslint-disable-next-line no-async-promise-executor
+      return new Promise(async (resolve, reject) => {
+        const {
+          data: couponList,
+          loading,
+          error,
+        } = useRequest(
+          () =>
+            receiveCouponApiNew({
+              couponid,
+              userstype,
+              usersidcardnumber,
+              usersshtyxydm,
+              usersname,
+              coupon2productids,
+              coupon2phone,
+              filesid,
+              coupon2merchantid,
+            }),
+          {
+            immediate: true,
+          },
+        )
+
+        await until(loading).toBe(false)
+
+        if (error.value) {
+          reject(new Error('领取优惠券失败'))
+        }
+        resolve(couponList.value)
+      })
+    }
+
     // 获取该用户下,已领取的优惠劵id,用于判断是否可以领取
     const getCoupon2id = async (params) => {
       const { data: couponList, loading } = useRequest(() => getCoupon2idApi(params), {
@@ -76,6 +122,7 @@ export const useCouponStore = defineStore(
     return {
       getCouponList,
       receiveCoupon,
+      receiveCouponNew,
       getCoupon2id,
       getCoupon2ViewmList,
       getCoupon2List,

+ 1 - 1
src/store/user.ts

@@ -70,7 +70,7 @@ export const useUserStore = defineStore(
     // 获取销售网点列表
     const getSellUserList = async () => {
       const { data: userList, loading } = useRequest(
-        () => getUserListApi({ usersnature: '渠道' }, { pageindex: 1, rows: 999 }),
+        () => getUserListApi({ usersnature: '经销商' }, { pageindex: 1, rows: 999 }),
         {
           immediate: true,
         },

+ 13 - 0
src/types/coupon2.ts

@@ -5,11 +5,16 @@
 //   `coupon2adddatetime` datetime DEFAULT NULL COMMENT '优惠券申请时间',
 //   `coupon2reviewdatetime` datetime DEFAULT NULL COMMENT '优惠券审核时间',
 //   `coupon2userid` varchar(50) DEFAULT NULL COMMENT '关联申请人id',
+//   `coupon2openid` varchar(50) DEFAULT NULL COMMENT '关联申请人openid',
 //   `coupon2sype` tinyint(2) DEFAULT NULL COMMENT '优惠券(0:申请中,1:审核通过,2:审核失败)',
 //   `coupon2isused` tinyint(2) DEFAULT NULL COMMENT '是否已使用(0:未使用,1:已使用)',
+//   `coupon2merchantid` varchar(50) DEFAULT NULL COMMENT '对应渠道id',
 //   `coupon2productids` varchar(5000) DEFAULT NULL COMMENT '可用产品id',
 //   `coupon2coupon1id` varchar(50) DEFAULT NULL COMMENT '关联主券id',
 //   `coupon2phone` varchar(50) DEFAULT NULL COMMENT '领取手机号',
+//   `coupon2shuser` varchar(50) DEFAULT NULL COMMENT '优惠券审核人',
+//   `coupon2shdate` datetime DEFAULT NULL COMMENT '优惠券审核时间',
+//   `coupon2shbz` varchar(255) DEFAULT NULL COMMENT '优惠券审核备注',
 //   PRIMARY KEY (`coupon2sid`) USING BTREE,
 //   KEY `couponsid` (`coupon2sid`),
 //   KEY `coupon2code` (`coupon2code`)
@@ -37,4 +42,12 @@ export interface Coupon2Type {
   coupon2coupon1id: string
   /** 领取手机号 */
   coupon2phone: string
+  /** 优惠券审核人 */
+  coupon2shuser: string
+  /** 优惠券审核时间 */
+  coupon2shdate: string
+  /** 优惠券审核备注 */
+  coupon2shbz: string
+  /** 对应渠道id */
+  coupon2merchantid: string
 }

+ 2 - 2
src/types/user.ts

@@ -2,7 +2,7 @@
 // CREATE TABLE `users` (
 //   `usersid` varchar(50) NOT NULL COMMENT '用户id',
 //   `usersname` varchar(50) DEFAULT NULL COMMENT '用户名称',
-//   `usersnature` varchar(50) DEFAULT NULL COMMENT '用户性质(用户/渠道)',
+//   `usersnature` varchar(50) DEFAULT NULL COMMENT '用户性质(购机者/经销商)',
 //   `userssuperiorid` varchar(50) DEFAULT NULL COMMENT '用户关联上级id',
 
 //   `usersidcardnumber` varchar(50) DEFAULT NULL COMMENT '用户证件号码',
@@ -37,7 +37,7 @@ export interface UserType {
   usersid: string
   /** 用户名称 */
   usersname: string
-  /** 用户性质(用户/渠道) */
+  /** 用户性质(经销商/购机者) */
   usersnature: string
   /** 用户关联上级id */
   userssuperiorid: string

+ 1 - 1
src/utils/http.ts

@@ -71,7 +71,7 @@ export const http = <T>(options: CustomRequestOptions & { formatData?: boolean }
               if (appStore.isLoginState) {
                 uni.showToast({
                   icon: 'none',
-                  title: Message || '请求错误',
+                  title: Message || 'token已过期,请重新登录',
                   duration: 3000,
                   success: () => {
                     userStore.clearUserInfo()

+ 2 - 1
src/utils/request.ts

@@ -25,7 +25,8 @@ const http = <T>(options: CustomRequestOptions) => {
           // 401错误  -> 清理用户信息,跳转到登录页
           // userStore.clearUserInfo()
           // uni.navigateTo({ url: '/pages/login/login' })
-          reject(res)
+          // reject(res)
+          uni.navigateTo({ url: '/pages-sub/auth/index' })
         } else {
           // 其他错误 -> 根据后端错误信息轻提示
           !options.hideErrorToast &&