// pages/coupons.js
const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo

wxService.page({
  /**
   * 页面的初始数据
   */
  data: {
    contentInfo:[],
    id:'',
    pageNo:1,
    pageSize:30,
    proList:[]
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options && options.id){
      console.log(options.id)
      this.setData({
        id: options.id
      })
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getContentDetail()
  },

  // 获取内容详情
  getContentDetail(){
    wxService.post(`/merchant/contentMobileTerminal/getContentParticulars?id=${this.data.id}`).then(res => {
      if (!res) return false
      const { result, data } = res.data
      if (result == 0) {
        this.setData({
          contentInfo: data
        })
        this.getProList()
      }

    }).finally(() => {
    })
  },

  //获取内容下商品列表
  getProList(){
    var params = {
      productIds: this.data.contentInfo.productIds
    }
    wxService.post(`/sale/product/buyer/listPageByCategoryId?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, params).then(res => {
      if (!res) return false
      const { result, data } = res.data
      if (result == 0) {
        this.setData({
          proList: data
        })
      }

    }).finally(() => {
    })
  }
 

  
 
})