用户登录&退出 #1
@@ -1,17 +1,24 @@
|
||||
import request from '@/utils/request'
|
||||
const service_name ='oil-identity'
|
||||
const group_name ='weChatCloudAuthorization'
|
||||
const service_name ='xkhl-identity'
|
||||
const group_name ='unionAuth'
|
||||
const Customer_name = 'oilCustomerChannelRelation'
|
||||
const WchatLogin_name ='weChatCloudAuthorization'
|
||||
export default{
|
||||
// 新登录接口 手机密码登录
|
||||
loginByPhonePwd (data) {
|
||||
return request({
|
||||
url: `/${service_name}/${group_name}/loginByPhonePwd`,
|
||||
url: `/${service_name}/${group_name}/loginPwd`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
},
|
||||
// 新登录接口 手机密码登录
|
||||
logout () {
|
||||
return request({
|
||||
url: `/${service_name}/${group_name}/logout`,
|
||||
method: 'get',
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
sendCode(code){
|
||||
return request({
|
||||
@@ -37,7 +44,7 @@ export default{
|
||||
url: `/${service_name}/${group_name}/verifyCodeLogin`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
//切换油站
|
||||
@@ -46,7 +53,7 @@ export default{
|
||||
url: `/xkhl-identity/unionAuth/changeSiteLogin`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
//微信一键登录 new
|
||||
@@ -55,7 +62,7 @@ export default{
|
||||
url: `/xkhl-identity/unionAuth/loginPersonal`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
//首次登录绑定手机号 绑定微信手机号 new
|
||||
@@ -64,7 +71,7 @@ export default{
|
||||
url: `/xkhl-identity/unionAuth/bindLoginByPhonePersonal`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
//首次登录绑定手机号 当用户拒绝获取微信手机号时走此接口,判断用户是否存在,不存在提示注册,存在就发送验证码登录 new
|
||||
@@ -73,7 +80,7 @@ export default{
|
||||
url: `/${service_name}/${WchatLogin_name}/bindWeChatSendVerifyCode`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
// 首次登录绑定手机号 当用户拒绝获取微信手机号时走此接kou 手机号存在账户时,调用此接口登录 个人通道
|
||||
@@ -82,7 +89,7 @@ export default{
|
||||
url: `/${service_name}/${WchatLogin_name}/bindWeChatLoginByVerifyCodePersonal`,
|
||||
method: 'post',
|
||||
data:data,
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
bindLoginByPhone (data) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<view class="margin text-center">
|
||||
<button class="cu-btn round bg-main-oil lg text-lg" open-type="getPhoneNumber"
|
||||
@@ -84,11 +84,11 @@
|
||||
if (res.code === 20000) {
|
||||
this.sessionKey = res.data.sessionKey
|
||||
uni.setStorageSync('openid', res.data.openId)
|
||||
uni.setStorageSync('unionid', res.data.unionId)
|
||||
uni.setStorageSync('unionid', res.data.unionId)
|
||||
if(_that.outType !== '1'){
|
||||
this.autoLogin()
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if (res.code == 1002) {
|
||||
uni.showModal({
|
||||
title: '微信登录失败提醒',
|
||||
@@ -96,7 +96,7 @@
|
||||
})
|
||||
} else {
|
||||
// console.log('res', res.code)
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.reLaunch({
|
||||
url: '/BagAuth/pages/login/boforeLogin/boforeLogin',
|
||||
@@ -126,7 +126,7 @@
|
||||
title: '您已拒绝授权手机号'
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
bindLoginByPhone(data, url) { //绑定用户手机号
|
||||
if (this.count < 1) {
|
||||
oilIdentityApi.bindLoginByPhonePersonal(data, url).then(res => {
|
||||
@@ -134,10 +134,10 @@
|
||||
this.loginSuccess(res)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
loginSuccess(res) {//这里是绑定登录
|
||||
if (res.data.authTokenDTO.loginFlag) {
|
||||
loginSuccess(res) {//这里是绑定登录
|
||||
if (res.data.authTokenDTO.loginFlag) {
|
||||
this.setStored(res)
|
||||
}
|
||||
},
|
||||
@@ -158,17 +158,22 @@
|
||||
let data={
|
||||
unionId:uni.getStorageSync('unionid'),
|
||||
openId:uni.getStorageSync('openid')
|
||||
}
|
||||
}
|
||||
console.log(data,'这里是自动登录data')
|
||||
oilIdentityApi.loginPersonal(data).then(res => { //微信自动登录
|
||||
console.log(res,'这里是自动登录res')
|
||||
if (res.data.authTokenDTO.loginFlag == true) {
|
||||
if (res.data.authTokenDTO.loginFlag == true) {
|
||||
this.setStored(res)
|
||||
}
|
||||
}else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: res.data.msg
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 存值本地 根据手机号获取其下的油站并且存储本地
|
||||
setStored(res){
|
||||
setStored(res){
|
||||
let user = res.data.authTokenDTO.loginUser,
|
||||
unionId = uni.getStorageSync('unionid'),
|
||||
openId = uni.getStorageSync('openid'),
|
||||
@@ -182,7 +187,7 @@
|
||||
}
|
||||
})
|
||||
}, 1000);
|
||||
uni.setStorageSync('user', user)
|
||||
uni.setStorageSync('user', user)
|
||||
uni.setStorage({
|
||||
key: 'Authorization',
|
||||
data: res.data.authTokenDTO.accessToken,
|
||||
@@ -229,20 +234,20 @@
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '未绑定油站请联系客服',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
nextStep() {
|
||||
if (this.oilSiteNo) {
|
||||
cloudSiteApi.verifyOilSite({
|
||||
oilSiteCode: this.oilSiteNo
|
||||
}).then(res => {
|
||||
}).then(res => {
|
||||
if (res.code === 20000) {
|
||||
//历史遗留代码---------------------------------
|
||||
// address: "安徽省合肥市庐阳区大杨镇"
|
||||
@@ -320,7 +325,7 @@
|
||||
this.toMain(nickName);
|
||||
},
|
||||
toMain(userName) {
|
||||
// this.login(userName)
|
||||
// this.login(userName)
|
||||
/**
|
||||
* 强制登录时使用reLaunch方式跳转过来
|
||||
* 返回首页也使用reLaunch方式
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<view class="bg-white margin padding radius shadow-warp">
|
||||
<view class="cu-form-group">
|
||||
<view class="title mini-label text-black">手机号</view>
|
||||
<input type="number" v-model="auth.phone" placeholder="请输入手机号" name="input" @blur="bulrInput" />
|
||||
<input type="number" v-model="auth.phone" placeholder="请输入手机号" name="input" />
|
||||
</view>
|
||||
<view class="cu-form-group padding-top-sm" v-if="showRandom">
|
||||
<view class="title text-black mini-label">验证码</view>
|
||||
@@ -75,11 +75,11 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-modal" :class="checkList">
|
||||
<view class="cu-dialog">
|
||||
<view class="cu-dialog">
|
||||
<view class="cu-bar bg-red justify-end">
|
||||
<view class="content " >
|
||||
{{ titleText }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="action" @tap="hidecheckList">
|
||||
<text class="cuIcon-close text-white"></text>
|
||||
</view>
|
||||
@@ -130,7 +130,7 @@
|
||||
frozen: false, // 二维码冷却时间
|
||||
oliList:[
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -146,7 +146,7 @@
|
||||
icon:'none'
|
||||
})
|
||||
console.log('-------------')
|
||||
return
|
||||
return
|
||||
}else{
|
||||
console.log(this.auth.phone)
|
||||
console.log('+++++++++++++')
|
||||
@@ -155,15 +155,15 @@
|
||||
uni.setStorageSync('oliList',res.data)
|
||||
this.oliList = res.data
|
||||
this.checkUser = true
|
||||
// this.checkList = 'show'
|
||||
// this.checkList = 'show'
|
||||
this.titleText = '油站时间'
|
||||
}else{
|
||||
let _that= this
|
||||
_that.auth.phone = ''
|
||||
//console.log(this.auth.phone)
|
||||
this.errMsg =res.msg
|
||||
this.checkUser = false
|
||||
this.checkList = 'show'
|
||||
this.checkUser = false
|
||||
this.checkList = 'show'
|
||||
this.titleText = '提示'
|
||||
}
|
||||
})
|
||||
@@ -179,35 +179,35 @@
|
||||
}
|
||||
})
|
||||
if(this.checkType == 0 ){
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
checkOli(n){
|
||||
// if(!this.checkUser){
|
||||
// this.checkList = 'show'
|
||||
// this.checkList = 'show'
|
||||
// return
|
||||
// }
|
||||
this.checkType = n
|
||||
if(n == 0 ){
|
||||
this.loginRandom( )
|
||||
//console.log('这里是验证码登录')
|
||||
}else{
|
||||
//console.log('这里是验证码登录')
|
||||
}else{
|
||||
if(!this.auth.phone){
|
||||
uni.showToast({
|
||||
title:'请输入手机号',
|
||||
icon:"none"
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
if(!this.auth.password){
|
||||
uni.showToast({
|
||||
title:'请输入密码',
|
||||
icon:"none"
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
this.loginPwd( )
|
||||
}
|
||||
},
|
||||
@@ -221,7 +221,7 @@
|
||||
},
|
||||
// 根据用户手机查询油站
|
||||
getByPhone(){
|
||||
|
||||
|
||||
},
|
||||
navToQr() {
|
||||
uni.setClipboardData({
|
||||
@@ -317,8 +317,8 @@
|
||||
// //console.log(err)
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
loginPwd(channelId) {
|
||||
// },
|
||||
loginPwd(channelId) {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: loginRes => {
|
||||
@@ -335,7 +335,7 @@
|
||||
code: code,
|
||||
unionId:res.data.unionId,
|
||||
openId:res.data.openId
|
||||
}
|
||||
}
|
||||
uni.setStorage({
|
||||
key: 'device',
|
||||
data: res.data.openId,
|
||||
@@ -360,7 +360,7 @@
|
||||
})
|
||||
//console.log('oilSiteCode', this.oilSiteNo)
|
||||
if (res.code === 20000) {
|
||||
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
fail: (err) => {
|
||||
@@ -379,7 +379,7 @@
|
||||
//console.log('Authorization成功', res.data.authTokenDTO.accessToken)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
uni.setStorageSync('userMenu', res.data.authTokenDTO.loginUser.roleMenus)
|
||||
//console.log( '这里是获取userMenu处',res.data.authTokenDTO.loginUser.roleMenus)
|
||||
uni.setStorageSync('loginUser', {
|
||||
@@ -403,7 +403,7 @@
|
||||
const code = loginRes.code
|
||||
//console.log(code)
|
||||
oilIdentityApi.sendCode(code).then((res)=>{
|
||||
|
||||
|
||||
oilIdentityApi.loginPersonal().then(res => {
|
||||
if (res.code === 20000) {
|
||||
uni.reLaunch({
|
||||
@@ -456,7 +456,7 @@
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
//console.log(err)
|
||||
@@ -532,7 +532,7 @@
|
||||
unionId:res.data.unionId, //根据code接收后台返回的值
|
||||
channelId:channelId, //所选油站channelId
|
||||
verifyCodeToken: this.auth.verifyCodeToken ,//验证码
|
||||
openId:res.data.openId
|
||||
openId:res.data.openId
|
||||
}
|
||||
//console.log('device')
|
||||
//console.log(res.data.openId)
|
||||
@@ -579,7 +579,7 @@
|
||||
//console.log('Authorization成功', res.data.authTokenDTO.accessToken)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
uni.setStorageSync('userMenu', res.data.authTokenDTO.loginUser.roleMenus)
|
||||
uni.setStorageSync('loginUser', {
|
||||
id: res.data.authTokenDTO.loginUser.id,
|
||||
@@ -589,8 +589,8 @@
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
//console.log(err)
|
||||
@@ -658,7 +658,7 @@
|
||||
}
|
||||
.page-content {
|
||||
min-height: 100%;
|
||||
position: relative;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.logo {
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
|
||||
<script>
|
||||
import cloudSiteApi from '@/api/cloud-site.js'
|
||||
import oilIdentityApi from "@/api/oil-identity";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -98,13 +99,22 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
async loginOut() {
|
||||
// await cloudSiteApi.logout();
|
||||
uni.clearStorage()
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/boforeLogin/boforeLogin?type=1' //
|
||||
})
|
||||
|
||||
loginOut() {
|
||||
oilIdentityApi.logout().then(res => {
|
||||
if (res.code===20000){
|
||||
uni.showToast({
|
||||
title: '退出登录成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
setTimeout(()=>{
|
||||
uni.clearStorage()
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/boforeLogin/boforeLogin?type=1'
|
||||
})
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
},
|
||||
getInfo() {
|
||||
this.userInfo = uni.getStorageSync('loginUser')
|
||||
@@ -179,4 +189,4 @@
|
||||
.bg-img .cu-list.menu>.cu-item::after {
|
||||
border-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -5,17 +5,17 @@ import utils from '@/utils/encode'
|
||||
// const env = 'test'// 仅用于测试、
|
||||
// const env = 'production'
|
||||
//42 洛超 /29 孙志华 /40 阿浩
|
||||
// 测试日日顺时需要连阿浩
|
||||
// 测试日日顺时需要连阿浩
|
||||
|
||||
const testUrl = 'http://192.168.26:38080'
|
||||
// const productionUrl = 'https://www.51xingka.net/oilApp' // 生产,加密 old
|
||||
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
|
||||
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
|
||||
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
|
||||
// const productionUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
|
||||
const productionUrl = 'http://uat.xingoil.com/adminapi'
|
||||
// const env = process.env.NODE_ENV // 环境
|
||||
const service = axios.create({
|
||||
baseURL: env=='production'?productionUrl:testUrl, //
|
||||
// baseURL: testUrl, //
|
||||
baseURL: env=='production'?productionUrl:testUrl, //
|
||||
// baseURL: testUrl, //
|
||||
timeout: 5000
|
||||
})
|
||||
|
||||
@@ -33,13 +33,13 @@ service.interceptors.request.use(
|
||||
title: '加载中...',
|
||||
mask:true
|
||||
})
|
||||
// }
|
||||
// }
|
||||
const token = uni.getStorageSync('Authorization')
|
||||
const openid = uni.getStorageSync('device')
|
||||
const openId = uni.getStorageSync('openid')
|
||||
const unionId = uni.getStorageSync('unionid')
|
||||
const accountSources = 'LOGIN_MP_WECHAT'
|
||||
|
||||
|
||||
// console.log(unionId)
|
||||
// 原本为 openid
|
||||
config.headers['Authorization'] = token
|
||||
@@ -89,7 +89,7 @@ service.interceptors.response.use(
|
||||
const res = response.data
|
||||
// const env = process.env.NODE_ENV
|
||||
// const env = 'production' // 测试中的生茶
|
||||
|
||||
|
||||
if (env === 'production') {
|
||||
// 生产环境,进行加密解密,不输出日志
|
||||
if (res.encrypt == 1) {
|
||||
@@ -117,7 +117,7 @@ service.interceptors.response.use(
|
||||
title: res.msg,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}
|
||||
if (res.msg === '登录已过期!') {
|
||||
outTimer = setTimeout(() => {
|
||||
uni.showModal({
|
||||
@@ -181,7 +181,7 @@ service.interceptors.response.use(
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if (res.code != 20000 && res.msg != '令牌为空,不允许操作' && res.code != 42077 && res.code != 42011 &&res.msg != '您的ip已经更改,请重新登录' && res.msg != '登录与操作设备不同') {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@@ -196,7 +196,7 @@ service.interceptors.response.use(
|
||||
// console.log(err)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
},
|
||||
@@ -212,7 +212,7 @@ service.interceptors.response.use(
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请求失败!',
|
||||
title: res.msg?res.msg:'请求失败!',
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user