|
@@ -102,12 +102,10 @@ export default {
|
|
|
immediate: true,
|
|
|
handler(n) {
|
|
|
this.getOrderProductInfo(n, true)
|
|
|
- this.beforeGetUserPower(true)
|
|
|
}
|
|
|
},
|
|
|
schemaKey() {
|
|
|
this.getOrderProductInfo(this.productType)
|
|
|
- this.beforeGetUserPower()
|
|
|
setTimeout(() => {
|
|
|
this.$refs.schemaForm.clearValidate()
|
|
|
}, 0)
|
|
@@ -115,6 +113,7 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
window.form = this
|
|
|
+ this.changeLoading(false)
|
|
|
},
|
|
|
methods: {
|
|
|
...mapMutations('order', [
|
|
@@ -133,7 +132,7 @@ export default {
|
|
|
},
|
|
|
onInput(e) {
|
|
|
this.emitInput(e)
|
|
|
- this.afterInput() // 用于动态修改用户限制选中项
|
|
|
+ this.afterInput() // 用于监听哪些字段做了变动,然后进行一些操作
|
|
|
},
|
|
|
onInitSchema() {
|
|
|
this.$emit('initd')
|
|
@@ -149,7 +148,10 @@ export default {
|
|
|
const r = Object.assign({}, this.value, obj)
|
|
|
this.emitInput(r)
|
|
|
},
|
|
|
- getOrderProductInfo(type, typeChanged) {
|
|
|
+ changeLoading(e) {
|
|
|
+ this.$emit('loading', e)
|
|
|
+ },
|
|
|
+ async getOrderProductInfo(type, typeChanged) {
|
|
|
// rules和schema可以根据productType、productInfo、form生成
|
|
|
const { schemaList, rules, defaultValue, changedFields } = createSchema({
|
|
|
type: type || this.productType,
|
|
@@ -171,8 +173,25 @@ export default {
|
|
|
this.onInitSchema()
|
|
|
// 更新完规则后,刷新规则相关判断
|
|
|
this.dynamicChangeSchema()
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.beforeGetUserPower()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async beforeGetUserPower() {
|
|
|
+ this.changeLoading(true)
|
|
|
+ try {
|
|
|
+ await this.getUserPowerCheck()
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ } finally {
|
|
|
+ this.changeLoading(false)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.dynamicChangeSchema()
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- async beforeGetUserPower(ent = false) {
|
|
|
+ async getUserPowerCheck(ent = false) {
|
|
|
// 判断购买主体是企业还是个人
|
|
|
const { buySubject, accountTel, companyName } = this.pageForm
|
|
|
if (buySubject === 1) {
|
|
@@ -185,13 +204,13 @@ export default {
|
|
|
await this.getUserService()
|
|
|
}
|
|
|
}
|
|
|
- this.afterInput()
|
|
|
},
|
|
|
async getUserService() {
|
|
|
const payload = {
|
|
|
phone: this.pageForm.accountTel,
|
|
|
entName: this.pageForm.companyName,
|
|
|
buySubject: this.pageForm.buySubject + '',
|
|
|
+ service_type: this.value.paymentType - 0, // 1购买 2续费 3升级 4试用
|
|
|
productType: productTypeMap[this.productType],
|
|
|
}
|
|
|
if (!payload.productType) return
|
|
@@ -219,7 +238,11 @@ export default {
|
|
|
needChangeSchema() {
|
|
|
const changedFieldsArr = this.getChangedFields()
|
|
|
const changedFields = changedFieldsArr.join(',')
|
|
|
- if (!changedFields) return true
|
|
|
+ const res = {
|
|
|
+ needChange: true,
|
|
|
+ changedFieldsArr
|
|
|
+ }
|
|
|
+ if (!changedFields) return res
|
|
|
// 能够更新的条件:
|
|
|
// 1. 当前产品需要的字段变更
|
|
|
// 求交集
|
|
@@ -229,9 +252,11 @@ export default {
|
|
|
// 求交集
|
|
|
const needChange = needChangedArr.length !== 0
|
|
|
// 此处规则log不要注释!!!需要通过此log判断在产品类型变更后是否产生了递归调用
|
|
|
- // <主要是this.value字段少 -> this.value 字段多时的情况>
|
|
|
+ // <主要是应对this.value字段少 -> this.value 字段多时的情况>
|
|
|
console.log('是否需要更新schema规则: ', needChange, needChangedArr) // 禁止移除
|
|
|
- return needChange
|
|
|
+ return Object.assign(res, {
|
|
|
+ needChange
|
|
|
+ })
|
|
|
},
|
|
|
// 暂定规则更新
|
|
|
pauseRefreshSchema() {
|
|
@@ -251,11 +276,11 @@ export default {
|
|
|
// 处理并分发各个产品卡片操作的限制
|
|
|
afterInput: debounce(function() {
|
|
|
// 修改某些字段时候才会更新schema
|
|
|
- const needChange = this.needChangeSchema()
|
|
|
+ const { needChange, changedFieldsArr } = this.needChangeSchema()
|
|
|
+ this.onChangedFields(changedFieldsArr)
|
|
|
if (!needChange) return
|
|
|
this.dynamicChangeSchema()
|
|
|
- }, 10),
|
|
|
-
|
|
|
+ }, 50),
|
|
|
getPriceRequest: debounce(async function getPrice(p) {
|
|
|
const commonP = {
|
|
|
productInfo: cloneDeep(this.thisProductInfoListItem),
|
|
@@ -267,8 +292,12 @@ export default {
|
|
|
this.$store.dispatch('order/getPrice', commonP).then(r => {
|
|
|
// 刷新xx组件价格
|
|
|
const key = schemaKeyMap.contractAmount
|
|
|
+ let standardMoney = ''
|
|
|
+ if (r) {
|
|
|
+ standardMoney = r / 100
|
|
|
+ }
|
|
|
this.refreshValue({
|
|
|
- [key]: Object.assign({}, this.value[key], { standardMoney: r / 100 })
|
|
|
+ [key]: Object.assign({}, this.value[key], { standardMoney })
|
|
|
})
|
|
|
this.startRefreshSchema()
|
|
|
})
|
|
@@ -301,30 +330,34 @@ export default {
|
|
|
},
|
|
|
// 工具:检查是否可以升级,并动态禁用启用付费类型相关选项
|
|
|
utilCheckAndEnabledUpgradeRenew() {
|
|
|
- let canRenewUpgrade = false
|
|
|
+ let hasAvailableService = false
|
|
|
const ma = this.getSchemaItemWithKey(schemaKeyMap.payment)
|
|
|
if (this.thisProductInfoListItem?.productUserService) {
|
|
|
const us = this.thisProductInfoListItem.productUserService
|
|
|
if (Array.isArray(us.serviceArrMap) && us.serviceArrMap.length > 0) {
|
|
|
+ // 有生效订单,且没过期,先禁用购买选项,并更改默认值为续费
|
|
|
if (us.serviceArrMap[0].vipExist) {
|
|
|
// 可以续费
|
|
|
- canRenewUpgrade = true
|
|
|
+ hasAvailableService = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 修改options
|
|
|
+ // 启用续费升级,禁用购买试用
|
|
|
ma.props.options.forEach(item => {
|
|
|
// 续费或升级
|
|
|
if (item.value === 2 || item.value === 3) {
|
|
|
- item.disabled = !canRenewUpgrade
|
|
|
+ item.disabled = !hasAvailableService
|
|
|
+ } else {
|
|
|
+ item.disabled = hasAvailableService
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// 如果被禁用的项被选中,则自动调整选中项
|
|
|
const changed = this.utilChangeAvailablePayment()
|
|
|
return {
|
|
|
- canRenewUpgrade,
|
|
|
+ hasAvailableService,
|
|
|
changed,
|
|
|
}
|
|
|
},
|
|
@@ -350,7 +383,7 @@ export default {
|
|
|
// 1.1 个人: serviceArrMap不能位空,且,vipExist为true。此时可以续费(升级),否则不可以续费(升级)
|
|
|
this.utilCheckAndEnabledUpgradeRenew()
|
|
|
} else if (buySubject === 2) {
|
|
|
- // 1.2 企业: 选择关联订单后再次查询。然后做1.1相同判断
|
|
|
+ // 1.2 企业: 选择关联订单后再次查询。然后固定权益
|
|
|
// 此处判断在关联订单选择完成后判断
|
|
|
}
|
|
|
}
|
|
@@ -376,6 +409,7 @@ export default {
|
|
|
} else {
|
|
|
relatedOrders.required = false
|
|
|
}
|
|
|
+ // this.$set(relatedOrders.props, 'required', relatedOrders.required)
|
|
|
relatedOrders.props.required = relatedOrders.required
|
|
|
|
|
|
this.$set(relatedOrders.hooks, 'confirm', async (p) => {
|
|
@@ -386,7 +420,7 @@ export default {
|
|
|
if (buySubject === 2) {
|
|
|
// 重新调用
|
|
|
await this.getUserService()
|
|
|
- this.utilCheckAndEnabledUpgradeRenew()
|
|
|
+ // this.utilCheckAndEnabledUpgradeRenew()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -628,6 +662,11 @@ export default {
|
|
|
// const { [schemaKeyMap.payment]: payment } = this.value
|
|
|
// const ma = this.getSchemaItemWithKey(schemaKeyMap.payment)
|
|
|
},
|
|
|
+ onChangedFields(changedArr) {
|
|
|
+ // 付费类型
|
|
|
+ if (changedArr.includes(schemaKeyMap.payment)) {}
|
|
|
+ console.log('以下字段变更了:', changedArr)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|