收藏
回答

问一下大神,像这种结构能不能用for循环?

Page({

  /**
   * 页面的初始数据
   */
  data: {
    checkboxItems: [
      { name: '草莓奶露11.88元', szbzld: "手抓饼(鸡蛋,火腿,肉松,培根,黑椒酱)", dgt: '粿条汤(小份,猪肉丸,猪肉卷,蟹柳,猪肉,乌木耳,猪肝,猪心,猪粉肠,辣椒,加柠檬', jd: '鸡块拼中翅', fds: '腐皮', bdw: '烟熏鸭肉铜锣烧',value: 0, checked: true },
      { name: '可乐4元', szbzld: "手抓饼(鸡蛋,火腿,肉松,鸡柳,培根,黑椒酱)", jd: '梅汁海石花', fds: '肥牛包金针菇', bdw: '芝士鸡肉铜锣烧', value: 1 },
      { name: '番茄酱', fds: '大白菜', bdw: '奥尔良鸡肉铜锣烧', value: 2 },
      { name: '蜜蜂芥末酱', fds: '汤底加餐盒(中辣)',value: 3 },
      { name: '海苔沙拉', value: 4 },
      { name: '孜然蟹柳9元', value: 5 },
      { name: 'test3', value: 6 },
      { name: 'test4', value: 7 },
      { name: 'test5', value: 8 },
      { name: 'test2', value: 9 },
      { name: 'test3', value: 10 },
      { name: 'test4', value: 11 },
      { name: 'test5', value: 12 },
      { name: 'test2', value: 13 },
      { name: 'test3', value: 14 },
      { name: 'test4', value: 15 },
      { name: 'test5', value: 16 }
    ],
   
    mof: 0,
    lla: 0,
    wwd: 0,
    ppc: 0,
    ggs: 0,
    llc: 0,
   
     
    jd: [{
      iconPath: "../../image/1.png",
      id: 0,
      latitude: "23.5694300972",
      longitude: "116.8175257526",
      width: 30,
      height: 30
    }]
  },
  checkboxChange(e) {
    let newArray1 = [];
    let newArray2 = [];

    this.data.checkboxItems.map((item) => {
      if (e.detail.value.indexOf('' + item.value) > -1) {
        item.checked = true
        newArray1.push(item)
      }
      else {
        item.checked = false
        newArray2.push(item)
      }
    })
    this.setData({
      checkboxItems: newArray1.concat(newArray2)
    })
  },
  bc: function (e) {
    wx.makePhoneCall({
      phoneNumber: '13433889894',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  jd: function (e) {
    wx.makePhoneCall({
      phoneNumber: '13433889894',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  bdw: function (e) {
    wx.makePhoneCall({
      phoneNumber: '17725768836',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  szbzld: function (e) {
    wx.makePhoneCall({
      phoneNumber: '13692066412',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  fds: function (e) {
    wx.makePhoneCall({
      phoneNumber: '13790832850',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  cz: function (e) {
    wx.makePhoneCall({
      phoneNumber: '17825705772',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  dgt: function (e) {
    wx.makePhoneCall({
      phoneNumber: '13612415550',
      success: function (res) {
        console.log("ok")
      },
      fail: function (res) {
        console.log("oclx")
      },
      complete: function (res) {
        console.log("nopb")
      },
    })
  },
  mof: function (e) {
    this.setData({
      mof: 6
    })
  },
 lla: function (e) {
    this.setData({
      lla: 6
    })
  },
  wwd: function (e) {
    this.setData({
      wwd: 6
    })
  },
  llc: function (e) {
    this.setData({
      llc: 6
    })
  },
  ppc: function (e) {
    this.setData({
      ppc: 6
    })
  },
  ggs: function (e) {
    this.setData({
      ggs: 6
    })
  },
 

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签