123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- <template>
- <view>
- <view class="password-type-2">
- <!--顶部返回按钮-->
- <text class="back-btn iconfont iconzuo" @tap="navBack"></text>
- <view class="login-top" :class="'bg-' + themeColor.name">
- <view class="desc">
- <view class="title">Hi~</view>
- <text>{{ this.$i18n.locale == 'zh' ? '找回密码' : 'RetrievePassword' }}!</text>
- </view>
- <image class="login-pic" :src="loginPic"></image>
- </view>
- <view class="login-type-content">
- <image class="login-bg" :src="loginBg"></image>
- <view class="main">
- <view class="login-type-form">
- <view class="input-item" style="display: flex;">
- <text class="iconfont icondianhua" :class="'text-' + themeColor.name"></text>
- <input class="login-type-input" type="number" name="mobile"
- v-model="resetPasswordParams.mobile" :placeholder="i18n('EnterMobile')"
- maxlength="20" />
- <text @click="toGR" style="width:240upx;">
- <text
- style="max-width:100upx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;display: inline-block;vertical-align: middle;">
- {{selectName}}</text>
- <text style="vertical-align: middle;"> ({{'+' + select}})</text>
- </text>
- </view>
- <view class="input-item input-item-sms-code">
- <text class="iconfont iconyanzhengma" :class="'text-' + themeColor.name"></text>
- <view class="input-wrapper">
- <view class="rf-input-wrapper">
- <input type="number" class="login-type-input" v-model="resetPasswordParams.code"
- :placeholder="i18n('EnterVerification')" maxlength="6" />
- </view>
- <button class="sms-code-btn" :disabled="smsCodeBtnDisabled" @click="getSmsCode">
- <text v-if="!smsCodeBtnDisabled">{{i18n('GetVerification')}}</text>
- <text v-else class="sms-code-resend">{{codeSeconds}}s{{i18n('resend')}}</text>
- <!-- {{`重新发送 (${codeSeconds})`}}</text> -->
- </button>
- </view>
- </view>
- <view class="input-item">
- <text class="iconfont iconmimaffffffpx" :class="'text-' + themeColor.name"></text>
- <input class="login-type-input" type="password" v-model="resetPasswordParams.password"
- :placeholder="this.$i18n.locale == 'zh' ? '请输入密码':'Please input a password'"
- maxlength="20" />
- </view>
- <view class="input-item">
- <text class="iconfont iconmimaffffffpx" :class="'text-' + themeColor.name"></text>
- <input class="login-type-input" type="password"
- v-model="resetPasswordParams.password_repetition"
- :placeholder="this.$i18n.locale == 'zh' ? '请输入确认密码':'Please input a password'"
- maxlength="20" />
- </view>
- </view>
- <view class="login-type-tips">
- <view @tap="navTo('/pages/public/login')" class="forget-section">
- {{this.$i18n.locale == 'zh' ? '马上登陆' :'login'}}
- </view>
- <text @tap="toHome">{{this.$i18n.locale == 'zh' ? '返回主页' :'Home'}}</text>
- </view>
- <button class="confirm-btn" :class="'bg-' + themeColor.name" :disabled="btnLoading"
- :loading="btnLoading" @tap="restPassword">
- {{this.$i18n.locale == 'zh' ? '找回密码' : 'RetrievePassword'}}
- </button>
- </view>
- </view>
- <view class="login-type-bottom" :class="'text-' + themeColor.name">
- {{ appName }}{{this.$i18n.locale == 'zh' ? '版权所有' : 'Copyright'}}
- </view>
- <u-toast ref="uToast" />
- </view>
- </view>
- </template>
- <script>
- import {
- smsCode,
- updatePassword
- } from '@/api/login';
- import moment from '@/common/moment';
- export default {
- data() {
- return {
- resetPasswordParams: {
- mobile: '',
- password: '',
- password_repetition: '',
- code: ''
- },
- btnLoading: false,
- type: null,
- smsCodeBtnDisabled: true,
- loginBg: this.$mAssetsPath.loginBg,
- loginPic: this.$mAssetsPath.loginPic,
- appName: this.$mSettingConfig.appName,
- reqBody: {},
- codeSeconds: 0, // 验证码发送时间间隔
- second: 60,
- service: '',
- phoneNum: '',
- userInfo: [],
- select: '0086',
- selectName: this.$i18n.locale == 'zh' ? '中国' : 'China',
- selectList: '',
- regLogStyle: '4'
- };
- },
- onLoad(options) {
- this.selectList = options.data ? JSON.parse(options.data) : {};
- this.select = this.selectList.id ? this.selectList.id : this.select;
- let countryName = this.$i18n.locale == 'zh' ? this.selectList.cnValue : this.selectList.enValue;
- this.selectName = countryName ? countryName : this.selectName;
- console.log('select:', this.select)
- console.log('selectName:', this.selectName)
- const time =
- moment().valueOf() / 1000 - uni.getStorageSync('pwdSmsCodeTime');
- if (time < 60) {
- this.codeSeconds =
- this.$mConstDataConfig.sendCodeTime - parseInt(time, 10);
- this.handleSmsCodeTime(this.codeSeconds);
- } else {
- this.codeSeconds = this.$mConstDataConfig.sendCodeTime;
- this.smsCodeBtnDisabled = false;
- uni.removeStorageSync('pwdSmsCodeTime');
- }
- this.type = options.type;
- },
- methods: {
- async getSmsCode() {
- //获取当前手机号的用户信息
- this.getUserInfo();
- },
- // 获取手机验证码
- async userInfoBack() {
- this.service = "TX";
- //发送验证码 判断当前是手机号还是邮箱号 短信:service:“TX" 邮件:service:“YJ
- let language = this.$i18n.locale;
- const res = await this.$myRequest({
- url: '/ums/umsUsers/Code',
- data: {
- account: this.phoneNum,
- service: this.service,
- language
- },
- });
- if (res.status == '200') {
- this.handleSmsCodeTime(this.second);
- return this.$refs.uToast.show({
- title: res.msg,
- type: 'success',
- }); //手机号不能为空
- } else {
- return this.$refs.uToast.show({
- title: res.msg,
- type: 'error',
- });
- }
- },
- //验证手机号合法性
- verificationTel(name) {
- if (!name) {
- return this.$refs.uToast.show({
- title: this.i18n('Mobilephonenumbercannotbeempty') + "!",
- type: 'warning',
- }); //手机号不能为空
- }
- // const regPhone = /^([0-9]*)$/;
- const regPhone = /^(0|86|17951)?(13[0-9]|15[123456789]|16[6]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
- if (regPhone.test(name)) {
- return true;
- } else {
- this.$refs.uToast.show({
- title: this.i18n('Pleaseenteravalidmobilephonenumber') + "!",
- type: 'warning',
- }); //请输入合法的手机号
- return false;
- }
- },
- async getUserInfo() {
- var bool = this.verificationTel(this.resetPasswordParams.mobile);
- if (!bool) {
- return;
- }
- //校验手机号/邮箱/验证码格式
- this.phoneNum = this.select + this.resetPasswordParams.mobile
- this.userInfoBack();
- //获取当前登录手机号的用户信息
- // const result = await this.$myRequest({
- // url: '/ums/umsUsers/getByUserName',
- // data: {
- // userName: this.phoneNum
- // }
- // });
- // if (result.status == 200 && result.data != null && result.data != "") {
- // this.userInfo = result.data;
- // } else {
- // this.$refs.uToast.show({
- // title: this.$i18n.locale == 'zh' ? '用户不存在' : 'user does not exist',
- // type: 'error',
- // })
- // };
- },
- handleSmsCodeTime(time) {
- let timer = setInterval(() => {
- if (time === 0) {
- clearInterval(timer);
- this.smsCodeBtnDisabled = false;
- } else {
- this.codeSeconds = time;
- this.smsCodeBtnDisabled = true;
- time--;
- }
- }, 1000);
- },
- //后台自动登录,获取token值
- async codeLogin() {
- this.service = "TX";
- const res = await this.$myRequest({
- url: '/sys/token',
- data: {},
- });
- const that = this;
- let token = res.data;
- let VCode = this.resetPasswordParams.code;
- this.phoneNum = this.select + this.resetPasswordParams.mobile
- // let page = JSON.stringify({
- // mobile: this.phoneNum,
- // code: VCode,
- // grant_type: 'password',
- // client_id: 'client_2',
- // client_secret: '1xapp',
- // });
- let page = {
- mobile: this.phoneNum,
- code: VCode,
- grant_type: 'password',
- client_id: 'client_2',
- client_secret: '1xapp',
- };
- const login = await this.$myRequest({
- url: '/ums/mobile/login',
- data: page,
- method: 'post',
- type: 'formData'
- });
- if (login.msg == 'ok') {
- try {
- uni.setStorageSync('user', login.data.userInfo);
- uni.setStorageSync('Auth-Token', login.data.access_token);
- //存储登录账号
- uni.setStorageSync('loginAccount', this.resetPasswordParams.mobile);
- } catch (e) {
- }
- this.toUpdatePassword();
- } else {
- return this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '修改失败请重新再试' :
- 'Modification failed. Please try again',
- type: 'error',
- });
- }
- },
- // 更新密码
- async toUpdatePassword() {
- let Storage_data;
- let token;
- try {
- Storage_data = JSON.parse(uni.getStorageSync('user'));
- token = uni.getStorageSync('Auth-Token');
- } catch (e) {
- }
- let userId = Storage_data.id
- // console.log('Storage_data', Storage_data)
- console.log('userId', userId)
- // this.Storage_data = JSON.parse(uni.getStorageSync('user'));
- // this.AuthToken = uni.getStorageSync('Auth-Token');
- if (userId == "" || userId == null) {
- return this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '系统繁忙,请稍后再试' :
- 'The system is busy. Please try again later',
- type: 'warning',
- });
- }
- if (this.resetPasswordParams.password == "" || this.resetPasswordParams.password == null) {
- return this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '新密码不能为空' : 'New password cannot be empty',
- type: 'warning',
- });
- }
- if (this.resetPasswordParams.password_repetition == "" || this.resetPasswordParams
- .password_repetition == null) {
- return this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '确认密码不能为空' : 'Confirm password cannot be empty',
- type: 'warning',
- });
- }
- //判断两次密码是否一致
- if (this.resetPasswordParams.password != this.resetPasswordParams.password_repetition) {
- return this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '两次输入密码不一致' : 'The two passwords are inconsistent',
- type: 'warning',
- });
- }
- //校验密码格式
- var msg = /((?=.*\d)(?=.*\D)(?=.*[a-z])(?=.*[A-Z]))(?!^.*[\u4E00-\u9FA5].*$)^\S{8,20}$/.test(
- this.resetPasswordParams.password_repetition) ? "" : this.$i18n.locale == 'zh' ? '请输入8~20为密码' :
- 'Your password strength is too low, please enter your password';
- if (msg != "") {
- return this.$refs.uToast.show({
- title: msg,
- type: 'warning',
- });
- }
- let param = JSON.stringify({
- id: userId,
- password: this.resetPasswordParams.password_repetition,
- Authorization: token
- });
- const result = await this.$myRequest({
- url: '/ums/umsUsers/changePassword',
- method: 'post',
- data: {
- param: param
- }
- });
- if (result.status == '200') {
- this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '密码修改成功,请使用新密码重新登录!' :
- 'Password modified successfully, please use the new password to login again!',
- type: 'success',
- });
- uni.removeStorageSync('user');
- uni.removeStorageSync('Auth-Token');
- setTimeout(() => {
- uni.navigateTo({
- url: `/pages/public/login`
- });
- }, 2000);
- } else {
- this.$refs.uToast.show({
- title: result.msg,
- type: 'error',
- });
- try {
- uni.removeStorageSync('user');
- uni.removeStorageSync('Auth-Token');
- } catch (e) {
- }
- }
- },
- async restPassword() {
- if (!this.resetPasswordParams.code) {
- this.$refs.uToast.show({
- title: this.$i18n.locale == 'zh' ? '验证码不能为空' : 'verificationCode cannot be empty',
- type: 'warning',
- });
- return;
- }
- this.codeLogin();
- },
- toGR() {
- uni.navigateTo({
- url: '/pages/public/GlobalRoaming?regLogStyle=' + this.regLogStyle
- })
- },
- i18n(data) {
- return this.$t('common.' + data);
- },
- navBack() {
- this.$mRouter.back();
- },
- navTo(route) {
- this.$mRouter.push({
- route
- });
- },
- toHome() {
- this.$mRouter.reLaunch({
- route: '/pages/index/index'
- });
- },
- }
- };
- </script>
- <style lang="scss">
- page {
- background: $color-white;
- }
- /* .container {
- padding-top: 60px;
- position: relative;
- width: 100vw;
- overflow: hidden;
- .wrapper {
- position: relative;
- width: 100vw;
- z-index: 90;
- background: #fff;
- padding-bottom: 40upx;
- .welcome {
- position: relative;
- left: 50upx;
- top: -90upx;
- font-size: 46upx;
- color: #555;
- text-shadow: 1px 0px 1px rgba(0, 0, 0, 0.3);
- }
- .input-content {
- padding: 0 60upx;
- }
- .input-item {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: center;
- padding: 0 30upx;
- background: $page-color-light;
- height: 120upx;
- border-radius: 4px;
- margin-bottom: 50upx;
- &:last-child {
- margin-bottom: 0;
- }
- .tit {
- height: 50upx;
- line-height: 56upx;
- font-size: $font-sm + 2upx;
- color: $font-color-base;
- }
- input {
- height: 60upx;
- font-size: $font-base + 2upx;
- color: $font-color-dark;
- width: 100%;
- }
- }
- .input-item-sms-code {
- position: relative;
- .sms-code-btn {
- position: absolute;
- right: 20upx;
- color: #111;
- bottom: 20upx;
- font-size: 28upx;
- }
- .sms-code-resend {
- color: #999;
- }
- }
- .forget-section {
- font-size: $font-sm + 2upx;
- color: $font-color-spec;
- text-align: center;
- margin-top: 40upx;
- }
- }
- .back-btn {
- position: absolute;
- left: 40upx;
- z-index: 9999;
- padding-top: var(--status-bar-height);
- top: 40upx;
- font-size: 40upx;
- color: $font-color-dark;
- }
- .left-top-sign {
- font-size: 120upx;
- color: $page-color-base;
- position: relative;
- left: -16upx;
- }
- .right-top-sign {
- position: absolute;
- top: 80upx;
- right: -30upx;
- z-index: 95;
- &:before,
- &:after {
- display: block;
- content: '';
- width: 400upx;
- height: 80upx;
- background: #b4f3e2;
- }
- &:before {
- transform: rotate(50deg);
- border-radius: 0 50px 0 0;
- }
- &:after {
- position: absolute;
- right: -198upx;
- top: 0;
- transform: rotate(-50deg);
- border-radius: 50px 0 0 0;
- }
- }
- .register-section {
- margin: 50upx 0 50upx 0;
- width: 100%;
- font-size: $font-sm + 2upx;
- color: $font-color-base;
- text-align: center;
- text {
- color: $font-color-spec;
- margin-left: 10upx;
- margin-right: 10upx;
- }
- }
- }
- */
- .password-type-2 {
- width: 100%;
- position: relative;
- .back-btn {
- position: absolute;
- left: 40upx;
- z-index: 9999;
- padding-top: var(--status-bar-height);
- top: 40upx;
- font-size: 48upx;
- color: $color-white;
- }
- .login-top {
- height: 460upx;
- position: relative;
- .desc {
- position: absolute;
- top: 200upx;
- left: 40upx;
- font-size: 48upx;
- z-index: 2;
- .title {
- font-size: 48upx;
- }
- }
- .login-pic {
- position: absolute;
- width: 750upx;
- height: 270upx;
- right: 30upx;
- top: 100upx;
- z-index: 1;
- }
- }
- .login-type-content {
- position: relative;
- top: -72upx;
- .login-bg {
- width: 94vw;
- height: 114vw;
- margin: 0 3vw;
- }
- .main {
- width: 94vw;
- position: absolute;
- top: 0;
- left: 3vw;
- .nav-bar {
- display: flex;
- height: 100upx;
- justify-content: center;
- align-items: center;
- position: relative;
- z-index: 10;
- .nav-bar-item {
- flex: 1;
- display: flex;
- height: 100%;
- line-height: 96upx;
- font-size: $font-lg;
- display: flex;
- margin: 0 120upx;
- justify-content: center;
- }
- .nav-bar-item-active {
- border-bottom: 5upx solid;
- }
- }
- .login-type-form {
- width: 80%;
- margin: 50upx auto;
- .input-item {
- position: relative;
- height: 90upx;
- line-height: 90upx;
- margin-bottom: $spacing-lg;
- .iconfont {
- font-size: 50upx;
- position: absolute;
- left: 0;
- }
- .login-type-input {
- height: 90upx;
- padding-left: 80upx;
- border-bottom: 1upx solid rgba(0, 0, 0, .1);
- }
- .sms-code-btn,
- sms-code-resend {
- width: 240upx;
- font-size: $font-base - 2upx;
- }
- }
- }
- .login-type-tips {
- padding: 0 50upx;
- display: flex;
- justify-content: space-between;
- }
- .confirm-btn {
- height: 80upx;
- line-height: 80upx;
- }
- }
- }
- .login-type-bottom {
- width: 100%;
- padding-bottom: 30upx;
- text-align: center;
- font-size: $font-lg;
- }
- }
- </style>
|