detail_1.js 3.4 KB
// pages/kind/detail_1/detail_1.js
const app = getApp();
var WxParse = require('../../../wxParse/wxParse.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    index: 1,
    showModal: false,
    hide: false,
    num: 1,
    detail_id: null,
    detailCon: {},
    assess: [],
    id:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      detail_id: options.id,
      id:options.id
    })
    this.detaiFun(options.id)
    this.assessFun()
  },
  goFirm_order1(e) {
    wx.navigateTo({
      url: '../firm_order1/firm_order1?id=' + e.currentTarget.dataset.id + "&&num=" + this.data.num,
    })
  },

  // 商品详情数据
  detaiFun(id) {
    let that = this;
    let url = "home/index/shopEdit";
    let params = {
      shop_id: that.data.id
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res)
      that.setData({
        detailCon: res.data,
        content: res.content
      })
      WxParse.wxParse('content', 'html', this.data.content, this, 5);
      console.log(that.data.detailCon)
    }).catch((err) => {
      console.log(err)
    })
  },
  // 商品评价页面
  assessFun() {
    let that = this;
    let url = "home/index/shopMessage";
    let header = {
      "XX-Token": '123123',
      "XX-Device-Type": 'wxapp'
    }
    let params = {
      shop_id: that.data.detail_id,
    }
    app.post(url, params, header).then((res) => {
      console.log(res)
      that.setData({
        assess: res.data.list
      })
    }).catch((err) => {
      console.log(err)
    })
  },
  // 加入收藏
  addFun() {
    let that = this;
    let url = "home/index/shopCollect";
    let params = {
      shop_id: that.data.detail_id,
    };
    let header = {
      "XX-Token": '123123',
      "XX-Device-Type": 'wxapp'
    };
    app.post(url, params, header).then((res) => {
      console.log(res)
      // if(res.code == 20000){
      wx.showToast({
        title: res.msg,
        icon: "none",
        duration: 1500
      })

      // }     
    }).catch((err) => {
      console.log(err)
    })
  },
  goy(e) {
    this.setData({
      index: e.currentTarget.dataset.id,
    })
  },
  goConfirm: function () {
    this.setData({
      showModal: true,
    })
  },
  m_close: function () {
    this.setData({
      showModal: false,
    })
  },
  // 点击加减
  bindMinus: function () {
    var num = this.data.num;
    if (num > 1) {
      num--;
    }
    this.setData({
      num: num,
    });
  },
  // 点击加
  bindPlus: function () {
    var num = this.data.num;
    num++;
    this.setData({
      num: num,
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})