// packageG/o2o/HomeSeller/HomeSeller.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { mainInfo: {}, store_id: "", page_id: "", clientWidth: "375", page_name: "", btnFlag: false, store_components: [], store_pageInfo: {}, bottom_info: {}, foot_type: "", current_page: 1, total_page: 0, decorate_isLoadMore: true, lastIndex: "", bottomShowBol: false, bottomShowBolIndex: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ store_id: options.store_id, }); this.getStoreInfo(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { this.setData({ clientWidth: wx.getSystemInfoSync().windowWidth, }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, getStoreInfo() { let that = this; let urlStr = app.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-the-provider"); app._getNetWork({ url: urlStr, data: { store_id: this.data.store_id, }, success: (resdata) => { var res = resdata.data; that.setData({ isShow: true, }); if (res.result == 1) { if (res.data.store_decorate && res.data.store_decorate.datas) { that.setData({ mainInfo: res.data.store_info, page_id: res.data.store_decorate.id, store_components: res.data.store_decorate.datas, store_pageInfo: res.data.store_decorate.page_info, foot_type: res.data.store_decorate.foot_type, }); // 装修的底部有三种情况 if (res.data.store_decorate.foot_type == -1) { // 不显示 this.setData({ bottom_info: {}, }); } else if (res.data.store_decorate.foot_type == 1) { // 显示默认 if (!res.data.store_decorate.foot_id || !res.data.store_decorate.foot_id.page_info) { // 显示系统默认 this.setData({ bottom_info: {}, }); } else { // 显示列表设置的默认 this.setData({ bottom_info: JSON.parse(res.data.store_decorate.foot_id.page_info), }); } } else if (res.data.store_decorate.foot_type == 2) { // 显示自定义的底部导航 if (!res.data.store_decorate.foot_id || res.data.store_decorate.foot_id instanceof Array) { this.setData({ bottom_info: {}, }); } else { this.setData({ bottom_info: JSON.parse(res.data.store_decorate.foot_id.page_info), }); } } wx.setNavigationBarTitle({ title: this.data.store_pageInfo.page_title || "商家", }); wx.setNavigationBarColor({ backgroundColor: this.data.store_pageInfo.preview_color, frontColor: this.data.store_pageInfo.font_color == 1 ? "#ffffff" : "#000000", animation: { duration: 400, timingFunc: "easeIn", }, }); } } else { wx.showToast({ title: res.msg, icon: "none", duration: 1500, }); } }, fail: function (res) { console.log(res); }, }); }, // 跳转 turnTo() { let item = this.data.advertising; if (item.is_minapp == 2) { if (item.minapp_sid) { if (item.minapp_link2) { try { wx.navigateToMiniProgram({ appId: item.minapp_sid, path: item.minapp_link2, extraData: {}, envVersion: "release", success(res) { // 打开成功 }, fail(res) { wx.showToast({ title: "小程序跳转失败", icon: "none", duration: 2000, }); }, }); } catch (e) { wx.showToast({ title: "小程序跳转失败", icon: "none", duration: 2000, }); } } else { wx.showToast({ title: "请设置跳转小程序后的跳转链接", icon: "none", duration: 2000, }); } } else { wx.showToast({ title: "请设置小程序所需跳转appId", icon: "none", duration: 2000, }); } } else { let url = item.minapp_link; try { wx.navigateTo({ url: url, }); } catch (e) { wx.showToast({ title: "链接设置错误", icon: "none", duration: 2000, }); } } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, // 获取滚动条当前位置 onPageScroll: function (e) { // 节流 if (e.scrollTop > 80) { if (!this.data.btnFlag) { this.setData({ btnFlag: true, }); } } else { if (this.data.btnFlag) { this.setData({ btnFlag: false, }); } } if (this.data.bottomShowBol) { this.setData({ bottomShowBol: false, }); } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ bottomShowBol: true, }); if (this.data.decorate_isLoadMore) { // this.getMoreDecorate(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: this.data.store_pageInfo.page_title ? this.data.store_pageInfo.page_title : "商家", path: `/packageG/o2o/HomeSeller/HomeSeller?store_id=${this.data.store_id}`, }; }, // 分享朋友圈 onShareTimeline() { return { title: this.data.store_pageInfo.page_title ? this.data.store_pageInfo.page_title : "商家", path: `/packageG/o2o/HomeSeller/HomeSeller?store_id=${this.data.store_id}`, }; }, });