123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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() {
- // 页面关闭
- },
- });
|