9 changed files with 444 additions and 15 deletions
Unified View
Diff Options
-
1app.json
-
293colorui/main.wxss
-
4pages/home/index/index.wxml
-
12pages/home/mobile/index.js
-
96pages/home/password/index.js
-
6pages/home/password/index.json
-
39pages/home/password/index.wxml
-
6pages/home/password/index.wxss
-
2pages/login/index.js
@ -0,0 +1,96 @@ |
|||||
|
// pages/home/password/index.js
|
||||
|
// 页面已经废弃,因为UEC的修改,暂时不会提供修改密码的功能
|
||||
|
import { postCaptcha, setPassword } from "../../../api/user" |
||||
|
const util = require('../../../utils/util') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Page({ |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
second: '获取验证码', |
||||
|
codeEnable: false, |
||||
|
pwdType: 'password', |
||||
|
pwd_icon: 'attention', |
||||
|
form: { |
||||
|
mobile: null, |
||||
|
password: null, |
||||
|
verifyCode: null |
||||
|
}, |
||||
|
requesting: false, |
||||
|
first: false |
||||
|
}, |
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
this.setData({ ['form.mobile']: app.userInfo.mobile }) |
||||
|
if(options.from){ |
||||
|
this.setData({ first: true }) |
||||
|
} |
||||
|
}, |
||||
|
bindForm: function (e) { |
||||
|
this.data.form[e.target.id] = e.detail.value |
||||
|
}, |
||||
|
changePwd: function (e) { |
||||
|
if (this.data.pwdType === 'password') { |
||||
|
this.setData({ pwdType: 'text', pwd_icon: 'attentionforbid' }) |
||||
|
} else { |
||||
|
this.setData({ pwdType: 'password', pwd_icon: 'attention' }) |
||||
|
} |
||||
|
}, |
||||
|
fetchCode: function () { |
||||
|
if (util.isEmpty(this.data.form.mobile)) { |
||||
|
util.showToast('请输入手机号码') |
||||
|
return |
||||
|
} |
||||
|
if (this.second && this.second.interval) return !1 |
||||
|
wx.showLoading({ title: '正在获取', mask: true }) |
||||
|
postCaptcha({ verifiableAccount: this.data.form.mobile, verifiableAccountType: 1, purpose: 2 }).then(result => { |
||||
|
wx.hideLoading() |
||||
|
this.setData({ codeEnable: true }) |
||||
|
util.showToast('验证码已经发送') |
||||
|
this.countDown = this.countDown || this.selectComponent('.count-down') |
||||
|
this.countDown.reset() |
||||
|
this.countDown.start() |
||||
|
}).catch(error => { |
||||
|
wx.hideLoading() |
||||
|
util.showToast(error) |
||||
|
}) |
||||
|
}, |
||||
|
onChange: function(e) { |
||||
|
this.setData({ second: e.detail.seconds + ' 秒 ' }) |
||||
|
}, |
||||
|
onFinished: function(){ |
||||
|
this.setData({ second: '重新获取验证码', codeEnable: false }) |
||||
|
}, |
||||
|
submitForm: function () { |
||||
|
if (this.data.requesting) { |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.mobile) && !this.data.first) { |
||||
|
util.showToast('请输入手机号码') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.password)) { |
||||
|
util.showToast('请输入密码') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.verifyCode) && !this.data.first) { |
||||
|
util.showToast('请输入验证码') |
||||
|
return |
||||
|
} |
||||
|
wx.showLoading({ title: '处理中', mask: true }) |
||||
|
this.data.requesting = true |
||||
|
setPassword(this.data.form).then(res => { |
||||
|
wx.hideLoading() |
||||
|
util.showBackToast('设置成功') |
||||
|
}).catch(error => { |
||||
|
wx.hideLoading() |
||||
|
this.data.requesting = false |
||||
|
util.showToast(error) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
}) |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"van-button": "/components/button/index", |
||||
|
"van-count-down": "/components/count-down/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
<!--pages/home/password/index.wxml--> |
||||
|
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
|
<view slot="content" style="color:black;font-size:18px">{{first ? '设置密码' : '密码重置'}}</view> |
||||
|
</cu-custom> |
||||
|
|
||||
|
<wux-alert theme="positive" title="为了简化登录流程,您可以设置登录密码,以后就可以直接使用密码进行登录了。" wx:if="{{first}}"/> |
||||
|
|
||||
|
<view class="cu-list menu no-card sm-border margin-top"> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:170rpx">登录密码:</view> |
||||
|
<input id="password" maxlength="24" type="password" placeholder="请输入新的登录密码" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="cu-list menu no-card sm-border margin-top" wx:if="{{!first}}"> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:170rpx">手机号:</view> |
||||
|
<input id="mobile" maxlength="11" disabled="true" type="number" value="{{form.mobile}}" placeholder="请输入当前登录手机号码" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:170rpx">验证码:</view> |
||||
|
<input id="verifyCode" maxlength="6" type="number" placeholder="请输入验证码" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
<van-button size="small" plain type="info" custom-style="width:220rpx" disabled="{{codeEnable}}" bind:click="fetchCode"> |
||||
|
<van-count-down id="count-down" time="{{ 60000 }}" use-slot auto-start="{{false}}" bind:change="onChange" bind:finish="onFinished"> |
||||
|
<text class="text-sm">{{second}}</text> |
||||
|
</van-count-down> |
||||
|
</van-button> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="flex flex-direction" style="padding:80rpx 32rpx"> |
||||
|
<van-button block type="info" bind:click="submitForm">提交</van-button> |
||||
|
</view> |
||||
@ -0,0 +1,6 @@ |
|||||
|
/* pages/home/password/index.wxss */ |
||||
|
.content-box { |
||||
|
background-color: #fff; |
||||
|
margin: 30rpx; |
||||
|
border-radius: 10rpx |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save