123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- <template>
- <view class="container">
- <u-icon class="back-btn" name="arrow-left" color="black" size="20" @click="navBack"></u-icon>
- <view class="wrapper">
- <h2>重置密码</h2>
- <view style='width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;' class="flex">
- <view style='width:15%;border-right:1px solid #E8E9ED;'>+86</view>
- <view style='width:85%;'><input maxlength="11" @input='phoneinput' style='padding-left:10px;' v-model='phone' placeholder="请输入手机号码" type="text"></view>
- </view>
- <view style='width:100%;border-bottom:1px solid #E8E9ED;position:relative;padding:10px;' class="flex">
- <view style='width:85%;'><input maxlength="6" v-model='verifyCode' placeholder="请输入验证码" type="text"></view>
- <button @click='getcode' :class='status&&!sendDisabled?"active":""' class='getcode'>{{sendText}}</button>
- </view>
- <view style='border-bottom:1px solid #E8E9ED;padding:10px;position:relative;'>
- <input class='password' style='height:30px;' v-model='password' placeholder="请输入新密码,6-16位字符" :type="type" value="" />
- <view style='position:absolute;right:0;top:38%;z-index:10;cursor:pointer;' class="iconfont ">
- <image class='yanjingicon' style='width:22px;height:22px;margin-top: -10rpx;' @click='switchover' v-if="type=='password'" src="../../../static/yioncang.png" mode=""></image>
- <image class='yanjingicon' style='width:22px;height:22px;margin-top: -10rpx;' @click='switchover' v-else src="../../../static/xianshi.png" mode=""></image>
- </view>
- </view>
- <button :class='phone!=""&&verifyCode!=""&&password!=""?"active":""' @click='reset' class='verificationCode'>重置密码</button>
- </view>
- </view>
- </template>
- <script>
- import {
- mapMutations
- } from 'vuex';
- // import { openFSqlite, createFSQL, selectFSQL, addFSQL } from '../../util/f.js'
- // import { queryData, upData, initData } from '../../util/dbUtil.js'
- export default {
- data() {
- return {
- inputContent: null,
- loginType: "wechat",
- phone: '',
- password: '',
- logining: false,
- isPhone: false,
- isApple: true,
- accessToken:'',
- params:{
- encryptedData:'',
- session_key:'',
- iv:'',
- },
- status:false,
- userInfo:{
- nickName:'',
- avatarUrl:'',
- gender:'',
- phone:''
- },
- consentStatus:false,
- type:'password',
- inputStatus:'none',
- verifyCode:null,
- sendText:'获取验证码',
- sendDisabled: false,
- system:'',
- platform:'',
- userData:undefined,
- canIUseProfile:false,
- isPhone:""
- }
- },
- onShow() {
- // this.loginType = "wechat"
- this.$api.logout()
- },
- onLoad(options) {
- this.phone = options.phone //个人首页修改密码
- if(this.phone.length==11){
- this.status=true
- }
- // this.isPhone = options.phone //个人首页修改密码成功后自动退出重新登录
- // if( wx.getUserProfile ){
- // console.log('--check getUserProfile--OK');
- // this.canIUseProfile = true;
- // }
- // console.log("login on load")
- // var that = this
- // that.$api.request('user', 'sendIsApple', {
- // }).then(res => {
- // that.isApple = res.data
- // })
- // uni.getSystemInfo({
- // success:(res) => {
- // // console.log(res)
- // this.system = res.system // ios
- // this.platform = res.platform // 14.3
- // }
- // })
- },
- methods: {
- phoneinput(e){
- if(e.detail.value.length==11){
- this.status=true
- }
- },
- getcode(e){
- if(this.phone.length!=11){
- uni.showToast({
- title: '请输入正确的手机号',
- icon:'none',
- duration: 2000
- })
- return
- }
- if(/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)){
- var that=this
- this.$request.baseRequest('get','/commonUser/sendVerifyCode',{phone:this.phone,identification:1,flag:2}).then(res => {
-
- if(res.code==200){
- that.sendDisabled = true
- let sec = 60
- let interval = setInterval(() => {
- sec--;
- that.sendText = sec + 's后重发'
- if (sec <= 0) {
- that.sendDisabled = false
- that.sendText = "获取验证码"
- clearInterval(interval)
- }
- }, 1000)
- }else{
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- }
-
- })
- .catch(res => {
- if(res.message){
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- }
- else{
- uni.showToast({
- title: "系统异常,请联系管理员",
- icon: 'none',
- duration: 2000
- })
- }
- });
- }else{
- uni.showToast({
- title: '请输入正确的手机号',
- icon:'none',
- duration: 2000
- })
- }
- },
- reset(){
- var that = this
- if (this.password.length < 6) {
- uni.showToast({
- title: '密码请输入6-16字符格式',
- icon: 'none',
- duration: 2000
- })
- return
- }
- uni.showLoading({
- title: '重置密码中'
- })
- this.$request.baseRequest('post','/commonUser/resetPassword',{phone:this.phone,password:this.password,verifyCode:this.verifyCode,identification:1}).then(res => {
- // 获得数据
- if(res.code==200){
- if(this.isPhone){//判断是否是在个人首页进来的(若是退出重进)
- uni.clearStorageSync();
- this.$request.baseRequest('post', '/auth/api/logout').then(res => {})
- this.$store.commit('logout')
- this.$api.logout()
- setTimeout(() => {
- uni.showToast({
- title: '修改成功',
- icon: 'none',
- duration: 2000
- })
- },2000)
- uni.navigateTo({
- url: `/pages/public/login`
- })
-
- }else{
- setTimeout(() => {
- uni.navigateBack()
- }, 1000)
- }
- uni.showToast({
- title: '重置成功',
- icon: 'none',
- duration: 2000
- })
- }else{
- uni.showToast({
- title: res.message,
- icon:'none',
- duration: 2000
- })
- }
- uni.hideLoading()
- })
- .catch(res => {
- uni.showToast({
- title: "系统异常,请联系管理员",
- icon:'none',
- duration: 2000
- })
- uni.hideLoading()
- });
- },
-
- switchover(){
- if(this.type=='password'){
- this.type='text'
- }else{
- this.type='password'
- }
- },
- cancel() {
- this.inputShow = false
- this.inputStatus = 'none'
- this.isPhone = false
- },
- ...mapMutations(['login']),
- inputChange(e) {
- const key = e.currentTarget.dataset.key;
- this[key] = e.detail.value;
- },
- navBack() {
- uni.navigateBack();
- },
-
- },
- }
- </script>
- <style lang='scss' scoped>
-
- .apple{
- background: #000;
- width: 35px;
- height: 35px;
- padding: 8px;
- border-radius: 50%;
- vertical-align: middle;
- }
- page {
- background: #fff;
- }
- .cuIcon-weixin{
- background: #2772FB;
- color: #fff;
- font-size: 18px;
- padding: 9px;
- border-radius: 50%;
- vertical-align: middle;
- margin-right:5px;
- }
- .container {
- padding-top: 85px;
- position: relative;
- width: 100vw;
- height:calc(100vh - 85px);
- overflow: hidden;
- background: url('~@/static/images/mine/bg@2x.png');
- background-size:100% 100vh;
- background-repeat: no-repeat;
- }
- .wrapper {
- position: relative;
- z-index: 90;
- padding-bottom: 40upx;
- height:100%;
- padding:0 30px;
- }
- .back-btn {
- position: absolute;
- left: 40upx;
- z-index: 9999;
- padding-top: var(--status-bar-height);
- top: 40upx;
- font-size: 40upx;
- color:black;
- }
- .verificationCode{
- margin-top:20px;
- background:#F5F6F9;
- color:#AFB3BF;
- }
- .verificationCode:after{
- border:none;
- }
- .verificationCode.active{
- background:#2772FB;
- color:#fff;
- }
- .register{
- position:absolute;
- bottom:20px;
- left:50%;
- transform: translateX(-50%);
- color:#333333;
- height:50px;
- line-height:50px;
- border-radius:30px;border: 1px solid #444444;
- }
- .register:after{
- border:none;
- }
- .getcode{
- font-size:14px;
- position:absolute;
- right:0;
- top:50%;
- transform: translateY(-50%);
- color:#AFB3BF;
- background:#F5F6F9;
- height:30px;
- line-height:30px;
-
- }
- .password{
- border:none;
- outline: none;
- }
- .getcode:after{
- border:none;
- }
- .getcode.active{
- background:#2772FB;
- color:#fff;
- }
- uni-navigator{
- display:inline-block;
- color:#2772FB;
- }
- .yanjingicon{
- margin: 0;
- justify-content: flex-end;
- }
- </style>
|