ソースを参照

住院问卷也发放优惠券

lighter 1 年間 前
コミット
b647862cfa

+ 1 - 1
src/router/index.js

@@ -422,7 +422,7 @@ export const constantRoutes = [
     }
   },
   {
-    path: '/resultSuccess',
+    path: '/resultSuccess/:title?/:subtitle?',
     name: 'resultSuccess',
     component: () => import('../views/public-pages/ResultSuccess.vue'),
     meta: {

+ 33 - 10
src/views/hospital-service/assessments/InpatientSatisfiedAssessment.vue

@@ -172,8 +172,15 @@ import {onMounted, reactive, ref} from "vue";
 import {submitInpatientSatisfiedAssessment} from '../../../api/assessments'
 import {showToast} from "vant";
 import {useRouter} from "vue-router";
+import {receiveAssessmentGift} from "../../../api/coupon";
 
 const router = useRouter()
+
+const routerValue = router.currentRoute.value
+const routerParams = routerValue.params.visitId
+const couponGift = routerValue.path.indexOf('inpatientSatisfiedByPush') > -1
+    && routerParams.indexOf('AND') > -1
+
 const answer = reactive({
   inpatientNo: null,
   times: null,
@@ -284,13 +291,30 @@ const submitAnswer = () => {
   }
   submitInpatientSatisfiedAssessment(answer).then(() => {
     disableSubmitButton.value = true
-    router.push({
-      name: 'resultSuccess',
-      params: {
-        title: '提交成功',
-        subtitle: '感谢您的评价,您的意见对我们非常重要。',
-      },
-    })
+    if (couponGift) {
+      receiveAssessmentGift(routerParams).then((res) => {
+        showToast({
+          message: res,
+          position: 'top',
+          duration: 3000,
+        })
+        gotoResult()
+      }).catch(() => {
+        gotoResult()
+      })
+    } else {
+      gotoResult()
+    }
+  })
+}
+
+const gotoResult = () => {
+  router.push({
+    name: 'resultSuccess',
+    params: {
+      title: '提交成功',
+      subtitle: '感谢您的评价,您的意见对我们非常重要。',
+    },
   })
 }
 
@@ -372,12 +396,11 @@ function getOptions(key) {
 }
 
 onMounted(() => {
-  let visitId = router.currentRoute.value.params.visitId
-  let visitIdArr = visitId.split('AND')
+  let visitIdArr = routerParams.split('AND')
   if (visitIdArr.length < 3) {
     answer.inpatientNo = 'unknown'
     answer.times = 0
-    answer.patientId = visitId
+    answer.patientId = routerParams
   } else {
     answer.inpatientNo = visitIdArr[0]
     answer.times = visitIdArr[1]