支付联调

This commit is contained in:
duan
2024-05-24 09:28:14 +08:00
parent dd5adf82b8
commit 7cea9eb628
21 changed files with 254 additions and 170 deletions

View File

@@ -137,7 +137,7 @@
</view>
</view>
</view>
</view>
</view>
<u-loadmore height='40' :status="form.status" iconSize='24' fontSize='24' />
<!-- </scroll-view> -->

View File

@@ -1,192 +0,0 @@
<template>
<view class="page">
<view>
<view class="pay-title">
<text>请输入6位支付密码</text>
</view>
<view class="pay-password" @click="onPayUp">
<view class="list">
<text v-show="passwordArr.length >= 1"></text>
</view>
<view class="list">
<text v-show="passwordArr.length >= 2"></text>
</view>
<view class="list">
<text v-show="passwordArr.length >= 3"></text>
</view>
<view class="list">
<text v-show="passwordArr.length >= 4"></text>
</view>
<view class="list">
<text v-show="passwordArr.length >= 5"></text>
</view>
<view class="list">
<text v-show="passwordArr.length >= 6"></text>
</view>
</view>
<view class="hint" @click="gopaypassword">
<text>忘记支付密码</text>
</view>
</view>
<!-- ref:唯一ref passwrdType密码样式pay keyInfo密码输入返回事件 -->
<cc-defineKeyboard ref="CodeKeyboard" passwrdType="pay" @KeyInfo="KeyInfo"></cc-defineKeyboard>
</view>
</template>
<script>
export default {
components: {
},
data() {
return {
// AffirmStatus: 1,
passwordArr: [],
oldPasswordArr: [],
newPasswordArr: [],
afPasswordArr: [],
};
},
onLoad() {
},
methods: {
// 忘记支付密码
gopaypassword() {
uni.pro.navigateTo('/pages/user/repairpassword', {
// shopId_id: uni.cache.get('shopUser')
})
},
/**
* 唤起键盘
*/
onPayUp() {
this.$refs.CodeKeyboard.show();
},
/**
* 支付键盘回调
* @param {Object} val
*/
KeyInfo(val) {
if (val.index >= 6) {
return;
}
// 判断是否输入的是删除键
if (val.keyCode === 8) {
// 删除最后一位
this.passwordArr.splice(val.index + 1, 1)
}
// 判断是否输入的是.
else if (val.keyCode == 190) {
// 输入.无效
} else {
this.passwordArr.push(val.key);
}
// uni.showModal({
// title: '温馨提示',
// content: '输入密码是 = ' + JSON.stringify(this.passwordArr)
// })
// 判断是否等于6
if (this.passwordArr.length === 6) {
// this.AffirmStatus = this.AffirmStatus + 1;
let str = ''
this.passwordArr.forEach(res => {
str += res
})
this.$emit('accountPayevent', str)
this.passwordArr = [];
}
// 判断到哪一步了
// if (this.AffirmStatus === 1) {
// this.oldPasswordArr = this.passwordArr;
// } else if (this.AffirmStatus === 2) {
// this.newPasswordArr = this.passwordArr;
// } else if (this.AffirmStatus === 3) {
// this.afPasswordArr = this.passwordArr;
// } else if (this.AffirmStatus === 4) {
// console.log(this.oldPasswordArr.join(''));
// console.log(this.newPasswordArr.join(''));
// console.log(this.afPasswordArr.join(''));
// uni.showToast({
// title: '修改成功',
// icon: 'none'
// })
// setTimeout(() => {
// uni.navigateBack();
// }, 2000)
// }
this.$forceUpdate();
}
}
}
</script>
<style scoped lang="scss">
$base: #555; // 基础颜色
.page {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #FFFFFF;
}
.pay-title {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 200rpx;
text {
font-size: 28rpx;
color: #555555;
}
}
.pay-password {
display: flex;
align-items: center;
width: 90%;
height: 80rpx;
margin: 20rpx auto;
border: 2rpx solid $base;
.list {
display: flex;
align-items: center;
justify-content: center;
width: 16.666%;
height: 100%;
border-right: 2rpx solid #EEEEEE;
text {
font-size: 32rpx;
}
}
.list:nth-child(6) {
border-right: none;
}
}
.hint {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100rpx;
text {
font-size: 28rpx;
color: $base;
}
}
</style>

View File

