联调app
This commit is contained in:
@@ -1,249 +1,250 @@
|
||||
<template>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<template v-if="step == 1">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
disabled
|
||||
type="text"
|
||||
maxlength="11"
|
||||
v-model="formData.phoneShow"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="text" v-model="formData.code" placeholder="请输入验证码" maxlength="6" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">
|
||||
获取验证码
|
||||
</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="firstSubmit">下一步</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
maxlength="11"
|
||||
type="number"
|
||||
v-model="formData.phone2"
|
||||
placeholder="请输入新手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="text" v-model="formData.code2" placeholder="请输入验证码" maxlength="6" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">
|
||||
获取验证码
|
||||
</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="secondSubmit">提交</button>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiComfirmCode, apiRebindPhone } from '@/common/api/user'
|
||||
export default {
|
||||
name: 'jiaban',
|
||||
data() {
|
||||
return {
|
||||
step: 1,
|
||||
loading: false,
|
||||
waitTime: 0,
|
||||
// 表单数据
|
||||
formData: {
|
||||
phone: '',
|
||||
phoneShow: '',
|
||||
code: '',
|
||||
phone2: '',
|
||||
code2: '',
|
||||
},
|
||||
rules: {
|
||||
phone: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
phone2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写新手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
getCode(type) {
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等',
|
||||
})
|
||||
apiGetYms({
|
||||
phone: type == 5 ? this.formData.phone : this.formData.phone2,
|
||||
type,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading()
|
||||
console.log(res)
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
init() {
|
||||
// 手机号中间四位隐藏
|
||||
this.formData.phone = uni.getStorageSync('userInfo').user_name
|
||||
this.formData.phoneShow = this.formData.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||
},
|
||||
firstSubmit() {
|
||||
apiComfirmCode({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code,
|
||||
})
|
||||
.then((res) => {
|
||||
this.step = 2
|
||||
clearInterval(this.inter)
|
||||
this.waitTime = 0
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
secondSubmit() {
|
||||
apiRebindPhone({
|
||||
phone: this.formData.phone2,
|
||||
code: this.formData.code2,
|
||||
})
|
||||
.then((res) => {
|
||||
this.$util.toast('绑定成功')
|
||||
uni.clearStorageSync()
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/user/login',
|
||||
})
|
||||
}, 1500)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
padding: 20rpx;
|
||||
|
||||
.submit-btn {
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-tips {
|
||||
margin-top: 60rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.login-box-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
|
||||
.login-box-input-icon {
|
||||
width: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.login-box-input-main {
|
||||
font-size: 28rpx;
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.login-box-input-btn {
|
||||
padding:0 40rpx;
|
||||
margin-left: 40rpx;
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-input-img {
|
||||
margin-left: 40rpx;
|
||||
background: skyblue;
|
||||
height: 80rpx;
|
||||
width: 200rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<template v-if="step == 1">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
disabled
|
||||
type="text"
|
||||
maxlength="11"
|
||||
v-model="formData.phoneShow"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="text" v-model="formData.code" placeholder="请输入验证码" maxlength="6" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">
|
||||
获取验证码
|
||||
</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="firstSubmit">下一步</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
maxlength="11"
|
||||
type="number"
|
||||
v-model="formData.phone2"
|
||||
placeholder="请输入新手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="text" v-model="formData.code2" placeholder="请输入验证码" maxlength="6" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">
|
||||
获取验证码
|
||||
</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="secondSubmit">提交</button>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiComfirmCode, apiRebindPhone } from '@/common/api/user'
|
||||
export default {
|
||||
name: 'jiaban',
|
||||
data() {
|
||||
return {
|
||||
step: 1,
|
||||
loading: false,
|
||||
waitTime: 0,
|
||||
// 表单数据
|
||||
formData: {
|
||||
phone: '',
|
||||
phoneShow: '',
|
||||
code: '',
|
||||
phone2: '',
|
||||
code2: '',
|
||||
},
|
||||
rules: {
|
||||
phone: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
phone2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写新手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
getCode(type) {
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
apiGetYms({
|
||||
phone: type == 5 ? this.formData.phone : this.formData.phone2,
|
||||
type,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading()
|
||||
console.log(res)
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
init() {
|
||||
// 手机号中间四位隐藏
|
||||
this.formData.phone = uni.getStorageSync('userInfo').user_name
|
||||
this.formData.phoneShow = this.formData.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||
},
|
||||
firstSubmit() {
|
||||
apiComfirmCode({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code,
|
||||
})
|
||||
.then((res) => {
|
||||
this.step = 2
|
||||
clearInterval(this.inter)
|
||||
this.waitTime = 0
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
secondSubmit() {
|
||||
apiRebindPhone({
|
||||
phone: this.formData.phone2,
|
||||
code: this.formData.code2,
|
||||
})
|
||||
.then((res) => {
|
||||
this.$util.toast('绑定成功')
|
||||
uni.clearStorageSync()
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/user/login',
|
||||
})
|
||||
}, 1500)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
padding: 20rpx;
|
||||
|
||||
.submit-btn {
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-tips {
|
||||
margin-top: 60rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.login-box-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
|
||||
.login-box-input-icon {
|
||||
width: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.login-box-input-main {
|
||||
font-size: 28rpx;
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.login-box-input-btn {
|
||||
padding:0 40rpx;
|
||||
margin-left: 40rpx;
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-input-img {
|
||||
margin-left: 40rpx;
|
||||
background: skyblue;
|
||||
height: 80rpx;
|
||||
width: 200rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,242 +1,243 @@
|
||||
<template>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<uni-forms ref="form" :modelValue="formData" :rules="rules">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
maxlength="11"
|
||||
disabled
|
||||
type="text"
|
||||
v-model="formData.showPhone"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入手机验证码" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode" size="mini">获取验证码</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="password">
|
||||
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入新的登录密码" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="password2">
|
||||
<uni-easyinput type="password" v-model="formData.password2" placeholder="请再次确认密码" />
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="submit">提交</button>
|
||||
<view class="login-box-tips">
|
||||
<view style="color: #999">说明:密码需要长度为8-16</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiModifyPsd, gongkey } from '@/common/api/user'
|
||||
import { sm2, encrypt } from '@/common/js/sm2.js'
|
||||
import { sm3Digest } from '@/common/js/sm3.js'
|
||||
export default {
|
||||
name: 'ChangePWd',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
waitTime: 0,
|
||||
// 表单数据
|
||||
formData: {
|
||||
showPhone: '',
|
||||
phone: '',
|
||||
code: '',
|
||||
password: '',
|
||||
password2: '',
|
||||
},
|
||||
rules: {
|
||||
phone: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写新密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写确认密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 手机号中间四位隐藏
|
||||
this.formData.phone = uni.getStorageSync('userInfo').user_name
|
||||
this.formData.showPhone = this.formData.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
uni.showLoading({
|
||||
title: '请稍等',
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
type: 2,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading()
|
||||
console.log(res)
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
console.log(valid)
|
||||
if (!valid) {
|
||||
if (this.formData.password != this.formData.password2) {
|
||||
uni.showToast({
|
||||
title: '两次密码不一致',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
// 密码需要长度为8-16
|
||||
if (this.formData.password.length < 8 || this.formData.password.length > 16) {
|
||||
uni.showToast({
|
||||
title: '密码需要长度为8-16',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let loginName = encrypt(this.formData.phone)
|
||||
gongkey({ loginName }).then((response) => {
|
||||
let publicKey = response.data
|
||||
let sm3Pwd = sm3Digest(this.formData.password)
|
||||
let jiamipassword = sm2(sm3Pwd + '|' + this.formData.password, publicKey, 0)
|
||||
// apiPwdLogin({
|
||||
// username: loginName,
|
||||
// password: jiamipassword,
|
||||
// imageCode: '',
|
||||
// grant_type: 'captcha',
|
||||
// verifyCode: 0,
|
||||
// }).then((res) => {
|
||||
// this.$util.loginSuccess(res.data)
|
||||
// })
|
||||
apiModifyPsd({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code,
|
||||
password: jiamipassword,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'none',
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
padding: 20rpx;
|
||||
|
||||
.submit-btn {
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-tips {
|
||||
margin-top: 60rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.login-box-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
|
||||
.login-box-input-icon {
|
||||
width: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.login-box-input-main {
|
||||
font-size: 28rpx;
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.login-box-input-btn {
|
||||
padding:0 40rpx;
|
||||
margin-left: 40rpx;
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-input-img {
|
||||
margin-left: 40rpx;
|
||||
background: skyblue;
|
||||
height: 80rpx;
|
||||
width: 200rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<uni-forms ref="form" :modelValue="formData" :rules="rules">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput
|
||||
maxlength="11"
|
||||
disabled
|
||||
type="text"
|
||||
v-model="formData.showPhone"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入手机验证码" />
|
||||
<view
|
||||
class="ml40"
|
||||
style="
|
||||
margin-left: 40rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
"
|
||||
v-if="waitTime > 0"
|
||||
>{{ waitTime + 's后重新获取' }}</view
|
||||
>
|
||||
<button class="login-box-input-btn" v-else @click="getCode" size="mini">获取验证码</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="password">
|
||||
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入新的登录密码" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="password2">
|
||||
<uni-easyinput type="password" v-model="formData.password2" placeholder="请再次确认密码" />
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="submit">提交</button>
|
||||
<view class="login-box-tips">
|
||||
<view style="color: #999">说明:密码需要长度为8-16</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiModifyPsd, gongkey } from '@/common/api/user'
|
||||
import { sm2, encrypt } from '@/common/js/sm2.js'
|
||||
import { sm3Digest } from '@/common/js/sm3.js'
|
||||
export default {
|
||||
name: 'ChangePWd',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
waitTime: 0,
|
||||
// 表单数据
|
||||
formData: {
|
||||
showPhone: '',
|
||||
phone: '',
|
||||
code: '',
|
||||
password: '',
|
||||
password2: '',
|
||||
},
|
||||
rules: {
|
||||
phone: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写手机号',
|
||||
},
|
||||
],
|
||||
},
|
||||
code: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写新密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
password2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请填写确认密码',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 手机号中间四位隐藏
|
||||
this.formData.phone = uni.getStorageSync('userInfo').user_name
|
||||
this.formData.showPhone = this.formData.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
uni.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
type: 2,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading()
|
||||
console.log(res)
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
console.log(valid)
|
||||
if (!valid) {
|
||||
if (this.formData.password != this.formData.password2) {
|
||||
uni.showToast({
|
||||
title: '两次密码不一致',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
// 密码需要长度为8-16
|
||||
if (this.formData.password.length < 8 || this.formData.password.length > 16) {
|
||||
uni.showToast({
|
||||
title: '密码需要长度为8-16',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let loginName = encrypt(this.formData.phone)
|
||||
gongkey({ loginName }).then((response) => {
|
||||
let publicKey = response.data
|
||||
let sm3Pwd = sm3Digest(this.formData.password)
|
||||
let jiamipassword = sm2(sm3Pwd + '|' + this.formData.password, publicKey, 0)
|
||||
// apiPwdLogin({
|
||||
// username: loginName,
|
||||
// password: jiamipassword,
|
||||
// imageCode: '',
|
||||
// grant_type: 'captcha',
|
||||
// verifyCode: 0,
|
||||
// }).then((res) => {
|
||||
// this.$util.loginSuccess(res.data)
|
||||
// })
|
||||
apiModifyPsd({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code,
|
||||
password: jiamipassword,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'none',
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
padding: 20rpx;
|
||||
|
||||
.submit-btn {
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-tips {
|
||||
margin-top: 60rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.login-box-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
|
||||
.login-box-input-icon {
|
||||
width: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.login-box-input-main {
|
||||
font-size: 28rpx;
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.login-box-input-btn {
|
||||
padding: 0 40rpx;
|
||||
margin-left: 40rpx;
|
||||
background: $uni-theme-color;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.login-box-input-img {
|
||||
margin-left: 40rpx;
|
||||
background: skyblue;
|
||||
height: 80rpx;
|
||||
width: 200rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -114,7 +114,8 @@ export default {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等',
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
|
||||
@@ -121,7 +121,8 @@ export default {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等',
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.phone,
|
||||
|
||||
@@ -135,7 +135,8 @@ export default {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等',
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
|
||||
Reference in New Issue
Block a user