diff --git a/libs/order.js b/libs/order.js index cf84f32..20da3eb 100644 --- a/libs/order.js +++ b/libs/order.js @@ -71,6 +71,7 @@ export function delOrderHandle(orderId) { } export function payOrderHandle(orderId, type, from) { + console.log(orderId, type, from, '支付') return new Promise((resolve, reject) => { uni.showLoading({ title: '加载中' }) payOrder(orderId, type, from) @@ -97,6 +98,10 @@ export function payOrderHandle(orderId, type, from) { weappPay(data.result.jsConfig).then(res => { resolve(data); }); + case "WECHAT_APP_PAY": + weappPay(data.result.jsConfig).then(res => { + resolve(data); + }); } }) .catch(err => { diff --git a/libs/wechat.js b/libs/wechat.js index 4acb0b4..63915a7 100644 --- a/libs/wechat.js +++ b/libs/wechat.js @@ -1,20 +1,47 @@ +import { getProvider } from "@/utils"; + // 支付模块 export const weappPay = (option) => { return new Promise((resolve, reject) => { // 吊起微信支付 - uni.requestPayment({ - ...option, - timeStamp: option.timeStamp + '', - success: (success) => { - uni.showToast({ - title: '支付成功', icon: 'success', duration: 2000 - }); - resolve(success) - }, - fail: (error) => { - uni.showToast({ title: '支付失败', icon: 'none', duration: 2000 }); - reject(error) + getProvider().then(provider => { + let orderInfo = { + ...option, + timeStamp: option.timestamp + '', } + console.log({ + provider: provider, + signType: "MD5", + timeStamp: orderInfo.timestamp, + nonceStr: orderInfo.noncestr, + package: orderInfo.prepayid, + signType: "MD5", + paySign: orderInfo.sign, + orderInfo, + },'发起支付') + // 调用登录接口 + uni.requestPayment({ + provider: provider, + signType: "MD5", + timeStamp: orderInfo.timeStamp, + nonceStr: orderInfo.noncestr, + package: orderInfo.prepayid, + signType: "MD5", + paySign: orderInfo.sign, + orderInfo, + success: (success) => { + console.log(error) + uni.showToast({ + title: '支付成功', icon: 'success', duration: 2000 + }); + resolve(success) + }, + fail: (error) => { + console.log(error) + uni.showToast({ title: '支付失败', icon: 'none', duration: 2000 }); + reject(error) + } + }) }) }) } diff --git a/main.js b/main.js index 34b32da..095619e 100644 --- a/main.js +++ b/main.js @@ -90,8 +90,8 @@ Vue.prototype.$platform = uni.getSystemInfoSync().platform // #ifdef MP-WEIXIN // 微信小程序编译的代码 -Vue.prototype.$deviceType = 'weixin' -store.commit('UPDATE_DEVICETYPE','weixin') +Vue.prototype.$deviceType = 'routine' +store.commit('UPDATE_DEVICETYPE','routine') // #endif // !!! ps 不建议在 template 中使用 $deviceType 去判断当前环境,很有可能出现 $deviceType 为 undefined 导致判断出错的问题,可以在 script 模块中正常使用 diff --git a/manifest.json b/manifest.json index 47ae761..15ffb8b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { - "name" : "yshopmall_uni", - "appid" : "", + "name" : "yshopmall", + "appid" : "__UNI__C7A519E", "description" : "", "versionName" : "1.0.0", - "versionCode" : "100", + "versionCode" : 1, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/authorization/index.vue b/pages/authorization/index.vue index 7064644..41ed92a 100644 --- a/pages/authorization/index.vue +++ b/pages/authorization/index.vue @@ -1,7 +1,7 @@