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"
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: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录

1
app.json

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

306
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
},
/**

2
pages/info/guideInfo/index.json

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

1
pages/list/six/index.json

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

1
pages/map/index.json

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

4
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"
}
}

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

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

1
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",

1
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",

3
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"
}
}

45
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);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

53
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) {

5
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"
}
}

1
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"

1
subPackages/indexs/index.json

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

4
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"
}
}
Loading…
Cancel
Save