import { tabberFunc } from "../../utils/util"; const app = getApp(); Page({ data: { Ios: app.globalData.Ios, isLoad: true, loadProgress: 100, CustomBar: app.globalData.CustomBar, // 通知栏 tips: [ // { key: 1, value: "一二三111122221112211222111222111122221112211222111222" }, ], // 商品 value: { page: 1, totalPage: 1, value: [ // { img: "https://ossweb-img.qq.com/images/lol/web201310/skin/big10006.jpg", title: "钢铁之翼", detail: "Only the guilty need fear me." }, ] } }, // 跳转详情页 onClickFunc (e) { let { index } = e.currentTarget.dataset, { value } = this.data; wx.navigateTo({ url: "/pages/detail/index?data=" + JSON.stringify(value['value'][index]) }); }, // tabber NavChange (e) { if (this.data.isLoad) return false; let { active, path } = e.currentTarget.dataset; tabberFunc(active, path) }, // 通知栏 tipsFunc (e) { let { index } = e.currentTarget.dataset, { tips } = this.data; wx.navigateTo({ url: "/pages/tips/index?data=" + JSON.stringify(tips[index]) }) }, // 请求 request_lock: false, async request () { try { let { value: _value } = this.data; let { page, totalPage, value } = _value; if (page > totalPage || this.request_lock) return false; this.request_lock = true; let res = await wx.$request({ method: "get", url: "/order/productList/", data: { limit: 10, page } }); ++page; totalPage = res.totalPage; value = res.data.map(item => ({ img: item.mail_image, id: item.id, month: item.month, title: item.name, details: item.details_image })); this.setData({ value: { page, totalPage, value } }); this.request_lock = false; } catch (err) { wx.$err(err); this.request_lock = false; } }, timer: null, onLoad: async function (options) { // 微信小程序生命周期执行 不友好 this.timer = setInterval(() => { if (app.globalData._initState) { clearInterval(this.timer); this.setData({ isLoad: false }) } }, 100); this.request(); try { let resB = await wx.$request({ method: "get", url: "/notices/list/" }); resB.data = resB.data.map(item => ({ key: item.id, value: item.title, detail: item.content, create_time: item.create_time, create_user: item.create_user })); this.setData({ tips: resB.data }); } catch (err) { wx.$err(err) } }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { clearInterval(this.timer); }, onPullDownRefresh: function () { }, onReachBottom: function () { this.request(); }, onShareAppMessage: function () { } })