tangning 4 hónapja
szülő
commit
2a60914dcb

BIN
src/assets/images/stripe.png


+ 1 - 1
src/stores/user.ts

@@ -7,7 +7,7 @@ export const useUserStore = defineStore('user', {
     return {
       token: localStorage.getItem('token'),
       openId: localStorage.getItem('openId'),
-      isEur: window.location.hostname.includes('eur'),
+      isEur: !window.location.hostname.includes('eur'),
     }
   },
   getters:{ // 相当于vue里面的计算属性,可以缓存数据

+ 31 - 0
src/utils/index.ts

@@ -1,5 +1,7 @@
 import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router';
 import type { App, Plugin } from 'vue';
+import { useUserStore } from '@/stores/user'
+import { useI18n } from 'vue-i18n'
 
 import { unref } from 'vue';
 import { isObject } from '@/utils/is';
@@ -117,3 +119,32 @@ export function GetRequest(value: string) {
   console.log('GetRequest', object)
   return object[value];
 }
+
+//支付备注
+export const getRemark = (list, orderType, t) => {
+  
+// const { locale, t } = useI18n()
+const { isEur } = useUserStore()
+  let str = []
+  list.map(item => {
+    let newStr = ''
+    if (orderType == 'cooperationOrder') {
+      newStr = t('mall.cooperationOrderName',{count: item.count })
+    } else if (orderType == 'downOrder') {
+      newStr = `${item.name} (${item.sceneNum})`
+    } else if (orderType != 'incrementOrder') {
+      newStr = `${locale.value == 'zh' ? item.name : item.nameEn}`
+    } else {
+      newStr = `${item.type == 1 ? t('payInfo.gjhy') : isEur ? t('payInfo.zyhys') : t('payInfo.zyhy')}`
+    }
+    if(orderType != 'cooperationOrder' && orderType != 'downOrder'){
+      newStr += `x ${item.count}` 
+    }
+    
+    if(orderType == 'incrementOrder'){
+      newStr += `,${item.type?t(`payInfo.expirationmon`, { num: item.monthQy || 1 }):t(`payInfo.expiration`, { num: 1 })}` 
+    }
+    str.push(newStr)
+  })
+  return str.join('、')
+}

+ 6 - 0
src/utils/status.ts

@@ -38,4 +38,10 @@ export const showMessage = (status:number|string) : string => {
             message = `连接出错(${status})!`;
     }
     return `${message},请检查网络或联系管理员!`;
+};
+export const paysidtype = {
+    wechatPay: 2,
+    alipay: 3,
+    paypal: 5,
+    stripe: 6
 };

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

@@ -4,7 +4,7 @@ import { ref, computed, onMounted } from 'vue'
 import { useUserStore } from '@/stores/user'
 import { openPay, getOrderInfo, wxLogin } from '@/api/api'
 import { useRoute } from 'vue-router'
-import { GetRequest, getWeChatCode } from '@/utils/index'
+import { GetRequest, getWeChatCode, getRemark } from '@/utils/index'
 import { useI18n } from 'vue-i18n'
 const route = useRoute()
 const orderDetal = ref({
@@ -49,8 +49,9 @@ onMounted(() => {
 async function handelPay() {
   let apiData = {
     orderSn: orderSn.value,
-    payType: isEur ? '5' : is_weixn.value ? '1' : payType.value,
+    payType: is_weixn.value ? '1' : payType.value,
     openId:openId.value,
+    productName: getRemark(orderDetal.value.goodsInfo, orderDetal.value.orderType, t),
   }
   const res = await openPay(apiData)
 
@@ -252,6 +253,13 @@ async function handleOpenPay() {
           </span>
           <div class="select" :class="{ active: payType == '5' }"></div>
         </div>
+        <div class="cell" @click="handleType('6')" v-if="isEur">
+          <span>
+            <img style="height:26px;width:62px" class="payTypeImg" src="@/assets/images/stripe.png" alt="" />
+            <!-- {{$t('payInfo.paypal')}} -->
+          </span>
+          <div class="select" :class="{ active: payType == '6' }"></div>
+        </div>
       </div>
     </div>
     <div class="bottomInfo">

+ 21 - 13
src/views/pc/index.vue

@@ -9,7 +9,8 @@ import QrcodeVue from 'qrcode.vue'
 import { show, showConfirm } from '@/components/Toast'
 import { openPay, queryOrderStatus, getOrderInfo } from '@/api/api'
 import { useRouter, useRoute } from 'vue-router'
-import { GetRequest } from '@/utils/index'
+import { GetRequest, getRemark } from '@/utils/index'
+import { paysidtype } from '@/utils/status'
 import { getCurrentInstance } from 'vue'
 
 //得到i18n的locale token, info,
@@ -19,11 +20,7 @@ const route = useRoute()
 const { isEur, info } = useUserStore()
 const orderSn = ref(route.query.id || GetRequest('orderSn'))
 let { $cdn } = getCurrentInstance()?.proxy
-let PAYSID = {
-  wechatPay: 0,
-  alipay: 1,
-  paypal: 2
-}
+
 const selectedPayType = ref(isEur ? 'paypal' : 'alipay')
 watch(selectedPayType, () => {
   getCode()
@@ -36,7 +33,6 @@ const response = ref({
 })
 onMounted(() => {
   getDetial()
-  getCode()
 })
 
 function inverRequest() {
@@ -77,6 +73,7 @@ async function handleQueryOrderStatus() {
 function getDetial() {
   getOrderInfo(orderSn.value).then((res) => {
     orderDetal.value = res
+    getCode()
   })
 }
 function handlePay() {
@@ -84,14 +81,10 @@ function handlePay() {
 }
 async function getCode() {
   qrCodeUrl.value = ''
-  let paysidtype = {
-    wechatPay: 2,
-    alipay: 3,
-    paypal: 5
-  }
   openPay({
     orderSn: orderSn.value,
     payType: paysidtype[selectedPayType.value],
+    productName: getRemark(orderDetal.value.goodsInfo, orderDetal.value.orderType, t),
     openId: ''
   }).then((res) => {
     qrCodeUrl.value = res.qrCodeUrl || res.redirect
@@ -209,7 +202,22 @@ async function getCode() {
               />
               <h-icon type="vip_true" class="select-icon"></h-icon>
               <img src="@/assets/images/vip_true.svg" class="t-click" alt />
-              <!-- paypal -->
+            </div>
+            
+            <div
+              v-if="isEur"
+              class="pay-type paypal-pay"
+              @click="selectedPayType = 'stripe'"
+              :class="{ 'is-active': selectedPayType === 'stripe' }"
+            >
+              <img
+                style="height: 26px; width: 62px"
+                src="@/assets/images/stripe.png"
+                class="t-icon"
+                alt
+              />
+              <h-icon type="vip_true" class="select-icon"></h-icon>
+              <img src="@/assets/images/vip_true.svg" class="t-click" alt />
             </div>
           </div>
           <div class="pay-info">