@@ -183,7 +183,7 @@
<script>
import webSocketUtils from '@/common/js/websocket.js'
import payPassword from './components/payPassword.vue'
import payPassword from '@/components/payPassword.vue'
export default {
components: {
payPassword
@@ -207,14 +207,19 @@
orderInfo: '',
// 可用优惠券数据
couponAmount: 0,
// 输入支付密码
// 输入支付密码 123
passwordArr: [],
ispws: false
ispws: false,
numValue: 0
};
},
onUnload() {
uni.$off('getMessage')
// uni.showToast({
// title: this.radiovalue1 + '-110',
// duration:5000
// })
},
onLoad(e) {
// 获取用户信息
@@ -232,6 +237,7 @@
// 获取可用优惠券数量
this.getcoupon()
this.vipId = uni.cache.get('userInfo').id
},
onShow() {
@@ -250,7 +256,7 @@
})
},
methods: {
async loginwxuserInfo() {
async loginwxuserInfo() {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
@@ -279,6 +285,7 @@ async loginwxuserInfo() {
}
},
getMessage(msg) {
if (msg.status != 'success') {
uni.showToast({
title: msg.msg,
@@ -339,23 +346,24 @@ async loginwxuserInfo() {
},
// 去结算
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,
// tableId:uni.cache.get('tableCode')
if (this.numValue == 0) {
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')
}
this.numValue = 1
uni.$u.debounce(this.socketSendMsg(data), 500)
} else {
this.showpopupclickdd()
}
console.log(data)
uni.$u.debounce(this.socketSendMsg(data), 500)
},
// 去充值
goRecharge() {
@@ -363,8 +371,10 @@ async loginwxuserInfo() {
shopId_id: uni.cache.get('shopUser')
})
},
async showpopupclickdd(i) {
console.log(this.radiovalue1, '调试121')
if (this.radiovalue1 == 1) {
let res = await this.api.payorderPay({
orderId: this.listinfoid
@@ -403,16 +413,14 @@ async loginwxuserInfo() {
// });
},
fail: (err) => {
setTimeout(() => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
uni.hideLoading()
}, 2000)
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this.listinfoid
});
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
@@ -444,29 +452,30 @@ async loginwxuserInfo() {
memberId: this.amountVIP.id,
pwd: pwd
})
console.log(res, '是否支付成功')
if(res.code ==0){
if (res.code == 0) {
uni.showToast({
icon: 'none',
title: '支付成功',
success:()=>{
setTimeout(()=>{
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this.listinfoid
});
},2000)
success: () => {
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo)
});
}, 1000)
}
})
} else if (res.data == 1) {
setTimeout(() => {
// 去充值
this.goRecharge()
}, 2000)
}
if(res.data==1){
setTimeout(() => {
// 去充值
this.goRecharge()
}, 2000)
}
},
clickselect(b) {

View File

@@ -49,7 +49,7 @@
</view>
<!-- 支付方式 -->
<view class="payType" v-if="false">
<view class="payType">
<view class="">
支付方式
</view>
@@ -77,12 +77,14 @@
</view>
</u-radio>
</u-radio-group>
<view style="font-weight: 400;font-size: 24rpx;color: #333333;">
会员卡余额${{ amount}} <text style="font-weight: 500;font-size: 28rpx;color: #FF4C11;"
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;">
会员卡余额{{ amountVIP.amount}} <text
style="font-weight: 500;font-size: 28rpx;margin-left: 16rpx;color: #FF4C11;"
@click="goRecharge">去充值</text>
</view>
</view>
</view>
<view class="placeBottom">
<view class="">
<text style="font-size: 24rpx;font-weight: bold;"> 合计 </text><text
@@ -94,14 +96,19 @@
</view>
<button class="btnStyle" @click="sumbitFrom">提交订单</button>
</view>
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
</view>
</template>
<script>
import payPassword from '@/components/payPassword.vue'
export default {
components: {
payPassword
},
onLoad(e) {
this.getInfo(e.id)
this.orderIds= e.id
this.orderIds = e.id
this.amount = uni.cache.get('userInfo').amount
this.vipId = uni.cache.get('userInfo').id
},
@@ -111,13 +118,56 @@
Quantity: 1,
radiovalue1: '1',
amount: 0,
orderIds:null,
vipId:null
orderIds: null,
vipId: null,
ispws: false,
amountVIP: null,
}
},
methods: {
async getAount() {
let res = await this.api.shopUserInfo({
// shopId:店铺ID
"shopId":this.info.shopId,
"userId": uni.cache.get('userInfo').id
})
if (res.code == 0) {
this.amountVIP = res.data
}
},
// 余额支付
async accountPayevent(pwd) {
this.ispws = false
let res = await this.api.accountPay({
orderId: this.listinfoid,
memberId: this.amountVIP.id,
pwd: pwd
})
if (res.code == 0) {
uni.showToast({
icon: 'none',
title: '支付成功',
success: () => {
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo)
});
}, 1000)
}
})
} else if (res.data == 1) {
setTimeout(() => {
// 去充值
this.goRecharge()
}, 2000)
}
},
goRecharge() {
// uni.pro.to
uni.pro.navigateTo('/pages/member/index', {
shopId_id: uni.cache.get('shopUser')
})
},
async sumbitFrom() {
// radiovalue1:为1的时候微信支付,为2是会员卡,需要输入支付密码
@@ -134,13 +184,30 @@
// 调用支付接口
this.payEvent(res.data.id)
}
}else{
let res = await this.api.accountPay({
orderId: this.orderIds,
memberId:this.vipId
})
if (res.code == 0) {
} else {
// let res = await this.api.accountPay({
// orderId: this.orderIds,
// memberId:this.vipId
// })
// if (res.code == 0) {
// }
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
let isVip = uni.cache.get('userInfo').isPwd
if (isVip == 0) {
uni.pro.navigateTo('/pages/user/repairpassword', {
// shopId_id: uni.cache.get('shopUser')
})
} else {
this.ispws = true
this.$nextTick(() => {
this.$refs.payPwd.onPayUp();
})
}
}
},
async payEvent(id) {
@@ -184,6 +251,8 @@
})
if (res.code == 0) {
this.info = res.data
// 获取余额
this.getAount()
}
}
}
@@ -296,6 +365,12 @@
>view:last-child {
margin-top: 32rpx;
}
.dfs {
display: flex;
align-items: center;
}
}
.placeBottom {