// component/relatedOrderItem/relatedOrderItem.js
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo

Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
    selectShow: { // 显示标识
      type: Boolean,
      value: false
    },
    proList: { // 显示标识
      type: Array,
      value: ''
    }
	
  },
  attached () {
   
	},
	/**
	 * 组件的初始数据
	 */
	data: {
		// isSelect:false,
    proList:[
      // {
      //   indexUrl:'',
      //   productName:'111111',
      //   productId:'11'
      // }
    ]
	},
	/**
	 * 组件的方法列表
	 */
	methods: {
		selectCoupon(e) {
      console.log(e)
      let proData = []
      let proList = this.data.proList
      var index = e.currentTarget.dataset.index
      if (proList[index].isSelect) {
        proList[index].isSelect = false
      } else {
        proList[index].isSelect = true
      }
      this.setData({
        proList: proList
      })
      for (var i in proList){
        if (proList[i].isSelect){
          proData.push(proList[i])
        }
      }
      console.log(proData)
      wxService.nextTick(() => {
        this.triggerEvent('_selectCoupon', proData)
      })
    },

    // getProList(){
    //   wxService.post(`/sale/product/buyer/listWithMember`).then(res => {
    //     const { result, data } = res.data
    //     if (result == 0) {
    //       data.forEach(item => {
    //         item.isSelect = false
    //       })
    //      this.setData({
    //        proList: data
    //      })
    //      console.log(data)
    //     }
    //   }).finally(() => {
    //   })

    // }
  }
})
