| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- const app = getApp();
- const util = require('../../../../utils/util.js')
- const api = require('../../../../utils/api.js');
- const Constants = require('../../../../utils/Constants.js');
- const common = require('../../../../utils/common');
- const config = require('../../../../config/config.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- saveFlag: true,
- checked_1: false,
- checked_2: false,
- checked_3: false,
- checked_4: false,
- checked_5: false,
- checked_6: false,
- checked_7: false,
- checked_8: false,
- //数量
- quantity_1: '0',
- quantity_2: '0',
- quantity_3: '0',
- quantity_4: '0',
- quantity_5: '0',
- quantity_6: '0',
- quantity_7: '0',
- quantity_8: '0',
- show: false,
- activeboxNames: ['1'],
- form: {
- customerName: '',
- customerPhone: '',
- AddressName: '',
- addressNo: '',
- FollowType: '',
- NextFollowTime: '', //提醒时间
- FollowUpContent: '', //跟进内容
- NextFollowUpPlan: '', //下次跟进计划
- CustomerIntentionsName: '', //客户意向
- LeaveTime: '', //留店时长
- CompetitionBrand: '', //竞品品牌
- OtherName: '其他',
- customerFrom: null,//客户来源
- customerFromName: '',
- },
- minDate: new Date().getTime(),
- radio_follow_up: '2',
- selectflag: false,
- followTypeFlag: false,
- otherFlag: false,
- customerIntentionsFlag: false,
- competitionBrandFlag: false,
- mustFillFlag: true, //必填项目
- columns: [],
- nextFollowTimeSearch: 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;
- },
- fileList: [], //图片
- },
- /**
- * 删除图片
- */
- deleteImg(e) {
- let index = e.detail.index;
- let arr = this.data.fileList;
- arr.splice(index, 1);
- this.setData({
- fileList: arr
- })
- },
- /**
- * @desc : 上传方法
- * @author : 于继渤
- * @date : 2022/6/02 16:16
- */
- afterRead(event) {
- const _this = this;
- const {
- file
- } = event.detail;
- file.forEach(res => {
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- wx.uploadFile({
- url: `${config.server_add}:${config.server_port}` + '/basic-server/file/upload',
- filePath: res.path,
- name: 'file',
- formData: {
- 'folder': 't_csm_follow/follow'
- },
- header: {
- 'Authorization': 'Bearer ' + app.globalData.token
- },
- success(res) {
- res.data = JSON.parse(res.data)
- if (res.data.code === 200) {
- let arr = _this.data.fileList;
- arr.push({
- url: res.data.data.absolutelyPath,
- FilePath: res.data.data.relativePath,
- deletable: true
- })
- _this.setData({
- fileList: arr
- })
- }
- },
- })
- })
- },
- /**
- * 小程序地图调用
- */
- onClickWxchartAddress() {
- // 跳转新建地图实例
- common.onClickWxchartAddress();
- },
- /**
- * 获取意向品类数据源
- */
- getGoodsSpecs() {
- let param = {
- dataSourceCode: "商品规格分类"
- }
- param.cpId = app.globalData.user.cpId
- return new Promise((resolve, reject) => {
- 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
- this.setData({
- specsList
- })
- resolve(res)
- } else {
- reject(res)
- }
- })
- })
- },
- /**
- *手风琴 复选框 数据源监听事件
- */
- onDataChange(e) {
- this.setData({
- specsList: e.detail.dataList
- })
- },
- /**
- * 获取接待时常数据
- */
- followTime_init_base() {
- 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
- })
- }
- })
- },
- /**
- * 新客接待单选
- * @param {} event
- */
- onRadio_Follow_Up(event) {
- // if (this.data.form.customerName == '无联系人' || this.data.type == 'add') {
- // this.setData({
- // radio_follow_up: event.detail,
- // });
- // }
- this.setData({
- radio_follow_up: event.detail,
- });
- },
- /**
- * 提醒时间
- */
- onChangePickDate() {
- this.setData({
- show: true
- })
- },
- /**
- * @desc : 标识日期变化事件
- * @author : 秦祺
- * @date : 2022/5/26 17:16
- */
- changeDate(e) {
- let key = e.currentTarget.dataset.key
- //提醒时间
- if (key === 'nextFollowTime') {
- this.setData({
- nextFollowTimeSearch: e.detail
- })
- }
- },
- /**
- * 关闭提醒时间
- */
- onCloseChooseDate() {
- this.setData({
- show: false
- })
- },
- /**
- * 确定提醒时间
- * @param {*} e
- */
- onConfirmChooseDate(e) {
- let form = this.data.form
- form.NextFollowTime = util.formatDataTime(new Date(this.data.nextFollowTimeSearch))
- this.setData({
- form: form,
- show: false
- })
- },
- /**
- * 取消提醒时间
- */
- onCloseChooseDate() {
- this.setData({
- show: false
- })
- },
- /**
- * 客户查重
- * @param {} event
- */
- blurCustomerPhone(event) {
- //根据联系电话判断客户是否存在 ,存在则跳转跟进
- let customerPhone = this.data.form.customerPhone
- if (customerPhone != '') {
- let param = {
- pageSize: '',
- currentPage: '',
- customerPhone: customerPhone,
- saleStatus: '查重',
- }
- param.cpId = app.globalData.user.cpId
- api.request(Constants.SALE_CUSTOMER_API + 'select_customer_list', 'POST', param).then(res => {
- this.setData({
- loading: false
- })
- if (res.data.code === 200) {
- let list = res.data.data.list; //后台返回数据
-
- if (list.length > 0) { //有数据 就赋值
- let form = this.data.form
- form.customerName = list[0].customerName
- form.customerId = list[0].customerId
- form.addressNo = list[0].addressNo
- form.addressArea = list[0].addressArea
- form.saleStatus = list[0].saleStatus
- form.addressName = list[0].addressName
- this.setData({
- form
- })
- } else {
- // 如果根据联系电话没有查到数据,需要清空客户id,客户编码(企业微信没有联系电话的除外)
- let form = this.data.form
- if (!form.noTelephone) {
- form.customerId = null;
- form.customerCode = null;
- }
- this.setData({
- form: form
- })
- }
- }
- })
- }
- },
- /**
- * 留店时长
- */
- showPopup() {
- this.setData({
- selectflag: true
- });
- },
- /**
- * 跟进方式
- */
- showFollowTypePopup() {
- this.setData({
- followTypeFlag: true
- });
- },
- /*
- * 客户意向
- */
- showCustomerIntentionsPopup(e) {
- let type = e.currentTarget.dataset.type
- if (type === 'CustomerIntentions') {
- this.setData({
- customerIntentionsFlag: true
- });
- }
- if (type === 'customerFrom') {
- this.setData({
- customerSourceFlag: true
- })
- }
- },
- //组件单选确定
- mutiSearch(e) {
- console.log(e)
- console.log('选择啦')
- let id = e.target.id
- let form = this.data.form
- if (id === 'customerFrom') {
- form.customerFromName = e.detail.name
- form.customerFrom = e.detail.id
- console.log(form)
- }
- if (id === 'customerIntentions') {
- form.CustomerIntentionsName = e.detail.name
- }
- if (id === 'other') {
- form.OtherName = e.detail.name
- }
- this.setData({
- form: form
- })
- if (form.CustomerIntentionsName == '已流失') {
- this.setData({
- competitionBrandFlag: true,
- })
- } else {
- this.setData({
- competitionBrandFlag: false,
- })
- }
- if (form.CustomerIntentionsName == '放入公海') {
- this.setData({
- mustFillFlag: false
- })
- } else {
- this.setData({
- mustFillFlag: true
- })
- }
- },
- /**
- * 留店时长
- * @param {*} e
- */
- onChange(e) {
- let form = this.data.form
- form.LeaveTime = e.detail.value
- this.setData({
- form: form,
- selectflag: false
- })
- },
- /**
- * 取消留店时长
- * @param {*} e
- */
- onCancel() {
- this.setData({
- selectflag: false
- })
- },
- /**
- * 跟进内容
- * @param {} event
- */
- onFollowUpContentChange(event) {
- let form = this.data.form
- form.FollowUpContent = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * 下次跟进计划
- * @param {} event
- */
- onNextFollowUpPlanChange(event) {
- let form = this.data.form
- form.NextFollowUpPlan = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * 客户名称
- * @param {*} event
- */
- onCustomerNameChange(event) {
- let form = this.data.form
- form.customerName = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * @desc : 联系电话输入事件
- * @author : 于继渤
- * @date : 2022/5/24 12:16
- */
- changeCustomerFormFieldPhone(e) {
- let key = e.detail.currentTarget.dataset.key
- let form = this.data.form
- form.customerPhone = e.detail.detail
- this.setData({
- form: form
- })
- },
- /**
- * @desc : 修改联系电话
- * @author : 周兴
- * @date : 2022/10/27 18:16
- */
- editPhone(e) {
- this.setData({
- telephoneFlag: true,
- telephone: this.data.form.customerPhone
- })
- },
- /**
- * @desc : 编辑联系电话事件
- * @author : 周兴
- * @date : 2022/10/27 12:16
- */
- closeCustomerPhonePop(e) {
- this.setData({
- telephoneFlag: false
- })
- },
- /**
- * @desc : 修改联系电话事件
- * @author : 周兴
- * @date : 2022/10/27 12:16
- */
- changeCustomerPhonePop(e) {
- this.setData({
- telephone: e.detail.detail
- })
- },
- /**
- * @desc : 更新联系电话
- * @author : 周兴
- * @date : 2022/10/27 12:16
- */
- updateCustomerPhone(e) {
- let form = this.data.form
- form.customerPhone = this.data.telephone
- this.setData({
- form: form,
- telephoneFlag: false
- })
- },
- /**
- * 联系电话
- * @param {*} event
- */
- onCustomerPhoneChange(event) {
- let form = this.data.form
- form.customerPhone = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * 客户地址
- * @param {*} event
- */
- onAddressNameChange(event) {
- let form = this.data.form
- form.AddressName = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * 门牌号
- * @param {*} event
- */
- onAddressNoChange(event) {
- let form = this.data.form
- form.addressNo = event.detail
- this.setData({
- form: form
- })
- },
- /**
- * 选择跟进方式
- * @param {*} e
- */
- onFollowTypeChange(e) {
- let form = this.data.form
- form.FollowType = e.detail.value
- this.setData({
- form: form
- })
- },
- /**
- * 选择客户意向
- * @param {*} e
- */
- onCustomerIntentionsChange(e) {
- let form = this.data.form
- form.CustomerIntentions = e.detail.value
- this.setData({
- form: form
- })
- },
- /**
- * 关闭
- *
- */
- onClose() {
- this.setData({
- selectflag: false,
- followTypeFlag: false,
- customerIntentionsFlag: false,
- })
- },
- /**
- * @desc : 跳转选商品 orderType 1预算报价
- * @author : 于继渤
- * @date : 2022/6/14 12:16
- */
- toPay(e) {
- this.setData({
- toPayFlag: true
- })
- //this.submit();
- let form = this.data.form
- form.ascpId = app.globalData.user.ascpId
- form.sale1Id = app.globalData.user.sale1Id
- form.sale2Id = app.globalData.user.sale2Id
- if (!form.noTelephone) {
- if (!form.customerPhone) {
- wx.showToast({
- title: '请输入联系电话',
- icon: 'none'
- })
- return false
- }
- if (!util.isPoneAvailable(form.customerPhone)) {
- wx.showToast({
- title: '联系电话格式不正确',
- icon: 'none'
- })
- return false
- }
- }
- let that = this
- setTimeout(function () {
- wx.navigateTo({
- url: '/package4/pages/order-billing/choose-goods/choose-goods?orderType=1&page=receiveCustomers&customerItem=' + JSON.stringify(that.data.form)
- })
- }, 200)
- },
- /**
- * 提交保存
- */
- submit() {
- if (!this.data.saveFlag) {
- return
- }
- //业务员
- let followUsers = app.globalData.user.userId
- let result = this.checkForm();
- if (result.flag) {
- this.setData({
- loading: true,
- loadingButtonFlag: true
- })
- let specsList = this.data.specsList
- let specsList_ = []
- specsList.forEach(function (item) {
- if (item.checked) {
- specsList_.push({
- "specsId": item.id,
- "specsName": item.name,
- "count": item.quantity,
- "value": item.checked,
- "other": item.other ? item.other : false
- })
- }
- });
- let param = {}
- param.ascpId = app.globalData.user.ascpId
- param.sale1Id = app.globalData.user.sale1Id
- param.sale2Id = app.globalData.user.sale2Id
- // 客户来源
- param.customerFrom = this.data.form.customerFrom
- //当前跟进人(业务员)
- param.followUsers = [],
- param.followUsers.push(followUsers) //业务员
- param.customerName = this.data.radio_follow_up == 1 ? "无联系人" : this.data.form.customerName //客户名称
- param.customerId = this.data.form.customerId ? this.data.form.customerId : null //客户ID
- param.salesChannel = app.globalData.user.channelId
- if (this.data.form.customerId != null) {
- if (this.data.form.saleStatus != '客成状态-成交') {
- param.saleStatus = '客成状态-潜客'
- } else {
- param.saleStatus = this.data.form.saleStatus
- }
- }
- param.customerPhone = this.data.form.customerPhone //联系电话
- param.addressName = this.data.form.addressName //客户地址
- if (this.data.form.addressArea) {
- param.addressFull = (this.data.form.addressArea.province ? this.data.form.addressArea.province : '') + (this.data.form.addressArea.city ? this.data.form.addressArea.city : '') + (this.data.form.addressArea.district ? this.data.form.addressArea.district : '') + (this.data.form.addressName ? this.data.form.addressName : '') + (this.data.form.addressNo ? this.data.form.addressNo : '')
- }
- param.addressGcj02 = this.data.form.addressGcj02,
- param.addressNo = this.data.form.addressNo //门牌号
- param.addressArea = this.data.form.addressArea
- //不同接待跟进状态不同
- if (this.data.radio_follow_up == 1) {
- param.followStatus = '跟进状态-接待' //跟进状态
- } else if (this.data.radio_follow_up == 2) {
- param.followStatus = '跟进状态-报备' //跟进状态
- }
- param.followType = '跟进方式-进店' //跟进方式
- param.followData = this.data.form.FollowUpContent //跟进内容
- param.nextFollowPlan = this.data.form.NextFollowUpPlan //下次跟进计划
- param.nextFollowTime = this.data.form.NextFollowTime //下次跟进计划
- param.stayTimeLen = '留店时长-' + this.data.form.LeaveTime //留店时长
- if (this.data.radio_follow_up == 2) {
- param.intention = '客户意向-' + this.data.form.CustomerIntentionsName //客户意向
- }
- param.competitiveBrands = this.data.form.CompetitionBrand //竞品品牌
- param.followOrg = app.globalData.user.orgId
- param.intentionInfo = specsList_ //意向品类
- let fileList_ = this.data.fileList
- let fileList = []
- fileList_.forEach(item => {
- fileList.push(item.FilePath)
- })
- // 跟进附件 20220613
- param.annexPaths = {
- annexPaths: fileList
- }
- if (this.data.radio_follow_up == '1') {
- //陌生接待清空其他数据
- param.customerPhone = ""
- param.addressGcj02 = null
- param.addressNo = ""
- param.addressArea = null
- param.addressName = null
- param.nextFollowPlan = "" //下次跟进计划
- param.nextFollowTime = "" //下次跟进计划
- }
- let API = ''
- if(this.data.pageFlag && this.data.pageFlag == 'edit'){
- //编辑客户接待
- API = 'update'
- param.followId = this.data.form.followId ? this.data.form.followId : null
- }else{
- API = 'insert'
- }
- api.request(Constants.SALE_CUSTOMERFOLLOW_API + API, 'POST', param).then(res => {
- this.setData({
- loading: false,
- })
- if (res.data.code === 200) {
- wx.showToast({
- title: '保存成功',
- image: '/static/image/success.png',
- duration: 1000
- })
- let deltaNum = 1
- let pagesNum = 2
- if(this.data.pageFlag && this.data.pageFlag == 'edit'){
- deltaNum = 2
- pagesNum = 3
- }
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - pagesNum];
- prevPage.setData({
- selectflag: true
- })
- this.setData({
- toPayFlag: false,
- saveFlag: false
- })
- setTimeout(function () {
- wx.navigateBack({
- delta: deltaNum
- })
- }, 1000)
- } else {
- this.setData({
- loadingButtonFlag: false
- })
- }
- })
- } else {
- this.setData({
- loading: false,
- loadingButtonFlag: false
- })
- setTimeout(function () {
- wx.showToast({
- title: result.msg,
- image: '/static/image/warning.png',
- duration: 1000
- })
- }, 1000)
- }
- },
- /* 表单校验 */
- checkForm() {
- //客户接待
- if (this.data.radio_follow_up == 2) {
- if (!this.data.form.customerName) {
- return {
- flag: false,
- msg: '客户名称为空'
- };
- }
- if (!this.data.form.customerPhone && !this.data.form.noTelephone) {
- return {
- flag: false,
- msg: '客户电话为空'
- };
- }
- if (!util.isPoneAvailable(this.data.form.customerPhone) && !this.data.form.noTelephone) {
- return {
- flag: false,
- msg: '客户电话不正确'
- };
- }
- if (!this.data.form.CustomerIntentionsName) {
- return {
- flag: false,
- msg: '客户意向为空'
- };
- }
- // if (!this.data.form.NextFollowTime && this.setData.mustFillFlag) {
- // return {
- // flag: false,
- // msg: '提醒时间为空'
- // };
- // }
- }
- if (!this.data.form.FollowUpContent) {
- return {
- flag: false,
- msg: '跟进内容为空'
- };
- }
- if (!this.data.form.LeaveTime) {
- return {
- flag: false,
- msg: '留店时长为空'
- };
- }
- return {
- flag: true,
- msg: '表单校验通过'
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- },
- /**
- * 页面取消
- */
- cancle() {
- wx.navigateBack({
- delta: -1
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- // 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
- chooseLocation.setLocation(null);
- },
- /**
- * @desc : 跳转选择客户
- * @author : 于继渤
- * @date : 2022/09/27 09:56
- */
- onChooseCustomer() {
- wx.navigateTo({
- url: '/package4/pages/order-billing/choose-customer/choose-customer?page=receiveAdd',
- })
- },
- /**
- * @desc : 加微信
- * @date :
- * @author :
- */
- onnavigateToAddCustomer: function (e) {
- if (!app.globalData.SystemInfo.environment) {
- wx.showToast({
- title: '请在企业微信模式下运行',
- icon: 'none'
- })
- return
- }
- wx.qy.navigateToAddCustomer({
- success: (res) => {
- },
- fail: (res) => {
- },
- complete: (res) => {
- }
- })
- },
- })
|