| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <view class="page">
- <view class="info">
- <u--form labelPosition="left" :model="info" ref="ownerForm" labelWidth="80" errorType="message"
- :labelStyle="{fontWeight:'bold',color:'#333'}">
- <u-form-item label="手机号" borderBottom>
- <u--input v-model="info.mobile" border="none" clearable placeholder="请输入新手机号"
- placeholderStyle="color:#999"></u--input>
- </u-form-item>
- <u-form-item label="验证码" borderBottom>
- <!-- #ifdef H5 -->
- <u--input v-model="info.smsCode" border="none" clearable placeholder="请输入手机验证码" maxlength="6"
- placeholderStyle="color:#999">
- <template slot="suffix">
- <u-code ref="uCode2" @change="codeChange2" uniqueKey="changePhoneNumber" keep-running
- start-text="发送验证码" style="color: #F9E000;"></u-code>
- <view @tap="getCode2" :text="tips2" class="u-page__code-text">{{tips2}}</view>
- </template>
- </u--input>
- <!-- #endif -->
- <!-- #ifdef APP-PLUS -->
- <u-input v-model="info.smsCode" border="none" clearable placeholder="请输入手机验证码" maxlength="6"
- placeholderStyle="color:#999">
- <template slot="suffix">
- <u-code ref="uCode2" @change="codeChange2" uniqueKey="changePhoneNumber" keep-running
- start-text="发送验证码" style="color: #F9E000;"></u-code>
- <view @tap="getCode2" :text="tips2" class="u-page__code-text">{{tips2}}</view>
- </template>
- </u-input>
- <!-- #endif -->
- </u-form-item>
- </u--form>
- </view>
- <view class="btn dis a-c j-c " @click="save">
- 确定
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from "vuex"
- export default {
- data() {
- return {
- tips2: "",
- info: {
- mobile: "",
- smsCode: "",
- userId: "",
- },
- }
- },
- onShow() {
- },
- onLoad(options) {
- if (options.userId) {
- this.info.userId = options.userId;
- }
- },
- computed: {},
- methods: {
- ...mapMutations(['emptyUserInfo']),
- codeChange2(text) {
- this.tips2 = text;
- },
- getCode2() {
- if (!this.info.mobile) {
- uni.showToast({
- title: '手机号为空',
- icon: 'none'
- });
- return;
- }
- if (this.$refs.uCode2.canGetCode) {
- this.smsCode(); // 向后端请求验证码
- uni.showLoading({
- title: '正在获取验证码'
- })
- setTimeout(() => {
- uni.hideLoading();
- // 这里此提示会被this.start()方法中的提示覆盖
- uni.$u.toast('验证码已发送');
- // 通知验证码组件内部开始倒计时
- this.$refs.uCode2.start();
- }, 1000);
- } else {
- uni.$u.toast('倒计时结束后再发送');
- }
- },
- //获取验证码
- async smsCode() {
- let res = await this.$http.get('/auth/sendSmsCode?mobile=' + this.info.mobile);
- },
- //更换手机号
- async save() {
- let res = await this.$http.post('/auth/sendSmsCodeMobile', this.info);
- if (res.code == '200') {
- uni.showToast({
- title: '更换成功,请重新登录',
- icon: 'none'
- });
- this.emptyUserInfo();
- setTimeout(() => {
- uni.reLaunch({
- url: "/pages/login/login"
- })
- }, 500);
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #fff;
- padding: 30rpx 60rpx;
- box-sizing: border-box;
- }
- .info {}
- .btn {
- padding: 20rpx;
- box-sizing: border-box;
- background: #FDE935;
- border-radius: 45rpx 45rpx 45rpx 45rpx;
- margin-top: 100rpx;
- font-size: 36rpx;
- color: #1F1F1F;
- font-weight: bold;
- }
- ::v-deep {
- .u-form-item__body {
- padding: 34rpx 0;
- }
- }
- .u-page__code-text {
- padding: 4rpx 18rpx;
- background: rgba(253, 233, 53, 0.2);
- border-radius: 6rpx 6rpx 6rpx 6rpx;
- border: 1rpx solid #FDE935;
- color: #333333;
- font-size: 26rpx;
- }
- </style>
|