From c10e81151778d658711a1cc5858aca9d4db7b654 Mon Sep 17 00:00:00 2001 From: jiazhipeng Date: Tue, 20 May 2025 17:32:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 97 +++--- app.json | 1 + pages/index/index.js | 306 +++--------------- pages/info/guideInfo/index.json | 2 +- pages/list/six/index.json | 1 - pages/map/index.json | 1 - pages/order/WineSceneOrder/index.json | 4 +- pages/order/components/contact/index.json | 1 - pages/order/scene/index.json | 1 - pages/order/showOrderNew/index.json | 1 - pages/pbService/feiyi/info/index.json | 3 +- pages/pbService/web/index.js | 45 ++- pages/user/user.js | 53 +-- subPackages/feiyiNew/index.json | 5 +- subPackages/goods/oneCardTour/info/index.json | 1 - subPackages/indexs/index.json | 1 - subPackages/techanNew/index.json | 4 +- 17 files changed, 164 insertions(+), 363 deletions(-) diff --git a/app.js b/app.js index 713c6ec..f354f30 100644 --- a/app.js +++ b/app.js @@ -2,64 +2,58 @@ import commonApi from "./utils/https/common" App({ onLaunch: function (options) { + // 用异步处理 if (options.query.authCode) { - wx.setStorageSync('authCode', options.query.authCode) + //wx.setStorageSync('authCode', options.query.authCode) + wx.setStorage('authCode', options.query.authCode) } else { - wx.removeStorageSync('authCode') + //wx.removeStorageSync('authCode') + wx.removeStorage('authCode') } this.updateApp() - let rect = wx.getSystemInfoSync(); - this.globalData.safeBottom = rect.safeArea ? (rect.safeArea.bottom - rect.safeArea.height) : 0 - // 获取uuid - commonApi._post("browse/get_uuid", {}).then(res => { - // console.log('uuid',res); - this.globalData.uuid = res.data.uuid; - wx.setStorageSync('uuid', res.data.uuid) - }) - // 获取前端配置文件 - commonApi._post("pbservice/Other/getClientConfig", { - unique_key: "wechatxcx" - }).then(res => { - let data = JSON.parse(res.data); - data.isTest = data.isTest189? true : false; - this.globalData.configJson = data - }).then(() => { - // 获取ui配置文件 - commonApi._post("adv/get_home_ui", {type_id: 3}).then(res => { - let obj = {} - res.data.content.forEach(item => { - obj[item.id] = item.image - }); - this.globalData.configJson.indexSeason = obj - this.globalData.loadIndexSeason = true - }) - }) - - - + + this.globalData.appLaunchFlag = false + }, - // 获取用户信息 - // wx.getSetting({ - // success: res => { - // if (res.authSetting['scope.userInfo']) { - // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - // wx.getUserInfo({ - // success: res => { - // // 可以将 res 发送给后台解码出 unionId - // this.globalData.userInfo = res.userInfo + onShow: function () { + // onshow 从后台打开会多次执行 用flag判断 + console.log("执行App onShow") + if (this.globalData.appLaunchFlag) return + console.log("执行App onShow2") + this.globalData.appLaunchFlag = true + // 缓存systemInfo + let systemInfo = wx.getSystemInfoSync(); + this.globalData.safeBottom = systemInfo.safeArea ? (systemInfo.safeArea.bottom - systemInfo.safeArea.height) : 0 + wx.setStorage('systemInfo', systemInfo) + let rect = wx.getMenuButtonBoundingClientRect(); + wx.setStorage("rect", rect) - // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 - // // 所以此处加入 callback 以防止这种情况 - // if (this.userInfoReadyCallback) { - // this.userInfoReadyCallback(res) - // } - // } - // }) - // } - // } - // }) - this.getShareCategoryId() + + // 获取uuid + commonApi._post("browse/get_uuid", {}).then(res => { + // console.log('uuid',res); + this.globalData.uuid = res.data.uuid; + wx.setStorageSync('uuid', res.data.uuid) + }) + // 获取前端配置文件 + commonApi._post("pbservice/Other/getClientConfig", {unique_key: "wechatxcx"}).then(res => { + let data = JSON.parse(res.data); + data.isTest = data.isTest189? true : false; + this.globalData.configJson = data + }).then(() => { + // 获取ui配置文件 在首页调用 + commonApi._post("adv/get_home_ui", {type_id: 3}).then(res => { + let obj = {} + res.data.content.forEach(item => { + obj[item.id] = item.image + }); + this.globalData.configJson.indexSeason = obj + this.globalData.loadIndexSeason = true + }) + }) + this.getShareCategoryId() }, + // 更新提示 updateApp: function () { const updateManager = wx.getUpdateManager() @@ -180,6 +174,7 @@ App({ }) }, globalData: { + appLaunchFlag: false, // App onLaunch执行结束 CategoryIds: {}, //分享出去的页面id category_id: "", //分享进来的参数 from: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录 diff --git a/app.json b/app.json index ac4fa44..6bf88ff 100644 --- a/app.json +++ b/app.json @@ -241,6 +241,7 @@ "navigationBarTextStyle": "black", "navigationStyle": "custom" }, + "lazyCodeLoading": "requiredComponents", "style": "v2", "sitemapLocation": "sitemap.json", "tabBar": { diff --git a/pages/index/index.js b/pages/index/index.js index 9d9cb7c..3c95918 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -146,10 +146,7 @@ Page({ isMayDay: new Date().getTime()>new Date('2025/05/01 00:00:00').getTime() }, - onLoad: function(options) { - this.getHeight() - //全屏广告 - wx.hideTabBar() //这里隐藏了底部导航栏 + onLoad: function(options) { commonApi._post("adv/getAdv", { position: 2, type_id: 3 @@ -205,56 +202,22 @@ Page({ }) if (options.from) { app.globalData.from = options.from; - } - // 获取今天的日期 + } + this.getHeight() + //全屏广告 + wx.hideTabBar() //这里隐藏了底部导航栏 + + // 获取今天的日期 let today = new Date(); + let d = new Date(); + let month = d.getMonth() + 1,day = d.getDate(); + month = month > 10 ? month : ("0" + month); + day = day > 10 ? day : ("0" + day); this.setData({ month: (this.data.months[today.getMonth()]).toUpperCase(), - date: today.getDate() - }) - let d = new Date(); - let month = d.getMonth() + 1, - day = d.getDate(); - month = month > 10 ? month : ("0" + month); - day = day > 10 ? day : ("0" + day); - this.setData({ - today: d.getFullYear() + "-" + month + "-" + day - }) - let systemInfo = wx.getSystemInfoSync(), - rect = wx.getMenuButtonBoundingClientRect(); - let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height; - wx.getLocation({ - type: 'gcj02', - success: (res) => { - this.setData({ - lat: res.latitude, - lon: res.longitude - }) - this.getList() - this.getHdrlList() - }, - fail: (err) => { - this.getList() - this.getHdrlList() - } - }) - this.setData({ - height: height, - padHeight: systemInfo.statusBarHeight, - right: (systemInfo.screenWidth - rect.right) + rect.width + date: today.getDate(), + today: d.getFullYear() + "-" + month + "-" + day }) - - commonApi._post("pbservice/Other/getClientConfig", { - unique_key: "urltopage" - }).then(res => { - let data = JSON.parse(res.data) - this.setData({ - urltopage: data - }) - }) - this.getTwoProduct() - this.getBanner() - this.getWeather() }, gobdDetail(e) { let item = e.currentTarget.dataset.item @@ -431,14 +394,16 @@ Page({ // 获取导航栏项目标题高度 getHeight() { let that = this - wx.getSystemInfo({ - success(res) { - console.log(res) - that.setData({ - viewHeight: res.windowHeight + 'px' - }) - console.log(that.data.viewHeight) - } + let systemInfo = wx.getStorageSync('systemInfo'),rect = wx.getMenuButtonBoundingClientRect(); + if (!systemInfo) {systemInfo = wx.getSystemInfoSync()} + if (!rect) {rect = wx.getMenuButtonBoundingClientRect()} + let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height; + + that.setData({ + viewHeight: systemInfo.windowHeight + 'px', + height: height, + padHeight: systemInfo.statusBarHeight, + right: (systemInfo.screenWidth - rect.right) + rect.width }) }, // getXpthList: function() { @@ -887,34 +852,7 @@ Page({ }) }, - // 热门推荐 去掉经纬度 接口排序方式变更(韩阳) - // getList: function() { - // if (!this.data.listMore) return; - // commonApi._post("search/recommend", { - // offset: this.data.list.length, - // limit: 16 - // }).then(res => { - // res.data.map(item => { - // if (item.ext.display_tags) { - // item.ext.display_tags = item.ext.display_tags.split(",").splice(0, 2) - // } else { - // item.ext.display_tags = [] - // } - // }) - // if (res.data.length < 15) { - // this.setData({ - // listMore: false - // }) - // } - // this.setData({ - // list: this.data.list.concat(res.data) - // }) - // }) - // }, onReachBottom: function() { - // if (this.data.list.length < 30) { - // this.getList() - // } }, gotoDetail: function(e) { let item = e.currentTarget.dataset.item; @@ -1042,186 +980,43 @@ Page({ url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(weburl), }) }, - // bannerClick2: function(e) { - // let item = e.currentTarget.dataset.item; - // if (item.action == 'href') { - // if (item.href.indexOf(",") != -1) { - // let info = item.href.split(","); - // wx.navigateToMiniProgram({ - // appId: info[0], - // path: info[1] - // }) - // } else if (item.href.indexOf('map/index') != -1) { - // wx.reLaunch({ - // url: item.href - // }) - // } else { - // wx.navigateTo({ - // url: item.href, - // }) - // } - // } else if (item.action == "web") { - // app.globalData.weburl = item.href; - // wx.navigateTo({ - // url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.href), - // }) - // } - // }, // 监听文旅查询的scroll listenScroll(e) { this.setData({ scrollLeft: e.detail.scrollLeft }) }, - // // 获取短视频大赛是否中奖 中奖详情 - // getVideoPrize() { - // let user_id = wx.getStorageSync('jstrip_userid'); - // if (!user_id || wx.getStorageSync('indexPriceNoTip')) return; - // commonApi.user_post('actonline/video_act/getRaffle', { - // act_id: 5 - // }).then(res => { - // this.setData({ - // videoPrize: res.data - // }) - // }) - // }, - // noMoreTip() { - // wx.setStorageSync('indexPriceNoTip', true) - // this.closePrice() - // }, - // closePrice() { - // this.setData({ - // videoPrize: false, - // prizeInfo: null - // }) - // }, - // 抽奖 - // choosePrize() { - // commonApi.user_post('actonline/video_act/luckyDraw', { - // act_id: 5 - // }).then(res => { - // this.setData({ - // prizeInfo: res.data - // }) - // if (res.data.type != 'none') { - // // 抽奖成功的话 弹框 - // wx.showModal({ - // title: "提示", - // content: "中奖人员请联系君到苏州客服,领奖方式以客服通知为准", - // showCancel: false - // }) - // } - // }) - // }, - // bannerJumpNew(item) { - // let that = this - // item = item.currentTarget.dataset.item - // if (item.tdata == '') return - // that.pagePoint({ - // event: "banner_click", - // type: 'banner' - // }, 1) - // switch (item.jump_type) { - // case 0: - // break; - // case 1: - // util.gotoDetail(item.product_model) - // break; - // case 2: - // if (item.front_model && item.front_model.mini) { - // wx.navigateTo({ - // url: "/" + item.front_model.mini - // }) - // } - // break; - // case 3: - // if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && - // item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) { - // // 外部h5 - // console.log(item.tdata) - // app.globalData.weburl = item.tdata.url; - // wx.navigateTo({ - // url: "/pages/pbService/web/index" - // }) - // } else { - // let page = item.tdata.url.split("/"); - // page = page[page.length - 1].split("?") - // console.log(page[0]) - // let url = this.data.urltopage[page[0]]; - // if (url && url.indexOf('map') != -1) { - // let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic', - // 'cinema', 'academes' - // ], - // type = page[1] ? page[1].split("=") : []; - // wx.reLaunch({ - // url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) : null) - // }) - // } else if (url) { - // wx.navigateTo({ - // url: url, - // }) - // } else { - // app.globalData.weburl = item.tdata.url; - // wx.navigateTo({ - // url: "/pages/pbService/web/index" - // }) - // } - // } - // break; - // case 4: - // if (item.tdata.appid == 'wxe5ca0f71e918e352' && wx.getStorageSync('jstrip_userid')) { - // // 如果是苏心游的小程序 直接把authCode带过去 - // userApi.user_post("user/getJumpThirdAppCode", {}).then(res => { - // let weburl = item.tdata.page - // if (weburl.indexOf('?') != -1) { - // weburl += '&authCode=' + res.data; - // } else { - // weburl += '?authCode=' + res.data - // } - // wx.navigateToMiniProgram({ - // appId: item.tdata.appid, - // path: weburl - // }) - // }).catch(err => { - // wx.navigateToMiniProgram({ - // appId: item.tdata.appid, - // path: item.tdata.page - // }) - // }) - // } else { - // wx.navigateToMiniProgram({ - // appId: item.tdata.appid, - // path: item.tdata.page - // }) - // } - // break; - // default: - // break; - // } - // return - // }, onReady: function() { + wx.getLocation({ + type: 'gcj02', + success: (res) => { + this.setData({ + lat: res.latitude, + lon: res.longitude + }) + this.getList() + this.getHdrlList() + }, + fail: (err) => { + this.getList() + this.getHdrlList() + } + }) + commonApi._post("pbservice/Other/getClientConfig", { + unique_key: "urltopage" + }).then(res => { + let data = JSON.parse(res.data) + this.setData({ + urltopage: data + }) + }) + // this.getTwoProduct() + this.getBanner() + this.getWeather() }, - // gotoOther: function(e) { - // let item = e.currentTarget.dataset.item; - // if (item.type == 'h5') { - // app.globalData.weburl = item.url - // wx.navigateTo({ - // url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.url) - // }) - // } else if (item.type == 'mini') { - // wx.navigateToMiniProgram({ - // appId: item.appid, - // path: item.path - // }) - // } else if (item.type == 'page') { - // wx.navigateTo({ - // url: item.page, - // }) - // } - // }, + pagePoint: function(e, type) { util.pagePoint(e, type) }, @@ -1241,7 +1036,6 @@ Page({ this.pagePoint({ event: 'home_view' }, 1) - // this.data.time!=5?wx.showTabBar():1 }, /** diff --git a/pages/info/guideInfo/index.json b/pages/info/guideInfo/index.json index 35cf02f..79be446 100644 --- a/pages/info/guideInfo/index.json +++ b/pages/info/guideInfo/index.json @@ -1,5 +1,5 @@ { "usingComponents": { - "title":"/pages/component/TitleHeader" + } } \ No newline at end of file diff --git a/pages/list/six/index.json b/pages/list/six/index.json index 4cc7ccc..35cf02f 100644 --- a/pages/list/six/index.json +++ b/pages/list/six/index.json @@ -1,6 +1,5 @@ { "usingComponents": { - "search":"/pages/component/SearchHeader", "title":"/pages/component/TitleHeader" } } \ No newline at end of file diff --git a/pages/map/index.json b/pages/map/index.json index 074fb77..9639d0a 100644 --- a/pages/map/index.json +++ b/pages/map/index.json @@ -1,6 +1,5 @@ { "usingComponents": { - "search":"/pages/component/SearchHeader", "title":"/pages/component/TitleHeader" } diff --git a/pages/order/WineSceneOrder/index.json b/pages/order/WineSceneOrder/index.json index 17ea59b..6e93399 100644 --- a/pages/order/WineSceneOrder/index.json +++ b/pages/order/WineSceneOrder/index.json @@ -1,10 +1,8 @@ { "usingComponents": { "title":"/pages/component/TitleHeader", - "date1":"../components/date/index", "contact":"../components/contact/index", "coupon":"../components/coupon/index", - "notice":"/pages/component/notice/notice", - "date":"/pages/order/components/date" + "notice":"/pages/component/notice/notice" } } \ No newline at end of file diff --git a/pages/order/components/contact/index.json b/pages/order/components/contact/index.json index da13845..78013bd 100644 --- a/pages/order/components/contact/index.json +++ b/pages/order/components/contact/index.json @@ -1,6 +1,5 @@ { "component": true, "usingComponents": { - "add":"/pages/user/linkman/add" } } \ No newline at end of file diff --git a/pages/order/scene/index.json b/pages/order/scene/index.json index 17ea59b..19927e7 100644 --- a/pages/order/scene/index.json +++ b/pages/order/scene/index.json @@ -1,7 +1,6 @@ { "usingComponents": { "title":"/pages/component/TitleHeader", - "date1":"../components/date/index", "contact":"../components/contact/index", "coupon":"../components/coupon/index", "notice":"/pages/component/notice/notice", diff --git a/pages/order/showOrderNew/index.json b/pages/order/showOrderNew/index.json index 17ea59b..19927e7 100644 --- a/pages/order/showOrderNew/index.json +++ b/pages/order/showOrderNew/index.json @@ -1,7 +1,6 @@ { "usingComponents": { "title":"/pages/component/TitleHeader", - "date1":"../components/date/index", "contact":"../components/contact/index", "coupon":"../components/coupon/index", "notice":"/pages/component/notice/notice", diff --git a/pages/pbService/feiyi/info/index.json b/pages/pbService/feiyi/info/index.json index eb3533f..35cf02f 100644 --- a/pages/pbService/feiyi/info/index.json +++ b/pages/pbService/feiyi/info/index.json @@ -1,6 +1,5 @@ { "usingComponents": { - "title":"/pages/component/TitleHeader", - "common-image":"/pages/component/commonImage/index" + "title":"/pages/component/TitleHeader" } } \ No newline at end of file diff --git a/pages/pbService/web/index.js b/pages/pbService/web/index.js index 689ac4a..0731d7d 100644 --- a/pages/pbService/web/index.js +++ b/pages/pbService/web/index.js @@ -11,7 +11,8 @@ Page({ data: { webUrl:"", shareTitle: "", - shareUrl: "" + shareUrl: "", + canSetData: true }, /** @@ -51,9 +52,10 @@ Page({ weburl += '&token='+res.data.token } }).finally(()=>{ - this.setData({ - webUrl:weburl - }) + // this.setData({ + // webUrl:weburl + // }) + this.setUrl(weburl) }) } // 遇见昆山 @@ -68,9 +70,10 @@ Page({ weburl += '&token='+res.data.token } }).finally(()=>{ - this.setData({ - webUrl:weburl - }) + // this.setData({ + // webUrl:weburl + // }) + this.setUrl(weburl) }) } // 君到苏州 加token @@ -83,13 +86,15 @@ Page({ weburl += '?token='+token } } - this.setData({ - webUrl:weburl - }) + // this.setData({ + // webUrl:weburl + // }) + this.setUrl(weburl) } else { - this.setData({ - webUrl:weburl - }) + // this.setData({ + // webUrl:weburl + // }) + this.setUrl(weburl) } // if(weburl.indexOf('m.cloud.sz-trip.com')!=-1){ @@ -148,6 +153,20 @@ Page({ } }, + setUrl (url) { + let that = this + if (this.data.canSetData) { + this.data.canSetData = false + this.setData({ + webUrl:url + }) + setTimeout(() => { + that.data.canSetData = true + }, 1000); + } + + }, + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/user/user.js b/pages/user/user.js index 06182c7..e5497a5 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -79,9 +79,11 @@ Page({ */ onShow: function () { userApi.user_post("user/getMyInfo").then(res => { - this.setData({ - info: res.data - }) + if (res && res.data) { + this.setData({ + info: res.data + }) + } }) util.pagePoint({ event:'mine_view' @@ -103,28 +105,31 @@ Page({ limit:10, keywords:'' }).then(res=>{ - console.log(res); - let arr = [] - let trr = [] - let yrr = [] - let reslist = res.data.list - this.setData({}) - let nowDateTime = parseInt(new Date().getTime() / 1000) - for (let i = 0; i < reslist.length; i++) { - let del = nowDateTime - this.strtotime(reslist[i].create_time) - if (del < reslist[i].auto_close_time) { - trr.push(reslist[i].auto_close_time - del) - yrr.push(this.formatSeconds(reslist[i].auto_close_time - del)) - arr.push(reslist[i].order_product_list[0]) + console.log(res); + + if (res && res.data && res.data.length>0){ + let arr = [] + let trr = [] + let yrr = [] + let reslist = res.data.list + this.setData({}) + let nowDateTime = parseInt(new Date().getTime() / 1000) + for (let i = 0; i < reslist.length; i++) { + let del = nowDateTime - this.strtotime(reslist[i].create_time) + if (del < reslist[i].auto_close_time) { + trr.push(reslist[i].auto_close_time - del) + yrr.push(this.formatSeconds(reslist[i].auto_close_time - del)) + arr.push(reslist[i].order_product_list[0]) + } + } + this.setData({ + list: arr, + orderList: reslist, + timeList: trr, + formatTime:yrr + }) + this.timer(this.data.timeList) } - } - this.setData({ - list: arr, - orderList: reslist, - timeList: trr, - formatTime:yrr - }) - this.timer(this.data.timeList) }) }, strtotime(str) { diff --git a/subPackages/feiyiNew/index.json b/subPackages/feiyiNew/index.json index 0861abd..2d9de7a 100644 --- a/subPackages/feiyiNew/index.json +++ b/subPackages/feiyiNew/index.json @@ -1,7 +1,6 @@ { "usingComponents": { - "title":"/pages/component/TitleHeader", - "common-image":"/pages/component/commonImage/index", - "search":"/pages/component/SearchHeader" + + "common-image":"/pages/component/commonImage/index" } } \ No newline at end of file diff --git a/subPackages/goods/oneCardTour/info/index.json b/subPackages/goods/oneCardTour/info/index.json index ee48bc8..5d2d101 100644 --- a/subPackages/goods/oneCardTour/info/index.json +++ b/subPackages/goods/oneCardTour/info/index.json @@ -1,7 +1,6 @@ { "usingComponents": { "title":"/pages/component/TitleHeader", - "notice":"/pages/component/notice/notice", "code":"/pages/order/components/wxqrCode/index", "date":"/pages/order/components/date" diff --git a/subPackages/indexs/index.json b/subPackages/indexs/index.json index 7c4437e..35cf02f 100644 --- a/subPackages/indexs/index.json +++ b/subPackages/indexs/index.json @@ -1,6 +1,5 @@ { "usingComponents": { - "common-image":"/pages/component/commonImage/index", "title":"/pages/component/TitleHeader" } } \ No newline at end of file diff --git a/subPackages/techanNew/index.json b/subPackages/techanNew/index.json index 0861abd..db066e2 100644 --- a/subPackages/techanNew/index.json +++ b/subPackages/techanNew/index.json @@ -1,7 +1,5 @@ { "usingComponents": { - "title":"/pages/component/TitleHeader", - "common-image":"/pages/component/commonImage/index", - "search":"/pages/component/SearchHeader" + "common-image":"/pages/component/commonImage/index" } } \ No newline at end of file