xiaozy_优化 #3
165
App.vue
165
App.vue
@@ -37,7 +37,6 @@
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
loginStatus: 'online',
|
|
||||||
msg: ''
|
msg: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -100,23 +99,15 @@
|
|||||||
this.menuList[1].detailList = this.menuList[1].detailList.concat(productCodes)
|
this.menuList[1].detailList = this.menuList[1].detailList.concat(productCodes)
|
||||||
this.menuList[2].detailList = this.menuList[2].detailList.concat(siteBrands)
|
this.menuList[2].detailList = this.menuList[2].detailList.concat(siteBrands)
|
||||||
uni.setStorageSync('filterData', this.menuList)
|
uni.setStorageSync('filterData', this.menuList)
|
||||||
console.log(uni.getStorageSync('filterData'),'pppppppppppppppppppppppp')
|
|
||||||
// this.$refs.slFilter.resetMenuList(this.menuList)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onShareAppMessage() {
|
onShareAppMessage() {
|
||||||
let that = this
|
|
||||||
wx.onAppRoute(() => {
|
wx.onAppRoute(() => {
|
||||||
let white = ['BagStation/pages/stationDetail/stationDetail']
|
|
||||||
// console.log('当前页面路由发生变化 触发该事件onShareAppMessage')
|
|
||||||
const pages = getCurrentPages() //获取加载的页面
|
const pages = getCurrentPages() //获取加载的页面
|
||||||
const view = pages[pages.length - 1] //获取当前页面的对象
|
const view = pages[pages.length - 1] //获取当前页面的对象
|
||||||
if (!view) return false //如果不存在页面对象 则返回
|
if (!view) return false
|
||||||
// 若想给个别页面做特殊处理 可以给特殊页面加isOverShare为true 就不会重写了
|
|
||||||
// const data = view.data
|
|
||||||
// if (!data.isOverShare) {
|
|
||||||
// data.isOverShare = true
|
|
||||||
view.onShareAppMessage = () => { //重写分享配置
|
view.onShareAppMessage = () => { //重写分享配置
|
||||||
return {
|
return {
|
||||||
title: '中品加油',
|
title: '中品加油',
|
||||||
@@ -125,82 +116,14 @@
|
|||||||
imageUrl: 'https://publicxingyou.oss-cn-hangzhou.aliyuncs.com/mp-oil/login-bg.png',
|
imageUrl: 'https://publicxingyou.oss-cn-hangzhou.aliyuncs.com/mp-oil/login-bg.png',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(view.route)
|
let white = ['pages/index/startPage/startPage']
|
||||||
clearTimeout(loginTimer)
|
if(view.route === 'BagStation/pages/stationDetail/stationDetail') {
|
||||||
clearTimeout(onlineTimer)
|
uni.removeStorageSync('refuseLogin')
|
||||||
|
|
||||||
if (view.route != 'pages/index/startPage/startPage' && view.route.indexOf('BagAuth') == -1) {
|
|
||||||
const token = uni.getStorageSync('Authorization')
|
|
||||||
const openid = uni.getStorageSync('openid')
|
|
||||||
|
|
||||||
let jumpUrl = '/BagAuth/pages/login/login'
|
|
||||||
let urlTarget = this.obtainUrlPathParameterTarget(view.$page.fullPath)
|
|
||||||
console.log('urlTarget',urlTarget)
|
|
||||||
let target = {}
|
|
||||||
if(urlTarget.q) {
|
|
||||||
let originLink = decodeURIComponent(decodeURIComponent(urlTarget.q))
|
|
||||||
target = this.obtainUrlPathParameterTarget(originLink)
|
|
||||||
target.siteId && (jumpUrl += `?scanningParams=${decodeURIComponent(urlTarget.q)}`)
|
|
||||||
}
|
|
||||||
// console.log('jumpUrl',jumpUrl)
|
|
||||||
if (token && openid) {
|
|
||||||
this.getAmount()
|
|
||||||
// if(!white.includes(view.route) ){
|
|
||||||
// this.getAmount()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(target.siteId || !white.includes(view.route) ){
|
|
||||||
// this.getAmount()
|
|
||||||
// }
|
|
||||||
|
|
||||||
onlineTimer = setTimeout(() => {
|
|
||||||
if (this.loginStatus == 'offline') {
|
|
||||||
uni.clearStorageSync()
|
|
||||||
uni.showModal({
|
|
||||||
title: '需要您重新登录',
|
|
||||||
content: this.msg,
|
|
||||||
duration: '3000',
|
|
||||||
success: function(res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
uni.redirectTo({
|
|
||||||
url: jumpUrl
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
clearTimeout(onlineTimer)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
// if(!uni.getStorageSync('filterData')){
|
|
||||||
// that.getFilterData()
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
target.siteId && uni.redirectTo({
|
|
||||||
url: jumpUrl
|
|
||||||
})
|
|
||||||
// loginTimer = setTimeout(() => {
|
|
||||||
// uni.showModal({
|
|
||||||
// title: '请您登录',
|
|
||||||
// content: '您还没有登录,暂时查不到油站哦',
|
|
||||||
// duration: '3000',
|
|
||||||
// success: function(res) {
|
|
||||||
// if (res.confirm) {
|
|
||||||
// uni.redirectTo({
|
|
||||||
// url: '/BagAuth/pages/login/login'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// }
|
// 是否跳过登陆
|
||||||
|
let isRefuseLogin = uni.getStorageSync('refuseLogin')
|
||||||
|
if(isRefuseLogin || white.includes(view.route) || view.route.includes('BagAuth')) return
|
||||||
|
this.getAmount()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -213,21 +136,25 @@
|
|||||||
target[item.split('=')[0]] = item.split('=')[1]
|
target[item.split('=')[0]] = item.split('=')[1]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log('11target',target)
|
|
||||||
return target
|
return target
|
||||||
},
|
},
|
||||||
|
|
||||||
// 是否token过期或ip更改
|
// 是否token过期或ip更改
|
||||||
getAmount() {
|
getAmount() {
|
||||||
clearTimeout(loginTimer)
|
|
||||||
accountApi.getTotalOilCardInfo().then(res => {
|
accountApi.getTotalOilCardInfo().then(res => {
|
||||||
console.log('res.code',res.code)
|
if (res.code == 42011) {
|
||||||
console.log(555)
|
uni.showModal({
|
||||||
if (res.code == 20000) {
|
title: '需要您重新登录',
|
||||||
this.loginStatus = 'online'
|
content: res.msg,
|
||||||
} else if (res.code == 42011) {
|
duration: '3000',
|
||||||
this.loginStatus = 'offline'
|
success: function(res) {
|
||||||
this.msg = res.msg
|
if (res.confirm) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: '/BagAuth/pages/login/login'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -238,7 +165,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
console.log(12388)
|
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
@@ -248,35 +174,36 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('onReady')
|
// const token = uni.getStorageSync('Authorization')
|
||||||
const token = uni.getStorageSync('Authorization')
|
// const openid = uni.getStorageSync('openid')
|
||||||
const openid = uni.getStorageSync('openid')
|
// let key = ''
|
||||||
let key = ''
|
// if (token && openid) {
|
||||||
if (token && openid) {
|
// this.getAmount()
|
||||||
this.getAmount()
|
// key = '真在线'
|
||||||
key = '真在线'
|
// } else {
|
||||||
} else {
|
// key = '离线'
|
||||||
key = '离线'
|
// }
|
||||||
}
|
// if (key == '在线') {
|
||||||
if (key == '在线') {
|
|
||||||
|
|
||||||
}
|
// }
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
console.log(key)
|
// if (key == '在线') {
|
||||||
if (key == '在线') {
|
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
// uni.redirectTo({
|
// // uni.redirectTo({
|
||||||
// url: '/BagAuth/pages/login/login'
|
// // url: '/BagAuth/pages/login/login'
|
||||||
// })
|
// // })
|
||||||
}
|
// }
|
||||||
}, 2000)
|
// }, 2000)
|
||||||
// uni.showShareMenu()
|
// // uni.showShareMenu()
|
||||||
// console.log('App Show')
|
// // console.log('App Show')
|
||||||
|
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
// console.log('App Hide')
|
// console.log('App Hide')
|
||||||
|
},
|
||||||
|
onUnload:function() {
|
||||||
|
uni.removeStorageSync('scanningParams')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -153,11 +153,17 @@
|
|||||||
sessionKey: '',
|
sessionKey: '',
|
||||||
nickName: '',
|
nickName: '',
|
||||||
loginOut: uni.getStorageSync('loginOut') ? true : false,
|
loginOut: uni.getStorageSync('loginOut') ? true : false,
|
||||||
scanningParams:null
|
// scanningParams:null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
let scanningParamsLocale = uni.getStorageSync('scanningParams')
|
||||||
uni.clearStorageSync()
|
uni.clearStorageSync()
|
||||||
|
if(scanningParamsLocale || options.scanningParams) {
|
||||||
|
// 用于扫码进入油站详情页面
|
||||||
|
uni.setStorageSync('scanningParams',options.scanningParams || scanningParamsLocale)
|
||||||
|
console.log('login scanningParams',uni.getStorageSync('scanningParams'))
|
||||||
|
}
|
||||||
this.refreshLocation()
|
this.refreshLocation()
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: 'weixin',
|
provider: 'weixin',
|
||||||
@@ -166,10 +172,6 @@
|
|||||||
this.onceCode = code
|
this.onceCode = code
|
||||||
oilIdentityApi.sendCode(this.onceCode).then(res => {
|
oilIdentityApi.sendCode(this.onceCode).then(res => {
|
||||||
if (res.code === 20000) {
|
if (res.code === 20000) {
|
||||||
if(options.scanningParams) {
|
|
||||||
// 用于扫码进入油站详情页面
|
|
||||||
this.scanningParams = options.scanningParams
|
|
||||||
}
|
|
||||||
this.sessionKey = res.data.sessionKey
|
this.sessionKey = res.data.sessionKey
|
||||||
uni.setStorageSync('openid', res.data.openId)
|
uni.setStorageSync('openid', res.data.openId)
|
||||||
uni.setStorageSync('unionid', res.data.unionId)
|
uni.setStorageSync('unionid', res.data.unionId)
|
||||||
@@ -200,6 +202,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refuseLogin() {
|
refuseLogin() {
|
||||||
|
uni.setStorageSync('refuseLogin',true)
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: '/pages/tabbar/home/home'
|
url: '/pages/tabbar/home/home'
|
||||||
})
|
})
|
||||||
@@ -225,7 +228,7 @@
|
|||||||
},
|
},
|
||||||
refuseEmpower() {
|
refuseEmpower() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/BagAuth/pages/login/oldLogin?scanningParams=${this.scanningParams}`
|
url: '/BagAuth/pages/login/oldLogin'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -280,9 +283,10 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 1000);
|
}, 1000);
|
||||||
if(this.scanningParams) {
|
let scanningParams = uni.getStorageSync('scanningParams')
|
||||||
|
if(scanningParams) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/BagStation/pages/stationDetail/stationDetail?q=${this.scanningParams}`
|
url: `/BagStation/pages/stationDetail/stationDetail?q=${scanningParams}`
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,13 +172,6 @@
|
|||||||
loginRes: {},
|
loginRes: {},
|
||||||
checked: false,
|
checked: false,
|
||||||
next: false,
|
next: false,
|
||||||
scanningParams:null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad(options) {
|
|
||||||
if(options.scanningParams) {
|
|
||||||
// 用于扫码进入油站详情页面
|
|
||||||
this.scanningParams = options.scanningParams
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow() {},
|
onShow() {},
|
||||||
@@ -409,9 +402,11 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}, 1000);
|
}, 1000);
|
||||||
if(this.scanningParams) {
|
|
||||||
|
let scanningParams = uni.getStorageSync('scanningParams')
|
||||||
|
if(scanningParams) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/BagStation/pages/stationDetail/stationDetail?q=${this.scanningParams}`
|
url: `/BagStation/pages/stationDetail/stationDetail?q=${scanningParams}`
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@
|
|||||||
} else {
|
} else {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title:'请您登录',
|
title:'请您登录',
|
||||||
content:"登录小星加油才可以加油 |˛˙꒳˙)♡",
|
content:"登录中品加油才可以加油 |˛˙꒳˙)♡",
|
||||||
confirmText:'去登陆',
|
confirmText:'去登陆',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if(res.confirm){
|
if(res.confirm){
|
||||||
|
|||||||
@@ -188,19 +188,12 @@
|
|||||||
|
|
||||||
|
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
// console.log('option',option)
|
|
||||||
// let userInfo = uni.getStorageSync('user')
|
|
||||||
// if(!userInfo && option.q) {
|
|
||||||
// uni.redirectTo({
|
|
||||||
// url: `/BagAuth/pages/login/login?scanningParams=${option.q}`
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(option.q) {
|
if(option.q) {
|
||||||
|
uni.setStorageSync('scanningParams',option.q)
|
||||||
|
console.log('stationDetail scanningParams',uni.getStorageSync('scanningParams'))
|
||||||
let originLink = decodeURIComponent(option.q)
|
let originLink = decodeURIComponent(option.q)
|
||||||
let target = this.obtainUrlPathParameterTarget(originLink)
|
let target = this.obtainUrlPathParameterTarget(originLink)
|
||||||
console.log('target',target)
|
|
||||||
if(target.siteId) {
|
if(target.siteId) {
|
||||||
this.siteId = target.siteId
|
this.siteId = target.siteId
|
||||||
this.getSiteInfo(target.siteId)
|
this.getSiteInfo(target.siteId)
|
||||||
@@ -323,10 +316,10 @@
|
|||||||
},
|
},
|
||||||
goBack() {
|
goBack() {
|
||||||
// this.innerAudioContext.stop()
|
// this.innerAudioContext.stop()
|
||||||
|
let scanningParams = uni.getStorageSync('scanningParams')
|
||||||
uni.switchTab({
|
scanningParams
|
||||||
url: '/pages/tabbar/home/home'
|
? uni.switchTab({url: '/pages/tabbar/home/home'})
|
||||||
});
|
: uni.navigateBack() ;
|
||||||
},
|
},
|
||||||
selectRadio() {
|
selectRadio() {
|
||||||
this.radio === 'A' ? this.radio = '' : this.radio = 'A'
|
this.radio === 'A' ? this.radio = '' : this.radio = 'A'
|
||||||
|
|||||||
@@ -83,14 +83,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
console.log(this.siteItem,'-----------------')
|
// console.log(this.siteItem,'-----------------')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
channelCodeFamt(value) {
|
channelCodeFamt(value) {
|
||||||
console.log(value)
|
// console.log(value)
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return '未知'
|
return '未知'
|
||||||
// 渠道编码 ( XOIL:星油 WJY:万金油 LV:老吕(找油网) TY:团油 YDJY:一点加油(壳牌))
|
// 渠道编码 ( XOIL:星油 WJY:万金油 LV:老吕(找油网) TY:团油 YDJY:一点加油(壳牌))
|
||||||
|
|||||||
@@ -357,7 +357,7 @@
|
|||||||
// this.goCall()
|
// this.goCall()
|
||||||
// break;
|
// break;
|
||||||
default:
|
default:
|
||||||
console.log('item.link')
|
// console.log('item.link')
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/tabbar/home/link?url=' + encodeURIComponent(JSON.stringify(item.link))
|
url: '/pages/tabbar/home/link?url=' + encodeURIComponent(JSON.stringify(item.link))
|
||||||
})
|
})
|
||||||
@@ -454,11 +454,7 @@
|
|||||||
} else if (index == 8) {
|
} else if (index == 8) {
|
||||||
this.goToPage('/BagAuth/pages/agreeMent/OperationGuide')
|
this.goToPage('/BagAuth/pages/agreeMent/OperationGuide')
|
||||||
}
|
}
|
||||||
// else if(index==8){
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/BagStation/myCars/myCars'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
else {
|
else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '功能暂无',
|
title: '功能暂无',
|
||||||
@@ -468,9 +464,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
showQr() {
|
showQr() {
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/BagStation/pages/stationDetail/stieQr'
|
|
||||||
// })
|
|
||||||
this.showThreeSites = true
|
this.showThreeSites = true
|
||||||
},
|
},
|
||||||
toCards() {
|
toCards() {
|
||||||
@@ -492,16 +485,11 @@
|
|||||||
let params = {
|
let params = {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
params: { //类型:Object 必有字段 备注:// 筛选对象
|
params: {
|
||||||
// longitude: 117.157817, // 必有字段 备注:// 当前位置经度
|
|
||||||
// latitude: 31.802472, // 必有字段 备注:// 当前位置维度
|
|
||||||
// siteBrand: "", // 备注:// 石油品牌 ( 1-中国石油 2-中国石化 3-壳牌 4-民营 5-中海油 6-京博 7-中化石油 8-其他 )
|
|
||||||
// channelCode: "", // 备注:// 渠道编码 ( OIL:星油 WJY:万金油 LV:老吕(找油网) TY:团油 YDJY:一点加油(壳牌))
|
|
||||||
// oilProductCode: "0#" // 备注:// 油号选择 ( 0# 92# 92#)
|
|
||||||
clientBelong:'ZHONGPIN',
|
clientBelong:'ZHONGPIN',
|
||||||
comprehensiveSort:1,
|
comprehensiveSort:1,
|
||||||
zpDisable:'ENABLE',
|
zpDisable:'ENABLE',
|
||||||
sort: "juli", //类型:String 必有字段 备注:// 智能排序 ( price:价格最低 juli:距离最近 ) 默认距离排序
|
sort: "juli", // price:价格最低 juli:距离最近
|
||||||
...uni.getStorageSync('location'),
|
...uni.getStorageSync('location'),
|
||||||
...this.filterData,
|
...this.filterData,
|
||||||
}
|
}
|
||||||
@@ -511,7 +499,6 @@
|
|||||||
oilSiteApi.readOnlySites(params).then(res => {
|
oilSiteApi.readOnlySites(params).then(res => {
|
||||||
this.getCount++
|
this.getCount++
|
||||||
if (res.code == 20000) {
|
if (res.code == 20000) {
|
||||||
// console.log(res.data.list)
|
|
||||||
this.siteList = res.data.list
|
this.siteList = res.data.list
|
||||||
} else {
|
} else {
|
||||||
if (this.getCount == 1) {
|
if (this.getCount == 1) {
|
||||||
@@ -552,8 +539,7 @@
|
|||||||
},
|
},
|
||||||
toDetail(item) {
|
toDetail(item) {
|
||||||
let itemS = encodeURIComponent(JSON.stringify(item))
|
let itemS = encodeURIComponent(JSON.stringify(item))
|
||||||
// console.log(uni.getStorageSync('user'))
|
|
||||||
// return
|
|
||||||
if (uni.getStorageSync('user')) {
|
if (uni.getStorageSync('user')) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/BagStation/pages/stationDetail/stationDetail?item=${itemS}`,
|
url: `/BagStation/pages/stationDetail/stationDetail?item=${itemS}`,
|
||||||
@@ -567,7 +553,7 @@
|
|||||||
} else {
|
} else {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title:'请您登录',
|
title:'请您登录',
|
||||||
content:"登录小星加油才可以加油 |˛˙꒳˙)♡",
|
content:"登录中品加油才可以加油 |˛˙꒳˙)♡",
|
||||||
confirmText:'去登陆',
|
confirmText:'去登陆',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if(res.confirm){
|
if(res.confirm){
|
||||||
@@ -686,7 +672,7 @@
|
|||||||
scanType: 'qrCode',
|
scanType: 'qrCode',
|
||||||
onlyFromCamera: false,
|
onlyFromCamera: false,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log(res.result)
|
// console.log(res.result)
|
||||||
this.getScanRes(res.result)
|
this.getScanRes(res.result)
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|||||||
@@ -438,7 +438,7 @@
|
|||||||
} else {
|
} else {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '请您登录',
|
title: '请您登录',
|
||||||
content: "登录小星加油才可以加油 |˛˙꒳˙)♡",
|
content: "登录中品加油才可以加油 |˛˙꒳˙)♡",
|
||||||
confirmText: '去登陆',
|
confirmText: '去登陆',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import utils from '@/utils/encode'
|
import utils from '@/utils/encode'
|
||||||
|
|
||||||
// const env = process.env.NODE_ENV
|
|
||||||
// const env = 'production'/* */
|
|
||||||
const env = 'production'
|
const env = 'production'
|
||||||
const testUrl = 'http://192.168.110.230:38080'
|
const testUrl = 'http://192.168.110.230:38080'
|
||||||
// const productUrl = 'http://121.196.213.68/adminapi' //预生产
|
|
||||||
|
|
||||||
// const productUrl = 'https://www.xingoil.com/adminapi' // 生产,加密 new
|
// const productUrl = 'https://www.xingoil.com/adminapi' // 生产
|
||||||
const productUrl = 'http://uat.xingoil.com/adminapi' // 生产,加密 new
|
const productUrl = 'http://uat.xingoil.com/adminapi' // uat
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: env == 'production' ? productUrl : testUrl,
|
baseURL: env == 'production' ? productUrl : testUrl,
|
||||||
// baseURL: testUrl,
|
timeout: 5000
|
||||||
timeout: 5000
|
|
||||||
})
|
})
|
||||||
var url = ''
|
var url = ''
|
||||||
|
|
||||||
@@ -24,11 +20,8 @@ service.interceptors.request.use(
|
|||||||
})
|
})
|
||||||
const token = uni.getStorageSync('Authorization')
|
const token = uni.getStorageSync('Authorization')
|
||||||
const unionId = uni.getStorageSync('unionid')
|
const unionId = uni.getStorageSync('unionid')
|
||||||
console.log(unionId)
|
|
||||||
const openId = uni.getStorageSync('openid')
|
const openId = uni.getStorageSync('openid')
|
||||||
// const accountSources = 'WE_CHAT_PROGRAM'
|
|
||||||
const accountSources = 'LOGIN_MP_WECHAT'
|
const accountSources = 'LOGIN_MP_WECHAT'
|
||||||
// console.log('取出来缓存', token, openid)
|
|
||||||
|
|
||||||
config.headers['openId'] = openId
|
config.headers['openId'] = openId
|
||||||
config.headers['Authorization'] = token
|
config.headers['Authorization'] = token
|
||||||
@@ -37,28 +30,19 @@ service.interceptors.request.use(
|
|||||||
config.headers['dataSources'] = 'MP'
|
config.headers['dataSources'] = 'MP'
|
||||||
|
|
||||||
if (env === 'production') {
|
if (env === 'production') {
|
||||||
// 生产环境,加密,不输出任何东西
|
// 生产环境加密
|
||||||
// 设置jsessionid和token
|
|
||||||
const JSESSIONID = utils.uuid()
|
const JSESSIONID = utils.uuid()
|
||||||
config.headers['JSESSIONID'] = JSESSIONID
|
config.headers['JSESSIONID'] = JSESSIONID
|
||||||
config.headers['token'] = utils.md5Salt(JSESSIONID)
|
config.headers['token'] = utils.md5Salt(JSESSIONID)
|
||||||
// if ( encryptWhite.indexOf(config.url) < 0) {
|
const data = {
|
||||||
// if (!notEncrypt && encryptWhite.indexOf(config.url) < 0) {
|
params: ''
|
||||||
// 这是定义在哪的
|
|
||||||
const data = { // 用于存储加密
|
|
||||||
params: '' // 加密后的密文
|
|
||||||
}
|
}
|
||||||
// 要加密
|
|
||||||
data.params = utils.encrypt(JSON.stringify(config.data))
|
data.params = utils.encrypt(JSON.stringify(config.data))
|
||||||
// console.log('参数', config.url, '参数加密前',config.data)
|
|
||||||
config.data = data
|
config.data = data
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
// console.log('\n\n-----------------------')
|
|
||||||
// console.log('参数', config.url, '参数加密前', config.data)
|
|
||||||
url = config.url
|
url = config.url
|
||||||
}
|
}
|
||||||
|
// uni.hideLoading()
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@@ -76,28 +60,23 @@ service.interceptors.response.use(
|
|||||||
const res = response.data
|
const res = response.data
|
||||||
|
|
||||||
if (env === 'production') {
|
if (env === 'production') {
|
||||||
// 生产环境,进行加密解密,不输出日志
|
// 生产环境解密
|
||||||
if (res.encrypt == 1) {
|
if (res.encrypt == 1) {
|
||||||
// 加密的数据,需要解密
|
|
||||||
const dataParam = JSON.parse(utils.decrypt(res.data))
|
const dataParam = JSON.parse(utils.decrypt(res.data))
|
||||||
res.data = JSON.stringify(dataParam) === '{}' ? null : dataParam
|
res.data = JSON.stringify(dataParam) === '{}' ? null : dataParam
|
||||||
// console.log('返回', response.config.url, '返回结果',res)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// console.log('返回', response.config.url, '返回结果未加密', res)
|
|
||||||
// console.log('-------------------------------------------\n\n')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
let dontTipTextArr = ['令牌为空,不允许操作','您的ip已经更改,请重新登录','登录与操作设备不同']
|
||||||
|
let dontTipCodeArr = [20000,42011]
|
||||||
if(response.config.url.indexOf('/oil-site/oilSiteOrderInfo/getOrderQrCode') === -1){
|
if(response.config.url.indexOf('/oil-site/oilSiteOrderInfo/getOrderQrCode') === -1){
|
||||||
if (res.code != 20000 && res.msg != '令牌为空,不允许操作' && res.msg != '您的ip已经更改,请重新登录' && res.msg != '登录与操作设备不同') {
|
if (!dontTipCodeArr.includes(res.code) && !dontTipTextArr.includes(res.msg)) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: "none"
|
icon: "none"
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user