|
@@ -4,35 +4,42 @@ const BindPhoneDirective = {
|
|
inserted(el, binding, vNode) {
|
|
inserted(el, binding, vNode) {
|
|
const { value } = binding
|
|
const { value } = binding
|
|
const vm = vNode.context
|
|
const vm = vNode.context
|
|
- /**
|
|
|
|
- * props: 接受的传参
|
|
|
|
- * pass: 无需校验是否绑定即可进行下一步,场景:金刚区(部分产品需要绑定手机号、部分产品不需要绑定手机号)
|
|
|
|
- * next: 绑定过手机号的下一步操作(必传)
|
|
|
|
- * close: 关闭弹框操作
|
|
|
|
- * bound:弹框绑定完手机号回调操作(大多数场景与next方法逻辑一致,部分场景有额外需求的会不一致,当绑定完成回调与next不一致时,需要传入bound方法)
|
|
|
|
- */
|
|
|
|
|
|
|
|
- el.addEventListener('click', async (event) => {
|
|
|
|
|
|
+ el.isVerified = false
|
|
|
|
+
|
|
|
|
+ const clickHandler = async (event) => {
|
|
|
|
+ if (el.isVerified) return
|
|
const { props = {}, pass, bound, close, next } = value
|
|
const { props = {}, pass, bound, close, next } = value
|
|
|
|
+ /**
|
|
|
|
+ * props: 接受的传参
|
|
|
|
+ * pass: 无需校验是否绑定即可进行下一步,场景:金刚区(部分产品需要绑定手机号、部分产品不需要绑定手机号)
|
|
|
|
+ * next: 绑定过手机号的下一步操作(必传)
|
|
|
|
+ * close: 关闭弹框操作
|
|
|
|
+ * bound:弹框绑定完手机号回调操作(大多数场景与next方法逻辑一致,部分场景有额外需求的会不一致,当绑定完成回调与next不一致时,需要传入bound方法)
|
|
|
|
+ */
|
|
console.log(
|
|
console.log(
|
|
`pass: ${pass}, bound: ${bound},next: ${next}, props: ${JSON.stringify(
|
|
`pass: ${pass}, bound: ${bound},next: ${next}, props: ${JSON.stringify(
|
|
props
|
|
props
|
|
)}`
|
|
)}`
|
|
)
|
|
)
|
|
-
|
|
|
|
- event.stopPropagation()
|
|
|
|
- event.preventDefault()
|
|
|
|
- // 从cookie中获取是否绑定过手机号
|
|
|
|
- const needPhoneBound = Cookies.get('EXPERIENCESIGN') === 'experiencing'
|
|
|
|
- // 无需绑定手机号
|
|
|
|
|
|
+ // 无需校验/无需绑定手机号
|
|
if (typeof pass === 'function') {
|
|
if (typeof pass === 'function') {
|
|
pass()
|
|
pass()
|
|
|
|
+ el.isVerified = true
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 从cookie中获取是否绑定过手机号
|
|
|
|
+ const needPhoneBound = Cookies.get('EXPERIENCESIGN') === 'experiencing'
|
|
// 已绑定过手机号
|
|
// 已绑定过手机号
|
|
if (!needPhoneBound) {
|
|
if (!needPhoneBound) {
|
|
typeof next === 'function' && next()
|
|
typeof next === 'function' && next()
|
|
|
|
+ el.isVerified = true
|
|
|
|
+ return
|
|
} else {
|
|
} else {
|
|
|
|
+ event.stopPropagation()
|
|
|
|
+ event.preventDefault()
|
|
|
|
+ event.stopImmediatePropagation()
|
|
props.visible = true
|
|
props.visible = true
|
|
// 未绑定过手机号
|
|
// 未绑定过手机号
|
|
vm.$bindPhoneDialog({
|
|
vm.$bindPhoneDialog({
|
|
@@ -40,11 +47,7 @@ const BindPhoneDirective = {
|
|
slots: {},
|
|
slots: {},
|
|
on: {
|
|
on: {
|
|
bound: () => {
|
|
bound: () => {
|
|
- if (bound && typeof bound === 'function') {
|
|
|
|
- bound()
|
|
|
|
- } else {
|
|
|
|
- typeof next === 'function' && next()
|
|
|
|
- }
|
|
|
|
|
|
+ el.isVerified = true
|
|
// 绑定完清除cookie
|
|
// 绑定完清除cookie
|
|
Cookies.remove('EXPERIENCESIGN')
|
|
Cookies.remove('EXPERIENCESIGN')
|
|
// 绑定成功埋点
|
|
// 绑定成功埋点
|
|
@@ -54,6 +57,17 @@ const BindPhoneDirective = {
|
|
source: props.name + '-绑定成功'
|
|
source: props.name + '-绑定成功'
|
|
})
|
|
})
|
|
} catch (error) {}
|
|
} catch (error) {}
|
|
|
|
+
|
|
|
|
+ if (bound && typeof bound === 'function') {
|
|
|
|
+ bound()
|
|
|
|
+ } else {
|
|
|
|
+ if (next) {
|
|
|
|
+ typeof next === 'function' && next()
|
|
|
|
+ } else {
|
|
|
|
+ // 没有bound和next方法时,自动触发当前点击dom的click事件(工作台、我的页面不细分唤起,点击任意地方都唤起)
|
|
|
|
+ event.target.click()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
close: () => {
|
|
close: () => {
|
|
if (typeof close === 'function') {
|
|
if (typeof close === 'function') {
|
|
@@ -65,7 +79,13 @@ const BindPhoneDirective = {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+ // 绑定主点击事件
|
|
|
|
+ el.addEventListener('click', clickHandler, true)
|
|
|
|
+ el._clickHandler = clickHandler
|
|
|
|
+ },
|
|
|
|
+ unbind(el) {
|
|
|
|
+ el.removeEventListener('click', el._clickHandler)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|