// packageG/cps/cpsDetail/cpsDetail.js
var cpsApi = require("../component/cpsApi");
Page({
  behaviors: [cpsApi],
  /**
   * 页面的初始数据
   */
  data: {
    good: {},
    hoet: false,
    showContent: true,

    ratioCommissionAmount: 0,
    shareCommissionAmount: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      good: options,
      showContent: true,
    });
    this.getCPSLogin('good');
  },
  getCoupon() {
    let we_app_info = this.data.goodsDetail.we_app_info;
    wx.navigateToMiniProgram({
      appId: we_app_info.app_id,
      path: we_app_info.page_path,
      extraData: {},
    });
  },
  toShowContent() {
    this.setData({
      showContent: !this.data.showContent
    });
  },
  goBack() {
    wx.navigateBack({
      delta: 1
    });
  },
  gotoMember() {
    wx.reLaunch({
      url: '/packageG/member_v2/member_v2'
    });
  },
  gotoHome() {
    wx.reLaunch({
      url: '/packageG/index/index',
    });
  },

  onPageScroll(e) {
    let scrollTop = e.scrollTop;
    if (scrollTop > 35) {
      if (!this.data.hoet) {
        this.setData({
          hoet: true,
        });
      }
    } else {
      if (this.data.hoet) {
        this.setData({
          hoet: false,
        });
      }
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareTimeline() {
    var value = wx.getStorageSync("yz_uid");
    var mid = "";
    if (value) {
      mid = value;
    }
    return {
      title: this.data.goodsDetail.title,
      query: `item_id=${this.data.good.item_id}&platform_id=${this.data.good.platform_id}&mid=${mid}`,
    };
  },
  onShareAppMessage: function () {
    var value = wx.getStorageSync('yz_uid');
    let mid = '';
    if (value) {
      mid = value;
    }
    return {
      title: this.data.goodsDetail.title,
      path: `/packageG/cps/cpsGoodDetail/cpsGoodDetail?item_id=${this.data.good.item_id}&platform_id=${this.data.good.platform_id}&mid=${mid}`,
    };
  }
});