const app = getApp(); const api = require('../../../utils/api.js'); const Constants = require('../../../utils/Constants.js'); const util = require('../../../utils/util.js') const common = require('../../../utils/common.js') import Dialog from '../../../dist/dialog/dialog.js'; Page({ /** * 页面的初始数据 */ data: { statusItem_org: { text: '业务部门', value: -1 }, staffIds: [], selectflag: false, checked_1: false, checked_2: false, checked_3: false, checked_4: false, checked_5: false, checked_6: false, checked_7: false, checked_8: false, checked_9: false, checked_10: false, checked_11: false, checked_12: false, show: false, showTime: false, activeboxNames: [], customerName: '', noMore: false, loading: false, pageInfo: { pageSize: 6, currentPage: 1 }, list: [], totallength: 0, //视图下方提醒数量 active: 0, createTimeType: { text: '近30天', value: 5 }, followUpPerson: { text: '张三', value: -1 }, followUpOrg: { text: '佛山居然店', value: -1 }, columns: [], currentDate: new Date().getTime() + 100, formatter(type, value) { if (type === 'year') { return `${value}年`; } if (type === 'month') { return `${value}月`; } if (type === 'day') { return `${value}日`; } if (type === 'hour') { return `${value}时`; } if (type === 'minute') { return `${value}分`; } return value; }, form: { LeaveTime: '请选择', LeaveTime_: '请选择', OtherName: '其他', remindTime: '', followCount: '', followCount_: '', nextFollowTimeList: [], nextFollowTime: '', nextFollowTime_: '', }, list: [], searchText: '', searchFormNumber: 0, //筛选字段 searchForm: { overDueStatus:0, followStatusList: [], nextFollowTimeList: [], }, nextFollowTime: '', }, toAdd() { wx.navigateTo({ url: './add/add?type=add', }) }, onChangePickDate() { this.setData({ showTime: true }) }, /** * @desc : 跳转客户收款新建 * @date : 2022/7/9 15:01 * @author : 常皓宁 */ toCollectionAdd(e) { let customerItem = e.currentTarget.dataset.item if (!customerItem.customerId) { wx.showToast({ title: '无此联系人,或陌生接待', icon: 'none' }) return } this.setData({ showShare: false }) wx.navigateTo({ url: '/package4/pages/order-billing/customer-collection/add/add?customerItem=' + encodeURIComponent(JSON.stringify(customerItem)), }) }, /** * 跳转 */ toDetail(e) { let item = e.currentTarget.dataset.item if(this.data.active ==1 ){ wx.navigateTo({ url: '/package-basic-data/pages/customer-follow-up/detail/detail?item=' + encodeURIComponent(JSON.stringify(item)), }) return } wx.navigateTo({ url: './detail/detail?item=' + encodeURIComponent(JSON.stringify(item)), }) }, onCloseChooseDate() { this.setData({ showTime: false }) }, /** * 留店时长 */ showPopup() { this.setData({ LeaveTimeFlag: true }); }, /** * @desc : 打电话 * @date : 2022/5/18 15:49 * @author : 于继渤 */ openTelPhone(e) { let tel = e.currentTarget.dataset.item.customerPhone if (tel) { wx.makePhoneCall({ phoneNumber: tel, }) } else { wx.showModal({ title: '手机号不正确', message: '' }) } }, //抽屉打开 openSearchPop() { this.setData({ show: true, }) let that = this setTimeout(function () { that.setData({ activeboxNames: ['1', '2'], }) }, 100) }, closeSearchPop() { this.selectComponent("#pick").toggle(false) //取消选中样式 this.setData({ show: false }) }, onChangefollowCount(e) { let form = this.data.form form.followCount_ = e.detail this.setData({ form: form }) }, onChangebox(e) { this.setData({ activeboxNames: e.detail }) }, //抽屉确定 doSearchData(e) { this.selectComponent("#pick").toggle(false) //取消选中样式 let form = this.data.form let searchFormNumber = 0 form.followCount = this.data.form.followCount_ form.nextFollowTime = this.data.nextFollowTime form.LeaveTime = this.data.form.LeaveTime_ let specsList_ = this.data.specsList_ let specsList_flag = false specsList_.forEach(element => { if (element.checked) { specsList_flag = true } }); let receptionStatusList_ = this.data.receptionStatusList_ let receptionStatusList_flag = false receptionStatusList_.forEach(element => { if (element.checked) { receptionStatusList_flag = true } }); if (this.data.form.LeaveTime_ != '请选择') { searchFormNumber++ } if (this.data.form.followCount_ != '') { searchFormNumber++ } if (this.data.form.nextFollowTime_ != '') { searchFormNumber++ } if (specsList_flag) { searchFormNumber++ } if (receptionStatusList_flag) { searchFormNumber++ } this.setData({ show: false, specsList: this.data.specsList_, receptionStatusList: this.data.receptionStatusList_, form, searchFormNumber }) this.doSearch() }, onTimeClose() { this.setData({ LeaveTimeFlag: false, }) }, /** * @desc : 抽屉重置 * @author : 于继渤 * @date : 2022/6/7 19:16 */ clearSearchForm() { let searchForm = this.data.searchForm searchForm = { followStatusList: [], nextFollowTimeList: [], } let form = this.data.form form.LeaveTime_ = '请选择', form.followCount_ = '', form.nextFollowTime_ = '', this.setData({ specsList_: this.data.specsList_center, receptionStatusList_: this.data.receptionStatusList_center, form, searchFormNumber: 0 }) this.selectComponent("#followStatus").clearForm() this.setData({ searchForm: searchForm, nextFollowTime: '', }) }, /** * @desc : 跟进时间确认事件 * @author : 于继渤 * @date : 2022/5/26 17:16 */ onConfirmChooseDate(e) { let key = e.currentTarget.dataset.key //跟进时间 if (key === 'nextFollowTime') { let form = this.data.form form.nextFollowTimeList = [util.formatDayTime(new Date(this.data.nextFollowTimeDefaultSearch)) + ' 00:00:00', util.formatDayTime(new Date(this.data.nextFollowTimeDefaultSearch)) + ' 23:59:59'], form.nextFollowTime_ = util.formatDayTime(new Date(this.data.nextFollowTimeDefaultSearch)), this.setData({ form: form, nextFollowTimeFlag: false, }) } else if (key === 'leaveTime') { let form = this.data.form let columns = this.data.columns form.LeaveTime_ = this.data.form.LeaveTime_ == "请选择" ? columns[0] : this.data.form.LeaveTime_ this.setData({ form: form, LeaveTimeFlag: false }) } }, /** * 留店时长 * @param {*} e */ onChange(e) { let form = this.data.form form.LeaveTime_ = e.detail.value this.setData({ form: form, }) }, onCloseChooseDate() { this.setData({ showTime: false }) }, /** * @desc :跟进时间变化事件 * @author : 于继渤 * @date :2022/6/8 9:16 */ changeDate(e) { let key = e.currentTarget.dataset.key //跟进时间 if (key === 'nextFollowTime') { this.setData({ nextFollowTimeDefaultSearch: e.detail }) } }, /** * @desc : 筛选选择跟进提醒时间 * @author : 于继渤 * @date : 2022/6/8 9:16 */ onClickTime(e) { let key = e.currentTarget.dataset.key if (key === 'nextFollowTime') { this.setData({ nextFollowTimeDefaultSearch: new Date().getTime() + 100, nextFollowTimeFlag: true }) } }, //抽屉离焦关闭 onClose() { this.setData({ showShare: false, LeaveTimeFlag: false, show: false }) this.selectComponent("#pick").toggle(false) //取消选中样式 }, /** * @desc : 调取企业微信会话 * @date : 2022/5/18 15:49 * @author : 于继渤 */ openWeChat(e) { if (!app.globalData.SystemInfo.environment) { wx.showToast({ title: '请在企业微信模式下运行', icon: 'none' }) return } let item = e.currentTarget.dataset.item wx.qy.openEnterpriseChat({ // 注意:userIds和externalUserIds至少选填一个,且userIds+externalUserIds总数不能超过2000,如果externalUserIds有微信联系人,则总数不能超过40人。 userIds: '', //参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。 // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。 externalUserIds: item.qvExternalUserid, groupName: '', // 必填,会话名称。单聊时该参数传入空字符串""即可。 chatId: "", //新建会话时,chatId必须为空串 success: function (res) { // 回调 var chatId = res.chatId; //返回chatId仅在企业微信3.0.36及以后版本支持; }, fail: function (res) { // 失败处理 wx.showToast({ title: res.data.message, icon: 'none' }) } }); }, /** * tabs切换 * @param {*} e */ onChangeTabs(e) { this.setData({ list: [] }) let title = e.detail.title if (title === '所有接待') { this.setData({ active: 0 }) } if (title === '跟进任务') { this.setData({ active: 1 }) } if (title === '邀约进店') { this.setData({ active: 2 }) } if (title === '预约量尺') { this.setData({ active: 3 }) } // this.getData() this.doSearch() }, /** * @desc : 日期组件后的回调 * @author : 于继渤 * @date : 2022/5/24 12:16 */ dateCommit(e) { let dateType = e.detail.dateType if (dateType === 'createtime') { let data = e.detail.date this.setData({ createTimeSearch: data, createTimeType: e.detail.dateDefault }) this.selectComponent('#create-time-type').toggle(); } this.doSearch() }, /** * @desc : 下拉多选关闭 * @author : 于继渤 * @date : 2022/5/26 12:16 */ muticloseAll(e) { let id = e.currentTarget.id if (id === 'staff') { this.setData({ staffFlag: false }) this.selectComponent("#statusItemStaff").toggle() } if (id === 'org') { this.setData({ orgFlag: false }) this.selectComponent("#statusItemOrg").toggle() } }, onSearchText(e) { this.setData({ searchText: e.detail, searchTextFlag: e.detail ? true : false//TOP搜索输入标识 }) }, /** * @desc : 获取数据 * @author : 于继渤 * @date : 2022/5/23 15:16 */ getData(e) { let list = [{ "addressArea": { "province": "辽宁省", "city": "沈阳市", "district": "铁西区" }, "addressFull": "辽宁省沈阳市铁西区小四川水煮鱼(鑫丰中心里店)12313123122", "addressGcj02": { "latitude": 41.810535, "longitude": 123.38065 }, "addressName": "小四川水煮鱼(鑫丰中心里店)", "addressNo": "12313123122", "annexCount": 0, "annexPaths": [], "competitiveBrands": "", "cpId": 20760, "createTime": "2024-01-23", "customerCode": "12313123122-100310", "customerId": 3924, "customerName": "12313123122", "customerPhone": "13112122111", "designName": null, "designUser": null, "flgAgainMeasure": null, "flgValid": true, "followCount": 1, "followData": "11", "followId": 1928, "followQvRecord": null, "followStatus": "跟进状态-报备", "followStatusName": "留资接待", "followTime": "2024-01-23 16:07", "followTimeLen": null, "followType": "跟进方式-进店", "followTypeName": "进店", "followUser": 643, "followUserName": "王英杰", "hourTime": null, "intention": "客户意向-有意向", "intentionInfo": [], "intentionName": "有意向", "intentionTags": [], "intentionTagsName": null, "inviteResult": null, "inviteTime": null, "loseReasonName": null, "measureAnnex": null, "measureRemarks": null, "measureStatus": null, "measureTime": null, "nextFollowPlan": "", "nextFollowTime": null, "orgName": "北海富安居店", "qvChatId": null, "qvExternalUserid": null, "remarks": null, "saleStatus": "客成状态-成交", "saleStatusName": "成交", "stayTimeLen": "留店时长-0-10分钟", "tagName": [], "weekTime": null }]; this.setData({ list }) }, /** * @desc : 查询 * @author : 于继渤 * @date : 2022/5/24 08:49 */ doSearch() { let pageInfo = this.data.pageInfo; pageInfo.pageSize = 6; pageInfo.currentPage = 1; this.setData({ show: false, noMore: false, pageInfo: pageInfo, list: [] }) this.getData() }, /** * @desc : 页面上拉触底事件的处理函数 * @author : 于继渤 * @date : 2022/5/24 08:49 */ onReachBottom: function () { if (this.data.loading || this.data.noMore) { return; } this.setData({ pageInfo: { pageSize: this.data.pageInfo.pageSize, currentPage: this.data.pageInfo.currentPage + 1 } }) this.getData('more') }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //按钮权限 // let Receive_Customer_Add = common.hasButtonRight(Constants.Receive_Customer_Add) //新建 // let Receive_Customer_Follow = common.hasButtonRight(Constants.Receive_Customer_Follow) //跟进 // let Receive_Customer_Task = common.hasButtonRight(Constants.Receive_Customer_Task) //跟进任务 // let Receive_Customer_Order = common.hasButtonRight(Constants.Receive_Customer_Order) //销售订单 // let Receive_Customer_Receive = common.hasButtonRight(Constants.Receive_Customer_Receive) //客户收款 // let Receive_Customer_Measure = common.hasButtonRight(Constants.Receive_Customer_Measure) //量尺回执 this.setData({ Receive_Customer_Add: true, Receive_Customer_Follow: true, Receive_Customer_Task: true, Receive_Customer_Order: true, Receive_Customer_Receive: true, Receive_Customer_Measure: true, }) this.doSearch() }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (this.data.selectflag) { this.doSearch() this.followTime_init_base() } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { let that = this //调用刷新时将执行的方法 that.setData({ loadingShow: true, }) this.doSearch() this.followTime_init_base() //隐藏导航条加载动画 wx.hideNavigationBarLoading(); setTimeout(function () { that.setData({ loadingShow: false, }) //停止下拉刷新 wx.stopPullDownRefresh(); }, 800) }, /** * 获取接待时常数据 */ followTime_init_base() { return let param = { dataSourceCode: 'followTime' } api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => { if (res.data.code === 200) { let followTime = [] let columns = [] followTime = res.data.data followTime.forEach(element => { columns.push(element.name) }); this.setData({ columns }) } }) }, /** * @desc : 下拉多选确定 * @author : 于继渤 * @date : 2022/5/26 12:16 */ mutiSearchAll(e) { let id = e.currentTarget.id if (id === 'staff') { this.setData({ staffIds: e.detail.idList, staffNames: e.detail.names, staffFlag: false }) this.selectComponent("#statusItemStaff").toggle(false) this.doSearch() } if (id === 'org') { this.setData({ orgIds: e.detail.idList, orgNames: e.detail.names, orgFlag: false }) this.selectComponent("#statusItemOrg").toggle(false) this.doSearch() } }, /** * @desc : 下拉多选事件 * @author : 于继渤 * @date : 2022/5/26 12:16 */ openDropdown(e) { this.setData({ staffFlag: true }) }, /** * @desc : 下拉多选事件 * @author : 于继渤 * @date : 2022/5/26 12:16 */ dropdowncommit(e) { this.setData({ orgFlag: true }) }, /** * 获取意向品类数据源 */ getGoodsSpecs() { let param = { dataSourceCode: "商品规格分类" } param.cpId = app.globalData.user.cpId api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => { if (res.data.code === 200) { let specsList = [] specsList = res.data.data specsList.forEach(element => { element.checked = false }); this.setData({ specsList, specsList_: specsList, specsList_center: specsList }) } }) }, /** * 获取接待状态数据源 */ getReceptionStatus() { let param = { dataSourceCode: "接待状态" } param.cpId = app.globalData.user.cpId api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => { if (res.data.code === 200) { let receptionStatusList = [] receptionStatusList = res.data.data receptionStatusList.forEach(element => { element.checked = false element.id = element.code }); this.setData({ receptionStatusList, receptionStatusList_: receptionStatusList, receptionStatusList_center: receptionStatusList }) } }) }, /** *手风琴 复选框 数据源监听事件 ---接待状态 */ onReceptionStatusDataChange(e) { this.setData({ receptionStatusList_: e.detail.dataList }) }, /** *手风琴 复选框 数据源监听事件 ---意向品类 */ onSpecsDataChange(e) { this.setData({ specsList_: e.detail.dataList }) }, //3点 onclik(e) { this.setData({ showShare: true, bottomItem: e.currentTarget.dataset.item, customerName: e.currentTarget.dataset.item.customerName, onclikItem: e.currentTarget.dataset.item }) }, follow() { wx.navigateTo({ url: '/package-basic-data/pages/customer-follow-up/customer-follow-up' , }) }, followtask() { this.setData({ showShare: false }) wx.navigateTo({ // url: '/package-basic-data/pages/follow-up-tasks/follow-up-tasks', url: '/package-basic-data/pages/customer-follow-up/follow-up-tasks/follow-up-tasks' , }) }, //量尺回执 measure() { this.setData({ showShare: false }) wx.navigateTo({ url: '/package3/pages/customer-follow-up/measure-to/measure-to?item=' + encodeURIComponent(JSON.stringify(this.data.onclikItem)), }) }, /** * @desc : 跳转预算报价新建 * @date : 2022/7/7 14:12 * @author : 于继渤 */ toOrderAdd(e) { let customerItem = e.currentTarget.dataset.item if (!customerItem.customerId) { wx.showToast({ title: '无此联系人,或陌生接待', icon: 'none' }) return } this.setData({ showShare: false }) wx.navigateTo({ url: '/package4/pages/order-billing/choose-goods/choose-goods?orderType=1&customerItem=' + encodeURIComponent(JSON.stringify(customerItem)), }) }, /** * @desc : 筛选数据源组件点击事件 * @author : 于继渤 * @date : 2022/5/31 08:59 */ onClickTag(e) { let key = e.detail.key let dataList = e.detail.dataList let searchForm = this.data.searchForm if (key === 'followStatus') { let tempList = [] //客意品类-智能,客意品类-定制 dataList.forEach(res => { if (res == 0) { tempList.push('跟进状态-报备') } if (res == 1) { tempList.push('跟进状态-接待') } }) searchForm.followStatusList = tempList } if (key === 'overDueStatus') { let tempList = [] let overDueStatus = 0 dataList.forEach(res => { if (res == 0) { tempList.push('逾期状态-未逾期') overDueStatus = 0 } if (res == 1) { tempList.push('逾期状态-逾期') overDueStatus = 1 } if (res == 2) { tempList.push('逾期状态-完结') overDueStatus = 2 } if (res == 3) { tempList.push('逾期状态-全部') overDueStatus = 3 } }) // searchForm.overdueStatusList = tempList searchForm.overDueStatus = overDueStatus } this.setData({ searchForm: searchForm }) }, /** * @desc : 筛选选择跟进提醒时间确认事件 * @author : 于继渤 * @date : 2022/7/5 18:16 */ nextFollowTimeDateCommit(e) { let searchForm = this.data.searchForm let nextFollowTime = this.data.nextFollowTime searchForm.nextFollowTimeList = e.detail.date nextFollowTime = e.detail.date[0] + '-' + e.detail.date[1] this.setData({ searchForm: searchForm, nextFollowTime: nextFollowTime }) //调查询 }, toOk() { this.setData({ showShare: false }) let _this = this Dialog.confirm({ message: '确认完成跟进任务吗?', }).then(() => { let bottomItem = this.data.bottomItem _this.isFlgvaild(bottomItem.planId) instance.close(); }).catch(() => { // _this.setData({ // showShare: true // }) }); }, isFlgvaild(planId) { this.setData({ loading: true }) api.request(Constants.SALE_CUSTOMERFOLLOW_PLAN_API + 'update_by_follow_plan_id' , 'POST', { planId:planId }).then(res => { this.setData({ loading: false }) if (res.data.code === 200) { wx.showToast({ title: '操作成功', image: '/static/image/success.png', duration: 1000 }) this.doSearch() } }) }, })