91521fa0 by simon

2

1 parent 12c9ed1b
...@@ -2,7 +2,8 @@ import api from "@/api/api"; ...@@ -2,7 +2,8 @@ import api from "@/api/api";
2 import { httpGet, httpPost } from "@/api/fetch-api.js"; 2 import { httpGet, httpPost } from "@/api/fetch-api.js";
3 3
4 import { contactMethodCheck } from "@utils/utils.js"; 4 import { contactMethodCheck } from "@utils/utils.js";
5 import { setTitle } from "@/utils/utils.js"; 5 import { setTitle, ascSort } from "@/utils/utils.js";
6 import { getNationsList, getNationsPhoneCodeList } from "@/utils/biz.js";
6 7
7 import Auth from "@components/auth/auth.vue"; 8 import Auth from "@components/auth/auth.vue";
8 import modalComp from "@/components/modal-comp/modal-comp.vue"; 9 import modalComp from "@/components/modal-comp/modal-comp.vue";
...@@ -23,12 +24,26 @@ export default { ...@@ -23,12 +24,26 @@ export default {
23 dataInit: false, 24 dataInit: false,
24 selectedPolicies: [], 25 selectedPolicies: [],
25 data: { 26 data: {
27 // 国际号码区号列表
26 mobileAreaCode: "", 28 mobileAreaCode: "",
29 // 电话
27 mobile: "", 30 mobile: "",
28 email: "", 31 // 国际地区区号
32 countryId: "",
33 // 省
34 provinceId: "",
35 // 市
36 cityId: "",
37 // 地址
29 address: "", 38 address: "",
39 // 同意接收宣传信息 1:同意 0:不同意
40 acceptMessage: 1,
30 41
31 areaCode: "" 42 // 上传信息
43 iobsKey: "a",
44 fileFormat: "xlsx",
45 fileSize: 123,
46 fileContentType: "mp4"
32 }, 47 },
33 errorTips: { 48 errorTips: {
34 e1: "", 49 e1: "",
...@@ -42,28 +57,10 @@ export default { ...@@ -42,28 +57,10 @@ export default {
42 modalIcon: "succ", 57 modalIcon: "succ",
43 modalContent: "", 58 modalContent: "",
44 59
45 // 新增
46 // 国际号码区号列表 60 // 国际号码区号列表
47 areaCodeList: [ 61 nationsPhoneCodeList: [],
48 { 62 // 国际地区区号
49 v: "abc", 63 nationsList: []
50 n: "abc"
51 },
52 {
53 v: "efg",
54 n: "efg"
55 }
56 ],
57 countryList:[
58 {
59 v: "cn",
60 n: "中国"
61 },
62 {
63 v: "en",
64 n: "美国"
65 }
66 ]
67 }; 64 };
68 }, 65 },
69 components: { 66 components: {
...@@ -108,7 +105,7 @@ export default { ...@@ -108,7 +105,7 @@ export default {
108 let b2 = this.checkEmail(); 105 let b2 = this.checkEmail();
109 let b3 = this.checkAddress(); 106 let b3 = this.checkAddress();
110 let b = b1 & b2 & b3; 107 let b = b1 & b2 & b3;
111 if (b) { 108 if (!b) {
112 if (this.loading) { 109 if (this.loading) {
113 return; 110 return;
114 } 111 }
...@@ -125,6 +122,8 @@ export default { ...@@ -125,6 +122,8 @@ export default {
125 emailAcceptMsg: this.checked3 ? 1 : 0, 122 emailAcceptMsg: this.checked3 ? 1 : 0,
126 policies: policies 123 policies: policies
127 }; 124 };
125 console.log("data:", JSON.stringify(data));
126 return;
128 this.loading = true; 127 this.loading = true;
129 httpPost({ 128 httpPost({
130 url: api.updatePolicyContanct, 129 url: api.updatePolicyContanct,
...@@ -165,6 +164,29 @@ export default { ...@@ -165,6 +164,29 @@ export default {
165 return true; 164 return true;
166 }, 165 },
167 initData() { 166 initData() {
167 let nationsPhoneCodeListTemp = getNationsPhoneCodeList();
168 // 去重
169 let obj = {};
170 let nationsPhoneCodeList = nationsPhoneCodeListTemp.reduce(
171 (cur, next) => {
172 //设置cur默认类型为数组,并且初始值为空的数组
173 obj[next.n] ? "" : (obj[next.n] = true && cur.push(next));
174 return cur;
175 },
176 []
177 );
178
179 // // 加数字属性标号用于排序
180 // nationsPhoneCodeList.forEach(element => {
181 // element.num = parseInt(element.n);
182 // });
183 // // 排序
184 // nationsPhoneCodeList = nationsPhoneCodeList.sort(ascSort("num", ""));
185
186 this.nationsPhoneCodeList = nationsPhoneCodeList;
187
188 this.nationsList = getNationsList(this.$i18n.locale);
189
168 if (this.dataInit) { 190 if (this.dataInit) {
169 return; 191 return;
170 } 192 }
...@@ -203,6 +225,7 @@ export default { ...@@ -203,6 +225,7 @@ export default {
203 }, 225 },
204 handlePolicySelect(data) { 226 handlePolicySelect(data) {
205 this.selectedPolicies = data; 227 this.selectedPolicies = data;
228 console.log("this.selectedPolicies:", this.selectedPolicies);
206 this.initData(); 229 this.initData();
207 }, 230 },
208 userLogout() { 231 userLogout() {
...@@ -220,49 +243,91 @@ export default { ...@@ -220,49 +243,91 @@ export default {
220 } 243 }
221 }, 244 },
222 updatePolicyContact() { 245 updatePolicyContact() {
223 let param={ 246 let param = {
224 "policyContactCode":"", 247 policyContactCode: "",
225 "policyId":"4655100", 248 policyId: "4655100",
226 "policyCode":"P000200000000009", 249 policyCode: "P000200000000009",
227 "mobileAreaCode":"0668", 250 mobileAreaCode: "0668",
228 "mobile":"13727826666", 251 mobile: "13727826666",
229 "countryId":"156", 252 countryId: "156",
230 "provinceId":"1", 253 provinceId: "1",
231 "cityId":"304", 254 cityId: "304",
232 "address":"上海迪士尼乐园", 255 address: "上海迪士尼乐园",
233 "acceptMessage":1, 256 acceptMessage: 1,
234 "iobsKey":"a", 257 iobsKey: "a",
235 "fileFormat":"xlsx", 258 fileFormat: "xlsx",
236 "fileSize":123, 259 fileSize: 123,
237 "fileContentType":"mp4/" 260 fileContentType: "mp4/"
238 } 261 };
239 httpPost({ 262 httpPost({
240 url: api.policyContactApi, 263 url: api.policyContactApi,
241 data: param, 264 data: param,
242 sid: true 265 sid: true
243 }).then(response => { 266 })
244 console.log("response:", response) 267 .then(response => {
245 }).catch(res => { 268 console.log("response:", response);
246 269 })
247 }); 270 .catch(res => {});
248
249 }, 271 },
250 uploadExcel(){ 272 uploadExcel() {}
251
252 }
253 }, 273 },
254 watch: { 274 watch: {
255 "data.mobile": function() { 275 "data.mobileAreaCode": function() {
256 this.errorTips.e1 = ""; 276 this.errorTips.e1 = "";
257 }, 277 },
258 "data.address": function() { 278 "data.mobile": function() {
259 this.errorTips.e2 = ""; 279 this.errorTips.e2 = "";
260 }, 280 },
261 "data.email": function() { 281 "data.countryId": function() {
262 this.errorTips.e3 = ""; 282 this.errorTips.e3 = "";
263 } 283 },
284 "data.provinceId": function() {
285 this.errorTips.e4 = "";
286 },
287 "data.cityId": function() {
288 this.errorTips.e5 = "";
289 },
290 "data.address": function() {
291 this.errorTips.e6 = "";
292 },
264 }, 293 },
265 mounted() { 294 mounted() {
266 this.initTitle(); 295 this.initTitle();
296 },
297 created() {
298 // this.loading = true;
299 this.$root.eventBus.$on("langChange", () => {
300 try {
301 this.initData();
302 } catch (e) {}
303 });
267 } 304 }
268 }; 305 };
306
307 // var ttt = {
308 // areaCode:"",
309 // mobileNo: "1232321",
310 // address: "CHINA, GuangdongShenzhen咯农户心情来来来",
311 // email: "zhangwenjun110@ocft.com",
312 // mobileNoAcceptMsg: 0,
313 // addressAcceptMsg: 0,
314 // emailAcceptMsg: 0,
315 // policies: [{ policyId: "4661690", policyCode: "P000200000000458" }]
316 // };
317
318 var tttt2 = {
319 policyContactCode: "",
320 policyId: "4655100",
321 policyCode: "P000200000000009",
322 mobileAreaCode: "0668",
323 mobile: "13727826666",
324 countryId: "156",
325 provinceId: "1",
326 cityId: "304",
327 address: "上海迪士尼乐园",
328 acceptMessage: 1,
329 iobsKey: "a",
330 fileFormat: "xlsx",
331 fileSize: 123,
332 fileContentType: "mp4"
333 };
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
22 <div class="ipt-wrap-linear"> 22 <div class="ipt-wrap-linear">
23 <div class="down-arrow"></div> 23 <div class="down-arrow"></div>
24 <div class="cont"> 24 <div class="cont">
25 <el-select class="ipt" v-model="data.areaCode" :placeholder="$t('policyChangeContact.form.InternationalArea')"> 25 <el-select class="ipt" v-model="data.mobileAreaCode" :placeholder="$t('policyChangeContact.form.InternationalArea')">
26 <el-option v-for="(item, index) in areaCodeList" :key="index" :label="item.n" :value="item.v"></el-option> 26 <el-option v-for="(item, index) in nationsPhoneCodeList" :key="index" :label="item.n" :value="item.n"></el-option>
27 </el-select> 27 </el-select>
28 </div> 28 </div>
29 </div> 29 </div>
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
53 <div class="ipt-wrap-linear"> 53 <div class="ipt-wrap-linear">
54 <div class="down-arrow"></div> 54 <div class="down-arrow"></div>
55 <div class="cont"> 55 <div class="cont">
56 <el-select class="ipt" v-model="data.countryCode" :placeholder="$t('policyChangeContact.form.Nation')"> 56 <el-select class="ipt" v-model="data.countryId" :placeholder="$t('policyChangeContact.form.Nation')">
57 <el-option v-for="(item, index) in countryList" :key="index" :label="item.n" :value="item.v"></el-option> 57 <el-option v-for="(item, index) in nationsList" :key="index" :label="item.n" :value="item.v"></el-option>
58 </el-select> 58 </el-select>
59 </div> 59 </div>
60 </div> 60 </div>
...@@ -63,16 +63,25 @@ ...@@ -63,16 +63,25 @@
63 </div> 63 </div>
64 </div> 64 </div>
65 65
66 <div class="pure-u-1 pure-u-md-6-24 ipt-gird-item"> 66 <!-- <div class="pure-u-1 pure-u-md-6-24 ipt-gird-item">
67 <div class="ipt-wrap-linear"> 67 <div class="ipt-wrap-linear">
68 <input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.District')"> 68 <input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.District')">
69 </div> 69 </div>
70 <div class="validator" v-if="errorTips.e2.length > 0"> 70 <div class="validator" v-if="errorTips.e2.length > 0">
71 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e2}} 71 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e6}}
72 </div> 72 </div>
73 </div> 73 </div>
74 74
75 <div class="pure-u-1 pure-u-md-12-24 ipt-gird-item"> 75 <div class="pure-u-1 pure-u-md-6-24 ipt-gird-item">
76 <div class="ipt-wrap-linear">
77 <input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.District')">
78 </div>
79 <div class="validator" v-if="errorTips.e2.length > 0">
80 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e6}}
81 </div>
82 </div> -->
83
84 <div class="pure-u-1 pure-u-md-18-24 ipt-gird-item">
76 <div class="ipt-wrap-linear"> 85 <div class="ipt-wrap-linear">
77 <input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.Address')"> 86 <input class="ipt" type="text" :class="{err : errorTips.e2.length > 0}" v-model="data.address" autocomplete="new-password" :placeholder="$t('policyChangeContact.form.Address')">
78 </div> 87 </div>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
37 background: url("~@/assets/images/insurance-query/triangle-down2.png") 37 background: url("~@/assets/images/insurance-query/triangle-down2.png")
38 no-repeat center center; 38 no-repeat center center;
39 background-size: 100% 100%; 39 background-size: 100% 100%;
40 top: 16px; 40 top: 21px;
41 right: 26px; 41 right: 26px;
42 } 42 }
43 43
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
92 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}} 92 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}}
93 </div> 93 </div>
94 </div> 94 </div>
95 <!-- <div class="pure-u-1 form-item"> 95 <div class="pure-u-1 form-item">
96 <div class="label"> 96 <div class="label">
97 <img src="@/assets/images/login/icon-login-password.png"> {{$t('login.password')}} 97 <img src="@/assets/images/login/icon-login-password.png"> {{$t('login.password')}}
98 </div> 98 </div>
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
102 <div class="validator" v-if="errorTips.e2.length > 0 "> 102 <div class="validator" v-if="errorTips.e2.length > 0 ">
103 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e2}} 103 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e2}}
104 </div> 104 </div>
105 </div> --> 105 </div>
106 <div class="pure-u-1 form-item"> 106 <div class="pure-u-1 form-item">
107 <div class="label"> 107 <div class="label">
108 <img src="@/assets/images/login/icon-login-phone.png"> {{$t('login.SMSVerificationCode')}} 108 <img src="@/assets/images/login/icon-login-phone.png"> {{$t('login.SMSVerificationCode')}}
......
1 // 正在表达式 1 // 正在表达式
2 export const REGEXPS = { 2 export const REGEXPS = {
3 "mobile": /^1\d{10}$/ 3 mobile: /^1\d{10}$/
4 } 4 };
5 5
6 // 验证手机 6 // 验证手机
7 export function checkMobile(str) { 7 export function checkMobile(str) {
...@@ -14,37 +14,38 @@ export function checkMobile(str) { ...@@ -14,37 +14,38 @@ export function checkMobile(str) {
14 * @param {*} url 14 * @param {*} url
15 */ 15 */
16 export function param2Obj(url) { 16 export function param2Obj(url) {
17 const search = url.split('?')[1] 17 const search = url.split("?")[1];
18 if (!search) { 18 if (!search) {
19 return {} 19 return {};
20 } 20 }
21 return JSON.parse( 21 return JSON.parse(
22 '{"' + 22 '{"' +
23 decodeURIComponent(search) 23 decodeURIComponent(search)
24 .replace(/"/g, '\\"') 24 .replace(/"/g, '\\"')
25 .replace(/&/g, '","') 25 .replace(/&/g, '","')
26 .replace(/=/g, '":"') + 26 .replace(/=/g, '":"') +
27 '"}' 27 '"}'
28 ) 28 );
29 } 29 }
30 30
31
32
33 //获取cookie、 31 //获取cookie、
34 export function getCookie(name) { 32 export function getCookie(name) {
35 var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); 33 var arr,
36 if (arr = document.cookie.match(reg)) 34 reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
37 return (arr[2]); 35 if ((arr = document.cookie.match(reg))) return arr[2];
38 else 36 else return null;
39 return null;
40 } 37 }
41 38
42 //设置cookie 39 //设置cookie
43 export function setCookie(c_name, value, second) { 40 export function setCookie(c_name, value, second) {
44 var exdate = new Date(); 41 var exdate = new Date();
45 exdate.setTime(exdate.getTime() + second * 1000); 42 exdate.setTime(exdate.getTime() + second * 1000);
46 document.cookie = c_name + "=" + escape(value) + ((second == null) ? "" : ";expires=" + exdate.toGMTString()); 43 document.cookie =
47 }; 44 c_name +
45 "=" +
46 escape(value) +
47 (second == null ? "" : ";expires=" + exdate.toGMTString());
48 }
48 49
49 //删除cookie 50 //删除cookie
50 export function delCookie(name) { 51 export function delCookie(name) {
...@@ -53,8 +54,7 @@ export function delCookie(name) { ...@@ -53,8 +54,7 @@ export function delCookie(name) {
53 var cval = getCookie(name); 54 var cval = getCookie(name);
54 if (cval != null) 55 if (cval != null)
55 document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); 56 document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
56 }; 57 }
57
58 58
59 /** 59 /**
60 * 获取环境信息 60 * 获取环境信息
...@@ -63,12 +63,12 @@ export function delCookie(name) { ...@@ -63,12 +63,12 @@ export function delCookie(name) {
63 export function getEnv() { 63 export function getEnv() {
64 var nav = window.navigator; 64 var nav = window.navigator;
65 var env = { 65 var env = {
66 "iphone": false, 66 iphone: false,
67 "ipad": false, 67 ipad: false,
68 "android": false, 68 android: false,
69 "pc": false, 69 pc: false,
70 "ios": false, 70 ios: false,
71 "ver": "0" 71 ver: "0"
72 }; 72 };
73 73
74 var ua = nav.userAgent; 74 var ua = nav.userAgent;
...@@ -76,15 +76,15 @@ export function getEnv() { ...@@ -76,15 +76,15 @@ export function getEnv() {
76 var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 76 var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
77 var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); 77 var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
78 if (ipad) { 78 if (ipad) {
79 env.ipad = ipad[1] && true || false; 79 env.ipad = (ipad[1] && true) || false;
80 env.ver = ipad[2] && ipad[2].replace(/-/g, ".") || ""; 80 env.ver = (ipad[2] && ipad[2].replace(/-/g, ".")) || "";
81 env.ios = true; 81 env.ios = true;
82 } else if (iphone) { 82 } else if (iphone) {
83 env.iphone = iphone[1] && true || false; 83 env.iphone = (iphone[1] && true) || false;
84 env.ver = iphone[2] && iphone[2].replace(/-/g, ".") || ""; 84 env.ver = (iphone[2] && iphone[2].replace(/-/g, ".")) || "";
85 env.ios = true; 85 env.ios = true;
86 } else if (android) { 86 } else if (android) {
87 env.android = android[1] && true || false; 87 env.android = (android[1] && true) || false;
88 env.ver = android[2]; 88 env.ver = android[2];
89 } else { 89 } else {
90 env.pc = true; 90 env.pc = true;
...@@ -104,16 +104,20 @@ export function setTitle(title) { ...@@ -104,16 +104,20 @@ export function setTitle(title) {
104 document.title = title; 104 document.title = title;
105 // if (ENV.ios && navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1) { 105 // if (ENV.ios && navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1) {
106 // 修复微信端IOS无法修改document.title的情况 106 // 修复微信端IOS无法修改document.title的情况
107 if (getEnv().ios && (navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1 || navigator.userAgent.toLowerCase().indexOf("alipay") !== -1)) { 107 if (
108 getEnv().ios &&
109 (navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1 ||
110 navigator.userAgent.toLowerCase().indexOf("alipay") !== -1)
111 ) {
108 //修复IOS微信端和支付宝无法修改document.title的情况 112 //修复IOS微信端和支付宝无法修改document.title的情况
109 var $iframe = document.createElement('iframe'); 113 var $iframe = document.createElement("iframe");
110 $iframe.className = "C-hiddenIframe"; 114 $iframe.className = "C-hiddenIframe";
111 $iframe.src = "/" + location.pathname.split('/')[1] + "/favicon.ico"; 115 $iframe.src = "/" + location.pathname.split("/")[1] + "/favicon.ico";
112 $iframe.style.visibility = 'hidden'; 116 $iframe.style.visibility = "hidden";
113 $iframe.style.width = '1px'; 117 $iframe.style.width = "1px";
114 $iframe.style.height = '1px'; 118 $iframe.style.height = "1px";
115 $iframe.onload = function onIframeLoad() { 119 $iframe.onload = function onIframeLoad() {
116 setTimeout(function () { 120 setTimeout(function() {
117 $iframe.onload = null; 121 $iframe.onload = null;
118 onIframeLoad = null; 122 onIframeLoad = null;
119 document.body.removeChild($iframe); 123 document.body.removeChild($iframe);
...@@ -126,23 +130,22 @@ export function setTitle(title) { ...@@ -126,23 +130,22 @@ export function setTitle(title) {
126 130
127 // 为链接添加参数 131 // 为链接添加参数
128 export function addQuery(url, query) { 132 export function addQuery(url, query) {
129 query = query || {} 133 query = query || {};
130 query = (function (query) { 134 query = (function(query) {
131 var q = [] 135 var q = [];
132 Object.keys(query).forEach(function (_q) { 136 Object.keys(query).forEach(function(_q) {
133 q.push(_q + '=' + query[_q]) 137 q.push(_q + "=" + query[_q]);
134 }) 138 });
135 return q.join('&') 139 return q.join("&");
136 })(query) 140 })(query);
137 if (url.indexOf('?') !== -1) { 141 if (url.indexOf("?") !== -1) {
138 url += '&' + query 142 url += "&" + query;
139 } else { 143 } else {
140 url += '?' + query 144 url += "?" + query;
141 } 145 }
142 return url 146 return url;
143 } 147 }
144 148
145
146 /** 149 /**
147 * 获得当前页面的path 150 * 获得当前页面的path
148 * @return {String} 页面path 151 * @return {String} 页面path
...@@ -157,7 +160,63 @@ export function getPath() { ...@@ -157,7 +160,63 @@ export function getPath() {
157 160
158 // 获取 url 参数 161 // 获取 url 参数
159 export function getQuery(name) { 162 export function getQuery(name) {
160 return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null; 163 return (
164 decodeURIComponent(
165 (new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
166 location.href
167 ) || [, ""])[1].replace(/\+/g, "%20")
168 ) || null
169 );
170 }
171
172 /**
173 * 升序排列
174 * @param name 主要参数
175 * @param minor 次要参数 主要参数相同时,比较次要参数
176 */
177 export function ascSort(name, minor) {
178 return function(o, p) {
179 var a, b;
180 if (o && p && typeof o === "object" && typeof p === "object") {
181 a = o[name];
182 b = p[name];
183 if (a === b) {
184 return typeof minor === "function" ? minor(o, p) : 0;
185 }
186 if (typeof a === typeof b) {
187 return a < b ? -1 : 1;
188 }
189 return typeof a < typeof b ? -1 : 1;
190 } else {
191 // throw ("error");
192 return null;
193 }
194 };
195 }
196
197 /**
198 * 升序排列
199 * @param name 主要参数
200 * @param minor 次要参数 主要参数相同时,比较次要参数
201 */
202 export function descSort(name, minor) {
203 return function(o, p) {
204 var a, b;
205 if (o && p && typeof o === "object" && typeof p === "object") {
206 a = o[name];
207 b = p[name];
208 if (a === b) {
209 return typeof minor === "function" ? minor(o, p) : 0;
210 }
211 if (typeof a === typeof b) {
212 return a > b ? -1 : 1;
213 }
214 return typeof a > typeof b ? -1 : 1;
215 } else {
216 // throw ("error");
217 return null;
218 }
219 };
161 } 220 }
162 221
163 /** 222 /**
...@@ -182,16 +241,15 @@ export function getObjByListKeyValue(value, key, list) { ...@@ -182,16 +241,15 @@ export function getObjByListKeyValue(value, key, list) {
182 * 用{{}}会当成字符串把 html渲染出来 241 * 用{{}}会当成字符串把 html渲染出来
183 */ 242 */
184 export function formatBr(str) { 243 export function formatBr(str) {
185 str = str.replace(/\n/g, '<br/>') 244 str = str.replace(/\n/g, "<br/>");
186 return str 245 return str;
187 }; 246 }
188 247
189 // dd-MM-yyyy转yyyy-MM-dd 248 // dd-MM-yyyy转yyyy-MM-dd
190 export function ddMMyyyy2yyyyMMdd(str) { 249 export function ddMMyyyy2yyyyMMdd(str) {
191 return str.replace(/-/g, '').replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1"); 250 return str.replace(/-/g, "").replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1");
192 } 251 }
193 252
194
195 /** 253 /**
196 * @desc 函数防抖 254 * @desc 函数防抖
197 * @param func 函数 255 * @param func 函数
...@@ -201,7 +259,7 @@ export function ddMMyyyy2yyyyMMdd(str) { ...@@ -201,7 +259,7 @@ export function ddMMyyyy2yyyyMMdd(str) {
201 export function debounce(func, wait, immediate) { 259 export function debounce(func, wait, immediate) {
202 let timeout; 260 let timeout;
203 261
204 return function () { 262 return function() {
205 let context = this; 263 let context = this;
206 let args = arguments; 264 let args = arguments;
207 265
...@@ -210,14 +268,14 @@ export function debounce(func, wait, immediate) { ...@@ -210,14 +268,14 @@ export function debounce(func, wait, immediate) {
210 var callNow = !timeout; 268 var callNow = !timeout;
211 timeout = setTimeout(() => { 269 timeout = setTimeout(() => {
212 timeout = null; 270 timeout = null;
213 }, wait) 271 }, wait);
214 if (callNow) func.apply(context, args) 272 if (callNow) func.apply(context, args);
215 } else { 273 } else {
216 timeout = setTimeout(function () { 274 timeout = setTimeout(function() {
217 func.apply(context, args) 275 func.apply(context, args);
218 }, wait); 276 }, wait);
219 } 277 }
220 } 278 };
221 } 279 }
222 280
223 /** 281 /**
...@@ -233,7 +291,7 @@ export function throttle(func, wait, type) { ...@@ -233,7 +291,7 @@ export function throttle(func, wait, type) {
233 } else if (type === 2) { 291 } else if (type === 2) {
234 var timeout; 292 var timeout;
235 } 293 }
236 return function () { 294 return function() {
237 let context = this; 295 let context = this;
238 let args = arguments; 296 let args = arguments;
239 if (type === 1) { 297 if (type === 1) {
...@@ -247,11 +305,11 @@ export function throttle(func, wait, type) { ...@@ -247,11 +305,11 @@ export function throttle(func, wait, type) {
247 if (!timeout) { 305 if (!timeout) {
248 timeout = setTimeout(() => { 306 timeout = setTimeout(() => {
249 timeout = null; 307 timeout = null;
250 func.apply(context, args) 308 func.apply(context, args);
251 }, wait) 309 }, wait);
252 } 310 }
253 } 311 }
254 } 312 };
255 } 313 }
256 314
257 /** 315 /**
...@@ -260,17 +318,17 @@ export function throttle(func, wait, type) { ...@@ -260,17 +318,17 @@ export function throttle(func, wait, type) {
260 * @param {string} value 318 * @param {string} value
261 */ 319 */
262 export function contactMethodCheck(type, value) { 320 export function contactMethodCheck(type, value) {
263 if (type == 'hkmobile') { 321 if (type == "hkmobile") {
264 // return /^[5689]{1}\d{7}$/.test(value); 322 // return /^[5689]{1}\d{7}$/.test(value);
265 return /^(\+)?(852)?(\-)?(5|6|8|9)\d{7}$/.test(value); 323 return /^(\+)?(852)?(\-)?(5|6|8|9)\d{7}$/.test(value);
266 } 324 }
267 325
268 if (type == 'mobile') { 326 if (type == "mobile") {
269 // 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); 327 // 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);
270 return /^(\+)?(86)?(\-)?1\d{10}$/.test(value); 328 return /^(\+)?(86)?(\-)?1\d{10}$/.test(value);
271 } 329 }
272 330
273 if (type == 'email') { 331 if (type == "email") {
274 return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value); 332 return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value);
275 } 333 }
276 return true; 334 return true;
...@@ -281,7 +339,7 @@ export function policyNumberCheck(policyNumber) { ...@@ -281,7 +339,7 @@ export function policyNumberCheck(policyNumber) {
281 } 339 }
282 340
283 export function checkVerifyCode(verifyCode) { 341 export function checkVerifyCode(verifyCode) {
284 return /^\d{6}$/.test(verifyCode) 342 return /^\d{6}$/.test(verifyCode);
285 } 343 }
286 344
287 export function checkName(name) { 345 export function checkName(name) {
......