5 changed files with 262 additions and 79 deletions
-
3src/js/api.js
-
5src/pages.json
-
95src/pages/index/index.vue
-
205src/pages/login/login.vue
-
33src/subpackage/device/pages/login/login.vue
@ -0,0 +1,205 @@ |
|||
<template> |
|||
<view class="login-container"> |
|||
<view class="lc-header"> |
|||
<view class="lh-logo"></view> |
|||
<view class="lh-name">欧轩智能场馆</view> |
|||
</view> |
|||
<view class="lc-form"> |
|||
<view class="lf-frame"><input placeholder="请输入品牌ID" v-model="formData.brand_id" /></view> |
|||
<view class="lf-frame"><input placeholder="请输入账号" v-model="formData.account" /></view> |
|||
<view class="lf-frame"><input placeholder="请输入密码" v-model="formData.password" password /></view> |
|||
</view> |
|||
|
|||
<button |
|||
class="lf-btn" |
|||
hover-class="hover-active" |
|||
open-type="getUserInfo" |
|||
lang="zh_CN" |
|||
@getuserinfo="submitBtn" |
|||
>登录</button> |
|||
<view class="lf-tip">提示:请联系管理员添加您为员工账号</view> |
|||
<view class="lf-bot-btn" @click="toWebView">成为商家</view> |
|||
|
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import { API } from '../../js/api'; |
|||
import { servers } from '../../js/server'; |
|||
import util from '../../utils/util'; |
|||
const uniGetSetting = util.promisify(uni.getSetting); |
|||
const uniLogin = util.promisify(uni.login); |
|||
const APPID = uni.getAccountInfoSync().miniProgram.appId; |
|||
export default { |
|||
data(){ |
|||
return { |
|||
formData: { |
|||
brand_id: '', |
|||
account: '', |
|||
password: '', |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
async submitBtn(userRes){ |
|||
try{ |
|||
util.showLoad(); |
|||
if(!userRes.detail.userInfo){ |
|||
util.hideLoad(); |
|||
return util.showNone('获取用户信息失败!请稍后重试'); |
|||
} |
|||
|
|||
let loginRes = await uniLogin(); |
|||
|
|||
if(!loginRes.code){ |
|||
util.hideLoad(); |
|||
return util.showNone('获取登陆凭证失败!稍后重试'); |
|||
} |
|||
let userInfo = userRes.detail || {}; |
|||
console.log(userRes) |
|||
let { formData } = this; |
|||
servers.post({ |
|||
url: API.WechatMiniApplogin, |
|||
data: { |
|||
appid: APPID, |
|||
code: loginRes.code, |
|||
encryptedData: userInfo.encryptedData, |
|||
// is_details: 1, |
|||
// 后端解密错误,直接传用户信息 |
|||
user_info: userInfo.userInfo, |
|||
user_raw_data: userInfo.rawData, |
|||
...userInfo.userInfo, |
|||
username: formData.account, |
|||
password: formData.password, |
|||
brand_id: formData.brand_id, |
|||
}, |
|||
isDefaultGet: false, |
|||
}) |
|||
.then(res=>{ |
|||
util.hideLoad(); |
|||
let _data = res.data || {}; |
|||
if(_data.code == 0){ |
|||
util.showNone(_data.message || '操作成功!'); |
|||
|
|||
uni.setStorageSync('token',_data.data); |
|||
setTimeout(_=>{ |
|||
util.routeTo(`/pages/index/index`, rL); |
|||
}, 1200); |
|||
}else{ |
|||
util.showNone(_data.message || '操作失败!'); |
|||
} |
|||
|
|||
}) |
|||
.catch(util.hideLoad) |
|||
}catch(err){ |
|||
util.hideLoad(); |
|||
console.warn('login err', err); |
|||
} |
|||
}, |
|||
toWebView(){ |
|||
util.routeTo(`/pages/web_view/web_view`,'rL'); |
|||
} |
|||
}, |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
@import '~style/public.scss'; |
|||
page{ |
|||
background-color: #fff; |
|||
} |
|||
.login-container{ |
|||
padding-bottom: 0; |
|||
padding-bottom: calc( 0 + constant(safe-area-inset-bottom)); /* 兼容 iOS < 11.2 */ |
|||
padding-bottom: calc( 0 + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */ |
|||
.lc-header{ |
|||
position: relative; |
|||
padding-top: 130upx; |
|||
margin-bottom: 86upx; |
|||
height: 470upx; |
|||
width: 100%; |
|||
overflow: hidden; |
|||
&::before{ |
|||
content: ''; |
|||
display: block; |
|||
position: absolute; |
|||
left: 50%; |
|||
bottom: 0upx; |
|||
z-index: -1; |
|||
transform: translateX(-50%); |
|||
background-color: $themeColor; |
|||
width: 3000upx; |
|||
height: 3000upx; |
|||
border-radius: 50%; |
|||
} |
|||
.lh-logo{ |
|||
margin: 0 auto 24upx; |
|||
width: 190upx; |
|||
height: 190upx; |
|||
border-radius: 50%; |
|||
background-color: #fff; |
|||
overflow: hidden; |
|||
>image{ |
|||
width: 100%; |
|||
height: 100%; |
|||
} |
|||
} |
|||
.lh-name{ |
|||
padding: 0 24upx; |
|||
text-align: center; |
|||
line-height: 50upx; |
|||
font-weight: 500; |
|||
font-size: 36upx; |
|||
color: #fff; |
|||
} |
|||
} |
|||
.lc-form{ |
|||
margin-bottom: 84upx; |
|||
.lf-frame{ |
|||
margin: 0 auto 28upx; |
|||
padding: 0 20upx; |
|||
width: 610upx; |
|||
height: 108upx; |
|||
border: 2upx solid #dddddd; |
|||
border-radius: 54upx; |
|||
>input{ |
|||
width: 100%; |
|||
height: 100%; |
|||
text-align: center; |
|||
font-size: 32upx; |
|||
color: #333; |
|||
} |
|||
&:last-child{ |
|||
margin-bottom: 0; |
|||
} |
|||
} |
|||
} |
|||
.lf-btn{ |
|||
margin-bottom: 16upx; |
|||
width: 610upx; |
|||
height: 108upx; |
|||
border-radius: 54upx; |
|||
border: none; |
|||
background-color: $themeColor; |
|||
font-size: 36upx; |
|||
line-height: 108upx; |
|||
color: #fff; |
|||
} |
|||
.lf-tip{ |
|||
margin-bottom: 118upx; |
|||
text-align: center; |
|||
line-height: 40upx; |
|||
text-align: center; |
|||
font-size: 28upx; |
|||
color: #9A9A9D; |
|||
} |
|||
.lf-bot-btn{ |
|||
margin-bottom: 20upx; |
|||
line-height: 40upx; |
|||
text-align: center; |
|||
font-size: 28upx; |
|||
color: $themeColor; |
|||
text-decoration: underline; |
|||
} |
|||
} |
|||
</style> |
@ -1,33 +0,0 @@ |
|||
<template> |
|||
<view class="login-container"> |
|||
<view class="lc-header"> |
|||
<view class="lh-logo"></view> |
|||
<view class="lh-name"></view> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
@import '~style/public.scss'; |
|||
.login-container{ |
|||
.lc-header{ |
|||
padding-bottom: 136upx; |
|||
height: 236upx; |
|||
background-color: $themeColor; |
|||
.lh-log{ |
|||
margin: 0 auto 24upx; |
|||
width: 190upx; |
|||
height: 190upx; |
|||
} |
|||
.lh-name{ |
|||
font-size: 18upx; |
|||
} |
|||
} |
|||
} |
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue