|
|
@@ -3,29 +3,11 @@ |
|
|
|
<view class="login-main as-gravity-center as-layout-vertical"> |
|
|
|
<image :src="`${$imgUrl}login/logo.png`" class="logo" mode="aspectFill"></image> |
|
|
|
<view class="title">九州ETC</view> |
|
|
|
<view class="form"> |
|
|
|
<view class="form-input"> |
|
|
|
<view> +86</view> |
|
|
|
<image :src="`${$imgUrl}common/arror_down_black.png`" class="arror" mode="aspectFill" /> |
|
|
|
<input class="input" v-model="state.username" focus placeholder="请输入手机号" |
|
|
|
placeholder-class="form-placeholder" type="number" maxlength="11" /> |
|
|
|
</view> |
|
|
|
<view class="form-input" v-if="state.loginType === 'pwd'"> |
|
|
|
<input class="input" v-model="state.password" type="text" placeholder="请输入密码" |
|
|
|
placeholder-class="form-placeholder" :password="state.isPwdType ? true : false" /> |
|
|
|
<image :src="`${$imgUrl}login/${ |
|
|
|
state.isPwdType ? 'icon_eye_close' : 'icon_eye_open' |
|
|
|
}.png`" class="eye" @click="state.isPwdType = !state.isPwdType" mode="aspectFill"></image> |
|
|
|
</view> |
|
|
|
<view class="form-input" v-if="state.loginType === 'code'"> |
|
|
|
<input class="input" v-model="state.code" placeholder="请输入验证码" placeholder-class="form-placeholder" |
|
|
|
maxlength="6" type="number" /> |
|
|
|
<verification-code :bg="false" :mobile="state.username"></verification-code> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="btn"> |
|
|
|
<submit-button title="登录" @submit="doLogin"></submit-button> |
|
|
|
<button v-if="state.checked" size="default" type="primary" class="ui-btn" open-type="getPhoneNumber" |
|
|
|
@getphonenumber="doLogin">一键登录</button> |
|
|
|
<button v-else size="default" type="primary" class="ui-btn" @click="choiceAgreement">一键登录</button> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="agreement"> |
|
|
@@ -38,7 +20,7 @@ |
|
|
|
<view class="txt-green" @click="toRead">《平台用户服务隐私协议》</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="btns as-layout-horizontal"> |
|
|
|
<!-- <view class="btns as-layout-horizontal"> |
|
|
|
<view class="as-layout-vertical as-gravity-center" @click="navTo('/login/register-step1')"> |
|
|
|
<view class="bg blue as-gravity-center"> |
|
|
|
<image :src="`${$imgUrl}login/icon_register.png`" class="img" mode="aspectFill" /> |
|
|
@@ -65,31 +47,7 @@ |
|
|
|
</view> |
|
|
|
<view class="label">忘记密码</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="mask" v-if="state.showPopup"> |
|
|
|
<view class="mask-content"> |
|
|
|
<filter> |
|
|
|
<view class="mask-close"> |
|
|
|
<image :src="`${fileURL}image/newHome/close-dan.png`" class="icon-closed" @click="closeMask"></image> |
|
|
|
</view> |
|
|
|
<view class="mask-title">请选择登录类型</view> |
|
|
|
<view class="mask-tab"> |
|
|
|
<view class="tab-item" @click="checkboxChangeLogin('PERSONAL')"> |
|
|
|
<image :src="`${fileURL}image/newHome/geren.png`" mode="aspectFill" class='img'></image> |
|
|
|
<view class="r-info"> |
|
|
|
<view class="tab-tit">个人用户登录</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="tab-item" @click="checkboxChangeLogin('ENTERPRISE')"> |
|
|
|
<image :src="`${fileURL}image/newHome/danwei.png`" mode="aspectFill" class='img'></image> |
|
|
|
<view class="r-info"> |
|
|
|
<view class="tab-tit">单位用户登录</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</filter> |
|
|
|
</view> |
|
|
|
</view> --> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
@@ -97,16 +55,14 @@ |
|
|
|
import { reactive } from "vue"; |
|
|
|
import { checkStr, msg, navTo, subscribeMessages } from "@/utils/utils"; |
|
|
|
import { onLoad, onUnload } from "@dcloudio/uni-app"; |
|
|
|
import { login, loginCode, loginTime, wechatAppID,userBasicGetOpenId,userBasicGetPhoneNumber,getUserType } from "@/utils/network/api.js"; |
|
|
|
import { requestNew} from "@/utils/network/request.js"; |
|
|
|
import { login, loginCode, loginTime, wechatAppID, userBasicGetOpenId, userBasicGetPhoneNumber } from "@/utils/network/api.js"; |
|
|
|
import { requestNew } from "@/utils/network/request.js"; |
|
|
|
import { stringToJson } from "@/utils/network/encryption"; |
|
|
|
import { useUserStore } from "@/stores/user"; |
|
|
|
import { setItem } from "@/utils/storage"; |
|
|
|
const userStore = useUserStore(); |
|
|
|
const { fetchToken } = userStore; |
|
|
|
import { |
|
|
|
fileURL |
|
|
|
} from "@/datas/fileURL.js"; |
|
|
|
|
|
|
|
const state = reactive({ |
|
|
|
checked: false, //是否勾选协议 |
|
|
|
isPwdType: true, //是不是密码类型 |
|
|
@@ -115,19 +71,7 @@ |
|
|
|
password: "", //密码 |
|
|
|
code: "", //验证码 |
|
|
|
back: 0, //从app扫码看协议过来 登录了 还需要回到手机号验证页面 0 是原本的登录 1 要回去的登录(从哪来回哪去) 2运维跳转过来得中转页 |
|
|
|
params:{}, |
|
|
|
items: [{ |
|
|
|
value: 'PERSONAL', |
|
|
|
name: '个人' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 'ENTERPRISE', |
|
|
|
name: '单位', |
|
|
|
|
|
|
|
}, |
|
|
|
], |
|
|
|
showPopup:false, |
|
|
|
userType:"" |
|
|
|
params: {} |
|
|
|
}); |
|
|
|
|
|
|
|
onLoad((option) => { |
|
|
@@ -146,103 +90,32 @@ |
|
|
|
onUnload(() => { |
|
|
|
uni.$off("login"); |
|
|
|
}); |
|
|
|
const closeMask = () => { |
|
|
|
state.showPopup = false; |
|
|
|
}; |
|
|
|
const checkboxChange = (e) => { |
|
|
|
console.log(e); |
|
|
|
state.checked = !state.checked; |
|
|
|
}; |
|
|
|
const checkboxChangeLogin = (e) => { |
|
|
|
console.log(e); |
|
|
|
state.userType=e |
|
|
|
//判断是验证码登录,还是账号密码登录 |
|
|
|
denglu() |
|
|
|
}; |
|
|
|
// const sure=()=>{ |
|
|
|
// if(!state.userType){ |
|
|
|
// msg("请选择登录身份!"); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// 去协议页面 |
|
|
|
const toRead = () => { |
|
|
|
navTo("/login/agreement") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* 登录 */ |
|
|
|
const doLogin = () => { |
|
|
|
if (!state.username) { |
|
|
|
msg("请输入手机号!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (state.loginType === "pwd" && !state.password) { |
|
|
|
msg("请输入密码!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (state.loginType === "code" && !state.code) { |
|
|
|
msg("请输入验证码!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!checkStr(state.username, "mobile")) { |
|
|
|
msg("请输入正确的手机号!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
const choiceAgreement = () => { |
|
|
|
if (!state.checked) { |
|
|
|
msg("请勾选我已阅读并同意《平台用户服务隐私协议》"); |
|
|
|
return; |
|
|
|
} |
|
|
|
getUserTypeQuery().then((data : any) => { |
|
|
|
if(data.userTypes.length==1){ |
|
|
|
state.userType=data.userTypes[0] |
|
|
|
denglu() |
|
|
|
//判断是验证码登录,还是账号密码登录 |
|
|
|
|
|
|
|
}else{ |
|
|
|
state.showPopup=true |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}; |
|
|
|
const denglu=()=>{ |
|
|
|
if (state.loginType === "code") { |
|
|
|
reqLogin(loginCode, { |
|
|
|
mobile: state.username, |
|
|
|
code: state.code, |
|
|
|
loginTime: loginTime, |
|
|
|
userType:state.userType |
|
|
|
}); |
|
|
|
} else { |
|
|
|
reqLogin(login, { |
|
|
|
mobile: state.username, |
|
|
|
password: state.password, |
|
|
|
loginTime: loginTime, |
|
|
|
userType:state.userType |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
const getUserTypeQuery = () => { |
|
|
|
const options = { |
|
|
|
type: 2, |
|
|
|
data: { |
|
|
|
mobile:state.username |
|
|
|
}, |
|
|
|
method: "POST", |
|
|
|
showLoading: true, |
|
|
|
}; |
|
|
|
return new Promise(async (resolve, reject) => { |
|
|
|
const res = await requestNew(getUserType, options); |
|
|
|
const result = res; |
|
|
|
console.log("查询登录",result); |
|
|
|
|
|
|
|
resolve(result); |
|
|
|
}).catch((error) => { |
|
|
|
reject(error); |
|
|
|
/* 登录 */ |
|
|
|
const doLogin = (e) => { |
|
|
|
console.log("e", e) |
|
|
|
reqLogin(userBasicGetPhoneNumber, { |
|
|
|
jsCode: e.detail.code, |
|
|
|
iv: e.detail.iv, |
|
|
|
encryptedData: e.detail.encryptedData, |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
/* 执行登录 */ |
|
|
|
const reqLogin = (code : string, data : object) => { |
|
|
|
console.log(code, data); |
|
|
@@ -255,11 +128,9 @@ |
|
|
|
requestNew(code, options).then((res) => { |
|
|
|
const result = res; |
|
|
|
console.log(result); |
|
|
|
console.log(typeof (result)); |
|
|
|
fetchToken(result.code,state.userType).then((data : any) => { |
|
|
|
fetchToken(result.phoneNumber).then((data : any) => { |
|
|
|
console.log("登录", data); |
|
|
|
setItem('mobile', state.username) |
|
|
|
state.showPopup=false |
|
|
|
setItem('mobile', result.phoneNumber) |
|
|
|
subscribeMessages(); |
|
|
|
msg("登录成功!"); |
|
|
|
uni.$emit("refreshOrder"); |
|
|
@@ -270,9 +141,9 @@ |
|
|
|
} else if (state.back == 2) { |
|
|
|
const params = encodeURIComponent(JSON.stringify(state.params)) |
|
|
|
uni.redirectTo({ |
|
|
|
url:`/subpackage/after-sale/transfer-page?params=${params}` |
|
|
|
url: `/subpackage/after-sale/transfer-page?params=${params}` |
|
|
|
}) |
|
|
|
} else{ |
|
|
|
} else { |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/index/index' |
|
|
|
}) |
|
|
@@ -280,9 +151,6 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
const decryptPhoneNumber=(e)=>{ |
|
|
|
console.log("e",e) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
@@ -293,6 +161,7 @@ |
|
|
|
.logo { |
|
|
|
width: 260rpx; |
|
|
|
height: 160rpx; |
|
|
|
margin-top: 100rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.group { |
|
|
@@ -352,7 +221,7 @@ |
|
|
|
|
|
|
|
.btn { |
|
|
|
width: 100%; |
|
|
|
margin: 120rpx 40rpx 50rpx; |
|
|
|
margin: 580rpx 40rpx 50rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.agreement { |
|
|
@@ -409,76 +278,4 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.mask { |
|
|
|
background: $uni-bg-color-mask; |
|
|
|
position: fixed; |
|
|
|
left: 0; |
|
|
|
top: 0; |
|
|
|
right: 0; |
|
|
|
bottom: 0; |
|
|
|
z-index: 999; |
|
|
|
} |
|
|
|
|
|
|
|
.mask-content { |
|
|
|
background: #fff; |
|
|
|
width: 570rpx; |
|
|
|
position: absolute; |
|
|
|
left: 50%; |
|
|
|
top: 50%; |
|
|
|
transform: translate(-50%, -50%); |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
border-radius: 20rpx; |
|
|
|
z-index:999; |
|
|
|
} |
|
|
|
|
|
|
|
.mask-close { |
|
|
|
text-align: right; |
|
|
|
} |
|
|
|
|
|
|
|
.mask-title { |
|
|
|
text-align: center; |
|
|
|
margin-bottom: 50rpx; |
|
|
|
font-family: MicrosoftYaHei; |
|
|
|
font-size: 34rpx; |
|
|
|
color: #666666; |
|
|
|
} |
|
|
|
|
|
|
|
.mask-tab { |
|
|
|
margin: 0 40rpx; |
|
|
|
} |
|
|
|
.icon-closed { |
|
|
|
width: 30rpx; |
|
|
|
height: 30rpx; |
|
|
|
margin: 24rpx 24rpx 0 0; |
|
|
|
} |
|
|
|
|
|
|
|
.tab-item { |
|
|
|
padding: 20rpx 25rpx; |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
background: #F7F7F7; |
|
|
|
border-radius: 15rpx; |
|
|
|
margin-bottom: 30rpx; |
|
|
|
} |
|
|
|
.r-info{ |
|
|
|
margin-left: 25rpx; |
|
|
|
.tab-tit { |
|
|
|
font-family: MicrosoftYaHei; |
|
|
|
font-size: 30rpx; |
|
|
|
color: #333333; |
|
|
|
} |
|
|
|
|
|
|
|
.tab-desc{ |
|
|
|
font-family: MicrosoftYaHei; |
|
|
|
font-size: 24rpx; |
|
|
|
color: #999999; |
|
|
|
margin-top: 10rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.tab-item .img { |
|
|
|
width: 120rpx; |
|
|
|
height: 120rpx; |
|
|
|
} |
|
|
|
</style> |