shop-applet/pages/users/user_modify_pwd/index.vue

332 lines
7.9 KiB
Vue
Raw Normal View History

2023-09-20 18:16:59 +08:00
<template>
<view :style="viewColor">
<form report-submit='true'>
<view>
<view class="ChangePassword">
<view class="list">
<view class="item">
<text class="phone">{{userInfo.phone}}</text>
</view>
<view class="item acea-row row-between-wrapper codeVal">
2024-04-01 11:36:40 +08:00
<input type='number' maxlength="4" placeholder='验证码' placeholder-class='placeholder'
class="codeIput" v-model="captcha"></input>
2024-03-22 16:02:41 +08:00
<button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled'
@click="handleVerify">
2023-09-20 18:16:59 +08:00
{{ text }}
</button>
</view>
<view class="border"></view>
2024-04-01 11:36:40 +08:00
<block v-if="type == 'payPwd'">
<view class="item" @click="showPopup(1)">
<input style="pointer-events: none;" type='password' placeholder="请设置支付密码"
placeholder-class='placeholder' v-model="password" autocomplete="off"></input>
</view>
<view class="item" @click="showPopup(2)">
<input style="pointer-events: none;" type='password' placeholder="请再次设置支付密码"
placeholder-class='placeholder' v-model="repassword" autocomplete="off"></input>
</view>
</block>
2024-03-22 16:02:41 +08:00
<block v-else>
2024-04-01 11:36:40 +08:00
<view class="item">
<input type='password' placeholder="请设置密码" placeholder-class='placeholder'
v-model="password" autocomplete="off"></input>
</view>
<view class="item">
<input type='password' placeholder="请再次设置密码" placeholder-class='placeholder'
v-model="repassword" autocomplete="off"></input>
</view>
2024-03-22 16:02:41 +08:00
</block>
2023-09-20 18:16:59 +08:00
</view>
</view>
<button form-type="submit" @click="confirmSubmit" class="confirmBnt">确认</button>
</view>
</form>
2024-03-22 16:02:41 +08:00
<Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }"
ref="verify"></Verify>
2024-04-01 11:36:40 +08:00
<popups ref="popups" isPay title="请设置支付密码" @confirm="handleConfirm" @clear="handleClear" @change="handleChange">
</popups>
2023-09-20 18:16:59 +08:00
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
2024-03-22 16:02:41 +08:00
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
2023-09-20 18:16:59 +08:00
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import sendVerifyCode from "@/mixins/SendVerifyCode";
2024-03-22 16:02:41 +08:00
import {
modifyPassword,
verifyCode,
appletsDecrypt,
setPayPwd
} from '@/api/api.js';
import {
getUserInfo
} from '@/api/user.js';
import {
registerVerify
} from '@/api/user.js'
2023-09-20 18:16:59 +08:00
import {
mapGetters
} from "vuex";
2024-03-22 16:02:41 +08:00
import {
toLogin
} from '@/libs/login.js';
import Verify from '@/components/verify/verify.vue';
2024-04-01 11:36:40 +08:00
import popups from "@/components/popups/index.vue";
2023-09-20 18:16:59 +08:00
export default {
mixins: [sendVerifyCode],
components: {
2024-03-22 16:02:41 +08:00
Verify,
2024-04-01 11:36:40 +08:00
popups
2023-09-20 18:16:59 +08:00
},
data() {
return {
userInfo: {},
2024-03-22 16:02:41 +08:00
phone: '',
2023-09-20 18:16:59 +08:00
repassword: '',
password: '',
2024-03-22 16:02:41 +08:00
captcha: '',
2023-09-20 18:16:59 +08:00
key: '',
codeVal: '',
disabled: false,
2024-03-22 16:02:41 +08:00
type: '',
2024-04-01 11:36:40 +08:00
set_type: '',
2023-09-20 18:16:59 +08:00
};
},
computed: mapGetters(['isLogin', 'viewColor']),
2024-03-22 16:02:41 +08:00
onLoad(opt) {
2023-09-20 18:16:59 +08:00
let that = this
2024-03-22 16:02:41 +08:00
this.type = opt.type;
2023-09-20 18:16:59 +08:00
if (this.isLogin) {
this.getUserInfo()
} else {
2024-03-22 16:02:41 +08:00
toLogin()
2023-09-20 18:16:59 +08:00
}
// #ifdef MP
wx.login({
2024-03-22 16:02:41 +08:00
success(res) {
if (res.code) {
that.codeVal = res.code
} else {
console.log('登录失败!' + res.errMsg)
}
}
2023-09-20 18:16:59 +08:00
})
// #endif
},
methods: {
/**
* 获取个人用户信息
*/
getUserInfo: function() {
let that = this;
getUserInfo().then(res => {
that.userInfo = res.data
});
},
2024-04-01 11:36:40 +08:00
showPopup(type) {
this.set_type = type;
this.$refs.popups.handleOpen();
},
// 输入密码回调
handleConfirm(e) {
if (this.set_type == 1) this.password = e;
else this.repassword = e;
},
handleClear() {},
handleChange() {},
2024-03-22 16:02:41 +08:00
2023-09-20 18:16:59 +08:00
confirmSubmit: function() {
let that = this;
if (!that.password) return that.$util.Tips({
title: '请填写密码!'
});
if (!that.repassword) return that.$util.Tips({
title: '请确认新密码!'
});
if (that.password !== that.repassword) return that.$util.Tips({
title: '两次密码不一致,请重新填写!'
});
if (!that.captcha) return that.$util.Tips({
title: '请填写验证码'
});
2024-03-22 16:02:41 +08:00
if (this.type == 'payPwd') { //支付提现密码
setPayPwd({
password: that.password,
repassword: that.repassword,
2024-04-01 11:36:40 +08:00
sms_code: that.captcha,
2024-03-22 16:02:41 +08:00
}).then(res => {
that.$util.Tips({
2024-04-01 11:36:40 +08:00
title: '修改成功!',
icon: 'success'
}, () => {
uni.navigateBack();
});
}).catch(err => {
that.$util.Tips({
title: err,
icon: 'none'
})
2024-03-22 16:02:41 +08:00
})
} else { // 登录密码
modifyPassword({
password: that.password,
repassword: that.repassword,
sms_code: that.captcha
}).then(res => {
return that.$util.Tips({
title: '修改成功!',
icon: 'success'
}, {
tab: 5,
url: '/pages/users/user_info/index'
});
}).catch(err => {
return that.$util.Tips({
title: err
});
})
}
2023-09-20 18:16:59 +08:00
},
/**
* 发送验证码
*
*/
async code(data) {
let that = this;
// if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.userInfo.phone))) return that.$util.Tips({
// title: '请输入正确的手机号码!'
// });
this.disabled = true
await registerVerify({
2024-03-22 16:02:41 +08:00
phone: that.userInfo.phone,
code: that.captcha,
2024-04-01 11:36:40 +08:00
type: this.type == 'payPwd' ? 'pay_pwd' : 'change_pwd',
2024-03-22 16:02:41 +08:00
captchaType: 'blockPuzzle',
2023-09-20 18:16:59 +08:00
captchaVerification: data.captchaVerification
}).then(res => {
this.disabled = false
that.$util.Tips({
title: res.msg
});
that.sendCode();
}).catch(err => {
this.disabled = false
return that.$util.Tips({
title: err
});
});
},
2024-03-22 16:02:41 +08:00
success(data) {
2023-09-20 18:16:59 +08:00
this.$refs.verify.hide();
this.code(data);
},
handleVerify() {
this.$refs.verify.show();
}
}
}
</script>
<style lang="scss" scoped>
2024-03-22 16:02:41 +08:00
.ChangePassword {
2023-09-20 18:16:59 +08:00
background: #fff;
padding-top: 53rpx;
}
2024-03-22 16:02:41 +08:00
2023-09-20 18:16:59 +08:00
.ChangePassword .phone {
font-size: 32rpx;
}
.ChangePassword .list .item {
width: 580rpx;
margin: 0 auto;
height: 110rpx;
border-bottom: 2rpx solid #f0f0f0;
display: flex;
align-items: center;
}
.ChangePassword .list .item input {
width: 100%;
font-size: 32rpx;
}
2024-03-22 16:02:41 +08:00
/deep/.uni-input-input {
2023-09-20 18:16:59 +08:00
// box-shadow: inset 0 0 0 0 #fff;
}
.ChangePassword .list .item .placeholder {
color: #b9b9bc;
}
.ChangePassword .list .item input.codeIput {
width: 340rpx;
}
.ChangePassword .list .item .code {
font-size: 32rpx;
position: relative;
padding-left: 26rpx;
color: var(--view-theme);
2024-03-22 16:02:41 +08:00
&::before {
2023-09-20 18:16:59 +08:00
content: "";
width: 1rpx;
height: 30rpx;
position: absolute;
top: 10rpx;
left: 0;
background: #DDDDDD;
display: inline-block;
}
}
2024-03-22 16:02:41 +08:00
2023-09-20 18:16:59 +08:00
.ChangePassword .list .item .code.on {
color: #b9b9bc !important;
}
2024-03-22 16:02:41 +08:00
.ChangePassword .list .border {
2023-09-20 18:16:59 +08:00
width: 100%;
height: 21rpx;
background: #F5F5F5;
}
2024-03-22 16:02:41 +08:00
2023-09-20 18:16:59 +08:00
.confirmBnt {
font-size: 32rpx;
width: 580rpx;
height: 90rpx;
border-radius: 45rpx;
color: #fff;
margin: 70rpx auto 0 auto;
text-align: center;
line-height: 90rpx;
background-color: var(--view-theme);
}
2024-03-22 16:02:41 +08:00
.getPhoneBtn {
2023-09-20 18:16:59 +08:00
font-size: 32rpx;
width: 580rpx;
height: 90rpx;
border-radius: 45rpx;
border: 1px solid var(--view-theme);
color: var(--view-theme);
margin: 40rpx auto 0 auto;
text-align: center;
line-height: 90rpx;
2024-03-22 16:02:41 +08:00
.iconfont {
2023-09-20 18:16:59 +08:00
font-size: 32rpx;
margin-right: 12rpx;
}
}
2024-03-22 16:02:41 +08:00
</style>