import {mapState,mapMutations} from 'vuex'
import {LOCK} from '../../store/modules/actionType.js'
computed:{
...mapState('common',['lock'])
},
...mapMutations('common',[LOCK]),
async login(){
if(this.lock) return
let reslut = this.checkTel() && this.checkPas()
if(!reslut) return
this.Lock()
let data={
username:this.tel,
password:this.pas,
}
let res = await request(url.login,data,'post')
uni.showToast({
icon:'none',
title:res.message
})
uni.setStorageSync('timestamp',res.data.timestamp)
uni.setStorageSync('token',res.data.token)
let timer=setTimeout(()=>{
clearTimeout(timer)
uni.redirectTo({
url:'/pages/index/index'
})
},1500)
},
import {LOCK,UNLOCK} from'./actionType.js'
const common = {
state:{
lock:false
},
mutations:{
[LOCK](state){
state.lock=true
},
[UNLOCK](state){
state.lock=false
},
},
actions:{
[LOCK]({commit}){
commit(LOCK)
},
[UNLOCK]({commit}){
commit(UNLOCK)
},
}
}
export default {
namespaced:true,
...common
}
1 个回复
3***@qq.com
解决了吗?我在HbuilderX更新到3.1.8时失效的,不清楚是什么地方配置有问题...