| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <view class="tab-page">
- <view class="backimage">
- <image class="back" src="/static/image/login/back.png" mode=""></image>
- <image class="title-img" src="/static/image/login/code.png" mode=""></image>
- <text class="title">验证码已发送至:+86 {{this.info.userName || mobile}}</text>
- </view>
- <view class="info ">
- <!-- #ifdef H5 -->
- <u--input v-model="info.smsCode" border="bottom" clearable maxlength="6" placeholderStyle="color:#999"
- style="padding: 34rpx 0;box-sizing: border-box;" :focus="true">
- <template slot="suffix">
- <u-code ref="uCode2" @change="codeChange2" keep-running start-text="发送验证码" style="color: #F9E000;"
- uniqueKey="smsCode"></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="bottom" clearable maxlength="6" placeholderStyle="color:#999"
- style="padding: 34rpx 0;box-sizing: border-box;" :focus="true">
- <template slot="suffix">
- <u-code ref="uCode2" @change="codeChange2" keep-running start-text="发送验证码" style="color: #F9E000;"
- uniqueKey="smsCode"></u-code>
- <view @tap="getCode2" :text="tips2" class="u-page__code-text">{{tips2}}</view>
- </template>
- </u-input>
- <!-- #endif -->
- </view>
- <view v-if="routepage == 'pages/set/accountCancellation'" class=" btn dis a-c j-c " @click="confirmLogout">
- 确定注销
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from "vuex"
- export default {
- data() {
- return {
- isHidePassword: true, //是否隐藏密码
- tips2: '',
- info: {
- userName: "", //账号
- system: "APP", //系统code
- captcha: "", //验证码
- captchaId: "", //验证码id
- smsCode: "", //手机验证码
- },
- routepage: "", // 上一个页面路由
- mobile: "",
- userId: "",
- }
- },
- onLoad(options) {
- let pages = getCurrentPages(); // 当前页面路由
- if (pages.length > 1) {
- let beforePage = pages[pages.length - 2].route;
- this.routepage = beforePage;
- }
- if (this.routepage == 'pages/login/login') {
- let info = JSON.parse(options.info);
- this.info.userName = info.userName;
- this.info.captcha = info.captcha;
- this.info.captchaId = info.captchaId;
- } else {
- this.mobile = options.mobile;
- this.userId = options.userId;
- }
- },
- watch: {
- "info.smsCode": {
- handler(val) {
- if (val.length == 6) {
- switch (this.routepage) {
- //登录
- case 'pages/login/login':
- uni.showLoading({
- title: '请求登录'
- })
- setTimeout(() => {
- uni.hideLoading();
- this.$login({
- url: "/auth/login",
- data: this.info,
- }).then(res => {
- if (res) {
- return uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- return;
- })
- }, 1000);
- break;
- case 'pages/my/replacePhone':
- //更换手机号
- this.validateMethod();
- break;
- default:
- }
- }
- },
- deep: true
- },
- },
- onShow() {},
- methods: {
- ...mapMutations(['emptyUserInfo']),
- //注销
- async confirmLogout() {
- let res = await this.$http.post('/auth/cancel', {
- mobile: this.mobile,
- smsCode: this.info.smsCode,
- });
- if (res.code == 200) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- this.emptyUserInfo();
- setTimeout(() => {
- uni.reLaunch({
- url: "/pages/login/login"
- })
- }, 1500);
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- },
- //修改密码
- confirm() {
- //重置密码逻辑
- uni.navigateTo({
- url: '/pages/login/login'
- })
- },
- codeChange2(text) {
- this.tips2 = text;
- },
- getCode2() {
- if (!this.info.userName && !this.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() {
- if (this.routepage == 'pages/login/login') {
- let res = await this.$http.get('/auth/sendSmsCode?mobile=' + this.info.userName || this.mobile);
- } else {
- let res = await this.$http.get('/auth/sendSmsCode?mobile=' + this.mobile);
- }
- },
- //校验
- async validateMethod() {
- let res = await this.$http.post('/appUser/validateCode', {
- mobile: this.mobile,
- smsCode: this.info.smsCode,
- });
- if (res.code == '200' && res.data) {
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/my/changePhoneNumber?userId=' + this.userId,
- })
- }, 1000)
- } else {
- uni.showToast({
- title: "验证码错误",
- icon: 'none'
- });
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #fff;
- }
- .backimage {
- width: 100%;
- height: 503rpx;
- background-color: #fff;
- position: relative;
- .back {
- width: 100%;
- height: 100%;
- }
- .title-img {
- position: absolute;
- top: 247rpx;
- left: 60rpx;
- width: 387rpx;
- height: 91rpx;
- }
- .title {
- position: absolute;
- top: 347rpx;
- left: 60rpx;
- font-size: 36rpx;
- color: #1f1f1f;
- }
- }
- .info {
- padding: 0 75rpx;
- box-sizing: border-box;
- .icon-img {
- width: 30rpx;
- height: 30rpx;
- }
- }
- //登录
- .performLogin {
- margin-top: 100rpx;
- .buttom {
- width: 100%;
- padding: 19rpx;
- box-sizing: border-box;
- background-color: #FDE935;
- border-radius: 45rpx;
- font-weight: bold;
- font-size: 36rpx;
- color: #1f1f1f;
- }
- .arigon {
- font-size: 28rpx;
- color: #666;
- padding: 0 30rpx;
- box-sizing: border-box;
- }
- }
- .footer {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 62rpx;
- text {
- font-size: 26rpx;
- color: #999;
- }
- }
- .codemodal {
- padding: 40rpx;
- box-sizing: border-box;
- .buttom {
- width: 100%;
- padding: 19rpx;
- box-sizing: border-box;
- background-color: #FDE935;
- border-radius: 45rpx;
- font-weight: bold;
- font-size: 36rpx;
- color: #1f1f1f;
- }
- }
- .sendcode {
- font-size: 28rpx;
- color: #F9E000;
- }
- .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;
- }
- .btn {
- margin: 60rpx 75rpx 0;
- box-sizing: border-box;
- background: #FDE935;
- border-radius: 58rpx 58rpx 58rpx 58rpx;
- padding: 20rpx;
- box-sizing: border-box;
- font-weight: bold;
- }
- </style>
|