支付页面

This commit is contained in:
魏啾
2024-07-19 09:36:27 +08:00
parent a011e72584
commit c79a74d43f
10 changed files with 1054 additions and 18 deletions

View File

@@ -0,0 +1,267 @@
<template>
<view class='keyboard' @click.stop='_handleKeyPress'>
<view class='key-row'>
<view class='key-cell cell_b' data-num='7'>7</view>
<view class='key-cell cell_b' data-num='8'>8</view>
<view class='key-cell cell_b' data-num='9'>9</view>
<view class='key-cell cell_b' data-num='-1'></view>
</view>
<view class='key-row'>
<view class='key-cell cell_b' data-num='4'>4</view>
<view class='key-cell cell_b' data-num='5'>5</view>
<view class='key-cell cell_b' data-num='6'>6</view>
<view class='key-cell cell_b' data-num='-1'></view>
</view>
<view class='key-row'>
<view class='key-cell cell_b' data-num='1'>1</view>
<view class='key-cell cell_b' data-num='2'>2</view>
<view class='key-cell cell_b' data-num='3'>3</view>
<view class='key-cell cell_b' data-num='-1'></view>
</view>
<view class="key-zero-and-point">
<view class="a cell_b zero" data-num='0'>0</view>
<view class="a cell_b point" data-num='.'>.</view>
</view>
<view @touchstart="touchstart" @touchend="touchend" data-num='D' class="key-confirm2">
<text data-num='D'>C</text>
</view>
<view class='key-confirm' :style="{'background':btnColor}" data-num='S'>
<view data-num='S' class="">
<view data-num='S' class="title">{{title}}</view>
</view>
</view>
</view>
</template>
<script>
export default{
name:"keyBoard",
props:{
title:{
default:'确认',
type:String
},
btnColor:{
default:'green',
}
},
data(){
return {
money:'',
Cdel:'',
Time:''
}
},
watch:{
money(val){
this.$emit('update:money',val);
}
},
methods : {
touchstart(){
this.Time=setInterval(()=>{
console.log(this.money);
if(this.money==''){
clearInterval();
}
this.money = this.money.substring(0,this.money.length - 1);
},200)
},
touchend(){
clearInterval(this.Time);
},
//处理按键
_handleKeyPress(e) {
console.log('点击传e',e.target.dataset.num);
let num = e.target.dataset.num;
//不同按键处理逻辑
// -1 代表无效按键,直接返回
if (num == -1) return false;
switch (String(num)) {
//小数点
case '.':
this._handleDecimalPoint();
break;
//删除键
case 'D':
this._handleDeleteKey();
break;
//清空键
case 'C':
this._handleClearKey();
break;
//确认键
case 'S':
this._handleConfirmKey();
break;
default:
this._handleNumberKey(num);
break;
}
},
//处理小数点函数
_handleDecimalPoint() {
//如果包含小数点,直接返回
if (this.money.indexOf('.') > -1) return false;
//如果小数点是第一位补0
if (!this.money.length)
this.money = '0.';
//如果不是,添加一个小数点
else
this.money = this.money + '.';
},
//处理删除键
_handleDeleteKey() {
let S = this.money;
//如果没有输入,直接返回
if (!S.length) return false;
//否则删除最后一个
this.money = S.substring(0, S.length - 1);
},
//处理清空键
_handleClearKey() {
this.money = '';
},
//处理数字
_handleNumberKey(num) {
if(this.money.length==10){
return
}
let S = this.money;
//如果有小数点且小数点位数不小于2
if ( S.indexOf('.') > -1 && S.substring(S.indexOf('.') + 1).length < 2)
this.money = S + num;
//没有小数点
if (!(S.indexOf('.') > -1)) {
//如果第一位是0只能输入小数点
if (num == 0 && S.length == 0)
this.money = '0.';
else {
if (S.length && Number(S.charAt(0)) === 0) return;
this.money = S + num;
}
}
},
//提交
_handleConfirmKey() {
let S = this.money;
//未输入
if (!S.length||S==0){
uni.showToast({
title: '请输入正确的数值',
icon:'none',
duration: 1000
});
return false;
}
//将 8. 这种转换成 8.00
if (S.indexOf('.') > -1 && S.indexOf('.') == (S.length - 1))
S = Number(S.substring(0, S.length - 1)).toFixed(2);
//保留两位
S = Number(S).toFixed(2);
this.$emit('confirmEvent',S); //提交参数
}
}
}
</script>
<style lang="less" scoped>
.cell_b{
border-right: 1px solid #d5d5d6;
border-bottom: 1px solid #d5d5d6;
}
.key-container {
width: 100%;
display: flex;
flex-direction: column;
}
.keyboard {
flex: 1;
position: fixed;
bottom: 0;
left: 0;
height: 40vh;
width: 100%;
background: #FFFFFF;
}
.keyboard .key-row {
display: flex;
display: -webkit-flex;
position: relative;
height: 10vh;
line-height: 10vh;
}
.keyboard .key-cell {
flex: 1;
-webkit-box-flex: 1;
font-size: 60upx;
display: flex;
justify-content: center;
align-items: center;
}
.keyboard .key-confirm {
position: absolute;
text-align: center;
height: 30vh;
width: 25%;
line-height: 30vh;
color: #FFFFFF;
z-index: 5;
right: 0;
bottom: 0;
display:flex;
justify-content: center;
align-items: center;
}
.keyboard .key-confirm2 {
position: absolute;
height: 10vh;
width: 25%;
line-height: 10vh;
z-index: 9999;
right: 0;
top: 0;
display: flex;
justify-content: center;
align-items: center;
}
.key-zero-and-point{
display: flex;height: 10vh;justify-content: center;align-items: center;width:75%;font-size: 60upx;
.zero{
display: flex;justify-content: center;align-items: center;width: 66.66%;font-size: 60upx;text-align: center;height: 100%;
}
.point{
display: flex;justify-content: center;align-items: center;width: 33.33%;font-size: 60upx;text-align: center;height: 100%;
}
}
.key-cell:active{
color: white;
background: black; //黑色
opacity: 0.1; //这里重要,就是通过这个透明度来设置
}
.a:active,.key-confirm2:active{
color: white;
background: black; //黑色
opacity: 0.1; //这里重要,就是通过这个透明度来设置
}
</style>

