macmini 1 долоо хоног өмнө
parent
commit
8e638f8fd6

+ 22 - 0
src/api/me.ts

@@ -0,0 +1,22 @@
+import type {
+    couponIssuerApplyByAddResponse,
+    CouponIssuerApplyByIdResponse
+} from '@/api/types/me'
+import { http } from '@/http/alova'
+
+/**
+ *
+ * 发卷人查询审核状态
+ */
+
+export function getCouponIssuerApplyById() {
+    return http.Get<CouponIssuerApplyByIdResponse>('/couponCenter/APP/couponIssuerApply/queryById')
+}
+
+export interface CouponIssuerApplyByAddForm {
+    name: string
+    phone: string
+}
+export function couponIssuerApplyByAdd(couponIssuerApplyByAddForm: CouponIssuerApplyByAddForm) {
+    return http.Post<couponIssuerApplyByAddResponse>('/couponCenter/APP/couponIssuerApply/add', couponIssuerApplyByAddForm)
+}

+ 14 - 0
src/api/types/me.ts

@@ -0,0 +1,14 @@
+export interface CouponIssuerApplyByIdResponse {
+    name: string
+    phone: string
+    status: string
+    applyReason: string
+    auditBy: string
+    auditRemark: string
+    auditTime: string
+}
+
+export interface couponIssuerApplyByAddResponse {
+    name: string
+    phone: string
+}

+ 72 - 55
src/pages-A/applyForm/index.vue

@@ -1,6 +1,18 @@
 <script lang="ts" setup>
