overView.js 4.32 KB
// packageStoreAssistant/sopJourney/pages/overView/overView.js
import sopApi from '~/api/sopApi'
import stageData from '../../data/index'
// 1.短信 2.ai外呼 3.门店助手朋友圈 4.门店助手1v1转发 5.客户跟进提醒 
const TASK_LIST = [{
    icon: 'sms',
    title: '批量发短信',
    description: '批量发送续保膨胀金短信',
    url: '/packageStoreAssistant/packageActivity/pages/marketing/task/task?type=2',
    show: true
  }, {
    icon: 'ai-call',
    title: '批量外呼',
    description: '批量AI外呼,提醒续保',
    url: '/packageStoreAssistant/packageActivity/pages/marketing/task/task?type=1',
    show: true
  }, {
    icon: 'pyq',
    title: '分享朋友圈',
    description: '分享膨胀金链接到朋友圈',
    show: true
  },
  {
    icon: 'transmit',
    title: '转发给客户',
    description: '分享膨胀金链接到客户微信',
    url: '/packageStoreAssistant/packageActivity/pages/marketing/task/task?type=2',
    show: true
  },
  {
    icon: 'remind',
    title: '客户跟进提醒',
    description: '及时跟进客户,提醒续保',
    url: '/packageStoreAssistant/packageActivity/pages/marketing/task/task?type=2',
    show: true
  }
]
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab: [],
    tabIndex: 0,
    sopList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  onRoute(option) {
    if (option) {
      let {
        activityId,
        stageList,
        stageName
      } = option
      this.setData({
        activityId,
        stageName,
        tab: stageList
      }, () => {
        this.currentTab()
        this.getSopList()
      })

    }

  },
  tabClick(e) {
    let {
      index
    } = e.currentTarget.dataset, {
      tab
    } = this.data
    this.setData({
      tabIndex: index,
      stageName: tab[index].stageName
    })
    this.clearData()
  },
  clearData() {
    this.pageNum = 1
    this.setData({
      sopList: [],
      pageFlag: false
    })
    this.getSopList()
  },
  currentTab() {
    let {
      tab,
      tabIndex,
      stageName
    } = this.data;
    if (stageName) {
      tab.forEach((item, index) => {
        if (item.stageName == stageName) {
          tabIndex = index
          this.setData({
            tabIndex
          })
        }
      })
    } else {
      this.setData({
        stageName: tab[tabIndex].stageName
      })
    }

  },
  async getSopList() {
    wx.$api.showLoading('加载中...')
    let {
      tab,
      stageName
    } = this.data,
      sopArr = [],
      nothing

    try {
      let data;
      tab.forEach(item => {
        if (item.stageName == stageName) {
          data = item.nodeInfos
        }

      })
      console.log(data)
      // data = stageData[stageName]
      if (data.length == 0) nothing = true
      data.forEach(item => {
        if ([1, 2, 3, 4, 5].includes(item.nodeParam.taskType)) {
          if (sopArr[item.nodeParam.day - 1]) {
            sopArr[item.nodeParam.day - 1].data.push(item.nodeParam)
          } else {
            sopArr[item.nodeParam.day - 1] = {
              title: `客户旅程第${item.nodeParam.day}天`,
              data: [item.nodeParam]
            }
          }
        }



      })
      this.setData({
        sopList: sopArr,
        TASK_LIST: TASK_LIST,
        nothing,
        pageFlag: true,
        triggered: false
      })
      wx.hideLoading()
    } catch (error) {
      console.log(error)
      // wx.$api.showToast(error)
      wx.hideLoading()
      this.setData({
        pageFlag: false
      })
    }

  },
  // 下拉触底
  onScrolltolower(e) {
    let {
      pageNum,
      nothing
    } = this.data
    if (nothing) return

    this.setData({
      pageNum: ++pageNum
    }, () => {
      this.getSopList()
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})