const util = require('../../utils/util.js'); const api = require('../../config/api.js'); const user = require('../../utils/user.js'); //获取应用实例 const app = getApp(); Page({ data: { newGoods: [ { brief: "耐用", counterPrice: 599, id: 1152008, isHot: true, isNew: false, name: "600ML新晶彩茶韵国民水杯", picUrl: "/static/images/1152008.png", retailPrice: 59 } ,{ brief: "耐用", counterPrice: 299, id: 1152009, isHot: true, isNew: false, name: "400ML都市暖心保温杯秋日系列", picUrl: "/static/images/1152009.png", retailPrice: 59 } ,{ brief: "耐用", counterPrice: 299, id: 1152031, isHot: true, isNew: false, name: "400ML花香鸟鸣晶彩随心杯", picUrl: "/static/images/1152031.png", retailPrice: 59 }, { brief: "耐用", counterPrice: 299, id: 1152095, isHot: true, isNew: false, name: "新款晶彩茶韵杯/国民水杯", picUrl: "/static/images/1152095.png", retailPrice: 59 } ], hotGoods: [ { brief: "耐用", counterPrice: 599, id: 1152008, isHot: true, isNew: false, name: "新款晶彩茶韵杯/国民水杯", picUrl: "/static/images/1152008.png", retailPrice: 59 } ], // topics: [], // brands: [], // groupons: [], // floorGoods: [], // banner: [], channel: [] }, onShareAppMessage: function() { return { title: 'Renard', desc: '特百惠国民水杯', path: '/pages/index/index' } }, onPullDownRefresh() { this.getIndexData(); wx.stopPullDownRefresh() //停止下拉刷新 }, getIndexData: function() { wx.showLoading({ title: '加载中', }); setTimeout(function() { wx.hideLoading() }, 2000); let that = this; util.request(api.IndexUrl).then(function(res) { if (res.errno === 0) { that.setData({ // newGoods: res.data.newGoodsList, TODO // hotGoods: res.data.hotGoodsList, TODO // topics: res.data.topicList, // brands: res.data.brandList, // floorGoods: res.data.floorGoodsList, // banner: res.data.banner, // groupons: res.data.grouponList, // channel: res.data.channel }); wx.hideLoading(); } }); }, onLoad: function(options) { var that = this; wx.getSystemInfo({ success: function(res) { that.setData({ windowWidth: res.windowWidth, windowHeight: res.windowHeight }); } }); if (options.scene) { var scene = decodeURIComponent(options.scene); console.log("scene:" + scene); let info_arr = []; info_arr = scene.split(','); let _type = info_arr[0]; let id = info_arr[1]; if (_type == 'goods') { wx.navigateTo({ url: '../goods/goods?id=' + id }); } else if (_type == 'groupon') { wx.navigateTo({ url: '../goods/goods?grouponId=' + id }); } else { wx.navigateTo({ url: '../index/index' }); } } // 页面初始化 options为页面跳转所带来的参数 if (options.grouponId) { //这个pageId的值存在则证明首页的开启来源于用户点击来首页,同时可以通过获取到的pageId的值跳转导航到对应的详情页 wx.navigateTo({ url: '../goods/goods?grouponId=' + options.grouponId }); } // 页面初始化 options为页面跳转所带来的参数 if (options.goodId) { //这个pageId的值存在则证明首页的开启来源于用户点击来首页,同时可以通过获取到的pageId的值跳转导航到对应的详情页 wx.navigateTo({ url: '../goods/goods?id=' + options.goodId }); } // 页面初始化 options为页面跳转所带来的参数 if (options.orderId) { //这个pageId的值存在则证明首页的开启来源于用户点击来首页,同时可以通过获取到的pageId的值跳转导航到对应的详情页 wx.navigateTo({ url: '../ucenter/orderDetail/orderDetail?id=' + options.orderId }); } this.getIndexData(); }, onReady: function() { // 页面渲染完成 }, onShow: function() { // 页面显示 }, onHide: function() { // 页面隐藏 }, onUnload: function() { // 页面关闭 }, });