View File

@@ -0,0 +1,301 @@
<template>
<view class='keyboard' @click.stop='_handleKeyPress'>
<view class='key-row'>
<view class='key-cell cell_b' data-num='1'>1</view>
<view class='key-cell cell_b' data-num='2'>2</view>
<view class='key-cell cell_b' data-num='3'>3</view>
</view>
<view class='key-row'>
<view class='key-cell cell_b' data-num='4'>4</view>
<view class='key-cell cell_b' data-num='5'>5</view>
<view class='key-cell cell_b' data-num='6'>6</view>
</view>
<view class='key-row'>
<view class='key-cell cell_b' data-num='7'>7</view>
<view class='key-cell cell_b' data-num='8'>8</view>
<view class='key-cell cell_b' data-num='9'>9</view>
</view>
<view class='key-row'>
<view class='key-cell cell_b' data-num='.'></view>
<view class='key-cell cell_b' data-num='0'>0</view>
<view class='key-cell cell_b' data-num='D' style="background: #F9F9F9;" @touchstart="touchstart"
@touchend="touchend">
<image data-num='D' style="width: 47.49rpx; height: 25.59rpx;"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/user/x.png" mode="aspectFill"></image>
</view>
</view>
<!-- <view class="key-zero-and-point">
<view class="a cell_b zero" data-num='0'>0</view>
<view class="a cell_b point" data-num='.'>.</view>
</view> -->
<!-- <view class='key-confirm' :style="{'background':btnColor}" data-num='S'>
<view data-num='S' class="">
<view data-num='S' class="title">{{title}}</view>
</view>
</view> -->
</view>
</template>
<script>
export default {
name: "keyBoard",
props: {
title: {
default: '确认',
type: String
},
btnColor: {
default: 'green',
}
},
data() {
return {
money: '',
Cdel: '',
Time: ''
}
},
watch: {
money(val) {
this.$emit('update:money', val);
}
},
methods: {
touchstart() {
this.Time = setInterval(() => {
console.log(this.money);
if (this.money == '') {
clearInterval();
}
this.money = this.money.substring(0, this.money.length - 1);
}, 200)
},
touchend() {
clearInterval(this.Time);
},
//处理按键
_handleKeyPress(e) {
console.log('点击传e', e.target.dataset.num);
let num = e.target.dataset.num;
//不同按键处理逻辑
// -1 代表无效按键,直接返回
if (num == -1) return false;
switch (String(num)) {
//小数点
case '.':
// uni.showToast({
// title: '不可以设置.',
// icon: 'none'
// });
// this._handleDecimalPoint();
break;
//删除键
case 'D':
this._handleDeleteKey();
break;
//清空键
case 'C':
this._handleClearKey();
break;
//确认键
case 'S':
this._handleConfirmKey();
break;
default:
this._handleNumberKey(num);
break;
}
},
//处理小数点函数
_handleDecimalPoint() {
//如果包含小数点,直接返回
if (this.money.indexOf('.') > -1) return false;
//如果小数点是第一位补0
if (!this.money.length)
this.money = '0.';
//如果不是,添加一个小数点
else
this.money = this.money + '.';
},
//处理删除键
_handleDeleteKey() {
let S = this.money;
//如果没有输入,直接返回
if (!S.length) return false;
//否则删除最后一个
this.money = S.substring(0, S.length - 1);
},
//处理清空键
_handleClearKey() {
this.money = '';
},
//处理数字
_handleNumberKey(num) {
if (this.money.length == 6) {
return
}
let S = this.money;
//如果有小数点且小数点位数不小于2
// if (S.indexOf('.') > -1 && S.substring(S.indexOf('.') + 1).length < 2)
this.money = S + num;
//没有小数点
// if (!(S.indexOf('.') > -1)) {
// //如果第一位是0只能输入小数点
// if (num == 0 && S.length == 0)
// this.money = '0';
// else {
// if (S.length && Number(S.charAt(0)) === 0) return;
// this.money = S + num;
// }
// }
},
//提交
_handleConfirmKey() {
let S = this.money;
//未输入
if (!S.length || S == 0) {
uni.showToast({
title: '请输入正确的数值',
icon: 'none',
duration: 1000
});
return false;
}
//将 8. 这种转换成 8.00
if (S.indexOf('.') > -1 && S.indexOf('.') == (S.length - 1))
S = Number(S.substring(0, S.length - 1)).toFixed(2);
//保留两位
S = Number(S).toFixed(2);
this.$emit('confirmEvent', S); //提交参数
}
}
}
</script>
<style lang="less" scoped>
.cell_b {
border-right: 1px solid #DBDBDB;
border-bottom: 1px solid #DBDBDB;
}
.key-container {
width: 100%;
display: flex;
flex-direction: column;
}
.keyboard {
flex: 1;
position: fixed;
bottom: 0;
left: 0;
height: 32vh;
width: 100%;
z-index: 999;
border-top: 1rpx solid #DBDBDB;
padding-bottom: calc(24rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
background: #FFFFFF;
}
.keyboard .key-row {
display: flex;
display: -webkit-flex;
position: relative;
height: 8vh;
line-height: 8vh;
}
.keyboard .key-cell {
flex: 1;
-webkit-box-flex: 1;
font-family: Roboto, Roboto;
font-weight: 400;
font-size: 36rpx;
color: #333333;
display: flex;
justify-content: center;
align-items: center;
}
.keyboard .key-confirm {
position: absolute;
text-align: center;
height: 30vh;
width: 25%;
line-height: 30vh;
color: #FFFFFF;
z-index: 5;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
}
.keyboard .key-confirm2 {
position: absolute;
height: 8vh;
width: 25%;
line-height: 8vh;
z-index: 9999;
right: 0;
top: 0;
display: flex;
justify-content: center;
align-items: center;
}
.key-zero-and-point {
display: flex;
height: 8vh;
justify-content: center;
align-items: center;
width: 75%;
font-size: 60upx;
.zero {
display: flex;
justify-content: center;
align-items: center;
width: 66.66%;
font-size: 60upx;
text-align: center;
height: 100%;
}
.point {
display: flex;
justify-content: center;
align-items: center;
width: 33.33%;
font-size: 60upx;
text-align: center;
height: 100%;
}
}
.key-cell:active {
color: white;
background: black; //黑色
opacity: 0.1; //这里重要,就是通过这个透明度来设置
}
.a:active,
.key-confirm2:active {
color: white;
background: black; //黑色
opacity: 0.1; //这里重要,就是通过这个透明度来设置
}
</style>

View File

@@ -11,7 +11,7 @@ const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试
// #endif
// #ifdef H5
const baseUrl = debug ? proxyApi : "https://wxcashiertest.sxczgkj.cn/cashierService"
const baseUrl = debug ? proxyApi + '/cashierService' : "https://cashier.sxczgkj.cn/cashierService"
const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
// #endif

View File

@@ -80,7 +80,7 @@ async function request(options) {
environment: 'app',
// #endif
// #ifdef H5
environment: 'app',
environment: 'wx',
// #endif
// #ifdef MP-WEIXIN
environment: 'wx',

View File

@@ -78,7 +78,7 @@
"disableHostCheck" : false,
"proxy" : {
"/api" : {
"target" : "https://wxcashiertest.sxczgkj.cn/cashierService",
"target" : "https://wxcashiertest.sxczgkj.cn",
// "target" : "https://ky.sxczgkj.cn",
"ws" : false,
"changeOrigin" : true, //是否跨域

View File

@@ -30,10 +30,11 @@
</view>
</view>
</view>
<image style="margin:32rpx auto;" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png"
v-if="is_end" mode="aspectFill"></image>
<u-loadmore :status="form.status" loadmore-text="下拉加载更多" @loadmore="loadmorelang" fontSize="28"
color="#999" iconSize="28" />
</view>
<image style="margin:32rpx auto;" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png"
v-if="is_end" mode="aspectFill"></image>
<u-loadmore :status="form.status" fontSize="28" color="#999" iconSize="28" />
</scroll-view>
<!-- <image style="margin:32rpx auto;" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png"
v-if="is_end" mode="aspectFill"></image>
@@ -206,6 +207,7 @@
}, 200)
},
methods: {
handleScroll(e) {
console.log(e.detail.scrollTop)
},
@@ -279,7 +281,7 @@
if (res.data.pageNum >= res.data.pages) {
this.form.status = 'nomore';
} else {
this.form.status = 'loading';
this.form.status = 'loadmore';
}
}, 500)
}
@@ -315,17 +317,19 @@
signType: res.data.signType, //固定值
paySign: res.data.paySign, //签名
success: (res) => {
this.showpopup = false
uni.showToast({
title: "支付成功"
})
setTimeout(res => {
this.showpopup = false
uni.hideLoading()
this.init_fn()
uni.navigateTo({
url: '/pages/chooseasong/record?shopId=' + this.shopId
})
// uni.switchTab({
// url: '/pages/order/order'
// });
}, 500)
}, 1000)
},
fail: (err) => {
uni.showToast({
@@ -424,7 +428,7 @@
}
.contentclass {
padding: 0rpx 28rpx 166rpx 28rpx;
padding: 0rpx 28rpx 215rpx 28rpx;
overflow: auto;
.contentclassbox {

View File

@@ -28,7 +28,7 @@
<view>{{item.title}}</view>
</view>
<view class="goods" v-for="(item2,index2) in item.list" :key="index2">
<image src="@/static/logo.png" mode=""></image>
<image src="@/static/1.gif" mode=""></image>
<view>
<view>{{index2+1}}个商品标题</view>
<view class="describe">{{index2+1}}个商品的描述内容</view>

View File

@@ -67,14 +67,20 @@
<view class="shop-item" v-for="(item1,index1) in item.products" :key="item1.id">
<view class="cover langcover" style="width:180rpx; height: 180rpx;"
@click.stop="clickspecifications(item1,index,index1)">
<c-image style="position: absolute;z-index:2;"
<!-- <c-image style="position: absolute;z-index:2;"
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_90,h_90`" width="180"
height="180"></c-image>
height="180"></c-image> -->
<image style="position: absolute;z-index:2;width: 180rpx; height: 180rpx;"
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_90,h_90`"
:lazy-load='true'></image>
</view>
<view class="info" style="display: flex;flex-direction: column;justify-content: center;">
<view class="name">
{{ item1.name }}
</view>
<view class="namess" v-if="item1.suit>1">
{{ item1.suit }}
</view>
<view class="price-wrap">
<view class="price">
<text class="i"></text>
@@ -104,7 +110,7 @@
</view>
</view>
</view>
<view class="cart-wrap" v-if="cartLists.data">
<view class="cart-wrap" v-if="cartListsdatashow">
<view class="cart-content">
<view class="left">
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/icon_cart.png"
@@ -276,7 +282,8 @@
datasocket: {}, //储存传参数据
radiovalue: '1', //选择支付方式
amountVIP: null, //余额
barrageavatar: '' //弹幕头像
barrageavatar: '', //弹幕头像
cartListsdatashow: false //是否显示购物车
};
},
onPageScroll(e) {
@@ -330,7 +337,7 @@
if (res.code == 0) {
uni.cache.set('shopUser', res.data)
this.handlemessage() //监听websocket返回
this.productqueryProduct() //list 数据
// this.productqueryProduct() //list 数据
} else {
setTimeout(() => {
uni.pro.switchTab('index/index')
@@ -359,6 +366,7 @@
return false;
}
} else {
this.cartListsdatashow = msg.data.length == 0 ? false : true
switch (msg.type) {
case 'sku': // sku 数量 查询这个商品的价格和数量
this.$set(this, 'amountcartNumber', msg.amount)
@@ -885,6 +893,12 @@
font-weight: bold;
}
.namess {
margin-top: 16rpx;
font-size: 24upx;
font-weight: 300;
}
.select-sku-wrap {
.t {
color: #999;
@@ -893,7 +907,7 @@
}
.price-wrap {
padding-top: $paddingSize;
margin-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;

View File

@@ -0,0 +1,227 @@
<template>
<view class="content">
<view v-if="isPwd == 0">
<view class="contenttext flex-center">
{{form.password.length == 6?'请再次确认支付密码':"请设置新密码,用于支付验证"}}
</view>
<view class="contentbox flex-between">
<view class="contentboxitem flex-colum">
{{consumeFee.slice(0,1)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(1,2)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(2,3)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(3,4)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(4,5)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(5,6)}}
</view>
</view>
</view>
<view class="" v-else>
</view>
<cwx-keyboard ref="keyboard" v-if="isPwd == 0" @confirmEvent="confirmEvent"
:money.sync="consumeFee"></cwx-keyboard>
</view>
</template>
<script>
import cwxKeyboard from '@/components/cwx-keyboard/cwx-keyboard';
export default {
components: {
cwxKeyboard
},
data() {
return {
isPwd: uni.cache.get('userInfo').isPwd,
form: {
mobile: uni.cache.get('userInfo').telephone,
password: '', //密码
payPassword: '', //二次密码
checkCode: ''
},
passwords: false,
payPasswords: false,
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '发送验证码',
consumeFee: '', //第一遍
consumeFees: '', //第二遍
money: '',
showoverlay: true
};
},
onLoad() {
if (uni.cache.get('userInfo').isPwd != 0) {
uni.setNavigationBarTitle({
title: '忘记支付密码', // 标题文本,必须是字符串
});
}
},
watch: {
consumeFee(newVal, oldVal) {
if (this.form.password.length == 6) {
this.form.payPassword = newVal
if (this.form.payPassword.length == 6) {
this.userInfosavePayPassword()
}
} else {
this.form.password = newVal
if (this.form.password.length == 6) {
this.$refs.keyboard._handleClearKey() //清空
}
}
}
},
methods: {
confirmEvent(e) {
console.log(e)
},
async CodeRegister() {
const res = await this.api.phoneValidateCode({
// post 手机验证码
phone: this.form.mobile
});
if (res) {
uni.showToast({
title: '验证码获取成功',
icon: 'none'
});
// 定时器
this.showText = false;
this.Recapture = '重新获取';
var interval = setInterval(() => {
let times = --this.second;
this.second = times < 10 ? '0' + times : times; //小于10秒补 0
}, 1000);
setTimeout(() => {
clearInterval(interval);
this.second = 60;
this.showText = true;
}, 60000);
}
},
async loginwxuserInfo() {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (res.code == 0) {
uni.cache.set('userInfo', res.data);
}
},
async userInfosavePayPassword() {
if (this.form.mobile.length != 11 && this.isPwd == 0) {
uni.showToast({
title: '手机号必须是11位',
icon: 'none'
});
return false;
}
if (this.form.password == null || this.form.password == '') {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return false;
}
if (this.form.payPassword == null || this.form.payPassword == '') {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return false;
}
if (this.form.password.length != 6 || this.form.payPassword.length != 6) {
uni.showToast({
title: '密码必须是6位',
icon: 'none'
});
return false;
}
if (this.form.payPassword != this.form.password) {
this.$refs.keyboard._handleClearKey() //清空
this.form.payPassword = ''
this.form.password = ''
uni.showToast({
title: '密码和确认密码不一致',
icon: 'none'
});
return false;
}
if (this.form.checkCode == null || this.form.checkCode == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
let res = await this.api.loginresetPwd({
pwd: this.form.password,
code: this.form.checkCode
})
if (res.code == 0) {
if (uni.cache.get('userInfo').isPwd != 0) {
uni.showToast({
title: '修改成功',
icon: 'none'
});
} else {
uni.showToast({
title: '设置成功',
icon: 'none'
});
}
// 获取用户信息
this.loginwxuserInfo()
setTimeout(() => {
uni.navigateBack();
}, 1000);
} else {
this.$refs.keyboard._handleClearKey() //清空
this.form.payPassword = ''
this.form.password = ''
}
}
}
};
</script>
<style lang="scss">
.content {
height: 100%;
background: #FFFFFF;
.contenttext {
padding: 48rpx 0;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500;
font-size: 40rpx;
color: #333333;
}
.contentbox {
margin-top: 48rpx;
padding: 0 56rpx;
.contentboxitem {
width: 88rpx;
height: 88rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #999999;
}
}
}
</style>

View File

@@ -0,0 +1,223 @@
<template>
<view class="content">
<view v-if="isPwd == 0">
<view class="contenttext flex-center">
{{form.password.length == 6?'请再次确认支付密码':"请设置新密码,用于支付验证"}}
</view>
<view class="contentbox flex-between">
<view class="contentboxitem flex-colum">
{{consumeFee.slice(0,1)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(1,2)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(2,3)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(3,4)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(4,5)}}
</view>
<view class="contentboxitem flex-colum">
{{consumeFee.slice(5,6)}}
</view>
</view>
</view>
<view class="" v-else>
</view>
<cwx-keyboard ref="keyboard" v-if="isPwd == 0" @confirmEvent="confirmEvent"
:money.sync="consumeFee"></cwx-keyboard>
</view>
</template>
<script>
import cwxKeyboard from '@/components/cwx-keyboard/cwx-keyboard';
export default {
components: {
cwxKeyboard
},
data() {
return {
isPwd: uni.cache.get('userInfo').isPwd,
form: {
mobile: uni.cache.get('userInfo').telephone,
password: '', //密码
payPassword: '', //二次密码
checkCode: ''
},
passwords: false,
payPasswords: false,
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '发送验证码',
consumeFee: '', //第一遍
consumeFees: '', //第二遍
money: ''
};
},
onLoad() {
if (uni.cache.get('userInfo').isPwd != 0) {
uni.setNavigationBarTitle({
title: '忘记支付密码', // 标题文本,必须是字符串
});
}
},
watch: {
consumeFee(newVal, oldVal) {
if (this.form.password.length == 6) {
this.form.payPassword = newVal
if (this.form.payPassword.length == 6) {
this.userInfosavePayPassword()
}
} else {
this.form.password = newVal
if (this.form.password.length == 6) {
this.$refs.keyboard._handleClearKey() //清空
}
}
}
},
methods: {
confirmEvent(e) {
console.log(e)
},
async CodeRegister() {
const res = await this.api.phoneValidateCode({
// post 手机验证码
phone: this.form.mobile
});
if (res) {
uni.showToast({
title: '验证码获取成功',
icon: 'none'
});
// 定时器
this.showText = false;
this.Recapture = '重新获取';
var interval = setInterval(() => {
let times = --this.second;
this.second = times < 10 ? '0' + times : times; //小于10秒补 0
}, 1000);
setTimeout(() => {
clearInterval(interval);
this.second = 60;
this.showText = true;
}, 60000);
}
},
async loginwxuserInfo() {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (res.code == 0) {
uni.cache.set('userInfo', res.data);
}
},
async userInfosavePayPassword() {
if (this.form.mobile.length != 11 && this.isPwd == 0) {
uni.showToast({
title: '手机号必须是11位',
icon: 'none'
});
return false;
}
if (this.form.password == null || this.form.password == '') {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return false;
}
if (this.form.payPassword == null || this.form.payPassword == '') {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return false;
}
if (this.form.password.length != 6 || this.form.payPassword.length != 6) {
uni.showToast({
title: '密码必须是6位',
icon: 'none'
});
return false;
}
if (this.form.payPassword != this.form.password) {
this.$refs.keyboard._handleClearKey() //清空
this.form.payPassword = ''
this.form.password = ''
uni.showToast({
title: '密码和确认密码不一致',
icon: 'none'
});
return false;
}
if (this.form.checkCode == null || this.form.checkCode == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
let res = await this.api.loginresetPwd({
pwd: this.form.password,
code: this.form.checkCode
})
if (res.code == 0) {
if (uni.cache.get('userInfo').isPwd != 0) {
uni.showToast({
title: '修改成功',
icon: 'none'
});
} else {
uni.showToast({
title: '设置成功',
icon: 'none'
});
}
// 获取用户信息
this.loginwxuserInfo()
setTimeout(() => {
uni.navigateBack();
}, 1000);
} else {
this.$refs.keyboard._handleClearKey() //清空
this.form.payPassword = ''
this.form.password = ''
}
}
}
};
</script>
<style lang="scss">
.content {
height: 100%;
background: #FFFFFF;
.contenttext {
padding: 48rpx 0;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500;
font-size: 40rpx;
color: #333333;
}
.contentbox {
margin-top: 48rpx;
padding: 0 56rpx;
.contentboxitem {
width: 88rpx;
height: 88rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #999999;
}
}
}
</style>