Przeglądaj źródła

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

lifanagju_citu 7 miesięcy temu
rodzic
commit
6585ff1a0e

+ 2 - 2
src/components/personalRecharge/initPay.vue

@@ -65,7 +65,7 @@ const props = defineProps({
   },
   appId: {
     type: Number,
-    default: 11 // 10为一般情况下支付,11为充值支付
+    default: 8 // 10为一般情况下支付,8为充值支付
   },
 })
 
@@ -91,7 +91,7 @@ const payStatus = async () => {
   // setTimeout(() => { // 测试代码
   // }, 2000)
   try {
-    const data = await getOrderPayStatus({ id: (props.appId - 0) === 11 ? payOrder.value.payOrderId : payOrder.value.id })
+    const data = await getOrderPayStatus({ id: (props.appId - 0) === 8 ? payOrder.value.payOrderId : payOrder.value.id })
     if ((data?.status - 0) === 10) {
       // 支付成功
       if (payStatusTimer.value) clearInterval(payStatusTimer.value); payStatusTimer.value = null

+ 30 - 13
src/components/personalRecharge/pay.vue

@@ -37,7 +37,7 @@
 import QrCode from '@/components/QrCode'
 import { ref, watch, onUnmounted } from 'vue'
 import { definePayTypeList } from '@/utils/payType'
-import { getEnableCodeList } from '@/api/common'
+import { getEnableCodeList, getOrderPayStatus } from '@/api/common'
 const emit = defineEmits(['refreshQrCode'])
 const props = defineProps({
   // 价格
@@ -48,7 +48,7 @@ const props = defineProps({
   // 渠道id
   appId: {
     type: Number,
-    default: 8 // 8:个人微信付款
+    default: 13 // 13:个人微信付款
   },
   // 二维码text
   qrCode: {
@@ -62,6 +62,16 @@ const props = defineProps({
   payChannelCode: {
     type: String,
     default: 'wx_native'
+  },
+  // 过期时间
+  expirationTime: {
+    type: Number,
+    default: -1
+  },
+  // 订单ID
+  orderId: {
+    type: String,
+    default: ''
   }
 })
 
@@ -78,7 +88,7 @@ let _checkPayStatus = checkPayStatus()
 // 计时器
 const initIntervalFun = () => {
 
-  let remainder = 60000*5 // 倒计时五分钟
+  let remainder = props.expirationTime < 0 ? 60000 * 10 : props.expirationTime // 倒计时10分钟(ms)
   if (interTimer) {
     clearInterval(interTimer)
   }
@@ -97,21 +107,29 @@ const initIntervalFun = () => {
 }
 
 // 检测付款状态
-async function checkPayStatus() {
-  let statusLoading = false
-  return async (params) => {
-    if (!statusLoading) {
+/**
+ * WAITING( status: 0,name:"未支付"),
+ * SUCCESS( status: 10name:"支付成功"),
+ * REFUND( status: 20name:"已退款"),
+ * CLOSED(status:30.name:"支付关闭"),//注意:全部退款后,还是 REFUND 状态
+ */
+function checkPayStatus() {
+  let loading = false
+  return async () => {
+    if (loading) {
       return
     }
-    statusLoading = true
+    loading = true
     try {
-      console.log(params)
-      // const { data } = await ApiName
-      // console.log(data)
+      const data = await getOrderPayStatus({ id: props.orderId })
+      console.log(data.status)
+      if (data.status === 10) {
+        emit('paySuccess')
+      }
     } catch (error) {
       console.log(error)
     } finally {
-      statusLoading = false
+      loading = false
     }
   }
 }
@@ -134,7 +152,6 @@ const formatDuration = (remainder) => {
 async function getCodeList () {
   try {
     const list = await getEnableCodeList({appId: props.appId})
-    console.log(list)
     codeList.value = list || []
     if (!codeList.value.length) {
       return

+ 11 - 6
src/views/mall/purchasePackage/components/packageList.js

@@ -3,11 +3,12 @@ const equity = ['VIP会员标识', '简历刷新次数', '简历屏蔽', '优先
 export const packData =  [
   {
     title: '14天双周卡',
-    price: 1, // 128
+    price: 128, // 128
     type: '3',
     spuId: '3', // 编号
     equity,
-    showLength: 3
+    showLength: 3,
+    vipFlag: '14'
   },
   {
     title: '30天月卡',
@@ -15,7 +16,8 @@ export const packData =  [
     type: '4',
     spuId: '4', // 编号
     equity,
-    showLength: 4
+    showLength: 4,
+    vipFlag: '30'
   },
   {
     title: '60天月卡',
@@ -24,7 +26,8 @@ export const packData =  [
     recommend: true,
     spuId: '5', // 编号
     equity,
-    showLength: 5
+    showLength: 5,
+    vipFlag: '60'
   },
   {
     title: '90天月卡',
@@ -32,7 +35,8 @@ export const packData =  [
     type: '6',
     spuId: '6', // 编号
     equity,
-    showLength: 6
+    showLength: 6,
+    vipFlag: '90'
   },
   {
     title: '年度卡',
@@ -41,6 +45,7 @@ export const packData =  [
     type: '7',
     spuId: '7', // 编号
     equity,
-    showLength: 7
+    showLength: 7,
+    vipFlag: '365'
   }
 ]

+ 96 - 23
src/views/mall/purchasePackage/components/packageList.vue

@@ -1,7 +1,8 @@
 <!--  -->
 <template>
   <div class="d-flex mt-5 list">
-    <div v-for="(val, i) in packData" :key="i" class="list-item cursor-pointer" :class="{'active': active === i }" @click="handleClickItem(val, i)">
+    <div v-for="(val, i) in packDataList" :key="i" class="list-item cursor-pointer" :class="{'active': active === i }" @click="handleClickItem(val, i)">
+      <div v-if="val.vipFlag === userStore.userInfo?.vipFlag" class="recommend long">我的套餐</div>
       <div v-if="val.recommend" class="recommend">推荐</div>
       <div class="text-center font-weight-bold">{{ val.title }}</div>
       <div class="text-center my-5">
@@ -11,7 +12,7 @@
           <!-- /年 -->
         </div>
         <div v-if="val.cycle">¥<span class="font-weight-bold font-size-18 font-size-20">{{ val.price }}</span><span class="font-size-14 mr-3">起</span>  {{ val.cycle }}</div>
-        <div v-if="val.customized" class="font-size-20 font-weight-bold">按需定制</div>
+        <!-- <div v-if="val.customized" class="font-size-20 font-weight-bold">按需定制</div> -->
       </div>
       <v-divider></v-divider>
       <div v-if="val.equity">
@@ -24,30 +25,52 @@
         <h3 class="my-3">授权范围:</h3>
         <div class="font-size-15">扫描下方二维码联系高级客户经理为您定制</div>
       </div>
-      <div class="text-center item-btn">
-        <v-btn v-if="!val.customized" color="error" variant="outlined" rounded @click="createOrder(val)">开通会员</v-btn>
+      
+      <div
+        v-if="userStore.userInfo?.vipFlag === val.vipFlag && canUse"
+        style="font-size: 14px;" class="mt-5"
+      >
+        有效期:{{ timesTampChange(userStore.userInfo?.vipExpireDate, 'Y-M-D') }}
+      </div>
+      <div class="text-center item-btn" v-else>
+        <v-btn
+          color="error"
+          variant="outlined"
+          rounded 
+          :loading="val.loading"
+          @click="createOrder(val)"
+        >开通会员</v-btn>
       </div>
     </div>
   </div>
   
   <CtDialog :visible="open" :widthType="1" :footer="false" titleClass="text-h6" title="开通会员" @close="open = false">
     <m-pay
-      :payPrice="100"
+      :payPrice="payPrice"
       :qrCode="qrCode"
       :disabled="disabled"
+      :expirationTime="expirationTime"
+      :payChannelCode="payChannelCode"
+      :orderId="orderId"
       @overdue="handleOverdue"
       @refreshQrCode="refreshQrCode"
+      @paySuccess="paySuccess"
     ></m-pay>
   </CtDialog>
 </template>
 
 <script setup>
+defineOptions({name: 'purchasePackage-packageList'})
 import { packData } from './packageList.js'
-import { ref } from 'vue'
+import { ref, computed } from 'vue'
 // import Snackbar from '@/plugins/snackbar'
 import MPay from '@/components/personalRecharge/pay.vue'
-import { orderCreated, getOrder } from '@/api/common'
-defineOptions({name: 'purchasePackage-packageList'})
+import { orderCreated, getOrder, payOrderSubmit } from '@/api/common'
+import Snackbar from '@/plugins/snackbar'
+import { useUserStore } from '@/store/user'
+import { timesTampChange } from '@/utils/date'
+
+const userStore = useUserStore()
 
 
 const active = ref(2)
@@ -59,49 +82,96 @@ const open = ref(false)
 const disabled = ref(false)
 
 const qrCode = ref('')
+const payChannelCode = ref('wx_native')
+const payPrice = ref(0)
+
+const expirationTime = ref(-1)
+const orderId = ref('')
 
-// const itemInfo = ref(null)
+const canUse = computed(() => {
+  return new Date().getTime() < userStore.userInfo?.vipExpireDate
+})
 
-// 开通会员
-// const handleOpenMembership = (val) => {
-//   console.log(val)
-//   // createOrder()
-//   // open.value = true
-// }
+const packDataList = packData.map((item) => {
+  return {
+    ...item,
+    loading: false
+  }
+}).filter(e => e.vipFlag >= userStore.userInfo?.vipFlag)
 
 // 重新获取订单
-const refreshQrCode = () => {
-  // getOrder(payType)
+const refreshQrCode = (payType) => {
+  payChannelCode.value = payType
 }
 
 // 创建订单
 async function createOrder (val) {
+  val.loading = true
+  payPrice.value = val.price
   try {
-
     const data = await getOrder({
       spuId: val.spuId, // 商品编号
       type: val.type
     })
 
     if (data) {
+      // 获取支付码
+      paymentCode(data)
       return
     }
 
 
-    const orderId = await orderCreated({
+    await orderCreated({
       spuId: val.spuId, // 商品编号
       spuName: val.title, // 商品名称
-      price: val.price, // 价格
+      price: val.price * 100, // 价格
       type: val.type // 订单类型 0平台订单|1求职端订单|2招聘端订单|3用户会员-14天|4用户会员-30天|5用户会员-30天|6用户会员-90天|7用户会员-365天,
     })
-    // 获取二维码
-    console.log(orderId)
+
+    const _data = await getOrder({
+      spuId: val.spuId, // 商品编号
+      type: val.type
+    })
+
+    // 获取支付码
+    
+    paymentCode(_data)
     // qrCode.value = data
   } catch (error) {
-    // console.log(error)
+    console.log(error)
+  } finally {
+    val.loading = false
   }
 }
 
+async function paymentCode (param) {
+  try {
+    const res = await payOrderSubmit({
+      id: param.payOrder.id,
+      channelCode: payChannelCode.value
+    })
+    if (!res?.displayContent) {
+      Snackbar.error('获取支付码失败')
+      return 
+    }
+    orderId.value = param.payOrder.id
+    expirationTime.value = param.payOrder.expireTime - new Date().getTime()
+    // expirationTime.value = param.payOrder.expireTime - _now
+    qrCode.value = res.displayContent
+    open.value = true
+  } catch (error) {
+    console.log(error)
+  }
+}
+
+// 支付成功
+function paySuccess () {
+  Snackbar.success('支付成功')
+  // 更新个人资料
+  userStore.getUserInfos()
+  open.value = false
+}
+
 // 过期
 function handleOverdue () {
   disabled.value = true
@@ -173,6 +243,9 @@ ul li {
   color: #fff;
   text-align: center;
 }
+.long {
+  width: 100px;
+}
 .scanCode {
   border: 1px dashed #ccc;
   border-radius: 10px;

+ 1 - 1
src/views/recruit/personal/PersonalCenter/tradeOrder/index.vue

@@ -47,7 +47,7 @@ getPayChannelCode()
 
 const headers = [
   { title: '商品名称', key: 'spuName', sortable: false },
-  { title: '价格', key: 'price', sortable: false, value: item => item.price + '元' },
+  { title: '价格', key: 'price', sortable: false, value: item => item.price / 100 + '元' },
   { title: '是否已支付', key: 'payStatus', sortable: false, value: item => item.payStatus ? '已支付' : '未支付' },
   { title: '支付订单编号', key: 'payOrderId', sortable: false },
   { title: '支付渠道', key: 'payChannelCode', value: item => channelData.value.find(e => e.value === item.payChannelCode)?.label, sortable: false },