默认提交
Showing
8 changed files
with
272 additions
and
201 deletions
| ... | @@ -16,6 +16,8 @@ import { | ... | @@ -16,6 +16,8 @@ import { |
| 16 | Option | 16 | Option |
| 17 | } from 'element-ui'; | 17 | } from 'element-ui'; |
| 18 | 18 | ||
| 19 | import { ddMMyyyy2yyyyMMdd } from '@utils/utils.js'; | ||
| 20 | |||
| 19 | Vue.use(Loading); | 21 | Vue.use(Loading); |
| 20 | Vue.use(Select); | 22 | Vue.use(Select); |
| 21 | Vue.use(Option); | 23 | Vue.use(Option); |
| ... | @@ -109,6 +111,17 @@ export default { | ... | @@ -109,6 +111,17 @@ export default { |
| 109 | 111 | ||
| 110 | let b10 = this.policyIllegal; | 112 | let b10 = this.policyIllegal; |
| 111 | 113 | ||
| 114 | // console.log("b1:",b1); | ||
| 115 | // console.log("b2:",b2); | ||
| 116 | // console.log("b3:",b3); | ||
| 117 | // console.log("b4:",b4); | ||
| 118 | // console.log("b5:",b5); | ||
| 119 | // console.log("b6:",b6); | ||
| 120 | // console.log("b7:",b7); | ||
| 121 | // console.log("b8:",b8); | ||
| 122 | // console.log("b9:",b9); | ||
| 123 | // console.log("b10:",b10); | ||
| 124 | |||
| 112 | return b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8 || b9 || b10; | 125 | return b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8 || b9 || b10; |
| 113 | } | 126 | } |
| 114 | }, | 127 | }, |
| ... | @@ -217,7 +230,8 @@ export default { | ... | @@ -217,7 +230,8 @@ export default { |
| 217 | cid: this.cid, | 230 | cid: this.cid, |
| 218 | insuredId: insured.insuredId, | 231 | insuredId: insured.insuredId, |
| 219 | policyId: policy.policyId, | 232 | policyId: policy.policyId, |
| 220 | accidentTime: this.data.contactDate, | 233 | // accidentTime: this.data.contactDate, |
| 234 | accidentTime: ddMMyyyy2yyyyMMdd(this.data.contactDate), | ||
| 221 | applyReasonList: this.typeSelected.join(","), | 235 | applyReasonList: this.typeSelected.join(","), |
| 222 | treatmentAmount: this.data.amount, | 236 | treatmentAmount: this.data.amount, |
| 223 | imageList: imageList | 237 | imageList: imageList | ... | ... |
| ... | @@ -176,7 +176,7 @@ input { | ... | @@ -176,7 +176,7 @@ input { |
| 176 | margin-top: 48px; | 176 | margin-top: 48px; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | .mt24{ | 179 | .mt24 { |
| 180 | margin-top: 24px; | 180 | margin-top: 24px; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| ... | @@ -203,9 +203,13 @@ input { | ... | @@ -203,9 +203,13 @@ input { |
| 203 | 203 | ||
| 204 | hr { | 204 | hr { |
| 205 | border-top: 1px solid #eee; | 205 | border-top: 1px solid #eee; |
| 206 | margin-top: 48px; | 206 | margin-top: 42px; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | // .hr2{ | ||
| 210 | // margin-top: 42px; | ||
| 211 | // } | ||
| 212 | |||
| 209 | .tips { | 213 | .tips { |
| 210 | display: flex; | 214 | display: flex; |
| 211 | justify-content: flex-start; | 215 | justify-content: flex-start; |
| ... | @@ -224,7 +228,7 @@ input { | ... | @@ -224,7 +228,7 @@ input { |
| 224 | } | 228 | } |
| 225 | } | 229 | } |
| 226 | 230 | ||
| 227 | .tips2{ | 231 | .tips2 { |
| 228 | margin-top: -12px; | 232 | margin-top: -12px; |
| 229 | } | 233 | } |
| 230 | 234 | ||
| ... | @@ -361,13 +365,14 @@ input { | ... | @@ -361,13 +365,14 @@ input { |
| 361 | width: 100%; | 365 | width: 100%; |
| 362 | display: flex; | 366 | display: flex; |
| 363 | justify-content: flex-start; | 367 | justify-content: flex-start; |
| 364 | padding: 0 $marginSmall; | 368 | // padding: 0 $marginSmall; |
| 365 | margin-bottom: 1.333333rem; | 369 | margin-bottom: 1.333333rem; |
| 366 | 370 | ||
| 367 | .label { | 371 | .label { |
| 372 | @extend .bb; | ||
| 368 | align-items: center; | 373 | align-items: center; |
| 369 | width: 30%; | 374 | min-width: 260px; |
| 370 | padding-left: 5px; | 375 | padding-left: 70px; |
| 371 | letter-spacing: .25rem; | 376 | letter-spacing: .25rem; |
| 372 | font-size: 20px; | 377 | font-size: 20px; |
| 373 | 378 | ||
| ... | @@ -402,12 +407,13 @@ input { | ... | @@ -402,12 +407,13 @@ input { |
| 402 | 407 | ||
| 403 | 408 | ||
| 404 | .ipt2 { | 409 | .ipt2 { |
| 405 | width: 100%; | 410 | // width: 100%; |
| 406 | border-bottom: 1px solid #ccc; | 411 | border-bottom: 1px solid #ccc; |
| 407 | height: 3rem; | 412 | height: 3rem; |
| 408 | display: flex; | 413 | display: flex; |
| 409 | align-items: center; | 414 | align-items: center; |
| 410 | margin-bottom: .833333rem; | 415 | margin-bottom: .833333rem; |
| 416 | width: 700px; | ||
| 411 | } | 417 | } |
| 412 | 418 | ||
| 413 | // 长文本 | 419 | // 长文本 |
| ... | @@ -433,6 +439,10 @@ input { | ... | @@ -433,6 +439,10 @@ input { |
| 433 | 439 | ||
| 434 | } | 440 | } |
| 435 | } | 441 | } |
| 442 | |||
| 443 | &-item-3 { | ||
| 444 | margin-bottom: 0; | ||
| 445 | } | ||
| 436 | } | 446 | } |
| 437 | 447 | ||
| 438 | 448 | ... | ... |
| ... | @@ -103,7 +103,7 @@ | ... | @@ -103,7 +103,7 @@ |
| 103 | <div class="down-arrow"></div> | 103 | <div class="down-arrow"></div> |
| 104 | <div class="cont"> | 104 | <div class="cont"> |
| 105 | <div class="ipt-date"> | 105 | <div class="ipt-date"> |
| 106 | <date-picker v-model="data.contactDate" :filtModel="['future']" :check="checkDate" :cusStyle="{border:'none !important','background-color':'transparent !important','height':'58px', 'color':'#ff6839','font-weight':'bold','text-align': 'center'}"></date-picker> | 106 | <date-picker v-model="data.contactDate" :formatter="'dd-MM-yyyy'" :filtModel="['future']" :check="checkDate" :cusStyle="{border:'none !important','background-color':'transparent !important','height':'58px', 'color':'#ff6839','font-weight':'bold','text-align': 'center'}"></date-picker> |
| 107 | </div> | 107 | </div> |
| 108 | </div> | 108 | </div> |
| 109 | </div> | 109 | </div> |
| ... | @@ -111,7 +111,7 @@ | ... | @@ -111,7 +111,7 @@ |
| 111 | </div> | 111 | </div> |
| 112 | 112 | ||
| 113 | <template v-if="data.contactDate"> | 113 | <template v-if="data.contactDate"> |
| 114 | <div class="pure-u-1 form-item-2 mt20"> | 114 | <div class="pure-u-1 form-item-2 form-item-3 mt20"> |
| 115 | <div class="label"> | 115 | <div class="label"> |
| 116 | <div class="main-label"> | 116 | <div class="main-label"> |
| 117 | {{$t('clarms.step2.label10')}} | 117 | {{$t('clarms.step2.label10')}} |
| ... | @@ -123,7 +123,7 @@ | ... | @@ -123,7 +123,7 @@ |
| 123 | </div> | 123 | </div> |
| 124 | </div> | 124 | </div> |
| 125 | 125 | ||
| 126 | <div class="pure-u-1 form-item-2 mt20"> | 126 | <div class="pure-u-1 form-item-2 form-item-3 mt24"> |
| 127 | <div class="label"> | 127 | <div class="label"> |
| 128 | <div class="main-label"> | 128 | <div class="main-label"> |
| 129 | {{$t('clarms.step2.label13')}} | 129 | {{$t('clarms.step2.label13')}} |
| ... | @@ -138,7 +138,7 @@ | ... | @@ -138,7 +138,7 @@ |
| 138 | </template> | 138 | </template> |
| 139 | </div> | 139 | </div> |
| 140 | <template v-if="(data.HT41 && data.HT41.length > 0) && (data.HT26 && data.HT26.length > 0)"> | 140 | <template v-if="(data.HT41 && data.HT41.length > 0) && (data.HT26 && data.HT26.length > 0)"> |
| 141 | <hr v-if="data.amount > 0"> | 141 | <hr class="hr2" v-if="data.amount > 0"> |
| 142 | <div class="bottom-tip orange mt20">{{$t('clarms.step2.label17')}}</div> | 142 | <div class="bottom-tip orange mt20">{{$t('clarms.step2.label17')}}</div> |
| 143 | <div class="bottom-tip gray mt10">{{$t('clarms.step2.tip1')}}</div> | 143 | <div class="bottom-tip gray mt10">{{$t('clarms.step2.tip1')}}</div> |
| 144 | 144 | ... | ... |
| ... | @@ -12,10 +12,14 @@ import DatePicker from '@/components/date-picker/date-picker.vue'; | ... | @@ -12,10 +12,14 @@ import DatePicker from '@/components/date-picker/date-picker.vue'; |
| 12 | import { Loading } from 'vant'; | 12 | import { Loading } from 'vant'; |
| 13 | import { Select, Option } from 'element-ui'; | 13 | import { Select, Option } from 'element-ui'; |
| 14 | 14 | ||
| 15 | import { ddMMyyyy2yyyyMMdd } from '@utils/utils.js'; | ||
| 16 | |||
| 15 | Vue.use(Select); | 17 | Vue.use(Select); |
| 16 | Vue.use(Option); | 18 | Vue.use(Option); |
| 17 | Vue.use(Loading); | 19 | Vue.use(Loading); |
| 18 | 20 | ||
| 21 | |||
| 22 | |||
| 19 | export default { | 23 | export default { |
| 20 | data() { | 24 | data() { |
| 21 | return { | 25 | return { |
| ... | @@ -90,8 +94,10 @@ export default { | ... | @@ -90,8 +94,10 @@ export default { |
| 90 | if (this.loading) { | 94 | if (this.loading) { |
| 91 | return; | 95 | return; |
| 92 | } | 96 | } |
| 93 | this.loading = true; | 97 | this.loading = true; |
| 94 | httpPost({ url: api.getCidByVerify, data: this.data }).then(res => { | 98 | let param = this.data; |
| 99 | param.birthDate = ddMMyyyy2yyyyMMdd(param.birthDate); | ||
| 100 | httpPost({ url: api.getCidByVerify, data: param }).then(res => { | ||
| 95 | if (res) { | 101 | if (res) { |
| 96 | let cid = res; | 102 | let cid = res; |
| 97 | httpPost({ url: api.clarmsCustomerList, data: { cid: cid } }).then(res => { | 103 | httpPost({ url: api.clarmsCustomerList, data: { cid: cid } }).then(res => { | ... | ... |
| ... | @@ -4,7 +4,8 @@ | ... | @@ -4,7 +4,8 @@ |
| 4 | <u> | 4 | <u> |
| 5 | <span class="pointer" @click="toRegisterPage">{{$t('clarms.step1.register')}}</span>/ | 5 | <span class="pointer" @click="toRegisterPage">{{$t('clarms.step1.register')}}</span>/ |
| 6 | <span class="pointer" @click="toLoginPage">{{$t('clarms.step1.login')}}</span> | 6 | <span class="pointer" @click="toLoginPage">{{$t('clarms.step1.login')}}</span> |
| 7 | </u>{{$t('clarms.step1.t1')}}</div> | 7 | </u> |
| 8 | <span v-if="$i18n.locale == 'en'"> </span>{{$t('clarms.step1.t1')}}</div> | ||
| 8 | <div class="form-name default-mt"> {{$t('clarms.step1.label0')}}</div> | 9 | <div class="form-name default-mt"> {{$t('clarms.step1.label0')}}</div> |
| 9 | <div class="gird-g form default-mt"> | 10 | <div class="gird-g form default-mt"> |
| 10 | <div class="form-item"> | 11 | <div class="form-item"> |
| ... | @@ -63,7 +64,7 @@ | ... | @@ -63,7 +64,7 @@ |
| 63 | <div class="ipt-wrap"> | 64 | <div class="ipt-wrap"> |
| 64 | <div class="down-arrow"></div> | 65 | <div class="down-arrow"></div> |
| 65 | <div class="cont"> | 66 | <div class="cont"> |
| 66 | <date-picker class="ipt-date" v-model="data.birthDate" :filtModel="['future']" :check="checkDate" :cusStyle="{border:'none !important','background-color':'transparent !important',height:'48px', padding:'0', color:'#606266'}"></date-picker> | 67 | <date-picker class="ipt-date" :formatter="'dd-MM-yyyy'" v-model="data.birthDate" :filtModel="['future']" :check="checkDate" :cusStyle="{border:'none !important','background-color':'transparent !important',height:'48px', padding:'0', color:'#606266'}"></date-picker> |
| 67 | </div> | 68 | </div> |
| 68 | </div> | 69 | </div> |
| 69 | </div> | 70 | </div> | ... | ... |
| ... | @@ -6,14 +6,22 @@ import { | ... | @@ -6,14 +6,22 @@ import { |
| 6 | 6 | ||
| 7 | import Date from '@/utils/date.js'; | 7 | import Date from '@/utils/date.js'; |
| 8 | 8 | ||
| 9 | import { | ||
| 10 | ddMMyyyy2yyyyMMdd | ||
| 11 | } from '@utils/utils.js'; | ||
| 12 | |||
| 9 | export default { | 13 | export default { |
| 10 | inheritAttrs: false, | 14 | inheritAttrs: false, |
| 11 | props: { | 15 | props: { |
| 12 | // 周末是否可选 | ||
| 13 | value: { | 16 | value: { |
| 14 | type: String, | 17 | type: String, |
| 15 | default: "" | 18 | default: "" |
| 16 | }, | 19 | }, |
| 20 | // 日期格式 默认yyyy-MM-dd | ||
| 21 | formatter: { | ||
| 22 | type: String, | ||
| 23 | default: "yyyy-MM-dd" | ||
| 24 | }, | ||
| 17 | // 周末是否可选 | 25 | // 周末是否可选 |
| 18 | weekend: { | 26 | weekend: { |
| 19 | type: Boolean, | 27 | type: Boolean, |
| ... | @@ -26,14 +34,14 @@ export default { | ... | @@ -26,14 +34,14 @@ export default { |
| 26 | // today : 当日不可选择 | 34 | // today : 当日不可选择 |
| 27 | filtModel: { | 35 | filtModel: { |
| 28 | type: Array, | 36 | type: Array, |
| 29 | default() { | 37 | default () { |
| 30 | return ["history", "weekend", "today"] | 38 | return ["history", "weekend", "today"] |
| 31 | } | 39 | } |
| 32 | }, | 40 | }, |
| 33 | // 需要过滤的日期列表 格式 ["yyyy-MM-dd","yyyy-MM-dd"] | 41 | // 需要过滤的日期列表 格式 ["yyyy-MM-dd","yyyy-MM-dd"] |
| 34 | filterDates: { | 42 | filterDates: { |
| 35 | type: Array, | 43 | type: Array, |
| 36 | default() { | 44 | default () { |
| 37 | return [] // ["2019-11-26", "2019-11-28"] | 45 | return [] // ["2019-11-26", "2019-11-28"] |
| 38 | } | 46 | } |
| 39 | }, | 47 | }, |
| ... | @@ -62,7 +70,7 @@ export default { | ... | @@ -62,7 +70,7 @@ export default { |
| 62 | }, | 70 | }, |
| 63 | cusStyle: { | 71 | cusStyle: { |
| 64 | type: Object, | 72 | type: Object, |
| 65 | default() { | 73 | default () { |
| 66 | return {}; | 74 | return {}; |
| 67 | } | 75 | } |
| 68 | }, | 76 | }, |
| ... | @@ -125,7 +133,13 @@ export default { | ... | @@ -125,7 +133,13 @@ export default { |
| 125 | }, | 133 | }, |
| 126 | methods: { | 134 | methods: { |
| 127 | activity(item) { | 135 | activity(item) { |
| 128 | let ymd = item.year + "-" + (item.month > 9 ? item.month : "0" + item.month) + "-" + (item.date > 9 ? item.date : "0" + item.date); | 136 | let year = item.year; |
| 137 | let month = item.month > 9 ? item.month : "0" + item.month; | ||
| 138 | let date = item.date > 9 ? item.date : "0" + item.date; | ||
| 139 | let ymd = `${year}-${month}-${date}`; | ||
| 140 | if (this.formatter == "dd-MM-yyyy") { | ||
| 141 | ymd = `${date}-${month}-${year}`; | ||
| 142 | } | ||
| 129 | return ymd == this.dateValue; | 143 | return ymd == this.dateValue; |
| 130 | }, | 144 | }, |
| 131 | /** | 145 | /** |
| ... | @@ -361,13 +375,18 @@ export default { | ... | @@ -361,13 +375,18 @@ export default { |
| 361 | } | 375 | } |
| 362 | }, | 376 | }, |
| 363 | formatDateValue(year, month, date) { | 377 | formatDateValue(year, month, date) { |
| 378 | // console.log("year:", year); | ||
| 379 | // console.log("month:", month); | ||
| 380 | // console.log("date:", date); | ||
| 364 | if (month < 10) { | 381 | if (month < 10) { |
| 365 | month = "0" + month | 382 | month = "0" + month |
| 366 | } | 383 | } |
| 367 | if (date < 10) { | 384 | if (date < 10) { |
| 368 | date = "0" + date | 385 | date = "0" + date |
| 369 | } | 386 | } |
| 370 | this.dateValue = `${year}-${month}-${date}`; | 387 | // this.dateValue = `${year}-${month}-${date}`; |
| 388 | this.dateValue = Date.parse(`${year}.${month}.${date}`).toString(this.formatter); | ||
| 389 | // console.log("this.dateValue:", this.dateValue); | ||
| 371 | }, | 390 | }, |
| 372 | /** | 391 | /** |
| 373 | * 校验并返回日期 | 392 | * 校验并返回日期 |
| ... | @@ -384,14 +403,16 @@ export default { | ... | @@ -384,14 +403,16 @@ export default { |
| 384 | fortmatMonthData.forEach((element, idx) => { | 403 | fortmatMonthData.forEach((element, idx) => { |
| 385 | if (element) { | 404 | if (element) { |
| 386 | let curDate = `${element.year}-${element.month}-${element.date}`; | 405 | let curDate = `${element.year}-${element.month}-${element.date}`; |
| 387 | curDate = Date.parse(curDate).toString("yyyy-MM-dd"); //转成yyyy-MM-dd | 406 | curDate = Date.parse(curDate).toString(this.formatter); //转成yyyy-MM-dd |
| 388 | if (curDate == dateValue && element.disable == true) { | 407 | if (curDate == dateValue && element.disable == true) { |
| 389 | disable = true; | 408 | disable = true; |
| 390 | } | 409 | } |
| 391 | } | 410 | } |
| 392 | }); | 411 | }); |
| 393 | if (!disable) { | 412 | if (!disable) { |
| 394 | disable = !/^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/.test(dateValue); | 413 | if (this.formatter == "yyyy-MM-dd") { |
| 414 | disable = !/^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/.test(dateValue); | ||
| 415 | } | ||
| 395 | } | 416 | } |
| 396 | let result = { | 417 | let result = { |
| 397 | dateValue: this.dateValue, | 418 | dateValue: this.dateValue, |
| ... | @@ -404,15 +425,29 @@ export default { | ... | @@ -404,15 +425,29 @@ export default { |
| 404 | // 设置今天日期 | 425 | // 设置今天日期 |
| 405 | let isInit = false; | 426 | let isInit = false; |
| 406 | if (this.value) { | 427 | if (this.value) { |
| 407 | let ymd = this.value.split("-"); | 428 | // console.log("this.value:", this.value); |
| 408 | if (ymd.length == 3) { | 429 | // let ymd = this.value.split("-"); |
| 409 | try { | 430 | // if (ymd.length == 3) { |
| 410 | this.year = Number(ymd[0]); | 431 | // try { |
| 411 | this.month = Number(ymd[1]); | 432 | // this.year = Number(ymd[0]); |
| 412 | this.date = Number(ymd[2]); | 433 | // this.month = Number(ymd[1]); |
| 413 | isInit = true; | 434 | // this.date = Number(ymd[2]); |
| 414 | } catch (e) { } | 435 | // isInit = true; |
| 415 | } | 436 | // } catch (e) {} |
| 437 | // } | ||
| 438 | try { | ||
| 439 | let dateStr = this.value; | ||
| 440 | if (this.formatter == "dd-MM-yyyy") { | ||
| 441 | // dateStr = this.value.replace(/-/g, '').replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1"); | ||
| 442 | dateStr = ddMMyyyy2yyyyMMdd(this.value); | ||
| 443 | |||
| 444 | } | ||
| 445 | let curDate = Date.parse(dateStr); | ||
| 446 | this.year = curDate.getFullYear(); | ||
| 447 | this.month = curDate.getMonth() + 1; | ||
| 448 | this.date = curDate.getDate(); | ||
| 449 | isInit = true; | ||
| 450 | } catch (error) {} | ||
| 416 | } | 451 | } |
| 417 | if (!isInit) { | 452 | if (!isInit) { |
| 418 | let today = Date.today(); | 453 | let today = Date.today(); |
| ... | @@ -447,7 +482,7 @@ export default { | ... | @@ -447,7 +482,7 @@ export default { |
| 447 | 482 | ||
| 448 | } | 483 | } |
| 449 | }, | 484 | }, |
| 450 | mounted() { }, | 485 | mounted() {}, |
| 451 | created() { | 486 | created() { |
| 452 | this.initData(); | 487 | this.initData(); |
| 453 | }, | 488 | }, | ... | ... |
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | <div class="navigate"> | 3 | <div class="navigate"> |
| 4 | <div class="bg"></div> | 4 | <div class="bg"></div> |
| 5 | <div class="cont"> | 5 | <div class="cont"> |
| 6 | <span class="tt">索償申請</span> | 6 | <span class="tt">{{$t('customService.menu5')}}</span> |
| 7 | </div> | 7 | </div> |
| 8 | </div> | 8 | </div> |
| 9 | <div class="content clarms"> | 9 | <div class="content clarms"> | ... | ... |
| 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) { |
| 8 | return REGEXPS.mobile.test(str); | 8 | return REGEXPS.mobile.test(str); |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| ... | @@ -14,45 +14,45 @@ export function checkMobile(str) { | ... | @@ -14,45 +14,45 @@ 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 | 31 | ||
| 32 | 32 | ||
| 33 | //获取cookie、 | 33 | //获取cookie、 |
| 34 | export function getCookie(name) { | 34 | export function getCookie(name) { |
| 35 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); | 35 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); |
| 36 | if (arr = document.cookie.match(reg)) | 36 | if (arr = document.cookie.match(reg)) |
| 37 | return (arr[2]); | 37 | return (arr[2]); |
| 38 | else | 38 | else |
| 39 | return null; | 39 | return null; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | //设置cookie | 42 | //设置cookie |
| 43 | export function setCookie(c_name, value, second) { | 43 | export function setCookie(c_name, value, second) { |
| 44 | var exdate = new Date(); | 44 | var exdate = new Date(); |
| 45 | exdate.setTime(exdate.getTime() + second * 1000); | 45 | exdate.setTime(exdate.getTime() + second * 1000); |
| 46 | document.cookie = c_name + "=" + escape(value) + ((second == null) ? "" : ";expires=" + exdate.toGMTString()); | 46 | document.cookie = c_name + "=" + escape(value) + ((second == null) ? "" : ";expires=" + exdate.toGMTString()); |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | //删除cookie | 49 | //删除cookie |
| 50 | export function delCookie(name) { | 50 | export function delCookie(name) { |
| 51 | var exp = new Date(); | 51 | var exp = new Date(); |
| 52 | exp.setTime(exp.getTime() - 1); | 52 | exp.setTime(exp.getTime() - 1); |
| 53 | var cval = getCookie(name); | 53 | var cval = getCookie(name); |
| 54 | if (cval != null) | 54 | if (cval != null) |
| 55 | document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); | 55 | document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | 58 | ||
| ... | @@ -61,36 +61,36 @@ export function delCookie(name) { | ... | @@ -61,36 +61,36 @@ export function delCookie(name) { |
| 61 | * @return {Object} 环境信息对象 | 61 | * @return {Object} 环境信息对象 |
| 62 | */ | 62 | */ |
| 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; |
| 75 | var android = ua.match(/(Android)\s+([\d.]+)/); | 75 | var android = ua.match(/(Android)\s+([\d.]+)/); |
| 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; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | return env; | 93 | return env; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| ... | @@ -98,48 +98,48 @@ export function getEnv() { | ... | @@ -98,48 +98,48 @@ export function getEnv() { |
| 98 | * @param {[type]} title [description] | 98 | * @param {[type]} title [description] |
| 99 | */ | 99 | */ |
| 100 | export function setTitle(title) { | 100 | export function setTitle(title) { |
| 101 | if (!title) { | 101 | if (!title) { |
| 102 | return; | 102 | return; |
| 103 | } | 103 | } |
| 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 (getEnv().ios && (navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1 || navigator.userAgent.toLowerCase().indexOf("alipay") !== -1)) { |
| 108 | //修复IOS微信端和支付宝无法修改document.title的情况 | 108 | //修复IOS微信端和支付宝无法修改document.title的情况 |
| 109 | var $iframe = document.createElement('iframe'); | 109 | var $iframe = document.createElement('iframe'); |
| 110 | $iframe.className = "C-hiddenIframe"; | 110 | $iframe.className = "C-hiddenIframe"; |
| 111 | $iframe.src = "/" + location.pathname.split('/')[1] + "/favicon.ico"; | 111 | $iframe.src = "/" + location.pathname.split('/')[1] + "/favicon.ico"; |
| 112 | $iframe.style.visibility = 'hidden'; | 112 | $iframe.style.visibility = 'hidden'; |
| 113 | $iframe.style.width = '1px'; | 113 | $iframe.style.width = '1px'; |
| 114 | $iframe.style.height = '1px'; | 114 | $iframe.style.height = '1px'; |
| 115 | $iframe.onload = function onIframeLoad() { | 115 | $iframe.onload = function onIframeLoad() { |
| 116 | setTimeout(function () { | 116 | setTimeout(function () { |
| 117 | $iframe.onload = null; | 117 | $iframe.onload = null; |
| 118 | onIframeLoad = null; | 118 | onIframeLoad = null; |
| 119 | document.body.removeChild($iframe); | 119 | document.body.removeChild($iframe); |
| 120 | $iframe = null; | 120 | $iframe = null; |
| 121 | }, 0); | 121 | }, 0); |
| 122 | }; | 122 | }; |
| 123 | document.body.appendChild($iframe); | 123 | document.body.appendChild($iframe); |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | // 为链接添加参数 | 127 | // 为链接添加参数 |
| 128 | export function addQuery(url, query) { | 128 | export function addQuery(url, query) { |
| 129 | query = query || {} | 129 | query = query || {} |
| 130 | query = (function (query) { | 130 | query = (function (query) { |
| 131 | var q = [] | 131 | var q = [] |
| 132 | Object.keys(query).forEach(function (_q) { | 132 | Object.keys(query).forEach(function (_q) { |
| 133 | q.push(_q + '=' + query[_q]) | 133 | q.push(_q + '=' + query[_q]) |
| 134 | }) | 134 | }) |
| 135 | return q.join('&') | 135 | return q.join('&') |
| 136 | })(query) | 136 | })(query) |
| 137 | if (url.indexOf('?') !== -1) { | 137 | if (url.indexOf('?') !== -1) { |
| 138 | url += '&' + query | 138 | url += '&' + query |
| 139 | } else { | 139 | } else { |
| 140 | url += '?' + query | 140 | url += '?' + query |
| 141 | } | 141 | } |
| 142 | return url | 142 | return url |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | 145 | ||
| ... | @@ -148,16 +148,16 @@ export function addQuery(url, query) { | ... | @@ -148,16 +148,16 @@ export function addQuery(url, query) { |
| 148 | * @return {String} 页面path | 148 | * @return {String} 页面path |
| 149 | */ | 149 | */ |
| 150 | export function getPath() { | 150 | export function getPath() { |
| 151 | var path = window.location.hash; | 151 | var path = window.location.hash; |
| 152 | path = path || "#/"; | 152 | path = path || "#/"; |
| 153 | path = path === "#/" ? "#/index" : path; | 153 | path = path === "#/" ? "#/index" : path; |
| 154 | path = path.split("?"); | 154 | path = path.split("?"); |
| 155 | return path[0]; | 155 | return path[0]; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | // 获取 url 参数 | 158 | // 获取 url 参数 |
| 159 | export function getQuery(name) { | 159 | export function getQuery(name) { |
| 160 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null; | 160 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | /** | 163 | /** |
| ... | @@ -167,13 +167,13 @@ export function getQuery(name) { | ... | @@ -167,13 +167,13 @@ export function getQuery(name) { |
| 167 | * @param {*} list | 167 | * @param {*} list |
| 168 | */ | 168 | */ |
| 169 | export function getObjByListKeyValue(value, key, list) { | 169 | export function getObjByListKeyValue(value, key, list) { |
| 170 | let result = null; | 170 | let result = null; |
| 171 | list.forEach(element => { | 171 | list.forEach(element => { |
| 172 | if (element[key + ""] == value) { | 172 | if (element[key + ""] == value) { |
| 173 | result = element; | 173 | result = element; |
| 174 | } | 174 | } |
| 175 | }); | 175 | }); |
| 176 | return result; | 176 | return result; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /** | 179 | /** |
| ... | @@ -182,10 +182,15 @@ export function getObjByListKeyValue(value, key, list) { | ... | @@ -182,10 +182,15 @@ export function getObjByListKeyValue(value, key, list) { |
| 182 | * 用{{}}会当成字符串把 html渲染出来 | 182 | * 用{{}}会当成字符串把 html渲染出来 |
| 183 | */ | 183 | */ |
| 184 | export function formatBr(str) { | 184 | export function formatBr(str) { |
| 185 | str = str.replace(/\n/g, '<br/>') | 185 | str = str.replace(/\n/g, '<br/>') |
| 186 | return str | 186 | return str |
| 187 | }; | 187 | }; |
| 188 | 188 | ||
| 189 | // dd-MM-yyyy转yyyy-MM-dd | ||
| 190 | export function ddMMyyyy2yyyyMMdd(str) { | ||
| 191 | return str.replace(/-/g, '').replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1"); | ||
| 192 | } | ||
| 193 | |||
| 189 | 194 | ||
| 190 | /** | 195 | /** |
| 191 | * @desc 函数防抖 | 196 | * @desc 函数防抖 |
| ... | @@ -194,25 +199,25 @@ export function formatBr(str) { | ... | @@ -194,25 +199,25 @@ export function formatBr(str) { |
| 194 | * @param immediate true 表立即执行,false 表非立即执行 | 199 | * @param immediate true 表立即执行,false 表非立即执行 |
| 195 | */ | 200 | */ |
| 196 | export function debounce(func, wait, immediate) { | 201 | export function debounce(func, wait, immediate) { |
| 197 | let timeout; | 202 | let timeout; |
| 198 | 203 | ||
| 199 | return function () { | 204 | return function () { |
| 200 | let context = this; | 205 | let context = this; |
| 201 | let args = arguments; | 206 | let args = arguments; |
| 202 | 207 | ||
| 203 | if (timeout) clearTimeout(timeout); | 208 | if (timeout) clearTimeout(timeout); |
| 204 | if (immediate) { | 209 | if (immediate) { |
| 205 | var callNow = !timeout; | 210 | var callNow = !timeout; |
| 206 | timeout = setTimeout(() => { | 211 | timeout = setTimeout(() => { |
| 207 | timeout = null; | 212 | timeout = null; |
| 208 | }, wait) | 213 | }, wait) |
| 209 | if (callNow) func.apply(context, args) | 214 | if (callNow) func.apply(context, args) |
| 210 | } else { | 215 | } else { |
| 211 | timeout = setTimeout(function () { | 216 | timeout = setTimeout(function () { |
| 212 | func.apply(context, args) | 217 | func.apply(context, args) |
| 213 | }, wait); | 218 | }, wait); |
| 214 | } | 219 | } |
| 215 | } | 220 | } |
| 216 | } | 221 | } |
| 217 | 222 | ||
| 218 | /** | 223 | /** |
| ... | @@ -223,62 +228,62 @@ export function debounce(func, wait, immediate) { | ... | @@ -223,62 +228,62 @@ export function debounce(func, wait, immediate) { |
| 223 | * 时间戳版的函数触发是在时间段内开始的时候,而定时器版的函数触发是在时间段内结束的时候。 | 228 | * 时间戳版的函数触发是在时间段内开始的时候,而定时器版的函数触发是在时间段内结束的时候。 |
| 224 | */ | 229 | */ |
| 225 | export function throttle(func, wait, type) { | 230 | export function throttle(func, wait, type) { |
| 226 | if (type === 1) { | 231 | if (type === 1) { |
| 227 | var previous = 0; | 232 | var previous = 0; |
| 228 | } else if (type === 2) { | 233 | } else if (type === 2) { |
| 229 | var timeout; | 234 | var timeout; |
| 230 | } | 235 | } |
| 231 | return function () { | 236 | return function () { |
| 232 | let context = this; | 237 | let context = this; |
| 233 | let args = arguments; | 238 | let args = arguments; |
| 234 | if (type === 1) { | 239 | if (type === 1) { |
| 235 | let now = Date.now(); | 240 | let now = Date.now(); |
| 236 | 241 | ||
| 237 | if (now - previous > wait) { | 242 | if (now - previous > wait) { |
| 238 | func.apply(context, args); | 243 | func.apply(context, args); |
| 239 | previous = now; | 244 | previous = now; |
| 240 | } | 245 | } |
| 241 | } else if (type === 2) { | 246 | } else if (type === 2) { |
| 242 | if (!timeout) { | 247 | if (!timeout) { |
| 243 | timeout = setTimeout(() => { | 248 | timeout = setTimeout(() => { |
| 244 | timeout = null; | 249 | timeout = null; |
| 245 | func.apply(context, args) | 250 | func.apply(context, args) |
| 246 | }, wait) | 251 | }, wait) |
| 247 | } | 252 | } |
| 248 | } | 253 | } |
| 249 | } | 254 | } |
| 250 | } | 255 | } |
| 251 | 256 | ||
| 252 | /** | 257 | /** |
| 253 | * 几种常用的校验方式 | 258 | * 几种常用的校验方式 |
| 254 | * @param {string} type | 259 | * @param {string} type |
| 255 | * @param {string} value | 260 | * @param {string} value |
| 256 | */ | 261 | */ |
| 257 | export function contactMethodCheck(type, value) { | 262 | export function contactMethodCheck(type, value) { |
| 258 | if (type == 'hkmobile') { | 263 | if (type == 'hkmobile') { |
| 259 | // return /^[5689]{1}\d{7}$/.test(value); | 264 | // return /^[5689]{1}\d{7}$/.test(value); |
| 260 | return /^(\+)?(852)?(\-)?(5|6|8|9)\d{7}$/.test(value); | 265 | return /^(\+)?(852)?(\-)?(5|6|8|9)\d{7}$/.test(value); |
| 261 | } | 266 | } |
| 262 | 267 | ||
| 263 | if (type == 'mobile') { | 268 | if (type == 'mobile') { |
| 264 | // 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); | 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); |
| 265 | return /^1\d{10}$/.test(value); | 270 | return /^1\d{10}$/.test(value); |
| 266 | } | 271 | } |
| 267 | 272 | ||
| 268 | if (type == 'email') { | 273 | if (type == 'email') { |
| 269 | return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value); | 274 | return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value); |
| 270 | } | 275 | } |
| 271 | return true; | 276 | return true; |
| 272 | } | 277 | } |
| 273 | 278 | ||
| 274 | export function policyNumberCheck(policyNumber) { | 279 | export function policyNumberCheck(policyNumber) { |
| 275 | return /^(P|p)(0001|0002)\d{11}$/.test(policyNumber); | 280 | return /^(P|p)(0001|0002)\d{11}$/.test(policyNumber); |
| 276 | } | 281 | } |
| 277 | 282 | ||
| 278 | export function checkVerifyCode(verifyCode) { | 283 | export function checkVerifyCode(verifyCode) { |
| 279 | return /^\d{6}$/.test(verifyCode) | 284 | return /^\d{6}$/.test(verifyCode) |
| 280 | } | 285 | } |
| 281 | 286 | ||
| 282 | export function checkName(name) { | 287 | export function checkName(name) { |
| 283 | return /^\D+$/.test(name); | ||
| 284 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 288 | return /^\D+$/.test(name); | ||
| 289 | } | ... | ... |
-
Please register or sign in to post a comment