applyActivity.js 1.76 KB
import activityApi from "~/api/activityApi/index"
Page({

  data: {
    list: [
      {
        name: '新车洽谈场景',
        tip: '1.0 新车权益销售',
      },
      {
        name: '新车交付场景',
        tip: '1.1 新车精品升级',
      },
      {
        name: '0-12个月',
        tip: '1.2 新车线上转化',
      },
      {
        name: '12个月以上',
        tip: '1.3 存量用户众筹',
      },
    ],
    currentIndex: 0,
    product: [
      {
        id: 1,
        name: '360全景导航',
        isSelect: false
      },
      {
        id: 2,
        name: '360全景导航',
        isSelect: false
      },
      {
        id: 3,
        name: '360全景导航',
        isSelect: false
      },
      {
        id: 4,
        name: '360全景导航',
        isSelect: false
      },
      {
        id: 5,
        name: '360全景导航',
        isSelect: false
      }
    ]
  },
  select(e) {
    const { index } = e.currentTarget.dataset
    this.setData({
      currentIndex: index
    })
  },
  selectProduct(e) {
    const { item, index } = e.currentTarget.dataset
    let name = `product[${index}].isSelect`
    this.setData({
      [name]: !item.isSelect
    })
  },
  // 申请开通
  applyOpened() {
    // 获取已选的产品code
    let { product, currentIndex } = this.data
    let arr = []
    product.forEach(val => {
      if (val.isSelect) arr.push(val.id)
    })
    if (!arr.length) return wx.showToast({
      title: '请选择产品/活动',
      icon: "none"
    })
    activityApi.applyActivity({
      serviceMerchantId: 1,
      merchantId: 2,
      sceneCode: currentIndex,
      productCodes: arr
    }).then(res => {
      if (res.code == 200) {
        wx.$router.go('packageActivity.applySuccess')
      }
    })
  }

})