recordApply.js 2.05 KB
// components/recordApply/recordApply.js
import {
  businessApi
} from "../../api/api";
import {
  componentsMixin
} from "../../mixins/index";
Component({
  behaviors: [componentsMixin],
  /**
   * 组件的属性列表
   */
  properties: {
    applyData: {
      type: Array,
      default: [],
      observer(n) {
        this.setData({
          dataList: n
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    dataList: [],
    recordList: [],
    popShow: false,
    isClick: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getRecord(e) {
      this.setData({
        popShow: true
      })
      console.log(e);
      const {activityId} = e.currentTarget.dataset.info
      const params = {
        activityId
      }
      businessApi.getApplyRecord(params).then(res => {
        console.log(res, '000');
        if(res&&res.code == 0) {
          this.setData({
            recordList: res.data
          })
        } else {
          wx.showToast({
            title: res.message || '系统异常',
            icon: 'none'
          })
        }
      })
    },
    // 关闭pop
    closePop() {
      this.setData({
        popShow: false
      })
    },
    // 切换跟进状态
    changeFollow(e) {
      this.setData({
        isClick: true
      })
      const {activityId, followType} = e.currentTarget.dataset.follow
      let data = {
        activityId: activityId,
        followType: followType == 0 ? 1 : 0
      }
      businessApi.activityFollow(data).then(res => {
        if (res.code == 0) {
          this.triggerEvent('changeApplyData', activityId)
          wx.showToast({
            title: '跟进状态修改成功',
            icon: 'none'
          })
        } else {
          wx.showToast({
            title: res.message || '系统异常',
            icon: 'none'
          })
        }
      })
    },
    // 打电话
    callApply(e) {
      console.log(e);
      const phoneNumber = e.currentTarget.dataset.phone
      wx.makePhoneCall({
        phoneNumber: phoneNumber,
      });
    }
  }
})