| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view style="background-color: #FFFFFF;height: 100%;width: 100%;padding-top:80rpx">
- <view class="shopping-wrapper">
- <view>
- <u-icon name="close" bold color="#333333" size="20" @click="goBack()"></u-icon>
- </view>
- <view class="title">
- <view class="title-text mb8" v-if="type=='add'">请设置安全密码</view>
- <view class="title-text mb8" v-else-if="type=='set-2'">请输入原密码</view>
- <view class="title-text mb8" v-else>请输入新密码</view>
- <view class="title-prompt">6位数字</view>
- </view>
- <view class="mb12">
- <u-input
- :type="isPasswordVisible ? 'password' : 'text'"
- placeholder="确认安全密码"
- v-model="password"
- maxlength="6"
- :disabled="isSetPassword"
- shape="circle"
- placeholderStyle="color:#888888;"
- color="#333333"
- border="none"
- custom-style="background-color: #F3F6FC;padding-right: 20rpx;padding-left: 20rpx;opacity: 0.6;height: 94rpx;"
- >
- <template slot="suffix">
- <u-icon
- v-if="password.length>0&&!this.isSetPassword"
- :name="isPasswordVisible ? 'eye' : 'eye-off'"
- size="20"
- @click="togglePasswordVisibility"
- />
- </template>
- </u-input>
- </view>
- <view v-if="type=='add'">
- <u-input
- :type="isPasswordVisible2 ? 'password' : 'text'"
- placeholder="再次确认安全密码"
- v-model="password2"
- maxlength="6"
- :disabled="isSetPassword"
- shape="circle"
- placeholderStyle="color:#888888;"
- color="#333333"
- border="none"
- custom-style="background-color: #F3F6FC;padding-right: 20rpx;padding-left: 20rpx;opacity: 0.6;height: 94rpx;"
- >
- <template slot="suffix">
- <u-icon
- v-if="password2.length>0&&!this.isSetPassword"
- :name="isPasswordVisible2 ? 'eye' : 'eye-off'"
- size="20"
- @click="togglePasswordVisibility2"
- />
- </template>
- </u-input>
- </view>
- <view style="height: 108rpx; " class="btn-commnt" @click="setPassword()">
- <view class="btn-commnt-text" v-if="type=='add'||type=='set-3'">完成</view>
- <view class="btn-commnt-text" v-else>下一步</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {checkPayPswd, setPayPswd} from "@/common/api";
- import {getUserInfo} from "@/common/api/user";
- export default {
- data() {
- return {
- password: '',
- password2:'',
- userInfo: {},
- isSetPassword: false,
- isPasswordVisible: true,
- isPasswordVisible2: true,
- type: "add",
- verifyCode:"",
- };
- },
- onLoad(options) {
- // 保存查询参数到页面的数据对象中
- if (options.type) {
- this.type = options.type;
- }
- console.log("type", this.type)
- },
- onShow() {
- this.initUserInfo()
- },
- methods: {
- async getUserInfo() {
- const data = {}
- await getUserInfo(data)
- .then(res => {
- if (res.data) {
- uni.setStorageSync('token', res.data.token.token)
- uni.setStorageSync('userInfo', JSON.stringify(res.data))
- this.userInfo = res.data;
- }
- })
- .catch(() => {
- uni.hideLoading();
- });
- },
- async initUserInfo() {
- await this.getUserInfo();
- if (this.userInfo.pay_pswd && this.userInfo.pay_pswd.length > 0&& this.type == 'add' ) {
- this.isSetPassword = true;
- this.password = this.userInfo.pay_pswd;
- this.password2 = this.userInfo.pay_pswd;
- }
- },
- goBack() {
- uni.navigateBack({
- delta: 1 // 返回上一级页面
- });
- },
- change(e) {
- },
- togglePasswordVisibility() {
- this.isPasswordVisible = !this.isPasswordVisible;
- },
- togglePasswordVisibility2() {
- this.isPasswordVisible2 = !this.isPasswordVisible2;
- },
- savePad() {
- if (this.password.length < 6) {
- uni.showToast({
- title: '请输入6位数字',
- icon: 'none',
- duration: 2000
- });
- return
- }
- if (this.password!=this.password2 &&this.type=='add') {
- uni.showToast({
- title: '二次密码不一样,请重新确认',
- icon: 'none',
- duration: 2000
- });
- return
- }
- if (this.isSetPassword) {
- uni.showToast({
- title: '您已设置支付密码,无需重复设置',
- icon: 'none',
- duration: 2000
- });
- return
- }
- setPayPswd({pay_pswd: this.password}).then((res) => {
- if (this.type!="set-3"){
- uni.showToast({
- title: '保存成功'
- })
- }else{
- uni.showToast({
- title: '修改成功'
- })
- }
- this.isSetPassword = true
- setTimeout(() => {
- uni.navigateTo({
- url: '/subPages/setting/index',
- });
- }, 500);
- })
- },
- verifyPad() {
- if (this.password.length < 6) {
- uni.showToast({
- title: '请输入6位数字',
- icon: 'none',
- duration: 2000
- });
- return
- }
- checkPayPswd({pay_pswd: this.password}).then((res) => {
- uni.navigateTo({
- url: "/subPages/setting/setPwd?type=set-3",
- });
- })
- },
- setPassword() {
- switch (this.type) {
- case "add":
- this.savePad();
- break;
- case "set-1":
- break;
- case "set-2":
- this.verifyPad()
- break;
- case "set-3":
- this.savePad();
- break;
- default:
- break;
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .shopping-wrapper {
- width: 630rpx;
- margin: 0rpx auto 0rpx;
- padding: 30rpx 30rpx 178rpx;
- .title {
- display: flex;
- flex-direction: column;
- align-items: flex-start; /* 左对齐 */
- justify-content: flex-start; /* 左对齐 */
- margin-top: 112rpx;
- margin-bottom: 124rpx;
- .title-text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 600;
- font-size: 48rpx;
- color: #262424;
- line-height: 68rpx;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- .title-prompt {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- color: #888888;
- line-height: 36rpx;
- text-align: center;
- font-style: normal;
- text-transform: none;;
- }
- }
- .btn-commnt {
- margin-top: 40rpx;
- background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
- border-radius: 292rpx 292rpx 292rpx 292rpx;
- opacity: 0.6;
- display: flex;
- justify-content: center;
- align-items: center;
- .btn-commnt-text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 32rpx;
- color: #FFFFFF;
- line-height: 42rpx;
- text-align: center;
- font-style: normal;
- text-transform: none;
- }
- }
- }
- </style>
|