// pages/Store-Management/Store-Management.js
Page({
  data: {
      checkedAll: "",
      checkclo:'true',
      e:'red',
      items: [{
              value: 'OLD',
              name: '老式麻辣烫（微辣）',
              state:'活动中',
              price:'￥9.9',
              origin:'￥15.9',
              card:'20',
              content:'内容',
              checked: 'true',
              id:0,
              checkclo1:'false'
          },
          {
            value: 'old',
            name: '老式麻辣烫（微辣）',
            state:'审核中',
            card:'20',
            origin:'￥15.9',
            content:'内容',
            price:'￥9.9',
            id:1,
            checkclo1:'false'
          },
          {
            value: 'Old',
            name: '老式麻辣烫（微辣）',
            state:'申请活动',
            card:'20',
            origin:'￥15.9',
            content:'内容',
            price:'￥9.9',
            id:2,
            checkclo1:'false'
          },
      ]
  },

  acceptMission: function (e) {
    // 获取当前点击下标    
    var Index = e.currentTarget.dataset.index;
    console.log(Index);
    // data中获取列表   
    var Arr = this.data.items;
    for (let i in Arr) {
      //遍历列表数据      
      if (i == Index) {
        if(Arr[i].id==Index){
          // !this.data.items.checkclo1,
          !Arr.checkclo1
        }
        // !Arr.checkclo1
       
      }
      //数组重新赋值
      let completeStatus = `items[${Index}].checkclo1`
      this.setData({
        [completeStatus]: !this.data.items[Index].checkclo1
      })
    }
  },
 
    
  
  return(event){
    wx.switchTab({
      url: '/pages/me/me',
      success: (result)=>{},//成功回调
      fail: ()=>{},//失败回调
      complete: ()=>{},//无论成功还是失败都会执行
  })
},

  checkboxChange(e) {
      // console.log('checkbox发生change事件，携带value值为：', e.detail.value)
      const items = this.data.items
      const values = e.detail.value
      for (let i = 0, lenI = items.length; i < lenI; ++i) {
          items[i].checked = false
          for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
              if (items[i].value === values[j]) {
                  items[i].checked = true
                  break
              }
          }
      }
      this.setData({
          items
      })
      if (e.detail.value.length == 6) {
          console.log(this.data.checkedAll);
          this.setData({
              checkedAll: true
          })
      }else{
          this.setData({
              checkedAll: ""
          })
      }
  },
  checkboxAll(e) {
      if (e.detail.value.length == 1) {
          // 全选状态
          const items = this.data.items
          for (let i = 0; i < items.length; i++) {
              items[i].checked = true
          }
          this.setData({
              items
          })
      } else {
          // 没有全选状态
          const items = this.data.items
          for (let i = 0; i < items.length; i++) {
              items[i].checked = false
          }
          this.setData({
              items
          })
      }
  },
  switch1Change(event){
    // const checkclo = JSON.stringify(event.detail.value);
    const checkclo = event.detail.value;
    this.setData({checkclo})
    // console.log(checkclo)
    // console.log(event)
  },
  add:function(){
    wx.navigateTo({
      url: '../add/add',
    })
  },
  change:function(){
    wx.navigateTo({
      url: '../change/change',
    })
  }

})