Browse Source

优化登录操作

master
453530270@qq.com 2 years ago
parent
commit
315d2dd7ee
  1. 37
      pages/login/components/main.vue
  2. 7
      store/modules/user.js

37
pages/login/components/main.vue

@ -35,16 +35,17 @@
</view>
<!-- 找回密码 注册 -->
<view class="fdreg">
<text class="findpass">找回密码</text>
<text class="regnow">立即注册</text>
<text class="findpass" @click="findpass">找回密码</text>
<text class="regnow" @click="register">立即注册</text>
</view>
<!-- 隐私政策等 -->
<div class="privacy">
<label>
<checkbox :checked="isTick" color="#4399ff" class="ckbox" @click="readpri"></checkbox>
我已阅读并同意网站的 隐私政策 用户注册协议
</label>
</div>
<view class="privacy">
<checkbox :checked="isTick" color="#4399ff" class="ckbox" @click="readpri"></checkbox>
<view class="">
我已阅读并同意网站的 <text class="atxt" @click="gotopage('private')">隐私政策</text>
<text class="atxt" @click="gotopage('prototal')">用户注册协议</text>
</view>
</view>
</view>
@ -181,7 +182,8 @@
})
.then(result => {
//
app.$toast(result.message)
app.$toast("登录成功")
//app.$toast(result.message)
// :
uni.$emit('syncRefresh', true)
//
@ -209,7 +211,14 @@
} else {
this.$navTo('pages/index/index')
}
}
},
/**
* 阅读注册协议和隐私
*/
gotopage(str){
this.$toast(str)
}
}
}
@ -318,5 +327,13 @@
.privacy{
display: flex;
margin-top: 10rpx;
.ckbox{
border-radius: 50%;
}
.atxt{
color: #4399ff;
}
}
</style>

7
store/modules/user.js

@ -3,15 +3,15 @@ import storage from '@/utils/storage'
import * as LoginApi from '@/api/login'
// 登陆成功后执行
const loginSuccess = (commit, { token, userId }) => {
const loginSuccess = (commit, { token, accountId }) => {
// 过期时间30天
const expiryTime = 30 * 86400
// 保存tokne和userId到缓存
storage.set(USER_ID, userId, expiryTime)
storage.set(USER_ID, accountId, expiryTime)
storage.set(ACCESS_TOKEN, token, expiryTime)
// 记录到store全局变量
commit('SET_TOKEN', token)
commit('SET_USER_ID', userId)
commit('SET_USER_ID', accountId)
}
const user = {
@ -40,6 +40,7 @@ const user = {
.then(response => {
console.log("login ret:",response)
const result = response.data
console.log("user rest:",result)
loginSuccess(commit, result)
resolve(response)
})

Loading…
Cancel
Save