Browse Source

性能优化

master
jiazhipeng 11 months ago
parent
commit
c10e811517
  1. 97
      app.js
  2. 1
      app.json
  3. 306
      pages/index/index.js
  4. 2
      pages/info/guideInfo/index.json
  5. 1
      pages/list/six/index.json
  6. 1
      pages/map/index.json
  7. 4
      pages/order/WineSceneOrder/index.json
  8. 1
      pages/order/components/contact/index.json
  9. 1
      pages/order/scene/index.json
  10. 1
      pages/order/showOrderNew/index.json
  11. 3
      pages/pbService/feiyi/info/index.json
  12. 45
      pages/pbService/web/index.js
  13. 53
      pages/user/user.js
  14. 5
      subPackages/feiyiNew/index.json
  15. 1
      subPackages/goods/oneCardTour/info/index.json
  16. 1
      subPackages/indexs/index.json
  17. 4
      subPackages/techanNew/index.json

97
app.js

@ -2,64 +2,58 @@
import commonApi from "./utils/https/common" import commonApi from "./utils/https/common"
App({ App({
onLaunch: function (options) { onLaunch: function (options) {
// 用异步处理
if (options.query.authCode) { if (options.query.authCode) {
wx.setStorageSync('authCode', options.query.authCode) //wx.setStorageSync('authCode', options.query.authCode)
wx.setStorage('authCode', options.query.authCode)
} else { } else {
wx.removeStorageSync('authCode') //wx.removeStorageSync('authCode')
wx.removeStorage('authCode')
} }
this.updateApp() this.updateApp()
let rect = wx.getSystemInfoSync();
this.globalData.safeBottom = rect.safeArea ? (rect.safeArea.bottom - rect.safeArea.height) : 0 this.globalData.appLaunchFlag = false
// 获取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
})
})
// 获取用户信息 onShow: function () {
// wx.getSetting({ // onshow 从后台打开会多次执行 用flag判断
// success: res => { console.log("执行App onShow")
// if (res.authSetting['scope.userInfo']) { if (this.globalData.appLaunchFlag) return
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 console.log("执行App onShow2")
// wx.getUserInfo({ this.globalData.appLaunchFlag = true
// success: res => { // 缓存systemInfo
// // 可以将 res 发送给后台解码出 unionId let systemInfo = wx.getSystemInfoSync();
// this.globalData.userInfo = res.userInfo 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 以防止这种情况 // 获取uuid
// if (this.userInfoReadyCallback) { commonApi._post("browse/get_uuid", {}).then(res => {
// this.userInfoReadyCallback(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);
this.getShareCategoryId() 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 () { updateApp: function () {
const updateManager = wx.getUpdateManager() const updateManager = wx.getUpdateManager()
@ -180,6 +174,7 @@ App({
}) })
}, },
globalData: { globalData: {
appLaunchFlag: false, // App onLaunch执行结束
CategoryIds: {}, //分享出去的页面id CategoryIds: {}, //分享出去的页面id
category_id: "", //分享进来的参数 category_id: "", //分享进来的参数
from: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录 from: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录

1
app.json

@ -241,6 +241,7 @@
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationStyle": "custom" "navigationStyle": "custom"
}, },
"lazyCodeLoading": "requiredComponents",
"style": "v2", "style": "v2",
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"tabBar": { "tabBar": {

306
pages/index/index.js

@ -146,10 +146,7 @@ Page({
isMayDay: new Date().getTime()>new Date('2025/05/01 00:00:00').getTime() isMayDay: new Date().getTime()>new Date('2025/05/01 00:00:00').getTime()
}, },
onLoad: function(options) { onLoad: function(options) {
this.getHeight()
//全屏广告
wx.hideTabBar() //这里隐藏了底部导航栏
commonApi._post("adv/getAdv", { commonApi._post("adv/getAdv", {
position: 2, position: 2,
type_id: 3 type_id: 3
@ -205,56 +202,22 @@ Page({
}) })
if (options.from) { if (options.from) {
app.globalData.from = options.from; app.globalData.from = options.from;
} }
// 获取今天的日期 this.getHeight()
//全屏广告
wx.hideTabBar() //这里隐藏了底部导航栏
// 获取今天的日期
let today = new Date(); 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({ this.setData({
month: (this.data.months[today.getMonth()]).toUpperCase(), month: (this.data.months[today.getMonth()]).toUpperCase(),
date: today.getDate() date: today.getDate(),
}) today: d.getFullYear() + "-" + month + "-" + day
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
}) })
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) { gobdDetail(e) {
let item = e.currentTarget.dataset.item let item = e.currentTarget.dataset.item
@ -431,14 +394,16 @@ Page({
// 获取导航栏项目标题高度 // 获取导航栏项目标题高度
getHeight() { getHeight() {
let that = this let that = this
wx.getSystemInfo({ let systemInfo = wx.getStorageSync('systemInfo'),rect = wx.getMenuButtonBoundingClientRect();
success(res) { if (!systemInfo) {systemInfo = wx.getSystemInfoSync()}
console.log(res) if (!rect) {rect = wx.getMenuButtonBoundingClientRect()}
that.setData({ let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height;
viewHeight: res.windowHeight + 'px'
}) that.setData({
console.log(that.data.viewHeight) viewHeight: systemInfo.windowHeight + 'px',
} height: height,
padHeight: systemInfo.statusBarHeight,
right: (systemInfo.screenWidth - rect.right) + rect.width
}) })
}, },
// getXpthList: function() { // 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() { onReachBottom: function() {
// if (this.data.list.length < 30) {
// this.getList()
// }
}, },
gotoDetail: function(e) { gotoDetail: function(e) {
let item = e.currentTarget.dataset.item; let item = e.currentTarget.dataset.item;
@ -1042,186 +980,43 @@ Page({
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(weburl), 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 // 监听文旅查询的scroll
listenScroll(e) { listenScroll(e) {
this.setData({ this.setData({
scrollLeft: e.detail.scrollLeft 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() { 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) { pagePoint: function(e, type) {
util.pagePoint(e, type) util.pagePoint(e, type)
}, },
@ -1241,7 +1036,6 @@ Page({
this.pagePoint({ this.pagePoint({
event: 'home_view' event: 'home_view'
}, 1) }, 1)
// this.data.time!=5?wx.showTabBar():1
}, },
/** /**

2
pages/info/guideInfo/index.json

@ -1,5 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader"
} }
} }

1
pages/list/six/index.json

@ -1,6 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"search":"/pages/component/SearchHeader",
"title":"/pages/component/TitleHeader" "title":"/pages/component/TitleHeader"
} }
} }

1
pages/map/index.json

@ -1,6 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"search":"/pages/component/SearchHeader",
"title":"/pages/component/TitleHeader" "title":"/pages/component/TitleHeader"
} }

4
pages/order/WineSceneOrder/index.json

@ -1,10 +1,8 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"date1":"../components/date/index",
"contact":"../components/contact/index", "contact":"../components/contact/index",
"coupon":"../components/coupon/index", "coupon":"../components/coupon/index",
"notice":"/pages/component/notice/notice", "notice":"/pages/component/notice/notice"
"date":"/pages/order/components/date"
} }
} }

1
pages/order/components/contact/index.json

@ -1,6 +1,5 @@
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"add":"/pages/user/linkman/add"
} }
} }

1
pages/order/scene/index.json

@ -1,7 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"date1":"../components/date/index",
"contact":"../components/contact/index", "contact":"../components/contact/index",
"coupon":"../components/coupon/index", "coupon":"../components/coupon/index",
"notice":"/pages/component/notice/notice", "notice":"/pages/component/notice/notice",

1
pages/order/showOrderNew/index.json

@ -1,7 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"date1":"../components/date/index",
"contact":"../components/contact/index", "contact":"../components/contact/index",
"coupon":"../components/coupon/index", "coupon":"../components/coupon/index",
"notice":"/pages/component/notice/notice", "notice":"/pages/component/notice/notice",

3
pages/pbService/feiyi/info/index.json

@ -1,6 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader"
"common-image":"/pages/component/commonImage/index"
} }
} }

45
pages/pbService/web/index.js

@ -11,7 +11,8 @@ Page({
data: { data: {
webUrl:"", webUrl:"",
shareTitle: "", shareTitle: "",
shareUrl: "" shareUrl: "",
canSetData: true
}, },
/** /**
@ -51,9 +52,10 @@ Page({
weburl += '&token='+res.data.token weburl += '&token='+res.data.token
} }
}).finally(()=>{ }).finally(()=>{
this.setData({ // this.setData({
webUrl:weburl // webUrl:weburl
}) // })
this.setUrl(weburl)
}) })
} }
// 遇见昆山 // 遇见昆山
@ -68,9 +70,10 @@ Page({
weburl += '&token='+res.data.token weburl += '&token='+res.data.token
} }
}).finally(()=>{ }).finally(()=>{
this.setData({ // this.setData({
webUrl:weburl // webUrl:weburl
}) // })
this.setUrl(weburl)
}) })
} }
// 君到苏州 加token // 君到苏州 加token
@ -83,13 +86,15 @@ Page({
weburl += '?token='+token weburl += '?token='+token
} }
} }
this.setData({ // this.setData({
webUrl:weburl // webUrl:weburl
}) // })
this.setUrl(weburl)
} else { } else {
this.setData({ // this.setData({
webUrl:weburl // webUrl:weburl
}) // })
this.setUrl(weburl)
} }
// if(weburl.indexOf('m.cloud.sz-trip.com')!=-1){ // 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);
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

53
pages/user/user.js

@ -79,9 +79,11 @@ Page({
*/ */
onShow: function () { onShow: function () {
userApi.user_post("user/getMyInfo").then(res => { userApi.user_post("user/getMyInfo").then(res => {
this.setData({ if (res && res.data) {
info: res.data this.setData({
}) info: res.data
})
}
}) })
util.pagePoint({ util.pagePoint({
event:'mine_view' event:'mine_view'
@ -103,28 +105,31 @@ Page({
limit:10, limit:10,
keywords:'' keywords:''
}).then(res=>{ }).then(res=>{
console.log(res); console.log(res);
let arr = []
let trr = [] if (res && res.data && res.data.length>0){
let yrr = [] let arr = []
let reslist = res.data.list let trr = []
this.setData({}) let yrr = []
let nowDateTime = parseInt(new Date().getTime() / 1000) let reslist = res.data.list
for (let i = 0; i < reslist.length; i++) { this.setData({})
let del = nowDateTime - this.strtotime(reslist[i].create_time) let nowDateTime = parseInt(new Date().getTime() / 1000)
if (del < reslist[i].auto_close_time) { for (let i = 0; i < reslist.length; i++) {
trr.push(reslist[i].auto_close_time - del) let del = nowDateTime - this.strtotime(reslist[i].create_time)
yrr.push(this.formatSeconds(reslist[i].auto_close_time - del)) if (del < reslist[i].auto_close_time) {
arr.push(reslist[i].order_product_list[0]) 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) { strtotime(str) {

5
subPackages/feiyiNew/index.json

@ -1,7 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader",
"common-image":"/pages/component/commonImage/index", "common-image":"/pages/component/commonImage/index"
"search":"/pages/component/SearchHeader"
} }
} }

1
subPackages/goods/oneCardTour/info/index.json

@ -1,7 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"notice":"/pages/component/notice/notice",
"code":"/pages/order/components/wxqrCode/index", "code":"/pages/order/components/wxqrCode/index",
"date":"/pages/order/components/date" "date":"/pages/order/components/date"

1
subPackages/indexs/index.json

@ -1,6 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"common-image":"/pages/component/commonImage/index",
"title":"/pages/component/TitleHeader" "title":"/pages/component/TitleHeader"
} }
} }

4
subPackages/techanNew/index.json

@ -1,7 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "common-image":"/pages/component/commonImage/index"
"common-image":"/pages/component/commonImage/index",
"search":"/pages/component/SearchHeader"
} }
} }
Loading…
Cancel
Save