shopgoods.js 3.0 KB
// pages/shop/shopgoods/shopgoods.js
 const app=getApp();
// import menu from '../template/template'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgsUrls: [

      {
        imgId: '0',
        url: '/img/chair.png',
        
        touchnum:2870

      },
      {
        imgId: '1',
        url: '/img/chair.png',
       
        touchnum: 2870,

      },
      {
        imgId: '2',
        url: '/img/chair.png',
        touchnum: 2870

      },

    ],
    currentindex: 0,
    currentSwiper:0,
    num:2
  },
// 点赞
  touch(e){
    let that=this;
    let id=e.currentTarget.dataset.id;
    let newimgsUrls = that.data.imgsUrls;
    for (var obj of newimgsUrls){
      if (obj.imgId==id){
        obj.touchnum++
      }
    }

    that.setData({
      imgsUrls: newimgsUrls
    })
  },

  //详情页
  detail(){
    wx.navigateTo({
      url: '/pages/shop/goodtail/goodtail',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      num: wx.getStorageSync('num')
    })
    this.getshop()
  },

  //获取商品列表
  getshop(){
    let that = this;
    let url = '/Product/SelectProductList', params = {
      

    }
    app.post(url, params).then((res) => {
      console.log(res);

    }).catch((err) => {

    })
  },
  //底部导航跳转
  jump(e) {
    console.log(e)
    var that = this;
    wx.setStorageSync('num', e.currentTarget.dataset.num)
    let number = e.currentTarget.dataset.num
    console.log(number)
    if (number == 1) {
      wx.reLaunch({
       url: '/pages/homeindex/homeindex',
       
      })

    } else if (number == 2) {
      wx.redirectTo({
       // url: '/pages/shop/goodtail/goodtail',
        url: '/pages/shopgoods/shopgoods'
      })
    } else if (number == 3) {

      wx.reLaunch({
        url: '/pages/shopcar/shopcar',
      })
    } else if (number == 4) {
      wx.reLaunch({
        url: '/pages/myorder/myorder',
      })
    } else if (number == 5) {
      let type = e.currentTarget.dataset.type;
      if (type == 1) {
        wx.reLaunch({
          // url: '/pages/visitormine/visitormine',
          //url: '/pages/guidemine/guidemine'
          url: '/pages/jingxiaoshangmine/jingxiaoshangmine'
        })
      }

    }
  },

  handleChange(e) {
    this.setData({
      currentindex: e.detail.current,
      currentSwiper: e.detail.current
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})