This commit is contained in:
caolc
2023-07-05 18:19:02 +08:00
parent e883da3fff
commit cf253870a3
17 changed files with 861 additions and 343 deletions

View File

@@ -1,36 +1,12 @@
<template>
<view class="login-page bg-white">
<view class="image login-bg">
<image :src="yellowURL+'login-bg.png'" mode="widthFix"></image>
</view>
<scroll-view scroll-x class=" bg-white nav padding">
<view class="flex text-center padding-bottom">
<!-- <view class="cu-item flex-sub" :class="0==TabCur?'text-red cur':''" @tap="tabSelect(0)">
个人账号
<view class="login-page bg-white">
<view class="image login-bg">
<image :src="yellowURL+'login-bg.png'" mode="widthFix"></image>
</view>
<scroll-view scroll-x class=" bg-white nav padding">
<view class="flex text-center padding-bottom">
<!-- <view class="cu-item flex-sub" :class="0==TabCur?'text-red cur':''" @tap="tabSelect(0)">
个人账号
</view>
-->
<view class="cu-item text-bold text-lg flex-sub">
@@ -59,26 +35,30 @@
<button class="cu-btn margin-top round lg" @tap="refuseEmpower">
输入手机号码登录
</button>
<button v-if="isShow" class="cu-btn margin-top bg-0 round lg" @tap="refuseLogin">
<button class="cu-btn margin-top bg-0 round lg" @tap="refuseLogin">
跳过
</button>
</view>
<view class="isKLUser" v-if='otherUser'>
<view class="isKLUser">卡力用户仅支持跳转登录</view>
</view>
<SwitchEnterprises @logout='logout' @submit='goHome' :is-show.sync="isSwitchEnterprises"></SwitchEnterprises>
</view>
</template>
<script>
import SwitchEnterprises from '@/components/SwitchEnterprises.vue'
import loginBottom from './components/loginBottom.vue'
import oilIdentityApi from '@/api/oil-identity'
import accountApi from '@/api/account.js'
export default {
components: {
loginBottom
loginBottom,
SwitchEnterprises
},
data() {
return {
isSwitchEnterprises:false,
value:'123',
userHandle: false,
TabCur: 1,
@@ -95,49 +75,66 @@
loginRes: {},
sessionKey: '',
nickName: '',
loginOut: uni.getStorageSync('loginOut') ? true : false,
isShow:true
loginOut: uni.getStorageSync('loginOut') ? true : false
}
},
onLoad(option) {
if(option.companyId === '1460872936910831616'){
this.otherUser = true
uni.clearStorageSync()
this.weChatLogin(option)
// console.log('当前为卡力用户')
return
}
let IsOtherUser = uni.getStorageSync('isOther')
// console.log('这里是onload',IsOtherUser)
if(IsOtherUser){
uni.showToast({
title:'卡力用户仅支持跳转登录',
icon:'none'
})
this.otherUser = true
return
} else{
this.weChatLogin()
}
// console.log('小程序跳转参数接收onLoad----')
// console.log('姓名:',option.driverName)
// console.log('公司ID:',option.companyId)
// console.log('车牌号:',option.plateNumber)
// console.log('油站Id:',option.siteId)
// console.log('--------------------------')
// console.log('这里是登录')
this.init(option);
console.log('onLoad')
},
methods: {
onShow() {
console.log('show');
},
watch:{
isSwitchEnterprises(n,o){ }
},
methods: {
init(option){
if(option){
if(option.companyId === '1460872936910831616'){
this.otherUser = true
uni.clearStorageSync()
this.weChatLogin(option)
console.log('当前为卡力用户')
return
}
}
let IsOtherUser = uni.getStorageSync('isOther')
if(IsOtherUser){
uni.showToast({
title:'卡力用户仅支持跳转登录',
icon:'none'
})
this.otherUser = true
return
} else{
this.weChatLogin()
}
},
logout(){
let that = this
accountApi.logout('authSystem').then(res => {
if (res.code == '20000') {
uni.showToast({
title: res.msg
})
uni.clearStorageSync();
this.isSwitchEnterprises = false;
this.init()
}
})
},
goHome(){
uni.switchTab({
url: '/pages/tabbar/home/home'
})
},
weChatLogin(option){
let isJump = uni.getStorageSync('isJump');
let siteId = uni.getStorageSync('siteId')
uni.clearStorageSync();
if(isJump) uni.setStorageSync('isJump',isJump)
if(siteId) {
this.isShow = false
uni.setStorageSync('siteId',siteId)
if(isJump){
uni.setStorageSync('isJump',isJump)
}
this.refreshLocation()
let _that = this
@@ -146,15 +143,14 @@
success: (loginRes) => {
const code = loginRes.code
this.onceCode = code
// console.log('这里是code')
// console.log(this.onceCode)
console.log('这里是code')
console.log(this.onceCode)
oilIdentityApi.sendCode(this.onceCode).then(res => {
if (res.code === 20000) {
// console.log('这里是sendCode',res)
console.log('这里是sendCode',res)
this.sessionKey = res.data.sessionKey
uni.setStorageSync('openid', res.data.openId)
uni.setStorageSync('unionid', res.data.unionId)
// console.log('这里是213','++++++')
uni.setStorageSync('unionid', res.data.unionId)
if(option){
if(option.companyId == '1460872936910831616'){
let sysCustomerInfos = {
@@ -171,17 +167,17 @@
}
uni.setStorageSync('isOther',_that.otherUser)
uni.setStorageSync('otherUserInfo',sysCustomerInfos)
// console.log('此处为data参数',data)
// console.log('当前为卡利用户companyId 为',sysCustomerInfos.companyId)
console.log('此处为data参数',data)
console.log('当前为卡利用户companyId 为',sysCustomerInfos.companyId)
oilIdentityApi.wechatLogin(data).then(res=>{
// console.log('这里是wechatLogin',res)
console.log('这里是wechatLogin',res)
this.OtherloginSuccess(res)
// console.log(res)
console.log(res)
})
return
}
}else{
// console.log('这里是213','----')
console.log('这里是213','----')
this.autoLogin()
}
// uni.setStorageSync('isOther',_that.otherUser)
@@ -209,7 +205,7 @@
})
},
refuseLogin(){
uni.setStorageSync('refuseLogin',true)
uni.clearStorageSync()
uni.switchTab({
url: '/pages/tabbar/home/home'
})
@@ -228,7 +224,7 @@
// let url = 'loginPersonal'
oilIdentityApi.autoLogin({
unionId: uni.getStorageSync('unionid')
}, url).then(res => {
}, url,{closePrompt:true}).then(res => {
if (res.code == 20000) {
this.loginSuccess(res)
}
@@ -262,9 +258,8 @@
},
bindLoginByPhone(data, url) {
if (this.count < 1) {
oilIdentityApi.bindLoginByPhone(data, url).then(res => {
if (res.code == 20000) {
oilIdentityApi.bindLoginByPhone(data,url,{closePrompt:true}).then(res => {
if (res.code == 20000) {
this.loginSuccess(res)
}
})
@@ -283,14 +278,7 @@
uni.setStorageSync('accountStatus', resData.isCompanyAccount)
let user = resData.authTokenDTO.loginUser
uni.setStorageSync('user', user)
setTimeout(() => {
uni.showToast({
title: res.msg,
icon: 'none',
complete: (err) => {
// console.log(err)
}
})
setTimeout(() => {
}, 1000);
// 这里有问题
uni.redirectTo({
@@ -305,26 +293,11 @@
uni.setStorageSync('accountStatus', resData.isCompanyAccount)
let user = resData.authTokenDTO.loginUser
uni.setStorageSync('user', user)
setTimeout(() => {
uni.showToast({
title: res.msg,
icon: 'none',
complete: (err) => {
// console.log(err)
}
})
}, 1000);
let siteId = uni.getStorageSync('siteId')
if(siteId) {
uni.redirectTo({
url: `/BagStation/pages/stationDetail/stationDetail?siteId=${siteId}`
})
return
}
// 这里有问题
uni.switchTab({
url: '/pages/tabbar/home/home'
})
this.isSwitchEnterprises = true
// // 这里有问题
// uni.switchTab({
// url: '/pages/tabbar/home/home'
// })
}
},
}