-import { reactive, ref } from 'vue'
-import { useUserStore } from '@/store'
+import {
+    useRequest
+} from 'alova/client'
+import {
+    reactive,
+    ref
+} from 'vue'
+import {
+    couponIssuerApplyByAdd,
+    getCouponIssuerApplyById
+} from '@/api/me'
+import {
+    useUserStore
+} from '@/store'
 
 definePage({
     style: {
@@ -10,11 +22,11 @@ definePage({
 
 const userStore = useUserStore()
 
-const model = reactive({
+let model = reactive({
     name: '',
     phone: '',
-    result: '',
-    description: '',
+    status: '0',
+    auditRemark: '',
 })
 const rules = reactive({
     name: {
@@ -31,16 +43,51 @@ const rules = reactive({
         trigger: ['blur', 'change'],
     },
 })
+// 发卷人查询审核状态
+const {
+    send: getCouponIssuerApplyByIdRequest,
+    data: couponIssuerApplyByIdData,
+} = useRequest(getCouponIssuerApplyById, {
+    immediate: false,
+})
+const formResult = ref(null)
+onLoad(async (options) => {
+    await getCouponIssuerApplyByIdRequest()
+    console.log(999999, couponIssuerApplyByIdData.value.status)
+    if (couponIssuerApplyByIdData.value && couponIssuerApplyByIdData.value.status === '1') {
+        formResult.value = couponIssuerApplyByIdData.value
+        model = couponIssuerApplyByIdData.value
+    }
+})
 
 // 使用 ref 创建响应式引用
 const uFormRef = ref(null)
 
+// 发劵人审核-添加
+const {
+    send: couponIssuerApplyByAddRequest,
+    data: couponIssuerApplyByAddData,
+} = useRequest(couponIssuerApplyByAdd, {
+    immediate: false,
+})
+
 function submitForm() {
     uFormRef.value.validate().then((valid) => {
         if (valid) {
-            uni.$u.toast('校验通过')
+            const couponIssuerApplyByAddForm = {
+                name: model.name,
+                phone: model.phone,
+            }
+            couponIssuerApplyByAddRequest(couponIssuerApplyByAddForm).then(() => {
+                // 返回上一页
+                console.log('提交成功:', couponIssuerApplyByAddData)
+                uni.$u.toast('校验通过')
+                uni.navigateBack()
+            }).catch(() => {
+                uni.$u.toast('校验失败')
+            })
         }
-        else {
+    else {
             uni.$u.toast('校验失败')
         }
     }).catch(() => {
@@ -53,65 +100,29 @@ function submitForm() {
 <template>
     <view class="form-container">
         <view class="form-wrapper">
-            <u-form
-                ref="uFormRef"
-                label-position="left"
-                :model="model"
-                :rules="rules"
-            >
-                <u-form-item
-                    ref="item1"
-                    label="申请人姓名"
-                    prop="name"
-                    :border-bottom="true"
-                >
-                    <u-input
-                        v-model="model.name"
-                        border="none"
-                        placeholder="请输入申请人姓名"
-                    />
+            <u-form ref="uFormRef" label-position="left" :model="model" :rules="rules">
+                <u-form-item ref="item1" label="申请人姓名" prop="name" :border-bottom="true">
+                    <u-input v-model="model.name" border="none" placeholder="请输入申请人姓名" />
                 </u-form-item>
-                <u-form-item
-                    ref="item2"
-                    label="电话"
-                    prop="phone"
-                    :border-bottom="true"
-                >
-                    <u-input
-                        v-model="model.phone"
-                        border="none"
-                        placeholder="请输入小程序登录的手机号"
-                    />
+                <u-form-item ref="item2" label="电话" prop="phone" :border-bottom="true">
+                    <u-input v-model="model.phone" border="none" placeholder="请输入小程序登录的手机号" />
                 </u-form-item>
-                <u-form-item
-                    ref="item3"
-                    label="申请结果"
-                    :border-bottom="true"
-                >
-                    <view class="form-item-result u-text-danger">
+                <u-form-item v-if="formResult" ref="item3" label="申请结果" :border-bottom="true">
+                    <view v-if="formResult.status === '2'" class="form-item-result u-text-danger">
                         已拒绝
                     </view>
-                    <view class="form-item-result u-text-success">
+                    <view v-else class="form-item-result u-text-success">
                         已通过
                     </view>
                 </u-form-item>
-                <view class="form-item-des">
-                    <u-form-item
-                        ref="item4"
-                        label="拒绝说明"
-                        :border-bottom="true"
-                    >
-                        <u-textarea
-                            v-model="model.description"
-                            placeholder="此处显示拒绝说明"
-                            border="none"
-                            disabled
-                        />
+                <view v-if="formResult && formResult.status === '2'" class="form-item-des">
+                    <u-form-item ref="item4" label="拒绝说明" :border-bottom="true">
+                        <u-textarea v-model="model.auditRemark" placeholder="此处显示拒绝说明" border="none" disabled />
                     </u-form-item>
                 </view>
             </u-form>
 
-            <view class="form-btn" @click="submitForm">
+            <view v-if="formResult && formResult.status !== '1'" class="form-btn" @click="submitForm">
                 提交申请
             </view>
         </view>
@@ -125,14 +136,17 @@ function submitForm() {
   font-size: 26rpx !important;
   color: #333333 !important;
 }
+
 ::v-deep .u-input__content__field-wrapper__field {
   text-align: right !important;
 }
+
 ::v-deep .u-form-item__body__left__content__label {
   color: #333333 !important;
   font-size: 26rpx !important;
   font-weight: 400 !important;
 }
+
 ::v-deep .u-line {
   border-color: #eeeeee !important;
 }
@@ -141,6 +155,7 @@ function submitForm() {
   display: flex;
   justify-content: flex-end;
 }
+
 .form-container {
   background-color: #f5f5f5;
   min-height: 100vh;
@@ -159,10 +174,12 @@ function submitForm() {
   line-height: 44rpx;
   border-radius: 10rpx;
   text-align: center;
+
   &.u-text-danger {
     color: #ff3333;
     background: rgba(#ff7171, 0.2);
   }
+
   &.u-text-success {
     color: #64a6ff;
     background: rgba(#64a6ff, 0.2);

+ 77 - 48
src/pages/me/me.vue

@@ -1,88 +1,117 @@
 <script lang="ts" setup>
+import { useRequest } from 'alova/client'
 import { storeToRefs } from 'pinia'
 import { ref } from 'vue'
+import { getCouponSituation } from '@/api/home'
+import { getCouponIssuerApplyById } from '@/api/me'
 import { LOGIN_PAGE } from '@/router/config'
 import { useUserStore } from '@/store'
 import { useTokenStore } from '@/store/token'
 
 definePage({
-    style: {
-        navigationBarTitleText: '我的',
-        navigationStyle: 'custom',
-    },
+  style: {
+    navigationBarTitleText: '我的',
+    navigationStyle: 'custom',
+  },
 })
 
 const userStore = useUserStore()
 const tokenStore = useTokenStore()
 // 使用storeToRefs解构userInfo
 const { userInfo } = storeToRefs(userStore)
+const { hasLogin } = storeToRefs(tokenStore)
+console.log('Login:', userInfo.value, hasLogin.value)
+
+// 用户优惠券统计数据
+const { send: getCouponSituationRequest, data: couponSituationData } = useRequest(getCouponSituation, {
+    immediate: false,
+})
+// 发卷人查询审核状态
+const { send: getCouponIssuerApplyByIdRequest, data: couponIssuerApplyByIdData } = useRequest(getCouponIssuerApplyById, {
+    immediate: false,
+})
+onShow(() => {
+    // 登录后查询收益数据
+    if (hasLogin) {
+        getCouponSituationRequest()
+        getCouponIssuerApplyByIdRequest()
+        if (couponIssuerApplyByIdData.value) {
+            console.log('优惠券统计数据:', couponSituationData.value)
+            open()
+        }
+    }
+})
 
 // 微信小程序下登录
 async function handleLogin() {
-    // #ifdef MP-WEIXIN
-    // 微信登录
-    await tokenStore.wxLogin()
+  // #ifdef MP-WEIXIN
+  // 微信登录
+  await tokenStore.wxLogin()
 
-    // #endif
-    // #ifndef MP-WEIXIN
-    uni.navigateTo({
-        url: `${LOGIN_PAGE}`,
-    })
-    // #endif
+  // #endif
+  // #ifndef MP-WEIXIN
+  uni.navigateTo({
+    url: `${LOGIN_PAGE}`,
+  })
+  // #endif
 }
 
 function handleLogout() {
-    uni.showModal({
-        title: '提示',
-        content: '确定要退出登录吗?',
-        success: (res) => {
-            if (res.confirm) {
-                // 清空用户信息
-                useTokenStore().logout()
-                // 执行退出登录逻辑
-                uni.showToast({
-                    title: '退出登录成功',
-                    icon: 'success',
-                })
-                // #ifdef MP-WEIXIN
-                // 微信小程序,去首页
-                // uni.reLaunch({ url: '/pages/index/index' })
-                // #endif
-                // #ifndef MP-WEIXIN
-                // 非微信小程序,去登录页
-                // uni.navigateTo({ url: LOGIN_PAGE })
-                // #endif
-            }
-        },
-    })
+  uni.showModal({
+    title: '提示',
+    content: '确定要退出登录吗?',
+    success: (res) => {
+      if (res.confirm) {
+        // 清空用户信息
+        useTokenStore().logout()
+        // 执行退出登录逻辑
+        uni.showToast({
+          title: '退出登录成功',
+          icon: 'success',
+        })
+        // #ifdef MP-WEIXIN
+        // 微信小程序,去首页
+        // uni.reLaunch({ url: '/pages/index/index' })
+        // #endif
+        // #ifndef MP-WEIXIN
+        // 非微信小程序,去登录页
+        // uni.navigateTo({ url: LOGIN_PAGE })
+        // #endif
+      }
+    },
+  })
 }
 
 // 顶部导航栏高度,设置banner位置
 const navigationBarHeight = ref(0)
 // #ifdef MP-WEIXIN
 function getNavigationBarHeight() {
-    uni.getSystemInfo({
-        success: (res) => {
-            const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
-            console.log('顶部导航栏高度:', res.statusBarHeight, menuButtonInfo)
-            // 顶部导航栏高度 = 状态栏高度 + 胶囊的高度
-            navigationBarHeight.value = res.statusBarHeight + menuButtonInfo.height + 12
-        },
-    })
+  uni.getSystemInfo({
+    success: (res) => {
+      const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
+      console.log('顶部导航栏高度:', res.statusBarHeight, menuButtonInfo)
+      // 顶部导航栏高度 = 状态栏高度 + 胶囊的高度
+      navigationBarHeight.value = res.statusBarHeight + menuButtonInfo.height + 12
+    },
+  })
 }
 getNavigationBarHeight()
 // #endif
 
-const show = ref(true)
+const show = ref(false)
 function close() {
-    show.value = false
+  show.value = false
 }
 function open() {
-    show.value = true
+  show.value = true
 }
 function menuClick(page) {
+    if (couponIssuerApplyByIdData.value?.status === '0') {
+        open()
+        return
+    }
     uni.navigateTo({
-        url: `/pages-A/${page}/index`,
+        url: `/pages-A/${page}/index?couponSituation=${JSON.stringify(couponSituationData.value)}`,
     })
 }
 </script>