tangning 2 년 전
부모
커밋
f87a55df15
2개의 변경된 파일19개의 추가작업 그리고 30개의 파일을 삭제
  1. 0 28
      src/stores/user.ts
  2. 19 2
      src/views/mobile/index.vue

+ 0 - 28
src/stores/user.ts

@@ -1,32 +1,4 @@
-import { ref, computed } from 'vue'
 import { defineStore } from 'pinia';
-
-// export const useUserStore = defineStore('user', () => {
-//   const token = ref(localStorage.getItem('token'))
-//   const openId = ref(localStorage.getItem('openId'))
-//   const info = ref({
-//     userName: '我的测试',
-//     orderSn: '',
-//   })
-//   const isEur = ref(false)
-//   const getToken = computed(() => token.value || localStorage.getItem('token'))
-//   const getOpenId = computed(() => openId.value || localStorage.getItem('openId'))
-//   function setToken(newToken: string) {
-//     token.value = newToken
-//   }
-//   function setUserOpenId(value:string) {
-//     openId.value = value
-//     localStorage.setItem('openId', value,)
-//   }
-
-//   isEur.value = window.location.hostname.includes('eur')
-//   console.log('setUserOpenId',openId,getOpenId)
-//   return { token, getToken, getOpenId, setToken, info, isEur, openId, setUserOpenId }
-// })
-
-// 想要使用必须先引入 defineStore;
-// 这里我们使用的是es6 的模块化规范进行导出的。
-
 // defineStore 方法有两个参数,第一个参数是模块化名字(也就相当于身份证一样,不能重复)
 
 // 第二个参数是选项,对象里面有三个属性,相比于vuex 少了一个 mutations.

+ 19 - 2
src/views/mobile/index.vue

@@ -100,11 +100,28 @@ function handleType(params: string) {
 function getDetial() {
   getOrderInfo(orderSn.value).then((res) => {
     orderDetal.value = res
-    // if(is_weixn.value){
+    if(res.payStatus != 0){
+      showConfirm({
+        text: res.payStatus === 2 ? '支付失败' : '支付成功',
+        type: res.payStatus === 2 ? 'err' : 'success',
+        callback: () => {
+          handlePayresult(res)
+        }
+      })
+      return
+    }
+    if(is_weixn.value){
       handleWxlogin(res.wxAppId)
-    // }
+    }
   })
 }
+function handlePayresult(item){
+  if(item.orderType == 'incrementOrder'){
+    location.replace(`/mobile.html#/information`)
+  }else{
+    location.replace(`/mobile.html#/payresult/${item.payStatus == 2?'fail':'success'}`)
+  }
+}
 async function handleWxlogin(wxAppId: string) {
   // userStore.setUserOpenId('o3S0L1Hyd3O0vYI2Kr1lFDEtEO2k')
   const code = GetRequest('code')