| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <view class="page">
- <view :style="{'marginTop':'10rpx'}">
- <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
- <u-form-item :labelWidth="80" label="姓名:" borderBottom prop="name" ref="item1">
- <u--input v-model="form.username" placeholder="请输入姓名" border="none"></u--input>
- </u-form-item>
- <u-form-item :labelWidth="80" label="性别:" borderBottom prop="sex" ref="item1" @click="showSex = true">
- <u--input v-model="form.sex" disabled disabledColor="#ffffff" placeholder="请选择性别" border="none"></u--input>
- <u-icon slot="right" name="arrow-right"></u-icon>
- </u-form-item>
- <u-form-item :labelWidth="80" label="生日:" borderBottom prop="sex" ref="item1" @click="showBirthday = true">
- <u--input v-model="form.sex" disabled disabledColor="#ffffff" placeholder="请选择生日" border="none"></u--input>
- <u-icon slot="right" name="arrow-right"></u-icon>
- </u-form-item>
- <u-form-item :labelWidth="80" label="手机号:" borderBottom prop="username" ref="item1">
- <u--input v-model="form.username" placeholder="请输入手机号" border="none"></u--input>
- </u-form-item>
- <u-form-item :labelWidth="80" label="验证码:" borderBottom prop="code" ref="item1">
- <view class="inputCode">
- <u--input v-model="form.code" placeholder="请输入验证码" border="none"></u--input>
- </view>
- <u-button slot="right" @tap="getCode" :text="tips" type="success" size="small" :disabled="disabled1"></u-button>
- </u-form-item>
- <u-form-item :labelWidth="80" label="密码:" borderBottom prop="newPassword" ref="item1">
- <u--input v-model="form.newPassword" placeholder="请输入密码" type="password" border="none"></u--input>
- </u-form-item>
- <u-form-item :labelWidth="80" label="确认密码:" borderBottom prop="againPassword" ref="item1">
- <u--input v-model="form.againPassword" placeholder="再次确认密码" type="password" border="none"></u--input>
- </u-form-item>
- </u--form>
- <view :style="{'marginTop':'100rpx'}">
- <button class="customStyle" @click="retrievePassword">提交</button>
- </view>
- <view class="flex-row justify-end register">
- <text @click="gologin">去登录-></text>
- </view>
- </view>
- <u-code ref="uCode" @change="codeChange" seconds="60" @start="disabled1 = true" @end="disabled1 = false"></u-code>
- <u-action-sheet
- :show="showSex"
- :actions="actions"
- title="请选择性别"
- @close="showSex = false"
- @select="sexSelect">
- </u-action-sheet>
- <u-datetime-picker
- :show="showBirthday"
- :value="birthday"
- mode="date"
- closeOnClickOverlay
- @confirm="birthdayConfirm"
- @cancel="birthdayClose"
- @close="birthdayClose"
- ></u-datetime-picker>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- showBirthday:false,
- showSex:false,
- birthday: Number(new Date()),
- actions: [{
- name: '男',
- value:'1'
- },
- {
- name: '女',
- value:'0'
- },{
- name: '保密',
- value:'2'
- }
- ],
- tips:'',
- form:{
- username:'',
- code:'',
- newPassword:'',
- againPassword:''
- },
- rules: {
- 'username': {
- type: 'string',
- required: true,
- min:11,
- max: 11,
- pattern:this.$phonePattern,
- message: '请输入正确的电话号码',
- trigger: ['blur', 'change']
- },
- 'code': {
- type: 'string',
- required: true,
- min:4,
- max: 6,
- message: '请输入验证码',
- trigger: ['blur', 'change']
- },
- 'newPassword': {
- type: 'string',
- min:6,
- max: 16,
- required: true,
- message: '请输入6-18位密码',
- trigger: ['blur', 'change']
- },
- 'againPassword': {
- type: 'string',
- min:6,
- max: 16,
- required: true,
- message: '请输入6-18位密码',
- trigger: ['blur', 'change']
- }
- },
- }
- },
- methods: {
- gologin(){
- uni.navigateTo({
- url:'/pages/login/login'
- })
- },
- birthdayClose() {
- this.showBirthday = false
- // this.$refs.form1.validateField('userInfo.birthday')
- },
- birthdayConfirm(e) {
- console.log(e)
- this.showBirthday = false
- this.form.birthday = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
- // this.$refs.form1.validateField('userInfo.birthday')
- },
- sexSelect(e) {
- console.log(e)
- },
- retrievePassword(){
- this.$refs.uForm.validate().then(res => {
- this.$api.login.retrievePassword(this.form).then(res=>{
- uni.showToast({
- icon: 'success',
- duration: 2000,
- title: '修改成功,即将跳转登录页'
- });
- setTimeout(()=>{
- this.logout()
- },2000)
- })
- })
- },
- logout(){
- this.$api.login.logout().then(res=>{
- uni.clearStorageSync();
- uni.navigateTo({
- url:'/pages/login/login'
- })
- })
- },
- back(){
- uni.navigateBack({
- delta: 1
- });
- },
- codeChange(text) {
- this.tips = text;
- },
- getCode() {
- if (this.$refs.uCode.canGetCode) {
- // 模拟向后端请求验证码
- uni.showLoading({
- title: '正在获取验证码'
- })
- this.$api.service.getSmsCode({phonenumber: this.form.username}).then(res=>{
- uni.hideLoading();
- // 这里此提示会被this.start()方法中的提示覆盖
- uni.$u.toast('验证码已发送');
- // 通知验证码组件内部开始倒计时
- this.$refs.uCode.start();
- })
- } else {
- uni.$u.toast('倒计时结束后再发送');
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import './index.rpx.css';
- </style>
|