|
@@ -1,5 +1,11 @@
|
|
|
import { computed, reactive, ref, watch } from 'vue'
|
|
|
-import { requestBehaviorClues, requestGetStaticInfo, requestRetainedCapital } from '@/api/api'
|
|
|
+import {
|
|
|
+ requestBehaviorClues,
|
|
|
+ requestGetStaticInfo,
|
|
|
+ requestRetainedCapital,
|
|
|
+ requestSubmitLeaveInfo
|
|
|
+} from '@/api/api'
|
|
|
+import { getSourceInfo, showToast } from '@/utils'
|
|
|
|
|
|
// pc静态弹窗卡片信息获取
|
|
|
export function useStaticCustomInfo() {
|
|
@@ -32,6 +38,7 @@ export function usePreLeaveInfo(options = {}) {
|
|
|
remark: '',
|
|
|
wxer: '',
|
|
|
phone: '',
|
|
|
+ isCurrentPhone: true,
|
|
|
})
|
|
|
|
|
|
const source = computed(() => props.source)
|
|
@@ -48,6 +55,7 @@ export function usePreLeaveInfo(options = {}) {
|
|
|
const r = await useLeaveInfoRequest({ source: val })
|
|
|
if (r.info) {
|
|
|
configInfo.phone = r.info.phone
|
|
|
+ configInfo.isCurrentPhone = r.info.isCurrentPhone
|
|
|
}
|
|
|
})
|
|
|
watch(() => visible.value, async (val) => {
|
|
@@ -92,6 +100,82 @@ export async function useContactMeLogic(options = {}) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export function usePhoneCheck(options = {}) {
|
|
|
+ const { configInfo, props } = options
|
|
|
+ const phone = ref(configInfo.phone)
|
|
|
+ const source = computed(() => props.source)
|
|
|
+
|
|
|
+ const isLoginPhone = computed(() => configInfo.isCurrentPhone)
|
|
|
+
|
|
|
+ watch(() => configInfo.phone, (val) => {
|
|
|
+ phone.value = val
|
|
|
+ })
|
|
|
+
|
|
|
+ const changePhoneDialog = reactive({
|
|
|
+ show: false,
|
|
|
+ phoneNumber: '',
|
|
|
+ })
|
|
|
+ const successCheckDialog = reactive({
|
|
|
+ show: false,
|
|
|
+ title: '提交成功',
|
|
|
+ confirmButtonText: '我知道了',
|
|
|
+ cancelButtonText: '',
|
|
|
+ contentText: '我们的专属客服会在24小时内尽快与您联系,请注意电话接听。'
|
|
|
+ })
|
|
|
+
|
|
|
+ const confirmContentText = computed(() => {
|
|
|
+ return `专属客服将致电 <span class="highlight-text">${phone.value}</span>,<br />请核对联系电话是否准确`
|
|
|
+ })
|
|
|
+ const confirmPhoneDialog = reactive({
|
|
|
+ show: false,
|
|
|
+ confirmButtonText: '准确,我要提交',
|
|
|
+ cancelButtonText: '有误,我要修改',
|
|
|
+ contentText: confirmContentText,
|
|
|
+ })
|
|
|
+
|
|
|
+ function checkPhonePass(phone) {
|
|
|
+ const reg = /^1[3-9]\d{9}$/
|
|
|
+ return reg.test(phone)
|
|
|
+ }
|
|
|
+
|
|
|
+ async function doConfirmLeave() {
|
|
|
+ const payload = {
|
|
|
+ source: source.value,
|
|
|
+ phone: phone.value,
|
|
|
+ source_desc: '',
|
|
|
+ }
|
|
|
+ const info = getSourceInfo(payload.source)
|
|
|
+ if (info.desc) {
|
|
|
+ payload.source_desc = info.desc
|
|
|
+ }
|
|
|
+
|
|
|
+ requestSubmitLeaveInfo(payload)
|
|
|
+ }
|
|
|
+
|
|
|
+ function contactMe() {
|
|
|
+ const phonePass = checkPhonePass(phone.value)
|
|
|
+ if (!phonePass) {
|
|
|
+ return showToast('联系电话格式不正确')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isLoginPhone.value) {
|
|
|
+ doConfirmLeave()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ confirmPhoneDialog.show = true
|
|
|
+ }
|
|
|
+ doConfirmLeave()
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ phone,
|
|
|
+ changePhoneDialog,
|
|
|
+ successCheckDialog,
|
|
|
+ confirmPhoneDialog,
|
|
|
+ contactMe
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export async function useBehaviorCluesRequest(value) {
|
|
|
const res = await requestBehaviorClues({ source_desc: value })
|
|
|
const { error_code: code, data } = res
|