visitor.js 2.46 KB
import { IMG_URL_STORE } from "~/utils/constantData";
import ActivityApi from '~/api/activityApi/index'
import { commentTime } from '~/utils/format'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: [],
        allNum: 0,
        todayNum: 0,
        IMG_URL: IMG_URL_STORE,
        isPravite: false
    },

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

    onRoute(options) {
        wx.showLoading()
        let activityId = options.activityId
        ActivityApi.getActivityVisitorList({
            activityId,
            staffFlag: true
        }).then(res => {
            res.visitorList && res.visitorList.forEach(val => {
                val.lastVisitFormatTime = commentTime(val.lastVisitDate)
                if (!val.customerPhone && val.guestId) {
                    val.gId = (val.guestId.split('_')).pop() || ''
                }
            })
            this.setData({
                allNum: res.visitorTotal,
                todayNum: res.todayTotal,
                list: res.visitorList
            })
            wx.hideLoading()
        })
    },
    toCopyName(e) {
        const { name } = e.currentTarget.dataset
        if (name) {
            wx.setClipboardData({
                data: name
            })
        }
    },

    // 打电话
    callPhone(e) {
        let { mobile } = e.currentTarget.dataset
        wx.makePhoneCall({
            phoneNumber: mobile.toString()
        })
    },
    // 复制微信号
    copyWechart(e) {
        let { wechartno } = e.currentTarget.dataset
        wx.setClipboardData({
            data: wechartno.toString(),
            success(res) {
                wx.showToast({
                    title: '微信号已复制',
                    icon: "none"
                })
            }
        })
    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})