Compare commits

...

7 Commits

Author SHA1 Message Date
骆超
be6bc9c046 更换手机号,修改密码,新老手机号验证 2023-05-10 15:59:19 +08:00
69357846e7 Merge pull request '密码登录' (#2) from lc into caolc
Reviewed-on: #2
2023-05-09 02:30:30 +00:00
骆超
843ae242bc 密码登录 2023-05-09 10:29:56 +08:00
caolc
3c8c985cce Merge branch 'caolc' of http://121.196.213.68:3000/caoliancun/LSM_OIL_SITE_zhongping into caolc 2023-05-08 08:59:00 +08:00
caolc
50ffdddce6 1 2023-05-08 08:58:58 +08:00
a1ebcaf789 Merge pull request '用户登录&退出' (#1) from lc into caolc
Reviewed-on: #1
2023-05-06 09:03:48 +00:00
骆超
767f164e59 用户登录&退出 2023-05-06 17:03:05 +08:00
9 changed files with 133 additions and 106 deletions

View File

@@ -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) {

View File

@@ -1,6 +1,6 @@
import request from '@/utils/request'
const service_name ='oil-user'
const group_name ='oilCustomerChannelRelation'
const service_name ='xkhl-user'
const group_name ='oilCustomerChannelRelation'
const change_phone ='sysCustomerInfo'
export default{
//根据用户手机查询油站
@@ -91,7 +91,7 @@ export default{
initCouldUser(){
return request({
url: `/${service_name}/sysCustomerInfo/initCouldUser/initCouldUser`,
method: 'GET'
method: 'GET'
})
},
}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "星油云站",
"appid" : "__UNI__EA8D131",
"appid" : "__UNI__F1ED4B9",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",

View File

@@ -52,7 +52,9 @@
tips: '发送验证码',
frozen: false, // 验证码冷却时间
auth: {},
verifyCodeToken:'',
verifyCodeToken:'',
pwd:"",
authpwd:"",
loginUser: uni.getStorageSync('loginUser')
}
},

View File

@@ -1,7 +1,7 @@
<template>
<view class="page-content " :class="(PageCur=='home'||PageCur=='scan')?'my-bg':''">
<!-- <uni-nav-bar left-icon="back" left-text="返回" right-text="菜单" title="导航栏组件"></uni-nav-bar> -->
<home ref='homecheck' v-if="PageCur=='home'||PageCur=='scan'" :user-account="userAccount" @changMenus='changMenus' :site="userAccount" :menusList = 'menusList' :checkUser = 'checkUser'></home>
<home ref='homecheck' v-if="PageCur==='home'||PageCur==='scan'" :user-account="userAccount" @changMenus='changMenus' :site="userAccount" :menusList = 'menusList' :checkUser = 'checkUser'></home>
<setup v-if="PageCur=='setup'"></setup>
<view class="bottom-view">
<view class="padding-top radius shadow bottom-bar-fixed">
@@ -11,7 +11,7 @@
<text :class="PageCur=='home'?'text-red':'text-gray'">
加油站
</text>
</view>
</view>
<view class="action text-gray add-action" @tap="NavChange" data-cur="scan">
<button class="cu-btn cuIcon-scan sl shadow" :class="PageCur=='scan'?'bg-main-oil':'bg-gradual-orange'"></button>
<text :class="PageCur=='scan'?'text-red':'text-gray'">
@@ -30,11 +30,11 @@
</view>
</template>
<script>
<script>
import cloudSiteApi from '@/api/cloud-site.js'
import oliSiteApi from '@/api/oli-site.js'
import oliUserApi from '@/api/oli-user.js'
export default {
export default {
data() {
return {
checkUser:false,
@@ -48,7 +48,7 @@
totalCount: 0,
totalMoney: 0.00
},
loginUser: uni.getStorageSync('loginUser'),
loginUser: uni.getStorageSync('loginUser'),
channelId:uni.getStorageSync('channelId'),
menusList:[],
site: {},
@@ -62,10 +62,10 @@
url: '../../packageOrders/pages/printTicket/printTicket'
})
},
onShow() {
onShow() {
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('device')
if (token && openid) {
const openid = uni.getStorageSync('device')
if (token && openid) {
} else {
uni.showToast({
title: '您还没有登录哦',
@@ -74,9 +74,9 @@
setTimeout(function() {
uni.reLaunch({
url: '/pages/login/boforeLogin/boforeLogin',
success: () => {
success: () => {
},
fail: (err) => {
fail: (err) => {
}
})
}, 1500);
@@ -99,10 +99,10 @@
// this.Splicing(item)
menusList.push(this.Splicing(item))
}
})
})
//console.log('这里是menusLisPush',menusList)
// uni.setStorageSync('menusLists',menusList)
let check = uni.getStorageSync('checkFirst')
let check = uni.getStorageSync('checkFirst')
//console.log(check)
if(check){
_that.checkUser = true
@@ -110,7 +110,7 @@
uni.setStorageSync('menusChangeList',menusList)
this.menusList = menusList
//console.log('这里是menusfor循环完成处',this.menusList)
// this.getUserInfo()
// this.getUserInfo()
this.longiCheck()
// //console.log('++++++++')
//console.log('这里是传值处menus',this.menusList)
@@ -134,26 +134,26 @@
this.menusList =data
},
longiCheck(){
let userInfo = uni.getStorageSync('loginUser'),
_that =this
let userInfo = uni.getStorageSync('loginUser')
const _that = this
//console.log(userInfo)
oliUserApi.getByPhone(userInfo.userPhone).then((res)=>{
//console.log('调用')
if(res.code == 20000){
_that.checkList = 'show'
_that.oliList = res.data
_that.oliList = res.data
_that.checkList = 'show'
_that.changeChannel.username = _that.loginUser.userPhone
_that.changeChannel.unionId = uni.getStorageSync('unionId')
this.$refs.homecheck.oliList = res.data
}else{
uni.showToast({
title:'请求失败,请稍后再试',
icon:'none'
})
}
})
},
Splicing(list){
Splicing(list){
let obj = {
cuIcon: '',
path: '',
@@ -226,7 +226,7 @@
// getUserInfo() {
// // 获取云站当前登录用户的基础资料
// oliSiteApi.getSiteBasicData(this.channelId).then(res => {
// //console.log('用户资料', res)
// //console.log('用户资料', res)
// uni.stopPullDownRefresh();
// if (res.code === 20000) {
// uni.setStorageSync('ueserList',res.data)

View File

@@ -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方式

View File

@@ -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)
@@ -464,9 +464,12 @@
});
},
sendMsg() {
if(!this.checkUser){
return
}
console.log("发送验证码",this.checkUser)
// if(!this.checkUser){
// return
// }
if (!this.frozen) {
if (this.auth.phone) {
const data2 = {
@@ -532,7 +535,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 +582,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 +592,8 @@
}
})
})
},
fail: err => {
//console.log(err)
@@ -658,7 +661,7 @@
}
.page-content {
min-height: 100%;
position: relative;
position: relative;
}
.logo {

View File

@@ -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>

View File

@@ -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 testUrl = 'http://192.168.20: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"
})
}