diff --git a/common/httpRequest.js b/common/httpRequest.js index 959adac..37c3a6a 100644 --- a/common/httpRequest.js +++ b/common/httpRequest.js @@ -20,16 +20,15 @@ const refreshToken = () => { store.commit('setUserInfo', null) uni.removeStorageSync('userInfo'); + setTimeout(() => { + uni.navigateBack({ delta: 1 }) + }, 1500) uni.showToast({ - title: '用户失效,请重新登录', + title: '登录过期,请重新登录', icon: 'none', mask: true }) - setTimeout(() => { - uni.reLaunch({ - url: '/pages/index/index' - }); - },1500) + }else{ return module.exports.post(config.refreshToken, { refreshToken: refreshTokenValue }, 'application/json', null, false, false) @@ -55,7 +54,7 @@ const refreshToken = () => { const requestInterceptor = function (config) { - const tok = store.state.userInfo.accessToken || uni.getStorageSync('userInfo').accessToken; + const tok = uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').accessToken:null; if (tok) { config.header['Authorization'] = 'Bearer ' + tok; } @@ -97,6 +96,19 @@ const responseInterceptor = function (response,config) { }).catch(reject); }); } + if(code&&code==400){ + store.commit('setUserInfo', null) + console.log(store,'store清除了吗') + uni.removeStorageSync('userInfo'); + setTimeout(() => { + uni.navigateBack({ delta: 1 }) + }, 1500) + uni.showToast({ + title: '登录过期,请重新登录', + icon: 'none', + mask: true + }) + } return response[1]; }; diff --git a/common/login.js b/common/login.js index 0accebe..ca3f5f3 100644 --- a/common/login.js +++ b/common/login.js @@ -1,16 +1,16 @@ import store from '@/store'; // APP--授权登录 // type授权登录平台 'qq'、'weixin'、'apple' -export const loginApp = (type,successCallback,errorCallback) => { +export const loginApp = (type, successCallback, errorCallback) => { uni.login({ provider: type, - success: function(loginRes) { + success: function (loginRes) { // 获取用户信息 uni.getUserInfo({ provider: type, - success: function(infoRes) { + success: function (infoRes) { let data = {} - if(type=='qq'){ + if (type == 'qq') { data = { 'openid': loginRes.authResult.openid, 'nickname': infoRes.userInfo.nickname, @@ -19,7 +19,7 @@ export const loginApp = (type,successCallback,errorCallback) => { 'city': infoRes.userInfo.city, 'figureurl': infoRes.userInfo.figureurl_qq } - }else if(type=='weixin'){ + } else if (type == 'weixin') { data = { 'openid': loginRes.authResult.openid, 'nickname': infoRes.userInfo.nickName, @@ -30,21 +30,21 @@ export const loginApp = (type,successCallback,errorCallback) => { 'headimgurl': infoRes.userInfo.avatarUrl, 'unionid': loginRes.authResult.unionid } - }else if(type=='apple'){ + } else if (type == 'apple') { data = { verifyType: 'password', personalPhone: '13888888888', personalPhoneCountryCode: '86', - password:'123456' + password: '123456' } } successCallback && successCallback(data) } }); - },fail: function (err) { + }, fail: function (err) { console.log(res, "失败") errorCallback && errorCallback(res) - } + } }); } // 微信/支付宝小程序---手机号授权登录时使用 @@ -53,46 +53,46 @@ export const getPhoneInfo = (info, successCallback, errCallback) => { let httpData = {} // #ifdef MP-WEIXIN httpData = { - code: info.code, //小程序code - iv: info.iv, //小程序加密算法的初始向量 - encryptedData: info.encryptedData, //包括敏感数据在内的完整用户信息的加密数据 + code: info.code, //小程序code + iv: info.iv, //小程序加密算法的初始向量 + encryptedData: info.encryptedData, //包括敏感数据在内的完整用户信息的加密数据 }; // #endif // #ifdef MP-ALIPAY - httpData = { - code: '', //小程序code - iv: '', //小程序加密算法的初始向量 - encryptedData: info, //包括敏感数据在内的完整用户信息的加密数据 - }; + httpData = { + code: '', //小程序code + iv: '', //小程序加密算法的初始向量 + encryptedData: info, //包括敏感数据在内的完整用户信息的加密数据 + }; // #endif - + // 此时需要您的接口返回个人信息 - // uni.$u.http.post('您的接口', httpData).then(res => { - var loginInfo = { - // userId: res.id, - // sessionId: res.sessionId, - // phoneNum: res.phoneNum, - // userName: res.userName, - // openId: res.openId, - }; - successCallback && successCallback(loginInfo) + // uni.$u.http.post('您的接口', httpData).then(res => { + var loginInfo = { + // userId: res.id, + // sessionId: res.sessionId, + // phoneNum: res.phoneNum, + // userName: res.userName, + // openId: res.openId, + }; + successCallback && successCallback(loginInfo) // }, err => { // errCallback && errCallback(err) // }); } // 微信/支付宝小程序---通用授权个人信息登录 -export const getUserInfo = (successCallback,errorCallback) => { +export const getUserInfo = (successCallback, errorCallback) => { uni.showLoading({ title: '正在申请授权', }); // #ifdef MP-WEIXIN uni.getUserProfile({ desc: '用于完善会员资料', - success: function(res) { + success: function (res) { uni.hideLoading() var offUserInfo = res.userInfo successCallback && successCallback(offUserInfo) - },fail: (res) => { + }, fail: (res) => { uni.hideLoading() errorCallback && errorCallback(res) } @@ -105,12 +105,12 @@ export const getUserInfo = (successCallback,errorCallback) => { var offUserInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response offUserInfo.avatarUrl = offUserInfo.avatar successCallback && successCallback(offUserInfo) - },fail: (res) => { + }, fail: (res) => { uni.hideLoading() console.log(res, "失败") errorCallback && errorCallback(res) } - }) + }) // #endif } @@ -118,91 +118,86 @@ let lock = false let promiseResult = [] // 获取token export const getToken = () => { - return new Promise((resolve, reject) => { - promiseResult.push({ - resolve, - reject - }) - if (!lock) { - lock = true - // uni.login({ - // success(res){ - var httpData = { - username: 'ceshi', - password: '111111', - } - uni.$u.http.post('/api/Tokensys/login',httpData,{custom: {isFactory:false}}).then(res => { - if(res.code==1){ - let userInfo = { - token:res.token,//token用于判断是否登录 - } - console.log(res.token,'res.token') - store.commit('setUserInfo',userInfo) - console.log(store.state.userInfo.token,'getToken-token') - // uni.$emit("loginCallback") //全局登录监听回调方法 - } - while (promiseResult.length) { - // p1.resolve(res.data) - promiseResult.shift().resolve(res) - } - lock = false - }).catch(err => { - while (promiseResult.length) { - // p1.reject(err) - promiseResult.shift().reject(err) - } - lock = false - }) - // } - // }) - } - }) + return new Promise((resolve, reject) => { + promiseResult.push({ + resolve, + reject + }) + if (!lock) { + lock = true + // uni.login({ + // success(res){ + var httpData = { + username: 'ceshi', + password: '111111', + } + uni.$u.http.post('/api/Tokensys/login', httpData, { custom: { isFactory: false } }).then(res => { + if (res.code == 1) { + let userInfo = { + token: res.token,//token用于判断是否登录 + } + console.log(res.token, 'res.token') + store.commit('setUserInfo', userInfo) + console.log(store.state.userInfo.token, 'getToken-token') + // uni.$emit("loginCallback") //全局登录监听回调方法 + } + while (promiseResult.length) { + // p1.resolve(res.data) + promiseResult.shift().resolve(res) + } + lock = false + }).catch(err => { + while (promiseResult.length) { + // p1.reject(err) + promiseResult.shift().reject(err) + } + lock = false + }) + // } + // }) + } + }) } // 获取当前路径 export const getCurrentRouter = (callback) => { - let routes = getCurrentPages() // 获取当前打开过的页面路由数组 - let curRoute = routes[routes.length - 1].route - return curRoute + let routes = getCurrentPages() // 获取当前打开过的页面路由数组 + let curRoute = routes[routes.length - 1].route + return curRoute } var throttleLogin = true //判断是否登录(所有端) export const judgeLogin = (callback) => { - let storeUserInfo = store.state.userInfo; - if (!storeUserInfo.userId){ // nvue页面读取不到vuex里面数据,将取缓存 - // #ifdef MP-WEIXIN - storeUserInfo = uni.getStorageSync('userInfo') - // #endif - } - console.log(storeUserInfo,'storeUserInfo----') - if (!storeUserInfo.accessToken) { - if(throttleLogin){ - throttleLogin = false - setTimeout(()=>{ - throttleLogin = true //节流 - },1000) - store.commit('setCurrentRouter',getCurrentRouter()) //获取当前路径 - // #ifdef MP - store.commit('setLoginPopupShow', true); - // #endif - // #ifdef APP-PLUS - uni.$showModal({ - title: "登录提示", - confirmVal:'去登录', - cancelVal:'再逛会', - content:'此时此刻需要您登录喔~', - }).then(res=>{ - uni.navigateTo({ - url: "/pages/user/login" - }); - }).catch(res=>{}) - // #endif - - }else{ - // uni.$u.toast('您点击的太频繁了') - } - }else{ + console.log('judgeLogin', store) + const storeUserInfo = uni.getStorageSync('userInfo') + if (!storeUserInfo) { + if (throttleLogin) { + throttleLogin = false + setTimeout(() => { + throttleLogin = true //节流 + }, 1000) + store.commit('setCurrentRouter', getCurrentRouter()) //获取当前路径 + // #ifdef MP + store.commit('setLoginPopupShow', true); + // #endif + // #ifdef APP-PLUS + uni.$showModal({ + title: "登录提示", + confirmVal: '去登录', + cancelVal: '再逛会', + content: '此时此刻需要您登录喔~', + }).then(res => { + uni.navigateTo({ + url: "/pages/user/login" + }); + }).catch(res => { }) + // #endif + + } else { + // uni.$u.toast('您点击的太频繁了') + } + } else { callback && callback() } } \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 6a935e4..12f3a92 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -573,18 +573,10 @@ export default { }, goToDetail: function (type, guid, region) { if (type == "scenic") { - // const list = JSON.stringify(this.scenicList) - let arr = this.scenicList.filter((item) => item.guid != guid.guid); - let list = [] - if (arr.length <= 2) { - list = JSON.stringify(arr) - } else { - list = JSON.stringify(arr.slice(0, 2)) - } - console.log("list", list) + uni.navigateTo({ // url: "/subPageA/scenic/scenicdetial/scenicdetial?guid=" + guid + `&listA=` + list, - url: "/subPageA/scenic/scenicdetial/scenicdetial?guid=" + guid.guid + `&list=` + list, + url: "/subPageA/scenic/scenicdetial/scenicdetial?guid=" + guid.guid , }); } else if (type == "food") { uni.navigateTo({ diff --git a/store/modules/user.js b/store/modules/user.js index ed7e3f6..8f1ae33 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -13,6 +13,8 @@ export const mutations = { // #ifndef H5 uni.setStorageSync('userInfo', state.userInfo); // #endif + }else{ + state.userInfo = null } }, // 退出APP diff --git a/subPageA/scenic/scenicdetial/scenicdetial.css b/subPageA/scenic/scenicdetial/scenicdetial.css index 0e8bc1d..dbeb1f6 100644 --- a/subPageA/scenic/scenicdetial/scenicdetial.css +++ b/subPageA/scenic/scenicdetial/scenicdetial.css @@ -69,7 +69,7 @@ .btn_open{display: none} /*景区地址*/ -.btn_daoh{ background: #44b7ab; color: #fff; font-size:28rpx ; display: inline-block; padding:0rpx 30rpx; height: 60rpx; line-height: 60rpx; } +.btn_daoh{ background: #0983FF; color: #fff; font-size:28rpx ; display: inline-block; padding:0rpx 30rpx; height: 60rpx; line-height: 60rpx; } diff --git a/subPageA/scenic/scenicdetial/scenicdetial.vue b/subPageA/scenic/scenicdetial/scenicdetial.vue index 8864a00..83286fd 100644 --- a/subPageA/scenic/scenicdetial/scenicdetial.vue +++ b/subPageA/scenic/scenicdetial/scenicdetial.vue @@ -60,10 +60,10 @@ {{ item.refundRulesName }} - {{ + {{ item.settlementPrice | money }} - {{ item.qmxSettlementPrice + {{ item.qmxSettlementPrice | money }} @@ -74,10 +74,11 @@ - 附近玩乐 + 推荐景区 暂无数据 - + {{ p_item.cname || p_item.sname }} @@ -150,12 +151,12 @@ export default { mask: true, }); this.guid = options.guid; - if (options.list != "" && options.list != null) { - const arr = JSON.parse(options.list); + // if (options.list != "" && options.list != null) { + // const arr = JSON.parse(options.list); - this.wanleList = arr; + // this.wanleList = arr; - } + // } this.detailInfo(options.guid); this.getIsShow(); // #ifdef H5 @@ -263,6 +264,28 @@ export default { }, }, methods: { + getRedisData(){ + var data = { + key: this.$param.userkey + "_scenic_list", + }; + this.$Request.post(this.$config.getRedisData, data).then((res) => { + if (res.status == 200 && res.data.error == 0) { + let list = []; + list = res.data.list[0].content; + let filteredList = list.filter(item => { + return item.isrecommend === "YES" && item.cid != this.guid; + }); + if (Array.isArray(filteredList) && filteredList.length>0){ + filteredList.forEach(item=>{ + item.thumb = this.$config.ROOTPATH + item.thumb; + }) + } + this.wanleList = filteredList + } else { + this.wanleList = [] + } + }); + }, bookIt(val) { this.judgeLogin((resa) => { const obj = { @@ -346,6 +369,7 @@ export default { }); }, detailInfo: function (guid) { + this.guid = guid /* var that = this; var data = { key: this.$param.userkey+'_scenic_' + guid @@ -413,6 +437,7 @@ export default { this.getTicketList(this.info.controlInfo.cyjcScenicId); uni.hideLoading(); + this.getRedisData() }); }, diff --git a/subPageA/scenic/sceniclist/sceniclist.vue b/subPageA/scenic/sceniclist/sceniclist.vue index 471fd5c..027dfa8 100644 --- a/subPageA/scenic/sceniclist/sceniclist.vue +++ b/subPageA/scenic/sceniclist/sceniclist.vue @@ -58,16 +58,22 @@ - - - - + + + + + + {{ p_item.cname }} {{ p_item.slevel - }} - {{ p_item.address }} + }} + + {{ p_item.address }} + @@ -394,16 +400,9 @@ export default { }, gotoDetail(e) { console.log(e); - let arr = this.scenicList.content.filter((item) => item.cid != e); - let list = [] - if (arr.length <= 2) { - list = JSON.stringify(arr) - } else { - list = JSON.stringify(arr.slice(0, 2)) - } - console.log("list", list) + uni.navigateTo({ - url: `/subPageA/scenic/scenicdetial/scenicdetial?guid=` + e + `&list=` + list, + url: `/subPageA/scenic/scenicdetial/scenicdetial?guid=` + e, }); }, getRedisRegion: function () { @@ -1034,8 +1033,8 @@ page { } .m-content { - overflow: hidden; - flex:1; + overflow: hidden; + flex: 1; margin-left: 15rpx; .product-title1 { @@ -1050,14 +1049,21 @@ page { padding: 3rpx 10rpx; margin-bottom: 20rpx; } - .product-con{ font-size: 28rpx;color: #999; - height: 40rpx; - overflow: hidden; - - text-overflow: ellipsis; - white-space: nowrap; - image{width: 24rpx;margin-right: 8rpx;} - } + + .product-con { + font-size: 28rpx; + color: #999; + height: 40rpx; + overflow: hidden; + + text-overflow: ellipsis; + white-space: nowrap; + + image { + width: 24rpx; + margin-right: 8rpx; + } + } } } } diff --git a/subPageB/static/css/scenicdetial.css b/subPageB/static/css/scenicdetial.css index 0e8bc1d..dbeb1f6 100644 --- a/subPageB/static/css/scenicdetial.css +++ b/subPageB/static/css/scenicdetial.css @@ -69,7 +69,7 @@ .btn_open{display: none} /*景区地址*/ -.btn_daoh{ background: #44b7ab; color: #fff; font-size:28rpx ; display: inline-block; padding:0rpx 30rpx; height: 60rpx; line-height: 60rpx; } +.btn_daoh{ background: #0983FF; color: #fff; font-size:28rpx ; display: inline-block; padding:0rpx 30rpx; height: 60rpx; line-height: 60rpx; } diff --git a/subPageC/bookTicket/bookTicket.vue b/subPageC/bookTicket/bookTicket.vue index 70004b1..ef8136a 100644 --- a/subPageC/bookTicket/bookTicket.vue +++ b/subPageC/bookTicket/bookTicket.vue @@ -61,7 +61,7 @@ @change="changeCount($event, ticket)" /> - @@ -875,7 +875,7 @@ export default { const index = res.data.findIndex(item => item.date == nowDate) if (index != -1) { if (res.data[index].isAvailable == true) { - that.maxBuyNums = res.data[index].inventory + that.maxBuyNums = res.data[index].inventory==-1? 100: res.data[index].inventory that.overSituation = true } else { that.overSituation = false diff --git a/subPageC/order/order.vue b/subPageC/order/order.vue index d1de4e0..51fd5b4 100644 --- a/subPageC/order/order.vue +++ b/subPageC/order/order.vue @@ -130,12 +130,9 @@ 退款清单 - {{ - item.ticketname }} - *{{ - item.ticketNums - }}张 + + {{item.ticketname }} + *{{item.ticketNums}}张 @@ -245,6 +242,7 @@ export default { }, closeBackMoney() { this.$refs.refundPopup.close(); + this.upCallback() }, //退款接口 backMoney() { @@ -753,6 +751,7 @@ export default { .m-item-label { width: 200rpx; color: #666; + flex: none; } .m-item-value-box {