Explorar o código

关闭支付界面后先查询订单支付状态

lighter %!s(int64=4) %!d(string=hai) anos
pai
achega
8d2f13317d

+ 8 - 0
src/api/wx-jsapi.js

@@ -15,3 +15,11 @@ export function createPayOrder(data) {
     data,
   })
 }
+
+export function queryOrderState(tradeNo) {
+  return request({
+    url: '/wxApi/queryOrderState',
+    method: 'get',
+    params: { tradeNo },
+  })
+}

+ 1 - 7
src/utils/wx-pay.js

@@ -14,13 +14,7 @@ export function wxPay(param, wxPayCallback) {
         totalFee: res.totalFee,
       },
       function (res2) {
-        if (res2.err_msg === 'get_brand_wcpay_request:ok') {
-          wxPayCallback(res, 1)
-        } else if (res2.err_msg === 'get_brand_wcpay_request:cancel') {
-          wxPayCallback(res, 2)
-        } else {
-          wxPayCallback(res, 3)
-        }
+        wxPayCallback(res)
       }
     )
   })

+ 2 - 0
src/views/hospital-service/appointment/Appointment.vue

@@ -40,6 +40,8 @@ export default {
       Cookies.set('activeIndex', val)
     }
     const handleSelectDept = (val) => {
+      Cookies.set('appointmentDeptCode', val.id)
+      Cookies.set('appointmentDeptName', val.text)
       router.push('/selectDoctorAndDate/' + val.id + '/' + val.text)
     }
     return {

+ 19 - 13
src/views/hospital-service/appointment/AppointmentConfirm.vue

@@ -70,7 +70,6 @@ import { computed, onMounted, reactive, ref, watchEffect } from 'vue'
 import Cookies from 'js-cookie'
 import { getGhFee, hasDoneCovidAssessment } from '../../../api/appointment'
 import router from '../../../router'
-import { Dialog } from 'vant'
 export default {
   name: 'AppointConfirm',
   setup() {
@@ -97,20 +96,27 @@ export default {
       return '还可添加' + (5 - patientCards.value.length) + '人'
     })
     const confirmAppointment = () => {
-      hasDoneCovidAssessment(data.appointment.patientId).then((res) => {
-        if (res === 'no valid assessment') {
-          router.push('/assessments/covid/' + data.appointment.patientId)
-        } else {
-          data.appointment.week = data.week
-          patientCards.value.forEach((item) => {
-            if (item.patientId === data.appointment.patientId) {
-              data.appointment.patientName = item.name
-            }
-          })
-          store.commit('SET_APPOINTMENTINFO', data.appointment)
-          router.push('/payAppointmentFee')
+      if (Cookies.get('appointmentDeptCode') !== '1260000') {
+        hasDoneCovidAssessment(data.appointment.patientId).then((res) => {
+          if (res === 'no valid assessment') {
+            router.push('/assessments/covid/' + data.appointment.patientId)
+          } else {
+            toPayPage()
+          }
+        })
+      } else {
+        toPayPage()
+      }
+    }
+    const toPayPage = () => {
+      data.appointment.week = data.week
+      patientCards.value.forEach((item) => {
+        if (item.patientId === data.appointment.patientId) {
+          data.appointment.patientName = item.name
         }
       })
+      store.commit('SET_APPOINTMENTINFO', data.appointment)
+      router.push('/payAppointmentFee')
     }
     const disableGhBtn = ref(true)
     onMounted(() => {

+ 3 - 1
src/views/hospital-service/appointment/DoctorArrangement.vue

@@ -100,6 +100,7 @@ import { getLocalOpenId } from '../../../utils/check-patient-id'
 import { genTextPortrait } from '../../../utils/portrait'
 import { getOneWeekText, getNextSevenDate } from '../../../utils/date'
 import { Toast } from 'vant'
+import Cookies from 'js-cookie'
 export default {
   name: 'DoctorArangement',
   setup() {
@@ -118,7 +119,8 @@ export default {
       qrcode: '',
     })
     const toAppointConfirm = (item) => {
-      item.deptName = data.doctorInfo.deptName
+      item.deptCode = Cookies.get('appointmentDeptCode')
+      item.deptName = Cookies.get('appointmentDeptName')
       item.date = data.date
       store.commit('SET_APPOINTMENTINFO', item)
       router.push('/appointmentConfirm')

+ 21 - 18
src/views/hospital-service/appointment/PayAppointmentFee.vue

@@ -50,6 +50,7 @@ import { saveAppointment } from '../../../api/appointment'
 import { wxPay } from '../../../utils/wx-pay'
 import { Toast } from 'vant'
 import router from '../../../router'
+import { queryOrderState } from '../../../api/wx-jsapi'
 export default {
   name: 'PayAppointmentFee',
   setup() {
@@ -60,25 +61,27 @@ export default {
     const countDownFinish = () => {
       data.disablePayButton = true
     }
-    const wxPayCallback = (res, flag) => {
-      if (flag === 1) {
-        const param = {
-          mzyReqrec: {
-            patientId: data.appointment.patientId,
-            paymode: 'WX',
-            psordnum: res.tradeNo,
-            agtordnum: res.nonceStr,
-          },
-          mzyRequestId: data.appointment.mzyRequestId,
-          totalFee: data.appointment.fee,
+    const wxPayCallback = (res) => {
+      queryOrderState(res.tradeNo).then((tradeState) => {
+        if (tradeState === 'SUCCESS') {
+          const param = {
+            mzyReqrec: {
+              patientId: data.appointment.patientId,
+              paymode: 'WX',
+              psordnum: res.tradeNo,
+              agtordnum: res.nonceStr,
+            },
+            mzyRequestId: data.appointment.mzyRequestId,
+            totalFee: data.appointment.fee,
+          }
+          saveAppointment(param).then((res2) => {
+            Toast.success(res2)
+            router.push('/hospitalService')
+          })
+        } else {
+          Toast.fail('支付失败')
         }
-        saveAppointment(param).then((res2) => {
-          Toast.success(res2)
-          router.push('/hospitalService')
-        })
-      } else {
-        Toast.fail('支付失败')
-      }
+      })
     }
     const pay = () => {
       const param = {

+ 1 - 2
src/views/hospital-service/covid-exam/CheckExamResult.vue

@@ -21,7 +21,6 @@
 
 <script>
 import { onMounted, ref } from 'vue'
-import { isValidIdcard } from '../../../utils/validate'
 import { checkIndexBySocialNo } from '../../../api/check-exam'
 import { Toast } from 'vant'
 import { useRouter } from 'vue-router'
@@ -34,7 +33,7 @@ export default {
     const socialNo = ref(null)
     const list = ref([])
     const startQuery = () => {
-      if (!isValidIdcard(socialNo.value)) {
+      if (!socialNo.value) {
         Toast({
           message: '请输入正确的身份证号码',
           position: 'top',

+ 14 - 11
src/views/hospital-service/inpatient-service/DisplayPrepaid.vue

@@ -63,6 +63,7 @@ import { getLocalOpenId } from '../../../utils/check-patient-id'
 import { wxPay } from '../../../utils/wx-pay'
 import { Toast } from 'vant'
 import { payYjjSuccessful } from '../../../api/inpatient-service'
+import { queryOrderState } from '../../../api/wx-jsapi'
 export default {
   setup() {
     const router = useRouter()
@@ -74,17 +75,19 @@ export default {
     const setPrepaidAmount = (val) => {
       prepaidAmount.value = val
     }
-    const wxPayCallback = (res, flag) => {
-      if (flag === 1) {
-        res.inpatientNo = params.inpatientNo
-        res.admissTimes = params.admissTimes
-        payYjjSuccessful(res).then((res2) => {
-          Toast.success(res2)
-          router.push('/hospitalService')
-        })
-      } else {
-        Toast.fail('支付失败')
-      }
+    const wxPayCallback = (res) => {
+      queryOrderState(res.tradeNo).then((tradeState) => {
+        if (tradeState === 'SUCCESS') {
+          res.inpatientNo = params.inpatientNo
+          res.admissTimes = params.admissTimes
+          payYjjSuccessful(res).then((res2) => {
+            Toast.success(res2)
+            router.push('/hospitalService')
+          })
+        } else {
+          Toast.fail('支付失败')
+        }
+      })
     }
     const pay = () => {
       const param = {

+ 12 - 9
src/views/hospital-service/pay-mz-fee/UnPaidDetail.vue

@@ -47,21 +47,24 @@ import { onMounted, ref } from 'vue'
 import { getLocalOpenId } from '../../../utils/check-patient-id'
 import { wxPay } from '../../../utils/wx-pay'
 import { Toast } from 'vant'
+import { queryOrderState } from '../../../api/wx-jsapi'
 export default {
   name: 'UnPaidDetail',
   setup() {
     const router = useRouter()
     const params = router.currentRoute.value.params
     const fees = ref([])
-    const wxPayCallback = (res, flag) => {
-      if (flag === 1) {
-        saveMzChargeInfo(res.tradeNo, params.hisOrdNum).then((res2) => {
-          Toast.success(res2)
-          router.go(-1)
-        })
-      } else {
-        Toast.fail('支付失败')
-      }
+    const wxPayCallback = (res) => {
+      queryOrderState(res.tradeNo).then((tradeState) => {
+        if (tradeState === 'SUCCESS') {
+          saveMzChargeInfo(res.tradeNo, params.hisOrdNum).then((res2) => {
+            Toast.success(res2)
+            router.go(-1)
+          })
+        } else {
+          Toast.fail('支付失败')
+        }
+      })
     }
     const wechatPay = () => {
       let bodyText = '门诊缴费'