|
@@ -2,7 +2,9 @@
|
|
|
<view class="page" v-if="payPriceShow">
|
|
|
<view class="pay-price">
|
|
|
<view class="price">
|
|
|
- <text class="unit">{{$t(`¥`)}}</text>
|
|
|
+ <text class="unit" v-if="paytype!='piPay'">{{$t(`¥`)}}</text>
|
|
|
+ <text class="unit" v-else>Pi</text>
|
|
|
+
|
|
|
<numberScroll :num='payPriceShow' color="#E93323" width='30' height='50' fontSize='50'></numberScroll>
|
|
|
</view>
|
|
|
<view class="count-down">
|
|
@@ -54,11 +56,6 @@
|
|
|
piPayReadSuccess,
|
|
|
piPayCancel
|
|
|
} from '@/api/pi.js'
|
|
|
- //初始化
|
|
|
- Pi.init({
|
|
|
- version: "2.0"
|
|
|
- // ,sandbox: true
|
|
|
- })
|
|
|
export default {
|
|
|
components: {
|
|
|
countDown,
|
|
@@ -103,19 +100,16 @@
|
|
|
title: this.$t(`找微信好友支付`),
|
|
|
payStatus: 1,
|
|
|
},
|
|
|
- {
|
|
|
- "name": this.$t(`PI支付`),
|
|
|
- "icon": "icon-haoyoudaizhifu",
|
|
|
- value: 'piPay',
|
|
|
- title: this.$t(`使用pi支付`),
|
|
|
- payStatus: 1,
|
|
|
- }
|
|
|
],
|
|
|
orderId: 0,
|
|
|
fromType: '',
|
|
|
active: 0,
|
|
|
+ //支付金额
|
|
|
payPrice: 0,
|
|
|
+ // 支付显示的金额
|
|
|
payPriceShow: 0,
|
|
|
+ //pi支付金额
|
|
|
+ piPrice:0,
|
|
|
payPostage: 0,
|
|
|
offlinePostage: false,
|
|
|
invalidTime: 0,
|
|
@@ -146,8 +140,22 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- if (options.order_id) this.orderId = options.order_id
|
|
|
- if (options.from_type) this.fromType = options.from_type
|
|
|
+ //初始化
|
|
|
+ if(Pi){
|
|
|
+ Pi.init({
|
|
|
+ version: "2.0"
|
|
|
+ // ,sandbox: true
|
|
|
+ })
|
|
|
+ this.cartArr.push({
|
|
|
+ "name": this.$t(`PI支付`),
|
|
|
+ "icon": "icon-haoyoudaizhifu",
|
|
|
+ value: 'piPay',
|
|
|
+ title: this.$t(`使用pi支付`),
|
|
|
+ payStatus: 1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (options.order_id){ this.orderId = options.order_id};
|
|
|
+ if (options.from_type){ this.fromType = options.from_type};
|
|
|
this.getBasicConfig()
|
|
|
},
|
|
|
onShow() {
|
|
@@ -224,7 +232,8 @@
|
|
|
});
|
|
|
getCashierOrder(this.orderId, this.fromType).then(res => {
|
|
|
console.log(res)
|
|
|
- this.payPrice = this.payPriceShow = res.data.pay_price
|
|
|
+ this.payPrice = this.payPriceShow = res.data.pay_price;
|
|
|
+ this.piPrice = (+res.data.pi_price)+'';
|
|
|
this.payPostage = res.data.pay_postage
|
|
|
this.offlinePostage = res.data.offline_postage
|
|
|
this.invalidTime = res.data.invalid_time
|
|
@@ -241,6 +250,12 @@
|
|
|
this.active = index;
|
|
|
this.paytype = paytype;
|
|
|
this.number = number;
|
|
|
+
|
|
|
+ if(paytype=='piPay'){
|
|
|
+ this.payPriceShow = this.piPrice;
|
|
|
+ }else{
|
|
|
+ this.payPriceShow = this.payPrice;
|
|
|
+ }
|
|
|
if (this.offlinePostage) {
|
|
|
if (paytype == 'offline') {
|
|
|
this.payPriceShow = this.$util.$h.Sub(this.payPrice, this.payPostage);
|
|
@@ -315,9 +330,9 @@
|
|
|
// window.alert('成功auth' + auth)
|
|
|
Pi.createPayment({
|
|
|
// 支付金额
|
|
|
- amount: 0.0001,
|
|
|
+ amount: that.piPrice,
|
|
|
// 支付说明
|
|
|
- memo: "请求支付", // e.g: "Digital kitten #1234",
|
|
|
+ memo: "请求支付商品Pi币", // e.g: "Digital kitten #1234",
|
|
|
// 用于保存自己要用的数据,后台查询时可获取到
|
|
|
metadata: {
|
|
|
tip: '我来支付了'
|
|
@@ -329,31 +344,46 @@
|
|
|
piPay({
|
|
|
paymentId
|
|
|
}).then((res) => {
|
|
|
- // window.alert('成功'+res)
|
|
|
+ // window.alert('成功'+JSON.parse(res))
|
|
|
}).catch((res) => {
|
|
|
- uni.showModal({
|
|
|
- title: '错误pia',
|
|
|
- content: res,
|
|
|
- showCancel: false,
|
|
|
- success: res => {},
|
|
|
- fail: () => {},
|
|
|
- complete: () => {}
|
|
|
- });
|
|
|
+ // window.alert('错误'+JSON.parse(res))
|
|
|
})
|
|
|
},
|
|
|
- // 请求服务器端支付确认
|
|
|
+ // 请求服务器端调起支付成功确认
|
|
|
onReadyForServerCompletion: function(paymentId, txid) {
|
|
|
piPaySuccess({
|
|
|
paymentId,
|
|
|
- txid
|
|
|
- }).then((res) => {}).catch((res) => {
|
|
|
+ txid,
|
|
|
+ orderid:that.orderId
|
|
|
+ }).then((res) => {
|
|
|
+ uni.hideLoading();
|
|
|
+ let goPages = `/pages/goods/order_pay_status/index?order_id=${that.orderId}&msg=${res.msg}&type=3&totalPrice=${this.payPriceShow}&Pi=${that.piPrice}`;
|
|
|
+ // window.alert(ok)
|
|
|
+ if(res.data.status==200){
|
|
|
+ that.$util.Tips({
|
|
|
+ title: that.$t(`支付成功`),
|
|
|
+ icon: 'success'
|
|
|
+ }, {
|
|
|
+ tab: 5,
|
|
|
+ url: goPages
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ return that.$util.Tips({
|
|
|
+ title: res.msg
|
|
|
+ }, {
|
|
|
+ tab: 5,
|
|
|
+ url: goPages
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch((res) => {
|
|
|
+ uni.hideLoading();
|
|
|
+ // let ok = '错误'+JSON.stringify(res)
|
|
|
+ // window.alert(ok)
|
|
|
uni.showModal({
|
|
|
- title: '错误read',
|
|
|
- content: res,
|
|
|
+ title: '错误re',
|
|
|
+ content: JSON.stringify(res),
|
|
|
showCancel: false,
|
|
|
- success: res => {},
|
|
|
- fail: () => {},
|
|
|
- complete: () => {}
|
|
|
});
|
|
|
})
|
|
|
},
|
|
@@ -361,9 +391,17 @@
|
|
|
piPayCancel({
|
|
|
paymentId
|
|
|
}).then((res) => {
|
|
|
- // window.alert('成功'+res)
|
|
|
+ uni.showModal({
|
|
|
+ title: 'onCancel',
|
|
|
+ content: JSON.stringify(res),
|
|
|
+ showCancel: false,
|
|
|
+ });
|
|
|
}).catch((res) => {
|
|
|
- // window.alert('错误can'+res)
|
|
|
+ uni.showModal({
|
|
|
+ title: '错误onCancel',
|
|
|
+ content: JSON.stringify(res),
|
|
|
+ showCancel: false,
|
|
|
+ });
|
|
|
})
|
|
|
},
|
|
|
onError: function(error, payment) {
|
|
@@ -371,9 +409,6 @@
|
|
|
title: '错误',
|
|
|
content: error + (payment ? JSON.stringify(payment) : ''),
|
|
|
showCancel: false,
|
|
|
- success: res => {},
|
|
|
- fail: () => {},
|
|
|
- complete: () => {}
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -382,9 +417,6 @@
|
|
|
title: '错误',
|
|
|
content: error,
|
|
|
showCancel: false,
|
|
|
- success: res => {},
|
|
|
- fail: () => {},
|
|
|
- complete: () => {}
|
|
|
});
|
|
|
});
|
|
|
return
|