|
@@ -2,16 +2,60 @@
|
|
<div class="report-buy">
|
|
<div class="report-buy">
|
|
<div class="j-main">
|
|
<div class="j-main">
|
|
<van-cell-group title="请填写订单信息">
|
|
<van-cell-group title="请填写订单信息">
|
|
- <van-field v-model="userInfo.email" class="field" center placeholder="输入邮箱地址" @blur="checkPass('email')" :error-message="errorMsg.email" />
|
|
|
|
|
|
+ <van-field
|
|
|
|
+ v-model="userInfo.email"
|
|
|
|
+ :formatter="formatter"
|
|
|
|
+ class="field"
|
|
|
|
+ center
|
|
|
|
+ placeholder="输入邮箱地址"
|
|
|
|
+ :disabled="sendedEmail && emailCodePass"
|
|
|
|
+ :error-message="errorMsg.email"
|
|
|
|
+ @blur="checkPass('email')"
|
|
|
|
+ />
|
|
<transition name="van-slide-right">
|
|
<transition name="van-slide-right">
|
|
- <van-field v-show="true" class="field" center v-model="userInfo.code" maxlength="6" @blur="checkPass('code')" placeholder="输入邮箱验证码" :error-message="errorMsg.code">
|
|
|
|
|
|
+ <van-field
|
|
|
|
+ v-show="showSendEmailCode"
|
|
|
|
+ v-model="userInfo.code"
|
|
|
|
+ :formatter="formatter"
|
|
|
|
+ :disabled="sendedEmail && emailCodePass"
|
|
|
|
+ :error-message="errorMsg.code"
|
|
|
|
+ class="field"
|
|
|
|
+ center
|
|
|
|
+ maxlength="6"
|
|
|
|
+ placeholder="输入邮箱验证码"
|
|
|
|
+ @blur="checkPass('code')"
|
|
|
|
+ >
|
|
<template #button>
|
|
<template #button>
|
|
- <countdown-button @click="sendCode" :countdown="120" :disabled="sendButtonDisabled"></countdown-button>
|
|
|
|
|
|
+ <countdown-button
|
|
|
|
+ ref="countdownButton"
|
|
|
|
+ :countdown="120"
|
|
|
|
+ :disabled="sendButtonDisabled"
|
|
|
|
+ @click="sendCode"
|
|
|
|
+ ></countdown-button>
|
|
</template>
|
|
</template>
|
|
</van-field>
|
|
</van-field>
|
|
</transition>
|
|
</transition>
|
|
- <van-field v-model="userInfo.phone" class="field" center type="tel" placeholder="输入手机号" @blur="checkPass('phone')" :error-message="errorMsg.phone" />
|
|
|
|
- <van-field v-model="userInfo.company" class="field" center autosize @blur="checkPass('company')" type="textarea" rows="1" maxlength="50" placeholder="输入公司名称" :error-message="errorMsg.company" />
|
|
|
|
|
|
+ <van-field
|
|
|
|
+ v-model="userInfo.phone"
|
|
|
|
+ class="field"
|
|
|
|
+ :formatter="formatter"
|
|
|
|
+ center type="tel"
|
|
|
|
+ placeholder="输入手机号"
|
|
|
|
+ @blur="checkPass('phone')"
|
|
|
|
+ :error-message="errorMsg.phone"
|
|
|
|
+ />
|
|
|
|
+ <van-field
|
|
|
|
+ v-model="userInfo.company"
|
|
|
|
+ class="field"
|
|
|
|
+ :formatter="formatter"
|
|
|
|
+ center
|
|
|
|
+ autosize
|
|
|
|
+ @blur="checkPass('company')"
|
|
|
|
+ type="textarea" rows="1"
|
|
|
|
+ maxlength="50"
|
|
|
|
+ placeholder="输入公司名称"
|
|
|
|
+ :error-message="errorMsg.company"
|
|
|
|
+ />
|
|
</van-cell-group>
|
|
</van-cell-group>
|
|
<div class="tips">
|
|
<div class="tips">
|
|
<p v-for="(item, index) in tipText" :key="index">* {{item}}</p>
|
|
<p v-for="(item, index) in tipText" :key="index">* {{item}}</p>
|
|
@@ -36,7 +80,7 @@
|
|
</div>
|
|
</div>
|
|
<van-cell class="statement" clickable @click="toggleStatementState" center :border="false">
|
|
<van-cell class="statement" clickable @click="toggleStatementState" center :border="false">
|
|
<template #icon>
|
|
<template #icon>
|
|
- <van-checkbox v-model="iAgreee" icon-size="17" checked-color="#2ABED1" ref="iAgreeeCheckbox" />
|
|
|
|
|
|
+ <van-checkbox v-model="iAgree" icon-size="17" checked-color="#2ABED1" ref="iAgreeCheckbox" />
|
|
</template>
|
|
</template>
|
|
<template #title>
|
|
<template #title>
|
|
<p class="state">
|
|
<p class="state">
|
|
@@ -55,7 +99,7 @@
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
import { Component, Vue } from 'vue-property-decorator'
|
|
import { Component, Vue } from 'vue-property-decorator'
|
|
import { Field, Cell, CellGroup, Checkbox, CheckboxGroup } from 'vant'
|
|
import { Field, Cell, CellGroup, Checkbox, CheckboxGroup } from 'vant'
|
|
-import { mapActions } from 'vuex'
|
|
|
|
|
|
+import { mapState, mapMutations, mapActions } from 'vuex'
|
|
import countdownButton from '@/components/common/CountDownButton.vue'
|
|
import countdownButton from '@/components/common/CountDownButton.vue'
|
|
import { inputFocusHideFooter } from '@/utils/globalFunctions'
|
|
import { inputFocusHideFooter } from '@/utils/globalFunctions'
|
|
|
|
|
|
@@ -70,14 +114,32 @@ import { inputFocusHideFooter } from '@/utils/globalFunctions'
|
|
countdownButton
|
|
countdownButton
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ ...mapState('home', {
|
|
|
|
+ buyState: (state: any) => state.buyState
|
|
|
|
+ }),
|
|
|
|
+ ...mapMutations({
|
|
|
|
+ saveBuyState: 'home/saveBuyState',
|
|
|
|
+ clearBuyState: 'home/clearBuyState'
|
|
|
|
+ }),
|
|
...mapActions({
|
|
...mapActions({
|
|
- // getServiceTerms: 'home/getServiceTerms'
|
|
|
|
|
|
+ getUserMsg: 'home/getUserMsg',
|
|
|
|
+ orderSubmit: 'home/orderSubmit',
|
|
|
|
+ sendEmailCode: 'home/sendEmailCode',
|
|
|
|
+ checkEmailCode: 'home/checkEmailCode'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
export default class BuyReport extends Vue {
|
|
export default class BuyReport extends Vue {
|
|
- // protected getServiceTerms!: any
|
|
|
|
|
|
+ protected getUserMsg!: any
|
|
|
|
+ protected orderSubmit!: any
|
|
|
|
+ protected sendEmailCode!: any
|
|
|
|
+ protected checkEmailCode!: any
|
|
|
|
+
|
|
|
|
+ // 保存恢复状态
|
|
|
|
+ protected buyState!: any
|
|
|
|
+ protected saveBuyState!: any
|
|
|
|
+ protected clearBuyState!: any
|
|
|
|
|
|
tipText = [
|
|
tipText = [
|
|
'数据报告将以邮件形式发至您的邮箱',
|
|
'数据报告将以邮件形式发至您的邮箱',
|
|
@@ -87,10 +149,17 @@ export default class BuyReport extends Vue {
|
|
|
|
|
|
// 订单金额等数据
|
|
// 订单金额等数据
|
|
orderInfo = {
|
|
orderInfo = {
|
|
|
|
+ reportId: '',
|
|
price: 123,
|
|
price: 123,
|
|
before_price: 2990
|
|
before_price: 2990
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ originInfo = {
|
|
|
|
+ email: '',
|
|
|
|
+ phone: '',
|
|
|
|
+ company: ''
|
|
|
|
+ }
|
|
|
|
+
|
|
// 用户信息(需要提交)
|
|
// 用户信息(需要提交)
|
|
userInfo = {
|
|
userInfo = {
|
|
email: '',
|
|
email: '',
|
|
@@ -99,8 +168,9 @@ export default class BuyReport extends Vue {
|
|
company: ''
|
|
company: ''
|
|
}
|
|
}
|
|
|
|
|
|
- allRegPass = false
|
|
|
|
- iAgreee = false
|
|
|
|
|
|
+ iAgree = false
|
|
|
|
+ sendedEmail = false
|
|
|
|
+ emailCodePass = false
|
|
|
|
|
|
// 错误提示信息
|
|
// 错误提示信息
|
|
errorMsg = {
|
|
errorMsg = {
|
|
@@ -130,8 +200,40 @@ export default class BuyReport extends Vue {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ get allRegPass () {
|
|
|
|
+ const info = this.userInfo
|
|
|
|
+ const regArr: any = []
|
|
|
|
+ for (const key in info) {
|
|
|
|
+ const r = this.errorMsgMap[key]
|
|
|
|
+ let pass = true
|
|
|
|
+ if (r.reg) {
|
|
|
|
+ // 有正则的就根据正则替换
|
|
|
|
+ pass = r.reg.test(info[key])
|
|
|
|
+ } else {
|
|
|
|
+ // 判断是不是company
|
|
|
|
+ if (key === 'code') {
|
|
|
|
+ pass = this.sendedEmail && this.emailCodePass
|
|
|
|
+ } else if (key === 'company') {
|
|
|
|
+ pass = !!info[key]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // console.log(r, key, pass)
|
|
|
|
+ regArr.push(pass)
|
|
|
|
+ }
|
|
|
|
+ return regArr.indexOf(false) === -1
|
|
|
|
+ }
|
|
|
|
+
|
|
get confirmDisabled () {
|
|
get confirmDisabled () {
|
|
- return !this.iAgreee || !this.allRegPass
|
|
|
|
|
|
+ return !this.iAgree || (!this.allRegPass && this.showSendEmailCode)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ get showSendEmailCode () {
|
|
|
|
+ const oe = this.originInfo.email
|
|
|
|
+ const ue = this.userInfo.email
|
|
|
|
+ if (oe === '' || oe !== ue) {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
}
|
|
}
|
|
|
|
|
|
get sendButtonDisabled () {
|
|
get sendButtonDisabled () {
|
|
@@ -141,20 +243,59 @@ export default class BuyReport extends Vue {
|
|
return !reg.test(email)
|
|
return !reg.test(email)
|
|
}
|
|
}
|
|
|
|
|
|
- toggleStatementState () {
|
|
|
|
- this.iAgreee = !this.iAgreee
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
mounted () {
|
|
mounted () {
|
|
|
|
+ const recover = this.recoverState()
|
|
|
|
+ if (!recover) {
|
|
|
|
+ this.getInfo()
|
|
|
|
+ }
|
|
const inputs: any = document.querySelectorAll('.field .van-field__control')
|
|
const inputs: any = document.querySelectorAll('.field .van-field__control')
|
|
inputFocusHideFooter(inputs, this.$refs.footer)
|
|
inputFocusHideFooter(inputs, this.$refs.footer)
|
|
}
|
|
}
|
|
|
|
|
|
- checkPass (type) {
|
|
|
|
|
|
+ getInfo () {
|
|
|
|
+ const toast = this.$toast.loading({
|
|
|
|
+ message: '加载中...',
|
|
|
|
+ forbidClick: true,
|
|
|
|
+ duration: 0
|
|
|
|
+ })
|
|
|
|
+ // test
|
|
|
|
+ const res = {
|
|
|
|
+ data: {
|
|
|
|
+ email: 'a@qq.com',
|
|
|
|
+ phone: '13200088125',
|
|
|
|
+ company: '金额急急急'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ toast.clear()
|
|
|
|
+ this.originInfo = res.data
|
|
|
|
+ for (const key in res.data) {
|
|
|
|
+ this.userInfo[key] = res.data[key]
|
|
|
|
+ }
|
|
|
|
+ }, 1000)
|
|
|
|
+ // this.getUserMsg().then(res => {
|
|
|
|
+ // toast.clear()
|
|
|
|
+ // if (res.error_code === 0) {
|
|
|
|
+ // this.originInfo = res.data
|
|
|
|
+ // for (const key in res.data) {
|
|
|
|
+ // this.userInfo[key] = res.data[key]
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ formatter (value) {
|
|
|
|
+ return value.replace(/\s+/, '')
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ toggleStatementState () {
|
|
|
|
+ this.iAgree = !this.iAgree
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async checkPass (type) {
|
|
const r = this.errorMsgMap[type]
|
|
const r = this.errorMsgMap[type]
|
|
const info = this.userInfo[type]
|
|
const info = this.userInfo[type]
|
|
// 数据为空不显示校验失败提示,直接认定校验失败
|
|
// 数据为空不显示校验失败提示,直接认定校验失败
|
|
- this.checkAllPass()
|
|
|
|
if (!info) return false
|
|
if (!info) return false
|
|
|
|
|
|
let pass = true
|
|
let pass = true
|
|
@@ -164,7 +305,7 @@ export default class BuyReport extends Vue {
|
|
} else {
|
|
} else {
|
|
// 判断是不是company
|
|
// 判断是不是company
|
|
if (type === 'code') {
|
|
if (type === 'code') {
|
|
- pass = !!info
|
|
|
|
|
|
+ pass = await this.verifyCode()
|
|
} else if (type === 'company') {
|
|
} else if (type === 'company') {
|
|
// 判断是不是company
|
|
// 判断是不是company
|
|
pass = !!info
|
|
pass = !!info
|
|
@@ -179,33 +320,8 @@ export default class BuyReport extends Vue {
|
|
return pass
|
|
return pass
|
|
}
|
|
}
|
|
|
|
|
|
- checkAllPass () {
|
|
|
|
- const info = this.userInfo
|
|
|
|
- const regArr: any = []
|
|
|
|
- for (const key in info) {
|
|
|
|
- const r = this.errorMsgMap[key]
|
|
|
|
- let pass = true
|
|
|
|
- if (r.reg) {
|
|
|
|
- // 有正则的就根据正则替换
|
|
|
|
- pass = r.reg.test(info[key])
|
|
|
|
- } else {
|
|
|
|
- // 判断是不是company
|
|
|
|
- if (key === 'code') {
|
|
|
|
- pass = !!info[key]
|
|
|
|
- } else if (key === 'company') {
|
|
|
|
- pass = !!info[key]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // console.log(r, key, pass)
|
|
|
|
- regArr.push(pass)
|
|
|
|
- }
|
|
|
|
- const f = regArr.indexOf(false) === -1
|
|
|
|
- this.allRegPass = f
|
|
|
|
- return f
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- toServiceTerms (e) {
|
|
|
|
- this.saveBuyState()
|
|
|
|
|
|
+ toServiceTerms () {
|
|
|
|
+ this.saveState()
|
|
// location.href = e.target.href
|
|
// location.href = e.target.href
|
|
}
|
|
}
|
|
|
|
|
|
@@ -214,26 +330,62 @@ export default class BuyReport extends Vue {
|
|
const email = this.userInfo.email
|
|
const email = this.userInfo.email
|
|
const emailPass = reg.test(email)
|
|
const emailPass = reg.test(email)
|
|
if (!emailPass) return
|
|
if (!emailPass) return
|
|
|
|
+ this.sendedEmail = true
|
|
cb && cb()
|
|
cb && cb()
|
|
- console.log('sendCode')
|
|
|
|
|
|
+ this.sendEmailCode({ email: this.userInfo.email })
|
|
}
|
|
}
|
|
|
|
|
|
verifyCode () {
|
|
verifyCode () {
|
|
- console.log('verifyCode')
|
|
|
|
|
|
+ return this.checkEmailCode({ email: this.userInfo.email, emailCode: this.userInfo.code }).then(res => {
|
|
|
|
+ if (res.error_code === 0) {
|
|
|
|
+ if (res.status === 1) {
|
|
|
|
+ // 将错误提示清空
|
|
|
|
+ this.errorMsg.code = ''
|
|
|
|
+ this.emailCodePass = true
|
|
|
|
+ return true
|
|
|
|
+ } else {
|
|
|
|
+ // 给出错误提示
|
|
|
|
+ this.errorMsg.code = this.errorMsgMap.code.text
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
onSubmit () {
|
|
onSubmit () {
|
|
- console.log(JSON.stringify(this.userInfo))
|
|
|
|
|
|
+ const data = {
|
|
|
|
+ email: this.userInfo.email,
|
|
|
|
+ phone: this.userInfo.phone,
|
|
|
|
+ company: this.userInfo.company,
|
|
|
|
+ reportId: this.orderInfo.reportId
|
|
|
|
+ }
|
|
|
|
+ console.log(JSON.stringify(data))
|
|
|
|
+ this.orderSubmit(data)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ recoverState () {
|
|
|
|
+ const buyState = this.buyState()
|
|
|
|
+ if (Object.keys(buyState).length === 0) return false
|
|
|
|
+ for (const key in buyState) {
|
|
|
|
+ this[key] = buyState[key]
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
|
|
|
|
- saveBuyState () {
|
|
|
|
- const JSON = {
|
|
|
|
|
|
+ saveState () {
|
|
|
|
+ const pageState = {
|
|
orderInfo: this.orderInfo,
|
|
orderInfo: this.orderInfo,
|
|
|
|
+ originInfo: this.originInfo,
|
|
userInfo: this.userInfo,
|
|
userInfo: this.userInfo,
|
|
- allRegPass: this.allRegPass,
|
|
|
|
- iAgreee: this.iAgreee,
|
|
|
|
|
|
+ iAgree: this.iAgree,
|
|
|
|
+ sendedEmail: this.sendedEmail,
|
|
|
|
+ emailCodePass: this.emailCodePass,
|
|
errorMsg: this.errorMsg
|
|
errorMsg: this.errorMsg
|
|
}
|
|
}
|
|
|
|
+ console.log(JSON.stringify(pageState))
|
|
|
|
+ this.saveBuyState(pageState)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|