Commit 607807d2997f00455827215cf1390c9e5904b811
1 parent
62689239
替换weixinjssdk
Showing
5 changed files
with
20 additions
and
17 deletions
apps/web-payment/index.html
apps/web-payment/package.json
apps/web-payment/src/views/payment/index.vue
| ... | ... | @@ -14,6 +14,7 @@ import { |
| 14 | 14 | import { ElButton, ElDialog, ElIcon, ElMessage, ElRadio } from 'element-plus'; |
| 15 | 15 | import qs from 'qs'; |
| 16 | 16 | import VConsole from 'vconsole'; |
| 17 | +import wx from 'weixin-js-sdk'; | |
| 17 | 18 | |
| 18 | 19 | import { |
| 19 | 20 | getOpenId, |
| ... | ... | @@ -280,12 +281,14 @@ const queryPayment = async () => { |
| 280 | 281 | payee: orderInfoData.value.mchName, |
| 281 | 282 | }; |
| 282 | 283 | const queryString = qs.stringify(params); |
| 283 | - console.log(wx); | |
| 284 | - if (typeof wx !== 'undefined' && wx.miniProgram) { | |
| 284 | + console.log('微信sdk', wx); | |
| 285 | + if (wx !== undefined && wx.miniProgram) { | |
| 285 | 286 | wx.miniProgram.redirectTo({ |
| 286 | 287 | url: `/packageA/pages/wxPay/index?${queryString}`, |
| 287 | 288 | }); |
| 288 | 289 | loading.value = false; |
| 290 | + } else { | |
| 291 | + console.log('wx.miniProgram is not available'); | |
| 289 | 292 | } |
| 290 | 293 | } catch (error) { |
| 291 | 294 | console.log(error); |
| ... | ... | @@ -311,7 +314,7 @@ const queryPayment = async () => { |
| 311 | 314 | const queryString = qs.stringify(pramsData); |
| 312 | 315 | |
| 313 | 316 | // 跳转到微信支付页面 |
| 314 | - if (typeof wx !== 'undefined' && wx.miniProgram) { | |
| 317 | + if (wx !== undefined && wx.miniProgram) { | |
| 315 | 318 | wx.miniProgram.navigateTo({ |
| 316 | 319 | url: `/packageA/pages/wxPay/index?${queryString}`, |
| 317 | 320 | }); | ... | ... |
apps/web-payment/src/views/payment/paySuccess.vue
| ... | ... | @@ -3,6 +3,7 @@ import { onMounted, ref } from 'vue'; |
| 3 | 3 | import { useRoute } from 'vue-router'; |
| 4 | 4 | |
| 5 | 5 | import { ElButton } from 'element-plus'; |
| 6 | +import wx from 'weixin-js-sdk'; | |
| 6 | 7 | |
| 7 | 8 | import EnvironmentDetector from '#/composables/environmentDetector'; |
| 8 | 9 | |
| ... | ... | @@ -19,23 +20,14 @@ const handleBack = () => { |
| 19 | 20 | if (queryData.value.redirectUrl) { |
| 20 | 21 | window.location.href = queryData.value.redirectUrl; |
| 21 | 22 | } else if ( |
| 22 | - typeof jWeixin !== 'undefined' && | |
| 23 | - jWeixin.miniProgram && | |
| 23 | + wx !== undefined && | |
| 24 | + wx.miniProgram && | |
| 24 | 25 | detector.value?.env.isMiniProgram |
| 25 | 26 | ) { |
| 26 | - jWeixin.miniProgram.switchTab({ | |
| 27 | + wx.miniProgram.switchTab({ | |
| 27 | 28 | url: `/pages/newhome/newhome`, |
| 28 | 29 | }); |
| 29 | 30 | } |
| 30 | - // if ( | |
| 31 | - // typeof jWeixin !== 'undefined' && | |
| 32 | - // jWeixin.miniProgram && | |
| 33 | - // detector.value?.env.isMiniProgram | |
| 34 | - // ) { | |
| 35 | - // jWeixin.miniProgram.switchTab({ | |
| 36 | - // url: `/pages/newhome/newhome`, | |
| 37 | - // }); | |
| 38 | - // } | |
| 39 | 31 | }; |
| 40 | 32 | |
| 41 | 33 | onMounted(() => { | ... | ... |
pnpm-lock.yaml
| ... | ... | @@ -892,6 +892,9 @@ importers: |
| 892 | 892 | vue-router: |
| 893 | 893 | specifier: 'catalog:' |
| 894 | 894 | version: 4.6.3(vue@3.5.24(typescript@5.9.3)) |
| 895 | + weixin-js-sdk: | |
| 896 | + specifier: ^1.6.5 | |
| 897 | + version: 1.6.5 | |
| 895 | 898 | devDependencies: |
| 896 | 899 | unplugin-element-plus: |
| 897 | 900 | specifier: 'catalog:' |
| ... | ... | @@ -10612,6 +10615,9 @@ packages: |
| 10612 | 10615 | webpack-virtual-modules@0.6.2: |
| 10613 | 10616 | resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} |
| 10614 | 10617 | |
| 10618 | + weixin-js-sdk@1.6.5: | |
| 10619 | + resolution: {integrity: sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ==} | |
| 10620 | + | |
| 10615 | 10621 | whatwg-encoding@3.1.1: |
| 10616 | 10622 | resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} |
| 10617 | 10623 | engines: {node: '>=18'} |
| ... | ... | @@ -20349,6 +20355,8 @@ snapshots: |
| 20349 | 20355 | |
| 20350 | 20356 | webpack-virtual-modules@0.6.2: {} |
| 20351 | 20357 | |
| 20358 | + weixin-js-sdk@1.6.5: {} | |
| 20359 | + | |
| 20352 | 20360 | whatwg-encoding@3.1.1: |
| 20353 | 20361 | dependencies: |
| 20354 | 20362 | iconv-lite: 0.6.3 | ... | ... |