Commit 1e2ada3f authored by Facius's avatar Facius

feat: 接入支付宝

parent 91ad6dc5
Pipeline #5699 canceled with stages
...@@ -35,18 +35,20 @@ ...@@ -35,18 +35,20 @@
data() { data() {
return { return {
show: false, show: false,
list: [{ list: [ {
image: '/static/image/mine/weixinzhifu@3x.png', image: '/static/image/mine/zhifubaozhifu@3x.png',
title: '微信支付', title: '支付宝',
select: true, select: true,
provider: 'wxpay' provider: 'alipay',
channel: 'ALIPAY'
}, },
// { {
// image: '/static/images/mine/zhifubaozhifu@3x.png', image: '/static/image/mine/weixinzhifu@3x.png',
// title: '支付宝', title: '微信支付',
// select: false, select: false,
// provider: 'alipay', provider: 'wxpay',
// }, channel: 'WX'
}
] ]
} }
}, },
...@@ -67,13 +69,13 @@ ...@@ -67,13 +69,13 @@
// }); // });
// return // return
// } // }
// for (var item of this.list) { for (var item of this.list) {
// if (item.provider == provider) { if (item.provider == provider) {
// item.select = !item.select item.select = !item.select
// } else { } else {
// item.select = false item.select = false
// } }
// } }
}, },
changeVisibleValue(val) { changeVisibleValue(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
...@@ -82,8 +84,13 @@ ...@@ -82,8 +84,13 @@
this.changeVisibleValue(false) this.changeVisibleValue(false)
}, },
handleClickBuy() { handleClickBuy() {
this.$emit('click') for (var item of this.list) {
this.changeVisibleValue(false) if (item.select) {
this.$emit('buy', item)
this.changeVisibleValue(false)
break
}
}
} }
}, },
} }
......
...@@ -111,6 +111,9 @@ ...@@ -111,6 +111,9 @@
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appid" : "wxf0a780908851623f", "appid" : "wxf0a780908851623f",
"UniversalLinks" : "https://kaying.cc/uni-universallinks/__UNI__EDB8C7C/" "UniversalLinks" : "https://kaying.cc/uni-universallinks/__UNI__EDB8C7C/"
},
"alipay" : {
"__platform__" : [ "ios", "android" ]
} }
}, },
"share" : { "share" : {
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
</view> </view>
</view> </view>
<view v-if="!hidePay" class="bottom-view"><button class="buy-button" @tap="$u.throttle(handleClickBuy, 500)">立即购买</button></view> <view v-if="!hidePay" class="bottom-view"><button class="buy-button" @tap="$u.throttle(handleClickBuy, 500)">立即购买</button></view>
<BottomPay :visible.sync="showPayBottom" @click="$u.throttle(getPaymentInfo, 500)" /> <BottomPay :visible.sync="showPayBottom" @buy="handleClickBottom" />
</view> </view>
</template> </template>
...@@ -219,10 +219,14 @@ export default { ...@@ -219,10 +219,14 @@ export default {
this.showPayBottom = true; this.showPayBottom = true;
} }
} else { } else {
this.getPaymentInfo(); this.getPaymentInfo({channel: 'WX',provider: 'wxpay'});
} }
}, },
async getPaymentInfo() { handleClickBottom(item) {
this.getPaymentInfo(item)
},
async getPaymentInfo(item) {
console.log('-------getPaymentInfo--------', item)
uni.showLoading({ uni.showLoading({
title: '正在获取订单信息' title: '正在获取订单信息'
}); });
...@@ -230,17 +234,19 @@ export default { ...@@ -230,17 +234,19 @@ export default {
goodsId: this.selected.id, goodsId: this.selected.id,
loginChannel: this.loginChannel, loginChannel: this.loginChannel,
authType: this.authType, authType: this.authType,
payChannel: this.platform == '4' && this.isIOS ? 'APPLEPAY' : 'WX' payChannel: this.platform == '4' && this.isIOS ? 'APPLEPAY' : item.channel
}; };
console.log('-------params-------',params)
try { try {
let { data } = await getOrderInfo(params); let { data } = await getOrderInfo(params);
this.startPay(data); console.log('-------getOrderInfos-------',data)
this.startPay(data,item.provider);
} catch (e) { } catch (e) {
this.showToast('获取订单信息失败'); this.showToast('获取订单信息失败');
//TODO handle the exception //TODO handle the exception
} }
}, },
startPay(charge) { startPay(charge,provider) {
uni.showLoading({ uni.showLoading({
title: '支付中' title: '支付中'
}); });
...@@ -263,7 +269,7 @@ export default { ...@@ -263,7 +269,7 @@ export default {
orderInfo: charge.orderInfo, orderInfo: charge.orderInfo,
// #endif // #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
provider: this.isIOS ? 'appleiap' : 'wxpay', provider: this.isIOS ? 'appleiap' : provider,
manualFinishTransaction: this.isIOS ? true : false, manualFinishTransaction: this.isIOS ? true : false,
orderInfo: charge.orderInfo, orderInfo: charge.orderInfo,
// #endif // #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment