|
|
@ -6,7 +6,11 @@ |
|
|
|
</view> |
|
|
|
<view class="li-name">欢迎使用欧轩智能场馆平板端系统</view> |
|
|
|
<view class="li-from"> |
|
|
|
<login-form></login-form> |
|
|
|
<login-form |
|
|
|
:username="username" @update:username="update_username" |
|
|
|
:password="password" @update:password="update_password" |
|
|
|
:brand_id="brand_id" @update:brand_id="update_brand_id" |
|
|
|
></login-form> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="li-tip">*登录账号密码请从pc端后台管理【设备运营管理平板管理】里获取</view> |
|
|
@ -25,10 +29,108 @@ |
|
|
|
import loginButton from '@/components/login/button.vue'; |
|
|
|
|
|
|
|
import util from "@/utils/util.js" |
|
|
|
import { |
|
|
|
API |
|
|
|
} from "@/utils/api"; |
|
|
|
import { |
|
|
|
ox |
|
|
|
} from "@/utils/server"; |
|
|
|
|
|
|
|
import { |
|
|
|
onMounted, |
|
|
|
ref, |
|
|
|
} from 'vue' |
|
|
|
import { onLoad,onReady } from '@dcloudio/uni-app'; |
|
|
|
|
|
|
|
onReady(async () => { |
|
|
|
autoLogin() |
|
|
|
}); |
|
|
|
// import { uni } from '@dcloudio/uni-h5'; |
|
|
|
|
|
|
|
const username = ref(''); |
|
|
|
const password = ref(''); |
|
|
|
const brand_id = ref(''); |
|
|
|
|
|
|
|
const update_username = (val)=>{username.value = val} |
|
|
|
const update_password = (val)=>{password.value = val} |
|
|
|
const update_brand_id = (val)=>{brand_id.value = val} |
|
|
|
//登录点击,调用登录接口,成功后跳转到首页并存储账户密码到本地 |
|
|
|
function clickLogin(){ |
|
|
|
util.routeTo(`/pages/login/success`, 'nT'); |
|
|
|
|
|
|
|
//测试代码 |
|
|
|
// saveUserInfo({username:username.value,password:password.value,brand_id:brand_id.value}) |
|
|
|
// return |
|
|
|
|
|
|
|
util.showLoad('登录中...'); |
|
|
|
let urlParams = { |
|
|
|
assistant_client: 'pc', |
|
|
|
brand_id:brand_id.value, |
|
|
|
username: username.value, |
|
|
|
password: password.value |
|
|
|
} |
|
|
|
ox.post({ |
|
|
|
url: API.padLogin, |
|
|
|
data: urlParams, |
|
|
|
isDefaultGet: true, |
|
|
|
failMsg: '操作失败!' |
|
|
|
}) |
|
|
|
.then(data => { |
|
|
|
util.hideLoad(); |
|
|
|
console.log("padLogin suc: ", data) |
|
|
|
|
|
|
|
//登录成功,存储账户密码到本地 |
|
|
|
let {token,role} = data |
|
|
|
let autoLogin = getApp().globalData.autoLogin |
|
|
|
let stadiumInfo = uni.getStorageSync('stadiumInfo'); |
|
|
|
saveUserInfo({username:username.value,password:password.value,brand_id:brand_id.value,token,role}) |
|
|
|
|
|
|
|
//跳转到首页 |
|
|
|
if(autoLogin&&stadiumInfo){ |
|
|
|
getApp().globalData.autoLogin = false |
|
|
|
setTimeout(()=>{ |
|
|
|
util.routeTo(`/pages/index/index`, 'nT'); |
|
|
|
},1000) |
|
|
|
return util.showNone("自动登录成功") |
|
|
|
}else{ |
|
|
|
getApp().globalData.autoLogin = false |
|
|
|
setTimeout(()=>{ |
|
|
|
util.routeTo(`/pages/login/success`, 'nT'); |
|
|
|
},1000) |
|
|
|
return util.showNone("自动登录成功,请先选择门店") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return data |
|
|
|
}).finally(()=>{ |
|
|
|
util.hideLoad(); |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
function saveUserInfo(userInfo){ |
|
|
|
uni.setStorageSync('userInfo', userInfo); |
|
|
|
getApp().globalData.accountInfo.brand_id = userInfo.brand_id |
|
|
|
getApp().globalData.accountInfo.username = userInfo.username |
|
|
|
getApp().globalData.accountInfo.password = userInfo.password |
|
|
|
getApp().globalData.accountInfo.token = userInfo.token |
|
|
|
getApp().globalData.accountInfo.role = userInfo.role |
|
|
|
|
|
|
|
console.log('存储到本地localStorage '+uni.getStorageSync('userInfo').username) |
|
|
|
} |
|
|
|
function autoLogin(){ |
|
|
|
let userInfo = uni.getStorageSync('userInfo'); |
|
|
|
console.log(`page-onReady autoLogin userInfo: `,userInfo||"none") |
|
|
|
|
|
|
|
if(userInfo){ |
|
|
|
username.value = userInfo.username |
|
|
|
password.value = userInfo.password |
|
|
|
brand_id.value = userInfo.brand_id |
|
|
|
clickLogin() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|