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