message.js 2.15 KB
import { GET } from '../../libs/request/request.js';
import config from '../../config.js'
// pages/message/message.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    'message_title': ['系统消息', '购买消息', '出售消息' ],
    'system_num': 8,
    'buy_num': 26,
    'sell_num': 666,
    list: [{ 'content': '您的商品AIR JORDAN 4 RETRO PURE MONEY 2017已被用户下单,请及时发货', 'time': '2018.08.08  17:20', 'isRead': true }, { 'content': '您的商品AIR JORDAN 4 RETRO PURE MONEY 2017已被用户下单,请及时发货', 'time': '2018.08.08  17:20', 'isRead': false }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    GET({
      url: config.domains.api + '/resources',
      params: {
        method: 'ufo.product.search.list',
        page: 1,
        limit: 20
      }
    }).then(data => {
      console.log(data);
    }).catch(error => {
      console.error(error);
    })
    // let buy_num = this.data.buy_num > 100 ? '99+' : this.data.buy_num;
    // let sell_num = this.data.sell_num > 100 ? '99+' : this.data.sell_num;
    // let system_num = this.data.system_num > 100 ? '99+' : this.data.system_num;

    // this.setData({
    //   buy_num,
    //   sell_num,
    //   system_num,
    // })
  },

  navToDetail: function (event) {
    let index = event.currentTarget.dataset.index;
    let title = this.data.message_title[index];
    wx.navigateTo({
      url: './messageDetail?' + 'index=' + index + '&title=' + title,
    })
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})