支付接口调用
This commit is contained in:
@@ -78,7 +78,43 @@
|
||||
<text style="color: red;">{{emitorderfoodform.couponsPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sixcontent" v-if="listinfo.status == 'unpaid'">
|
||||
<!-- 支付方式 -->
|
||||
<view class="payType">
|
||||
<view class="">
|
||||
支付方式
|
||||
</view>
|
||||
<view class="">
|
||||
<u-radio-group v-model="radiovalue1" iconPlacement="right" :size="28" placement="column">
|
||||
<u-radio activeColor="#ffd158" name="1">
|
||||
<view class="dfs">
|
||||
<image style="width:44rpx;height:44rpx"
|
||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/balance.png" mode="">
|
||||
</image>
|
||||
<text style="font-size: 28rpx;margin-left: 16rpx;">
|
||||
微信支付
|
||||
</text>
|
||||
</view>
|
||||
</u-radio>
|
||||
<view style="margin: 22rpx 0;width: 100%;height: 2rpx;background-color: #E5E5E5;">
|
||||
</view>
|
||||
<u-radio activeColor="#ffd158" name="2">
|
||||
<view class="dfs">
|
||||
<image style="width:44rpx;height:44rpx"
|
||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png" mode="">
|
||||
</image>
|
||||
<text style="font-size: 28rpx;margin-left: 16rpx;">
|
||||
会员卡支付</text>
|
||||
</view>
|
||||
</u-radio>
|
||||
</u-radio-group>
|
||||
<view style="font-weight: 400;font-size: 24rpx;color: #333333;">
|
||||
会员卡余额{{ amountVIP}} <text style="font-weight: 500;font-size: 28rpx;color: #FF4C11;"
|
||||
@click="goRecharge">去充值</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- <view class="sixcontent" >
|
||||
<view class="sixcontentone flex-between">
|
||||
<view class="sixcontent_one">
|
||||
支付方式
|
||||
@@ -96,7 +132,7 @@
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="sixcontenttowitem flex-between" @click="clickselect(2)">
|
||||
<view class="sixcontenttowitem flex-between" @click="clickselect(2)">
|
||||
<view class="sixcontenttowitemone flex-start">
|
||||
<u-icon name="zhifubao" color="#999999" size="26"></u-icon>
|
||||
<text class="sixcontenttowitemonetext">余额支付</text>
|
||||
@@ -105,31 +141,31 @@
|
||||
<u-icon v-if="pay_type == 2" name="checkmark-circle-fill" color="#333333" size="26"></u-icon>
|
||||
<u-icon v-else name="checkmark-circle-fill" color="#999999" size="26"></u-icon>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{height:height}">
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view :style="{height:height}">
|
||||
|
||||
</view>
|
||||
<view class="fixedview">
|
||||
<view class="flex-between">
|
||||
<view class="fixedview_one flex-start">
|
||||
<view class="fixedview_oneone">
|
||||
实付金额:
|
||||
</view>
|
||||
<view class="fixedview_onetow">
|
||||
<text>¥</text>{{listinfo.amount}}
|
||||
</view>
|
||||
<view class="fixedview_onethere" v-if="emitorderfoodform.couponsPrice">
|
||||
以优惠¥{{emitorderfoodform.couponsPrice}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixedview">
|
||||
<view class="flex-between">
|
||||
<view class="fixedview_one flex-start">
|
||||
<view class="fixedview_oneone">
|
||||
实付金额:
|
||||
</view>
|
||||
<view class="fixedview_tow" @click="showpopupclick">
|
||||
立即付款
|
||||
<view class="fixedview_onetow">
|
||||
<text>¥</text>{{listinfo.amount}}
|
||||
</view>
|
||||
<view class="fixedview_onethere" v-if="emitorderfoodform.couponsPrice">
|
||||
以优惠¥{{emitorderfoodform.couponsPrice}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixedview_tow" @click="showpopupclick">
|
||||
立即付款
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -139,7 +175,7 @@
|
||||
return {
|
||||
height: '',
|
||||
pay_type: 1,
|
||||
info: {},
|
||||
listinfoid: '',
|
||||
listinfo: {
|
||||
detailList: [],
|
||||
amount: '',
|
||||
@@ -147,22 +183,29 @@
|
||||
},
|
||||
emitorderfoodform: {
|
||||
clickiconone: ''
|
||||
}
|
||||
},
|
||||
amountVIP:0,
|
||||
radiovalue1: '1',
|
||||
vipId:null,
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
uni.$off('createOrdermessage')
|
||||
uni.$off('getMessage')
|
||||
},
|
||||
onLoad(e) {
|
||||
console.log(e, 140)
|
||||
// console.log(e, 140)
|
||||
let res = JSON.parse(e.tableId)
|
||||
// .toFixed(2)
|
||||
this.listinfo.detailList = res
|
||||
this.listinfo.amount = e.amount
|
||||
this.listinfo.amounts = e.amount
|
||||
this.listinfo.amount = e.amount // 算完了的价格
|
||||
this.listinfo.amounts = e.amount //本来的价格
|
||||
this.handlemessage()
|
||||
// uni.$on('createOrdermessage', this.creategetMessage)
|
||||
uni.$on('message', this.getMessage)
|
||||
|
||||
|
||||
this.amountVIP = uni.cache.get('userInfo').amount
|
||||
this.vipId = uni.cache.get('userInfo').id
|
||||
},
|
||||
onShow() {
|
||||
|
||||
@@ -182,18 +225,21 @@
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
creategetMessage(msg) {
|
||||
getMessage(msg) {
|
||||
console.log('tiaoshi1', msg)
|
||||
if (msg.status != 'success') {
|
||||
uni.showToast({
|
||||
title: msg.msg,
|
||||
icon: "none",
|
||||
})
|
||||
this.socketTicket.Close()
|
||||
uni.$off('createOrdermessage')
|
||||
uni.$off('getMessage')
|
||||
return false;
|
||||
} else {
|
||||
switch (msg.type) {
|
||||
case 'createOrder': //去结算
|
||||
console.log('tiaoshi2', msg)
|
||||
this.listinfoid = msg.data.id //下单需要的id
|
||||
this.showpopupclickdd()
|
||||
// let item = JSON.stringify(msg.data)
|
||||
// uni.redirectTo({
|
||||
@@ -206,7 +252,7 @@
|
||||
handlemessage() {
|
||||
this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
|
||||
this.socketTicket = new webSocketUtils(
|
||||
`${uni.conf.baseUrlwws}/websocket/table/${this.tableCode}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
|
||||
`${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
|
||||
5000)
|
||||
|
||||
},
|
||||
@@ -223,14 +269,6 @@
|
||||
|
||||
})
|
||||
},
|
||||
async ordercreatOrder() {
|
||||
let res = await this.api.ordercreatOrder({
|
||||
tableId: this.info.tableId,
|
||||
shopId: this.info.shopId,
|
||||
userId: this.info.userId
|
||||
})
|
||||
this.listinfo = res.data
|
||||
},
|
||||
copyHandle(e) {
|
||||
uni.setClipboardData({
|
||||
data: e,
|
||||
@@ -244,30 +282,42 @@
|
||||
},
|
||||
async paymodfiyOrderInfo() {
|
||||
let res = await this.api.paymodfiyOrderInfo({
|
||||
orderId: this.listinfo.id
|
||||
orderId: this.listinfoid
|
||||
})
|
||||
},
|
||||
// 去结算
|
||||
showpopupclick() {
|
||||
|
||||
let data = { //定义socket数据传参
|
||||
"skuId": '',
|
||||
"num": '', //数量
|
||||
"type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
"couponsId": this.emitorderfoodform.id ? this.emitorderfoodform.id : '', //优惠券ID,
|
||||
"isYhq": this.emitorderfoodform.id ? 1 : 0, // 是否使用优惠券( 1: 使用, 0: 不使用),
|
||||
"isBuyYhq": this.emitorderfoodform.clickiconone == 1 ? 1 : 0, // 是否购买优惠券( 1: 购买, 0: 不够买)
|
||||
"productId": '', //商品id
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
}
|
||||
console.log(data)
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
|
||||
let data = { //定义socket数据传参
|
||||
"skuId": '',
|
||||
"num": '', //数量
|
||||
"type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
"couponsId": this.emitorderfoodform.id ? this.emitorderfoodform.id : '', //优惠券ID,
|
||||
"isYhq": this.emitorderfoodform.id ? 1 : 0, // 是否使用优惠券( 1: 使用, 0: 不使用),
|
||||
"isBuyYhq": this.emitorderfoodform.clickiconone == 1 ? 1 : 0, // 是否购买优惠券( 1: 购买, 0: 不够买)
|
||||
"productId": '', //商品id
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id,
|
||||
// tableId:uni.cache.get('tableCode')
|
||||
}
|
||||
console.log(data)
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
|
||||
|
||||
},
|
||||
async showpopupclickdd() {
|
||||
|
||||
// 余额支付
|
||||
async accountPayevent(id){
|
||||
let res = await this.api.accountPay({
|
||||
orderId: id,
|
||||
memberId:this.vipId
|
||||
})
|
||||
console.log(res,'调试12')
|
||||
if (res.code == 0) {
|
||||
}
|
||||
},
|
||||
async showpopupclickdd(i) {
|
||||
let res = await this.api.payorderPay({
|
||||
orderId: this.listinfo.id,
|
||||
orderId: this.listinfoid
|
||||
}) //判断是否支付成功
|
||||
if (res.code == 0) {
|
||||
uni.showLoading({
|
||||
@@ -275,43 +325,48 @@
|
||||
mask: true
|
||||
})
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay', //支付类型-固定值
|
||||
partnerid: res.data.payAppId, // 微信支付商户号
|
||||
timeStamp: res.data.payTimeStamp, // 时间戳(单位:秒)
|
||||
nonceStr: res.data.paynonceStr, // 随机字符串
|
||||
package: res.data.payPackage, // 固定值
|
||||
signType: res.data.paySignType, //固定值
|
||||
paySign: res.data.paySign, //签名
|
||||
success: (res) => {
|
||||
uni.showToast({
|
||||
title: "支付成功"
|
||||
})
|
||||
setTimeout(res => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/order/order_detail?orderId=' + this
|
||||
.listinfo.id
|
||||
});
|
||||
}, 1000)
|
||||
this.paymodfiyOrderInfo()
|
||||
// uni.redirectTo({
|
||||
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
|
||||
// .order_id,
|
||||
// });
|
||||
},
|
||||
fail: (err) => {
|
||||
setTimeout(res => {
|
||||
if(this.radiovalue1==1){
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay', //支付类型-固定值
|
||||
partnerid: res.data.appId, // 微信支付商户号
|
||||
timeStamp: res.data.timeStamp, // 时间戳(单位:秒)
|
||||
nonceStr: res.data.nonceStr, // 随机字符串
|
||||
package: res.data.package, // 固定值
|
||||
signType: res.data.signType, //固定值
|
||||
paySign: res.data.paySign, //签名
|
||||
success: (res) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '支付失败'
|
||||
title: "支付成功"
|
||||
})
|
||||
uni.hideLoading()
|
||||
}, 2000)
|
||||
uni.redirectTo({
|
||||
url: '/pages/order/order_detail?orderId=' + this.listinfo.id
|
||||
});
|
||||
setTimeout(res => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/order/successful?orderId=' + this
|
||||
.listinfoid
|
||||
});
|
||||
}, 1000)
|
||||
this.paymodfiyOrderInfo()
|
||||
// uni.redirectTo({
|
||||
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
|
||||
// .order_id,
|
||||
// });
|
||||
},
|
||||
fail: (err) => {
|
||||
setTimeout(res => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '支付失败'
|
||||
})
|
||||
uni.hideLoading()
|
||||
}, 2000)
|
||||
uni.redirectTo({
|
||||
url: '/pages/order/order_detail?orderId=' + this.listinfoid
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
this.accountPayevent(this.listinfoid)
|
||||
}
|
||||
});
|
||||
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
@@ -506,6 +561,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
.payType {
|
||||
padding: 32rpx 34rpx;
|
||||
margin-top: 48rpx;
|
||||
background-color: #fff;
|
||||
|
||||
>view:first-child {
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.dfs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.fixedview {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
|
||||
Reference in New Issue
Block a user