text: 
  const api = require('../../config/api.js');
  const user = require('../../utils/user.js');
  const util = require('../../utils/util.js');
  const utils = require('../../utils/utils.js');
  
  //获取应用实例
  const app = getApp();
  
  Page({
    data: {
      newGoods: [],
      hotGoods: [],
      topics: [],
      topicdonate: [],
      brands: [],
      groupons: [],
      floorGoods: [],
      banner: [],
      channel: [],
      coupon: []
    },
  
    onShareAppMessage: function() {
      return {
        title: '商城',
        desc: '小程序商城',
        path: '/pages/index/index'
      }
    },
  
    onPullDownRefresh() {
      wx.showNavigationBarLoading() //在标题栏中显示加载
      this.getIndexData();
      wx.hideNavigationBarLoading() //完成停止加载
      wx.stopPullDownRefresh() //停止下拉刷新
    },
  
    getIndexData: function() {
      let that = this;
      util.request(api.IndexUrl).then(function(res) {
        if (res.errno === 0) {
          that.setData({
            newGoods: res.data.newGoodsList,
            hotGoods: res.data.hotGoodsList,
            topics: res.data.topicList,
            topicdonate: res.data.topicList1,
            brands: res.data.brandList,
            floorGoods: res.data.floorGoodsList,
            banner: res.data.banner,
            groupons: res.data.grouponList,
            channel: res.data.channel,
            coupon: res.data.couponList
          });
        }
      });
    },
    onLoad: function(options) {
        // 页面初始化 options为页面跳转所带来的参数
        if (options.q) {
            console.log("index 生命周期 onload" + JSON.stringify(options));
        try {
          let q = decodeURIComponent(options.q)
          if (q) {
            console.log("index 生命周期 onload url=" + q)
            var fromId = utils.getQueryString(q, 'id');
            var promoterId = utils.getQueryString(q, 'promoterId');
            console.log("index 生命周期 onload 参数 id=" + fromId)
            console.log("index 生命周期 onload 参数 promoterId=" + promoterId)
            wx.navigateTo({
              url: '../topicDetail/topicDetail?id=' + fromId
            });
            return {
              title: '签到',
              desc: '签到',
              path: '../topicDetail/topicDetail?id=' + fromId
            }
          }
        } catch (err) {
          console.error(err) // 可执行
        };
  
      }
      // 页面初始化 options为页面跳转所带来的参数
      if (options.scene) {
        //这个scene的值存在则证明首页的开启来源于朋友圈分享的图,同时可以通过获取到的goodId的值跳转导航到对应的详情页
        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) {
        //这个goodId的值存在则证明首页的开启来源于分享,同时可以通过获取到的goodId的值跳转导航到对应的详情页
        wx.navigateTo({
          url: '../goods/goods?id=' + options.goodId
        });
      }
  
      // 页面初始化 options为页面跳转所带来的参数
      if (options.orderId) {
        //这个orderId的值存在则证明首页的开启来源于订单模版通知,同时可以通过获取到的pageId的值跳转导航到对应的详情页
        wx.navigateTo({
          url: '../ucenter/orderDetail/orderDetail?id=' + options.orderId
        });
      }
  
      this.getIndexData();
    },
    onReady: function() {
      // 页面渲染完成
    },
    onShow: function() {
      // 页面显示
    },
    onHide: function() {
      // 页面隐藏
    },
    onUnload: function() {
      // 页面关闭
    },
    getCoupon(e) {
      if (!app.globalData.hasLogin) {
        wx.navigateTo({
          url: "/pages/auth/login/login"
        });
      }
  
      let couponId = e.currentTarget.dataset.index
      util.request(api.CouponReceive, {
        couponId: couponId
      }, 'POST').then(res => {
        if (res.errno === 0) {
          wx.showToast({
            title: "领取成功"
          })
        }
        else{
          util.showErrorToast(res.errmsg);
        }
      })
    },
  })