91521fa0 by simon

2

1 parent 12c9ed1b
......@@ -2,7 +2,8 @@ import api from "@/api/api";
import { httpGet, httpPost } from "@/api/fetch-api.js";
import { contactMethodCheck } from "@utils/utils.js";
import { setTitle } from "@/utils/utils.js";
import { setTitle, ascSort } from "@/utils/utils.js";
import { getNationsList, getNationsPhoneCodeList } from "@/utils/biz.js";
import Auth from "@components/auth/auth.vue";
import modalComp from "@/components/modal-comp/modal-comp.vue";
......@@ -23,12 +24,26 @@ export default {
dataInit: false,
selectedPolicies: [],
data: {
// 国际号码区号列表
mobileAreaCode: "",
// 电话
mobile: "",
email: "",
// 国际地区区号
countryId: "",
// 省
provinceId: "",
// 市
cityId: "",
// 地址
address: "",
// 同意接收宣传信息 1:同意 0:不同意
acceptMessage: 1,
areaCode: ""
// 上传信息
iobsKey: "a",
fileFormat: "xlsx",
fileSize: 123,
fileContentType: "mp4"
},
errorTips: {
e1: "",
......@@ -42,28 +57,10 @@ export default {
modalIcon: "succ",
modalContent: "",
// 新增
// 国际号码区号列表
areaCodeList: [
{
v: "abc",
n: "abc"
},
{
v: "efg",
n: "efg"
}
],
countryList:[
{
v: "cn",
n: "中国"
},
{
v: "en",
n: "美国"
}
]
nationsPhoneCodeList: [],
// 国际地区区号
nationsList: []
};
},
components: {
......@@ -108,7 +105,7 @@ export default {
let b2 = this.checkEmail();
let b3 = this.checkAddress();
let b = b1 & b2 & b3;
if (b) {
if (!b) {
if (this.loading) {
return;
}
......@@ -125,6 +122,8 @@ export default {
emailAcceptMsg: this.checked3 ? 1 : 0,
policies: policies
};
console.log("data:", JSON.stringify(data));
return;
this.loading = true;
httpPost({
url: api.updatePolicyContanct,
......@@ -165,6 +164,29 @@ export default {
return true;
},
initData() {
let nationsPhoneCodeListTemp = getNationsPhoneCodeList();
// 去重
let obj = {};
let nationsPhoneCodeList = nationsPhoneCodeListTemp.reduce(
(cur, next) => {
//设置cur默认类型为数组,并且初始值为空的数组
obj[next.n] ? "" : (obj[next.n] = true && cur.push(next));
return cur;
},
[]
);
// // 加数字属性标号用于排序
// nationsPhoneCodeList.forEach(element => {
// element.num = parseInt(element.n);
// });
// // 排序
// nationsPhoneCodeList = nationsPhoneCodeList.sort(ascSort("num", ""));
this.nationsPhoneCodeList = nationsPhoneCodeList;
this.nationsList = getNationsList(this.$i18n.locale);
if (this.dataInit) {
return;
}
......@@ -203,6 +225,7 @@ export default {
},
handlePolicySelect(data) {
this.selectedPolicies = data;
console.log("this.selectedPolicies:", this.selectedPolicies);
this.initData();
},
userLogout() {
......@@ -220,49 +243,91 @@ export default {
}
},
updatePolicyContact() {
let param={
"policyContactCode":"",
"policyId":"4655100",
"policyCode":"P000200000000009",
"mobileAreaCode":"0668",
"mobile":"13727826666",
"countryId":"156",
"provinceId":"1",
"cityId":"304",
"address":"上海迪士尼乐园",
"acceptMessage":1,
"iobsKey":"a",
"fileFormat":"xlsx",
"fileSize":123,
"fileContentType":"mp4/"
}
let param = {
policyContactCode: "",
policyId: "4655100",
policyCode: "P000200000000009",
mobileAreaCode: "0668",
mobile: "13727826666",
countryId: "156",
provinceId: "1",
cityId: "304",
address: "上海迪士尼乐园",
acceptMessage: 1,
iobsKey: "a",
fileFormat: "xlsx",
fileSize: 123,
fileContentType: "mp4/"
};
httpPost({
url: api.policyContactApi,
data: param,
sid: true
}).then(response => {
console.log("response:", response)
}).catch(res => {
});
})
.then(response => {
console.log("response:", response);
})
.catch(res => {});
},
uploadExcel(){
}
uploadExcel() {}
},
watch: {
"data.mobile": function() {
"data.mobileAreaCode": function() {
this.errorTips.e1 = "";
},
"data.address": function() {
"data.mobile": function() {
this.errorTips.e2 = "";
},
"data.email": function() {
"data.countryId": function() {
this.errorTips.e3 = "";
}
},
"data.provinceId": function() {
this.errorTips.e4 = "";
},
"data.cityId": function() {
this.errorTips.e5 = "";
},
"data.address": function() {
this.errorTips.e6 = "";
},
},
mounted() {
this.initTitle();
},
created() {
// this.loading = true;
this.$root.eventBus.$on("langChange", () => {
try {
this.initData();
} catch (e) {}
});
}
};
// var ttt = {
// areaCode:"",
// mobileNo: "1232321",
// address: "CHINA, GuangdongShenzhen咯农户心情来来来",
// email: "zhangwenjun110@ocft.com",
// mobileNoAcceptMsg: 0,
// addressAcceptMsg: 0,
// emailAcceptMsg: 0,
// policies: [{ policyId: "4661690", policyCode: "P000200000000458" }]
// };
var tttt2 = {
policyContactCode: "",
policyId: "4655100",
policyCode: "P000200000000009",
mobileAreaCode: "0668",
mobile: "13727826666",
countryId: "156",
provinceId: "1",
cityId: "304",
address: "上海迪士尼乐园",
acceptMessage: 1,
iobsKey: "a",
fileFormat: "xlsx",
fileSize: 123,
fileContentType: "mp4"
};
......
......@@ -22,8 +22,8 @@
<div class="ipt-wrap-linear">
<div class="down-arrow"></div>
<div class="cont">
<el-select class="ipt" v-model="data.areaCode" :placeholder="$t('policyChangeContact.form.InternationalArea')">
<el-option v-for="(item, index) in areaCodeList" :key="index" :label="item.n" :value="item.v"></el-option>
<el-select class="ipt" v-model="data.mobileAreaCode" :placeholder="$t('policyChangeContact.form.InternationalArea')">
<el-option v-for="(item, index) in nationsPhoneCodeList" :key="index" :label="item.n" :value="item.n"></el-option>
</el-select>
</div>
</div>
......@@ -53,8 +53,8 @@
<div class="ipt-wrap-linear">
<div class="down-arrow"></div>
<div class="cont">
<el-select class="ipt" v-model="data.countryCode" :placeholder="$t('policyChangeContact.form.Nation')">
<el-option v-for="(item, index) in countryList" :key="index" :label="item.n" :value="item.v"></el-option>
<el-select class="ipt" v-model="data.countryId" :placeholder="$t('policyChangeContact.form.Nation')">
<el-option v-for="(item, index) in nationsList" :key="index" :label="item.n" :value="item.v"></el-option>
</el-select>
</div>
</div>
......@@ -63,16 +63,25 @@
</div>
</div>
<div class="pure-u-1 pure-u-md-6-24 ipt-gird-item">
<!-- <div class="pure-u-1 pure-u-md-6-24 ipt-gird-item">
<div class="ipt-wrap-linear">
<input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.District')">
</div>
<div class="validator" v-if="errorTips.e2.length > 0">
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e2}}
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e6}}
</div>
</div>
<div class="pure-u-1 pure-u-md-12-24 ipt-gird-item">
<div class="pure-u-1 pure-u-md-6-24 ipt-gird-item">
<div class="ipt-wrap-linear">
<input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.District')">
</div>
<div class="validator" v-if="errorTips.e2.length > 0">
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e6}}
</div>
</div> -->
<div class="pure-u-1 pure-u-md-18-24 ipt-gird-item">
<div class="ipt-wrap-linear">
<input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.Address')">
</div>
......
......@@ -37,7 +37,7 @@
background: url("~@/assets/images/insurance-query/triangle-down2.png")
no-repeat center center;
background-size: 100% 100%;
top: 16px;
top: 21px;
right: 26px;
}
......
......@@ -92,7 +92,7 @@
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}}
</div>
</div>
<!-- <div class="pure-u-1 form-item">
<div class="pure-u-1 form-item">
<div class="label">
<img src="@/assets/images/login/icon-login-password.png"> {{$t('login.password')}}
</div>
......@@ -102,7 +102,7 @@
<div class="validator" v-if="errorTips.e2.length > 0 ">
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e2}}
</div>
</div> -->
</div>
<div class="pure-u-1 form-item">
<div class="label">
<img src="@/assets/images/login/icon-login-phone.png"> {{$t('login.SMSVerificationCode')}}
......
// 正在表达式
export const REGEXPS = {
"mobile": /^1\d{10}$/
}
mobile: /^1\d{10}$/
};
// 验证手机
export function checkMobile(str) {
......@@ -14,37 +14,38 @@ export function checkMobile(str) {
* @param {*} url
*/
export function param2Obj(url) {
const search = url.split('?')[1]
const search = url.split("?")[1];
if (!search) {
return {}
return {};
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"') +
'"}'
)
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"') +
'"}'
);
}
//获取cookie、
export function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return (arr[2]);
else
return null;
var arr,
reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if ((arr = document.cookie.match(reg))) return arr[2];
else return null;
}
//设置cookie
export function setCookie(c_name, value, second) {
var exdate = new Date();
exdate.setTime(exdate.getTime() + second * 1000);
document.cookie = c_name + "=" + escape(value) + ((second == null) ? "" : ";expires=" + exdate.toGMTString());
};
document.cookie =
c_name +
"=" +
escape(value) +
(second == null ? "" : ";expires=" + exdate.toGMTString());
}
//删除cookie
export function delCookie(name) {
......@@ -53,8 +54,7 @@ export function delCookie(name) {
var cval = getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
};
}
/**
* 获取环境信息
......@@ -63,12 +63,12 @@ export function delCookie(name) {
export function getEnv() {
var nav = window.navigator;
var env = {
"iphone": false,
"ipad": false,
"android": false,
"pc": false,
"ios": false,
"ver": "0"
iphone: false,
ipad: false,
android: false,
pc: false,
ios: false,
ver: "0"
};
var ua = nav.userAgent;
......@@ -76,15 +76,15 @@ export function getEnv() {
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
if (ipad) {
env.ipad = ipad[1] && true || false;
env.ver = ipad[2] && ipad[2].replace(/-/g, ".") || "";
env.ipad = (ipad[1] && true) || false;
env.ver = (ipad[2] && ipad[2].replace(/-/g, ".")) || "";
env.ios = true;
} else if (iphone) {
env.iphone = iphone[1] && true || false;
env.ver = iphone[2] && iphone[2].replace(/-/g, ".") || "";
env.iphone = (iphone[1] && true) || false;
env.ver = (iphone[2] && iphone[2].replace(/-/g, ".")) || "";
env.ios = true;
} else if (android) {
env.android = android[1] && true || false;
env.android = (android[1] && true) || false;
env.ver = android[2];
} else {
env.pc = true;
......@@ -104,16 +104,20 @@ export function setTitle(title) {
document.title = title;
// if (ENV.ios && navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1) {
// 修复微信端IOS无法修改document.title的情况
if (getEnv().ios && (navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1 || navigator.userAgent.toLowerCase().indexOf("alipay") !== -1)) {
if (
getEnv().ios &&
(navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1 ||
navigator.userAgent.toLowerCase().indexOf("alipay") !== -1)
) {
//修复IOS微信端和支付宝无法修改document.title的情况
var $iframe = document.createElement('iframe');
var $iframe = document.createElement("iframe");
$iframe.className = "C-hiddenIframe";
$iframe.src = "/" + location.pathname.split('/')[1] + "/favicon.ico";
$iframe.style.visibility = 'hidden';
$iframe.style.width = '1px';
$iframe.style.height = '1px';
$iframe.src = "/" + location.pathname.split("/")[1] + "/favicon.ico";
$iframe.style.visibility = "hidden";
$iframe.style.width = "1px";
$iframe.style.height = "1px";
$iframe.onload = function onIframeLoad() {
setTimeout(function () {
setTimeout(function() {
$iframe.onload = null;
onIframeLoad = null;
document.body.removeChild($iframe);
......@@ -126,23 +130,22 @@ export function setTitle(title) {
// 为链接添加参数
export function addQuery(url, query) {
query = query || {}
query = (function (query) {
var q = []
Object.keys(query).forEach(function (_q) {
q.push(_q + '=' + query[_q])
})
return q.join('&')
})(query)
if (url.indexOf('?') !== -1) {
url += '&' + query
query = query || {};
query = (function(query) {
var q = [];
Object.keys(query).forEach(function(_q) {
q.push(_q + "=" + query[_q]);
});
return q.join("&");
})(query);
if (url.indexOf("?") !== -1) {
url += "&" + query;
} else {
url += '?' + query
url += "?" + query;
}
return url
return url;
}
/**
* 获得当前页面的path
* @return {String} 页面path
......@@ -157,7 +160,63 @@ export function getPath() {
// 获取 url 参数
export function getQuery(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null;
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
location.href
) || [, ""])[1].replace(/\+/g, "%20")
) || null
);
}
/**
* 升序排列
* @param name 主要参数
* @param minor 次要参数 主要参数相同时,比较次要参数
*/
export function ascSort(name, minor) {
return function(o, p) {
var a, b;
if (o && p && typeof o === "object" && typeof p === "object") {
a = o[name];
b = p[name];
if (a === b) {
return typeof minor === "function" ? minor(o, p) : 0;
}
if (typeof a === typeof b) {
return a < b ? -1 : 1;
}
return typeof a < typeof b ? -1 : 1;
} else {
// throw ("error");
return null;
}
};
}
/**
* 升序排列
* @param name 主要参数
* @param minor 次要参数 主要参数相同时,比较次要参数
*/
export function descSort(name, minor) {
return function(o, p) {
var a, b;
if (o && p && typeof o === "object" && typeof p === "object") {
a = o[name];
b = p[name];
if (a === b) {
return typeof minor === "function" ? minor(o, p) : 0;
}
if (typeof a === typeof b) {
return a > b ? -1 : 1;
}
return typeof a > typeof b ? -1 : 1;
} else {
// throw ("error");
return null;
}
};
}
/**
......@@ -182,16 +241,15 @@ export function getObjByListKeyValue(value, key, list) {
* 用{{}}会当成字符串把 html渲染出来
*/
export function formatBr(str) {
str = str.replace(/\n/g, '<br/>')
return str
};
str = str.replace(/\n/g, "<br/>");
return str;
}
// dd-MM-yyyy转yyyy-MM-dd
export function ddMMyyyy2yyyyMMdd(str) {
return str.replace(/-/g, '').replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1");
return str.replace(/-/g, "").replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1");
}
/**
* @desc 函数防抖
* @param func 函数
......@@ -201,7 +259,7 @@ export function ddMMyyyy2yyyyMMdd(str) {
export function debounce(func, wait, immediate) {
let timeout;
return function () {
return function() {
let context = this;
let args = arguments;
......@@ -210,14 +268,14 @@ export function debounce(func, wait, immediate) {
var callNow = !timeout;
timeout = setTimeout(() => {
timeout = null;
}, wait)
if (callNow) func.apply(context, args)
}, wait);
if (callNow) func.apply(context, args);
} else {
timeout = setTimeout(function () {
func.apply(context, args)
timeout = setTimeout(function() {
func.apply(context, args);
}, wait);
}
}
};
}
/**
......@@ -233,7 +291,7 @@ export function throttle(func, wait, type) {
} else if (type === 2) {
var timeout;
}
return function () {
return function() {
let context = this;
let args = arguments;
if (type === 1) {
......@@ -247,11 +305,11 @@ export function throttle(func, wait, type) {
if (!timeout) {
timeout = setTimeout(() => {
timeout = null;
func.apply(context, args)
}, wait)
func.apply(context, args);
}, wait);
}
}
}
};
}
/**
......@@ -260,17 +318,17 @@ export function throttle(func, wait, type) {
* @param {string} value
*/
export function contactMethodCheck(type, value) {
if (type == 'hkmobile') {
if (type == "hkmobile") {
// return /^[5689]{1}\d{7}$/.test(value);
return /^(\+)?(852)?(\-)?(5|6|8|9)\d{7}$/.test(value);
}
if (type == 'mobile') {
if (type == "mobile") {
// return /^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$/.test(value);
return /^(\+)?(86)?(\-)?1\d{10}$/.test(value);
}
if (type == 'email') {
if (type == "email") {
return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value);
}
return true;
......@@ -281,7 +339,7 @@ export function policyNumberCheck(policyNumber) {
}
export function checkVerifyCode(verifyCode) {
return /^\d{6}$/.test(verifyCode)
return /^\d{6}$/.test(verifyCode);
}
export function checkName(name) {
......