123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718 |
- // 模板字符串
- var temp = `
- <div>
- <div class="user-data-dialog" id="collectUserInfoDialog" v-if="showForm">
- <div class="mask"></div>
- <div class="dialog-container">
- <div class="dialog-header"></div>
- <div class="dialog-content">
- <el-form class="user-form" :model="form" :rules="rules" ref="ruleForm">
- <!-- 基本信息 -->
- <div class="basic clearfix">
- <div class="form-title">基本信息</div>
- <div class="form-main clearfix">
- <div class="short-control fl" v-if="moduleShow.name">
- <el-form-item label="姓名 :" prop="name">
- <el-input v-model.trim="form.name" class="item-input" placeholder="请输入姓名" @focus="nameFocus" required>
- </el-input>
- </el-form-item>
- </div>
- <div class="short-control fr" v-if="moduleShow.mail">
- <el-form-item label="邮箱 :" prop="mail">
- <el-input v-model.trim="form.mail" class="item-input" placeholder="请输入邮箱" @focus="mailFocus"></el-input>
- </el-form-item>
- </div>
- <div class="short-control fl" v-if="moduleShow.phone">
- <el-form-item label="手机号 :" prop="phone">
- <el-input v-model.trim="form.phone" maxlength="11" @input="inputPhone" class="item-input" placeholder="请输入准确的手机号" @focus="phoneFocus"></el-input>
- </el-form-item>
- </div>
- <div class="short-control fr" v-if="showCode">
- <el-form-item label="验证码 :" prop="code">
- <el-input v-model.trim="form.code" maxlength="6" @change="checkCode" class="item-input code-input" placeholder="请输入手机验证码" @focus="codeFocus">
- <el-button slot="append" :disabled="sendCodeBtn" @click="sendCode">@@codeText@@</el-button>
- </el-input>
- </el-form-item>
- </div>
- </div>
- </div>
- <div class="company clearfix">
- <div class="form-title">公司信息</div>
- <div class="form-main">
- <div class="long-control" style="position: relative;" v-if="moduleShow.companyName">
- <el-form-item label="公司名称 :" prop="companyName">
- <el-input
- v-model.trim="form.companyName"
- data-long-input
- class="item-input company-name"
- @focus="companyFocus"
- @input="searchCompany"
- placeholder="请输入准确的公司名称">
- </el-input>
- </el-form-item>
- <div class="company-result" v-if="showSearchResult">
- <div class="company-list" v-for="item in companyList" :key="item" @click="selectCompany(item)" v-html="item"></div>
- </div>
- </div>
- <div class="long-control" v-if="moduleShow.companyType">
- <el-form-item label="公司类型 :" class="company-type" prop="companyType">
- <el-checkbox-group v-model="form.companyType">
- <el-checkbox label="投标企业"></el-checkbox>
- <el-checkbox label="招标采购单位"></el-checkbox>
- <el-checkbox label="厂商"></el-checkbox>
- <el-checkbox label="招标代理机构"></el-checkbox>
- <el-checkbox label="经销商"></el-checkbox>
- <el-checkbox label="服务提供商"></el-checkbox>
- <el-checkbox label="其他"></el-checkbox>
- </el-checkbox-group>
- </el-form-item>
- </div>
- <div class="short-control fl" v-if="moduleShow.job">
- <el-form-item label="职位 :" prop="job">
- <el-select v-model="form.job" placeholder="请选择职位" class="item-input" clearable>
- <el-option v-for="item in jobData" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </div>
- <div class="short-control fr" v-if="showBranch">
- <el-form-item label-width="0" label="" prop="branch" class="no-label">
- <el-select v-model="form.branch" placeholder="请选择部门" class="item-input" clearable>
- <el-option v-for="item in branchData" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </div>
- </div>
- </div>
- <div class="warm-prompt">
- <span class="icon-warning"></span>
- <span class="warm-text">温馨提示:请提供准确的信息,我们将为您推荐更准确、更个性化的商机和服务</span>
- </div>
- <div class="dialog-footer">
- <el-button class="cancel-btn" @click="cancelForm">暂不提供</el-button>
- <el-button class="submit-btn" @click="submitForm('ruleForm')">提交</el-button>
- </div>
- </el-form>
- </div>
- </div>
- </div>
- <div id="success-dialog" style="display: none;" v-show="showSuccess">
- <div class="mask"></div>
- <div class="success-dialog-container">
- <div class="success-title">提交成功</div>
- <div class="success-content" v-if="defaultSource">我们的客户经理会在24小时内尽快与您联系。</div>
- <div class="success-content" v-else>我们稍后将以邮件的形式发送数据样例。</div>
- <div class="success-footer">
- <button type="button" class="custom-btn go-know" @click="showSuccess = false">我知道了</button>
- </div>
- <div class="dialog-adv" v-if="!defaultSource" @click="dataExport">
- <img src="/common-module/pc-dialog/image/data-export.png" />
- </div>
- </div>
- </div>
- <div id="export-dialog" v-show="showExport">
- <div class="mask"></div>
- <div class="export-dialog-container">
- <div class="export-title">
- <span class="export-close" @click="showExport = false"></span>
- </div>
- <div class="export-content">您可以通过剑鱼标讯提供的全国招投标数据自助导出功能,指定关键词、发布时间、地区或行业等筛选条件,以Excel表格的形式打包下载,精准获取所需数据。</div>
- <div class="export-footer">
- <button type="button" class="custom-btn go-know" @click="dataExport">数据自助导出</button>
- </div>
- </div>
- </div>
- </div>
- `
- var jobJson = [
- '总裁',
- '总经理',
- '总监',
- '经理',
- '主管',
- '职员'
- ]
- var branchJson = [
- '市场',
- '产品',
- '销售',
- '渠道',
- '其他'
- ]
- var jobData = jobJson.map(function (item) {
- return {
- value: item,
- label: item
- }
- })
- // 防抖
- function debounce(fn, delay) {
- var timer
- return function () {
- var context = this
- var args = arguments
- clearTimeout(timer)
- timer = setTimeout(function () {
- fn.apply(context, args)
- }, delay)
- }
- }
- // 部门数据处理
- var branchData = branchJson.map(function(item) {
- return {
- value: item,
- label: item
- }
- })
- var vm = new Vue({
- el: '#vue-collect-user-info',
- delimiters: ['@@', '@@'],
- props: ['type'],
- template: temp,
- data: function () {
- var validName = function(rule,value,callback) {
- if(value === '') {
- return callback(new Error('姓名为必填项'));
- } else {
- if (value.length < 2) {
- return callback(new Error('姓名填写不正确'));
- }
- callback();
- }
- }
- var validPhone = function(rule,value,callback) {
- var status = /^1[3-9]\d{9}$/.test(value)
- if(value === '') {
- return callback(new Error('手机号为必填项'));
- } else if (!status) {
- return callback(new Error('手机号填写不正确'));
- } else {
- callback();
- }
- }
- var validCode = function(rule,value,callback) {
- var status = /\d{6}/.test(value)
- if(value === '') {
- return callback(new Error('短信验证码为必填项'));
- } else if (!status) {
- return callback(new Error('验证码格式不正确'));
- } else {
- setTimeout(function() {
- if (!vm.codeStatus) {
- return callback(new Error('短信验证码不正确'));
- } else {
- callback();
- }
- }, 500)
- }
- }
- var validEmail = function(rule,value,callback) {
- var status = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value)
- if (value === '') {
- return callback(new Error('邮箱为必填项'));
- } else {
- if (!status) {
- return callback(new Error('邮箱填写不正确'));
- } else {
- callback();
- }
- }
- }
- var validCompany = function(rule,value,callback) {
- if (value === '') {
- return callback(new Error('公司名称为必填项'));
- } else {
- if (value.length < 2) {
- return callback(new Error('公司名称至少输入2个字'));
- } else {
- callback();
- }
- }
- }
- var validComType = function(rule,value,callback) {
- if (value.length === 0) {
- return callback(new Error('公司类型为必填项'));
- } else {
- callback();
- }
- }
- var validJob = function(rule,value,callback) {
- if(value === '') {
- return callback(new Error('职位为必填项'));
- return callback();
- } else {
- if (value === '其他' && vm.form.otherJob === '') {
- return callback();
- } else {
- callback();
- }
- }
- }
- var validBranch = function(rule,value,callback) {
- if(value === '') {
- return callback(new Error('请选择部门'));
- } else {
- callback();
- }
- }
- return {
- dialogTitle: '为给您匹配精准的推荐信息,请完善个人信息',
- jobData: jobData, // 职位数据
- branchData: branchData,
- form: {
- oldPhone: '', // 带出来的手机号,用于判断是否需要短信验证码
- name: '', // 姓名
- phone: '', // 手机号
- mail: '', // 邮箱
- code: '', // 短信验证码
- companyName: '', // 公司名称
- companyType: [], // 公司类型
- job: '', // 职位值
- otherJob: '', //自定义职位
- branch: ''
- },
- codeText: '获取验证码',
- sendCodeBtn: false,
- countdown: 0,
- codeStatus: true,
- rules: {
- name: [
- {
- required: true,
- validator: validName,
- trigger: 'blur'
- }
- ],
- phone: [
- {
- required: true,
- validator: validPhone,
- trigger: 'blur'
- }
- ],
- mail: [
- {
- required: true,
- validator: validEmail,
- trigger: 'blur'
- }
- ],
- code: [
- {
- required: true,
- validator: validCode,
- message: '',
- trigger: 'blur'
- }
- ],
- companyName: [
- {
- required: true,
- validator: validCompany,
- trigger: 'blur'
- }
- ],
- companyType: [
- {
- required: true,
- validator: validComType,
- trigger: 'blur'
- }
- ],
- job: [
- {
- required: true,
- validator: validJob,
- trigger: 'blur'
- }
- ],
- branch: [
- {
- required: true,
- trigger: 'blur',
- validator: validBranch,
- message: ''
- }
- ],
- },
- showSearchResult: false,
- companyList: [],
- showForm: false, // 显示表单填写弹框
- showSuccess: false, // 显示提交成功弹框
- showExport: false,
- isForce: false, // 是否强制
- source: '', // 来源模块
- interest: '', // 感兴趣内容
- moduleShow: {
- name: true,
- phone: true,
- mail: true,
- code: false,
- companyName: true,
- companyType: true,
- job: true,
- branch: false
- }
- }
- },
- computed: {
- showOtherJob: function() {
- return this.form.job == '其他'
- },
- showCode: function () {
- return (this.form.phone !== this.form.oldPhone && this.form.phone.length === 11) || !this.form.oldPhone
- },
- defaultSource: function() {
- // 默认提交成功不显示广告图和邮箱文案 如果是结构化数据则显示
- var noEmailSource = ['structedData', 'pc_data_custom_export']
- return noEmailSource.indexOf(this.source) === -1
- },
- showBranch: function () {
- // 切换到总裁或总经理之后 把之前选择的部门清空
- if (this.form.job.indexOf('总裁') > -1 || this.form.job.indexOf('总经理') > -1) {
- this.form.branch = ''
- }
- var zc = this.form.job.indexOf('总裁') > -1
- var zjl = this.form.job.indexOf('总经理') > -1
- return !(zc || zjl) && this.form.job
- }
- },
- mounted() {
- var that = this;
- $(document).on('click', function (e) {
- let dom = $('.company-name')[0];
- if (dom) {
- // 如果点击的区域不在自定义dom范围
- if (!dom.contains((e.target))) {
- that.showSearchResult = false
- }
- }
- })
- $(window).on('resize', this.changeTop)
- },
- beforeDestroy() {
- $(document).off('click')
- },
- methods: {
- getModules: function () {
- var source = this.source
- switch (source) {
- case 'pc_supermarket_Noresults_customization':
- case 'pc_market_ApplicationScenario':
- case 'pc_supermarket_details_customization':
- case 'pc_supermarket_details_buy': {
- this.hideModule(['mail'])
- break;
- }
- default:
- this.hideModule()
- break;
- }
- },
- hideModule: function (keys) {
- if (!keys) return
- var hideType = keys
- for (var k in this.moduleShow) {
- if (hideType.indexOf(k) !== -1) {
- this.moduleShow[k] = false
- }
- }
- },
- changeTop: function () {
- this.$nextTick(function () {
- var dialogDom = $('#collectUserInfoDialog .dialog-container')
- var diffHeight = window.innerHeight - dialogDom.height() - 240
- if (diffHeight < 0) {
- dialogDom.css('margin-top', diffHeight.toString() + 'px')
- }
- })
- },
- nameFocus:function(){
- this.$refs['ruleForm'].clearValidate(['name']);
- },
- phoneFocus:function(){
- this.$refs['ruleForm'].clearValidate(['phone']);
- },
- mailFocus:function(){
- this.$refs['ruleForm'].clearValidate(['mail']);
- },
- codeFocus: function() {
- this.$refs['ruleForm'].clearValidate(['code']);
- },
- // 公司名称获取焦点时
- companyFocus: function() {
- this.$refs['ruleForm'].clearValidate(['companyName']);
- this.getResult(this.form.companyName)
- },
- otherFocus:function() {
- this.$refs['ruleForm'].clearValidate(['job','otherJob']);
- },
- // 发送验证码
- sendCode: function() {
- var status = /^1[3-9]\d{9}$/.test(this.form.phone)
- var _this = this
- if (!status) return
- $.ajax({
- type:'POST',
- url:'/salesLeads/sendMsg',
- data: {
- phoneNum: _this.form.phone
- },
- success:function (res) {
- if (res.data && res.data.success) {
- _this.sendCodeBtn = true
- _this.countdown = 60
- _this.codeText = '重新获取' + _this.countdown + 's'
- var timeInt = setInterval(function() {
- _this.countdown--
- _this.codeText = '重新获取' + _this.countdown + 's'
- if (_this.countdown <= 0) {
- _this.sendCodeBtn = false
- _this.codeText = '获取验证码'
- window.clearInterval(timeInt)
- }
- }, 1000)
- } else {
- _this.$message.error('短信验证码发送失败');
- }
- }
- })
- },
- // 校验验证码
- checkCode: function(val) {
- var _this = this
- if (val.length !== 6) return
- $.ajax({
- type:'POST',
- url:'/salesLeads/checkCode',
- data: {
- code: _this.form.code,
- phoneNum: _this.form.phone
- },
- success:function (res) {
- if (res.data && res.data.flag) {
- _this.$message.success('验证成功')
- _this.codeStatus = true
- } else {
- _this.codeStatus = false
- }
- }
- })
- },
- // 日志统计
- logAjax: function(source) {
- $.ajax({
- type:'POST',
- url:'/front/portraitClassify?source=' + source,
- success:function (res) {
- console.log(res)
- }
- })
- },
- // 是否留资
- isNeedSubmit: function(source, callback, interest) {
- if (!loginflag) {
- openLoginDig()
- return
- }
- this.source = source
- this.interest = interest
- this.logAjax(source)
- var _this = this
- $.ajax({
- type:'GET',
- url:'/salesLeads/retainedCapital',
- data: {
- source: source
- },
- success:function (res) {
- // 判断当前信息否在其他页面留资 如果全部留资 直接弹窗提交成功
- var checkKeys = ['name', 'phone', 'company', 'mail', 'branch', 'position', 'companyType']
- var result = checkRequiredKeys(checkKeys, res.info)
- res.info.interest = interest
- if (result) {
- callback && callback()
- _this.formAjax(_this.source, res.info)
- } else if (res.data) {
- _this.isForce = res.data.fource
- if (res.data.retainedCapital) {
- _this.showForm = true
- // 当前头部背景图
- _this.isSelfHeader()
- _this.changeTop()
- if (res.info) {
- echoRequiredValues(_this.form, res.info, ['name', 'phone', 'mail', 'branch'])
- // 原有赋值回显逻辑
- _this.form.oldPhone = res.info.phone ? res.info.phone : ''
- _this.form.companyName = res.info.company ? res.info.company : ''
- _this.form.companyType = res.info.companyType ? res.info.companyType.split(',') : []
- if (res.info.position) {
- if (jobJson.indexOf(res.info.position) == -1) {
- // _this.form.job = '其他'
- // _this.form.otherJob = res.data.position.replace('其他/', '')
- _this.form.job = ''
- _this.form.otherJob = ''
- } else {
- _this.form.job = res.info.position
- }
- } else {
- _this.form.job = ''
- }
- }
- } else {
- callback && callback()
- }
- }
- }
- })
- },
- // 自定义弹窗头部
- isSelfHeader: function(){
- var imgUrl = '/common-module/pc-dialog/image/structed-title.png'
- var custom_export = this.source.indexOf('custom_export') > -1
- var custom_data = this.source.indexOf('custom_data') > -1
- var api_interface = this.source.indexOf('api_interface') > -1
- // 数据超市source
- var marketNoResult = this.source.indexOf('pc_supermarket_Noresults_customization') > -1 // 数据超市列表无数据-申请定制
- var marketApplicationScenario = this.source.indexOf('pc_market_ApplicationScenario') > -1 // 数据市场落地页-大数据服务应用场景-立即咨询
- var marketBuy = this.source.indexOf('pc_supermarket_details_buy') > -1 // 数据超市详情页-申请购买
- var marketDetailCustom = this.source.indexOf('pc_supermarket_details_customization') > -1 // 数据超市详情页-申请定制
- if (custom_export || custom_data || marketNoResult || marketDetailCustom) {
- imgUrl = '/common-module/pc-dialog/image/leave-title-custom.png'
- } else if (api_interface) {
- imgUrl = '/common-module/pc-dialog/image/leave-title-api.png'
- } else if (marketApplicationScenario) {
- imgUrl = '/common-module/pc-dialog/image/data-supermarket-contact.png'
- } else if (marketBuy) {
- imgUrl = '/common-module/pc-dialog/image/data-supermarket-buy.png'
- }
- this.getModules()
- this.$nextTick(function(){
- $('#collectUserInfoDialog .dialog-header').css('background-image', 'url(' + imgUrl + ')')
- })
- },
- // 表单提交事件
- submitForm: function(formName) {
- var _this = this
- this.$refs[formName].validate(function (valid) {
- if (valid) {
- _this.formAjax(_this.source)
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- // 表单提交请求
- formAjax: function(source, info) {
- var params = {
- source: source,
- name: this.form.name,
- phone: this.form.phone,
- mail: this.form.mail,
- company: this.form.companyName, // 公司名称
- companyType: this.form.companyType.join(','),
- position: this.form.job == '其他' ? this.form.job + '/' + this.form.otherJob : this.form.job,
- code: this.form.code,
- agree: true, // 原来留资模块的同意协议字段,,,默认传一个true 方便后端处理
- branch: this.form.branch.indexOf('总裁') > -1 || this.form.branch.indexOf('总经理') > -1 || !this.form.job ? '' : this.form.branch,
- // interest: this.interest
- }
- if (info) {
- params = info
- params.source = source
- params.interest = info.interest // 感兴趣内容
- }
- var _this = this
- $.ajax({
- type:'POST',
- url: '/salesLeads/collectInfo',
- contentType: "application/json;charset=utf-8",
- data: JSON.stringify(params),
- success:function (res) {
- if (res.data) {
- _this.showForm = false
- _this.showSuccess = true
- } else {
- _this.$message.error(res.error_msg);
- }
- }
- })
- },
- // 手机号输入框input事件
- inputPhone: function(val) {
- this.form.phone = val.replace(/[^\d]/g,'')
- },
- // 企业名称联想
- getResult:function(name) {
- // 名称为空或长度小于2不发请求
- if (!name || name.length < 2) return
- var _this = this
- $.ajax({
- type:'POST',
- url:'/jypay/user/company/association',
- data: {
- name: name,
- companyCount:10
- },
- heads : {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- success:function (res) {
- console.log(res)
- if (res.data && res.data.length > 0) {
- var result = []
- res.data.map(function(item){
- item = _this.brightKeyword(item)
- result.push(item)
- return result
- })
- _this.companyList = result
- _this.showSearchResult = true
- }
- }
- })
- },
- searchCompany: debounce(function(val){
- if(val === '') { this.showSearchResult = false}
- this.getResult(val)
- }, 600),
- // 选择联想出来的公司名称
- selectCompany: function(item) {
- this.form.companyName = item.replace(/<.*?>/ig, '')
- this.showSearchResult = false
- },
- // 关键词高亮
- brightKeyword: function (val) {
- var name = this.form.companyName
- if (val.indexOf(name) !== -1) {
- return val.replace(name, `<span style='color:#2ABED1;'>${name}</span>`)
- } else {
- return val
- }
- },
- // 暂不提供
- cancelForm: function() {
- this.form.name = ''
- this.form.phone = ''
- this.form.mail = ''
- this.form.companyName = ''
- this.form.job = ''
- this.form.otherJob = ''
- this.form.code = ''
- var needExportSource = ['structedData', 'pc_data_custom_export', 'pc_data_custom_data']
- if (needExportSource.indexOf(this.source) > -1) {
- this.showForm = false
- this.showExport = true
- } else {
- this.showForm = false
- }
- this.showSearchResult=false
- },
- // 数据导出
- dataExport: function() {
- location.href = "/front/dataExport/toSieve"
- }
- }
- })
|