//index.js var app = getApp(); var utils = require('../../utils/util.js'); Page({ data: { imgUrls: [ ], indicatorDots: true, autoplay: true, interval: 2000, duration: 1000, page:1, dataList: [ ], hidden: true, listId:0 }, onLoad: function (options) { var that = this, source = ''; const userInfo = wx.getStorageSync('userInfo') || null; if (userInfo) { app.globalData.userInfo = userInfo; }else{ wx.redirectTo({url: '/pages/login/login'}) } if (options.source) { that.setData({source: options.source}) } const dataParam = Object.assign({}, app.globalData.common, {version: 2, platform: app.globalData.platform}); wx.request({ url: app.globalData.HOST + '/user/product/homeact', method: 'POST', data: dataParam, success: function (res) { if (res.data.errno == '0'){ that.setData({ imgUrls: res.data.rst.homeact}); } } }); utils.initList(that); }, onShow () { wx.stopPullDownRefresh(); wx.hideNavigationBarLoading(); }, onHide () { wx.stopPullDownRefresh() wx.hideNavigationBarLoading(); }, onPullDownRefresh: function () { //下拉 var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" }; that.data.page = 1; setTimeout(()=>{ utils.initList(that, obj, that.data.page); }, 800) }, onReachBottom: function () { //上拉 var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" }; if (that.data.hasNext) { utils.initList(that, obj, ++that.data.page); } }, onShareAppMessage: function () { return { title: app.globalData.title, imageUrl: app.globalData.img, path: '/pages/index/index', success: function(res) { app.noticeModal('分享成功') }, fail: function(res) { app.noticeModal('您取消了分享') } } }, //FormId formSubmit(e) { const formId = e.detail.formId, id = e.target.dataset.id; const userInfo = app.globalData.userInfo; this.getFromid(formId,id); wx.navigateTo({ url: '/pages/details/details?id='+id }) // console.log(formId + "formID首页") }, getFromid(formId,ids) { wx.request({ url: app.globalData.HOST + '/user/wx/getFromid', method: "POST", data: Object.assign({}, app.globalData.common, { from_id: formId }), success: function (res) { }, complete: function () { } }); } })