|
@@ -0,0 +1,806 @@
|
|
|
+<template>
|
|
|
+ <div class="subscribe-guide">
|
|
|
+ <div class="j-header">
|
|
|
+ <div class="step-container">
|
|
|
+ <van-steps :active="active">
|
|
|
+ <van-step v-for="(item, index) in steps" :key="index">{{
|
|
|
+ item.title
|
|
|
+ }}</van-step>
|
|
|
+ </van-steps>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="j-main" v-show="active === 0">
|
|
|
+ <div class="region-container">
|
|
|
+ <div class="region-header flex flex-items-center">
|
|
|
+ <span class="module-title">请选择关注地区</span>
|
|
|
+ <span class="module-note" v-if="isFree && someInfo.areaCount === 1"
|
|
|
+ >(免费用户仅支持订阅1个省)</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="region-content">
|
|
|
+ <!-- 免费用户 -->
|
|
|
+ <div class="free-content" v-if="isFree && someInfo.areaCount === 1">
|
|
|
+ <CheckboxGroup
|
|
|
+ v-model="freeSelectedProvince"
|
|
|
+ :options="provinceList"
|
|
|
+ :config="checkboxConfig"
|
|
|
+ @change="onChangeCheckbox"
|
|
|
+ >
|
|
|
+ </CheckboxGroup>
|
|
|
+ <div class="text-center other-province" v-show="!expand">
|
|
|
+ <span @click="onExpandArea">其他地区</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 付费用户、省份订阅包用户 -->
|
|
|
+ <div class="vip-content" v-else>
|
|
|
+ <div class="selected-province">
|
|
|
+ <span
|
|
|
+ class="selected-province-item"
|
|
|
+ :key="aIndex"
|
|
|
+ v-for="(area, aIndex) in flatAreaResult"
|
|
|
+ >
|
|
|
+ {{ area }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button
|
|
|
+ class="j-button-cancel j-button-choose"
|
|
|
+ @click="onChangeArea"
|
|
|
+ >
|
|
|
+ {{ flatAreaResult.length ? '继续' : '请' }}选择地区
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="j-main" v-show="active === 1">
|
|
|
+ <div class="keywords-container">
|
|
|
+ <div class="already-selected">
|
|
|
+ <div class="flex flex-(justify-between items-center)">
|
|
|
+ <span class="module-title"
|
|
|
+ >您关注的地区({{ flatAreaResult.length }})</span
|
|
|
+ >
|
|
|
+ <span class="module-action" @click="onEditArea">修改</span>
|
|
|
+ </div>
|
|
|
+ <div style="position: relative">
|
|
|
+ <div class="selected-province no-wrap">
|
|
|
+ <span
|
|
|
+ class="selected-province-item"
|
|
|
+ :key="aIndex"
|
|
|
+ v-for="(area, aIndex) in flatAreaResult"
|
|
|
+ >
|
|
|
+ {{ area }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div class="more-placeholder">...</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="keywords-content">
|
|
|
+ <RecommendedWords
|
|
|
+ v-model="someInfo.key"
|
|
|
+ :vSwitch="vSwitch"
|
|
|
+ :maxlength="keyMaxLength"
|
|
|
+ >
|
|
|
+ <div slot="header" class="flex">
|
|
|
+ <span class="module-title"
|
|
|
+ >请设置主营产品({{ someInfo.key.length }}/{{
|
|
|
+ keyMaxLength
|
|
|
+ }})</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </RecommendedWords>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="j-footer">
|
|
|
+ <div class="j-button-group" :class="{ height40: active === 1 }">
|
|
|
+ <button
|
|
|
+ v-show="active === 0"
|
|
|
+ @click="nextHandle"
|
|
|
+ class="j-button-confirm"
|
|
|
+ :class="{ opacity50: !nextDisabled }"
|
|
|
+ >
|
|
|
+ 下一步
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-show="active === 1"
|
|
|
+ @click="setMore"
|
|
|
+ class="j-button-cancel"
|
|
|
+ :class="{ opacity50: !finishDisabled }"
|
|
|
+ >
|
|
|
+ 设置更多条件
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-show="active === 1"
|
|
|
+ @click="onFinish"
|
|
|
+ class="j-button-confirm"
|
|
|
+ :class="{ opacity50: !finishDisabled }"
|
|
|
+ >
|
|
|
+ 完成,查看商机
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <van-popup
|
|
|
+ class="fix-pop-height"
|
|
|
+ v-model="popup.area"
|
|
|
+ round
|
|
|
+ position="bottom"
|
|
|
+ :safe-area-inset-bottom="true"
|
|
|
+ :close-on-popstate="true"
|
|
|
+ get-container="body"
|
|
|
+ :lazy-render="false"
|
|
|
+ :style="{ 'max-height': '80%' }"
|
|
|
+ >
|
|
|
+ <PopupLayout title="地区选择" @closeIconClick="popup.area = false">
|
|
|
+ <div class="area-result">
|
|
|
+ <span>可选:</span>
|
|
|
+ <span v-html="optionalAreaText"></span>
|
|
|
+ <span>已选:</span>
|
|
|
+ <span v-html="selectedAreaText"></span>
|
|
|
+ </div>
|
|
|
+ <AreaCitySidebar
|
|
|
+ class="area-city-sidebar"
|
|
|
+ :canEmptySelected="true"
|
|
|
+ :tagTextOnlySelectedCount="true"
|
|
|
+ :disabledCitySelect="false"
|
|
|
+ :useProvinceCitySplit="true"
|
|
|
+ v-model="vipSelectedProvince"
|
|
|
+ :before-change="areaExceedLimit"
|
|
|
+ ref="areaThreeSidebar"
|
|
|
+ ></AreaCitySidebar>
|
|
|
+ <div slot="footer">
|
|
|
+ <div class="j-button-group height40">
|
|
|
+ <button class="j-button-cancel" @click="popupReset('area')">
|
|
|
+ 重置
|
|
|
+ </button>
|
|
|
+ <button class="j-button-confirm" @click="popupConfirm('area')">
|
|
|
+ 确定
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </PopupLayout>
|
|
|
+ </van-popup>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters, mapActions } from 'vuex'
|
|
|
+import { Sticky, Steps, Step, Popup, Field } from 'vant'
|
|
|
+import { CheckboxGroup } from '@/ui'
|
|
|
+import { onlyProvinceList } from '@/data/selector'
|
|
|
+import PopupLayout from '@/components/common/PopupLayout'
|
|
|
+import AreaCitySidebar from '@/components/selector/area-three-sidebar/index'
|
|
|
+import RecommendedWords from '@/components/subscribe/RecommendedWords'
|
|
|
+import { mixinHeader } from '@/utils/mixins/header'
|
|
|
+import { pushHistoryState } from '@/utils/mixins/pushState'
|
|
|
+import {
|
|
|
+ getUserSubscribeSomeInfo,
|
|
|
+ saveSubscribeGuide,
|
|
|
+ getMySelectEntInfo,
|
|
|
+ getUserRule
|
|
|
+} from '@/api/modules'
|
|
|
+import { openAppOrWxPage, openLinkOfOther } from '@/utils'
|
|
|
+import { LINKS } from '@/data'
|
|
|
+export default {
|
|
|
+ name: 'SubscribeGuide',
|
|
|
+ mixins: [mixinHeader, pushHistoryState],
|
|
|
+ components: {
|
|
|
+ [Sticky.name]: Sticky,
|
|
|
+ [Steps.name]: Steps,
|
|
|
+ [Step.name]: Step,
|
|
|
+ [Popup.name]: Popup,
|
|
|
+ [Field.name]: Field,
|
|
|
+ CheckboxGroup,
|
|
|
+ PopupLayout,
|
|
|
+ AreaCitySidebar,
|
|
|
+ RecommendedWords
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ active: 0,
|
|
|
+ steps: [
|
|
|
+ { title: '选择关注地区' },
|
|
|
+ { title: '设置主营产品' },
|
|
|
+ { title: '查看商机' }
|
|
|
+ ],
|
|
|
+ checkboxConfig: {
|
|
|
+ multiple: false,
|
|
|
+ icon: true
|
|
|
+ },
|
|
|
+ expand: false,
|
|
|
+ freeSelectedProvince: [],
|
|
|
+ vipSelectedProvince: -1,
|
|
|
+ popup: {
|
|
|
+ area: false
|
|
|
+ },
|
|
|
+ someInfo: {
|
|
|
+ areaCount: 0,
|
|
|
+ area: {},
|
|
|
+ district: {},
|
|
|
+ key: []
|
|
|
+ },
|
|
|
+ flatAreaResult: [],
|
|
|
+ app_switch: false,
|
|
|
+ canSetArea: true,
|
|
|
+ pageLayoutConf: {
|
|
|
+ onClickLeft: this.onClickLeft
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters('user', [
|
|
|
+ 'isFree',
|
|
|
+ 'restfulApiUserTypeWitchVSwitch',
|
|
|
+ 'vSwitch'
|
|
|
+ ]),
|
|
|
+ provinceList() {
|
|
|
+ return this.expand ? onlyProvinceList : onlyProvinceList.slice(0, 12)
|
|
|
+ },
|
|
|
+ nextDisabled() {
|
|
|
+ return (
|
|
|
+ this.active === 0 &&
|
|
|
+ (this.freeSelectedProvince.length || this.vipSelectedProvince !== -1)
|
|
|
+ )
|
|
|
+ },
|
|
|
+ finishDisabled() {
|
|
|
+ return (
|
|
|
+ this.active === 1 &&
|
|
|
+ this.someInfo.key.length > 0 &&
|
|
|
+ this.flatAreaResult.length > 0
|
|
|
+ )
|
|
|
+ },
|
|
|
+ // 可选地区
|
|
|
+ optionalAreaText() {
|
|
|
+ const { areaCount } = this.someInfo
|
|
|
+ if (areaCount === -1) {
|
|
|
+ return '全国,'
|
|
|
+ } else {
|
|
|
+ return `<i class="highlight-text">${areaCount}</i>个省,`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 已选地区
|
|
|
+ selectedAreaText() {
|
|
|
+ const vipSelectedProvince = this.vipSelectedProvince
|
|
|
+ if (!vipSelectedProvince || vipSelectedProvince === -1) {
|
|
|
+ return '<i class="highlight-text">0</i>个省'
|
|
|
+ } else {
|
|
|
+ if (Object.keys(vipSelectedProvince).length === 0) {
|
|
|
+ return '全国'
|
|
|
+ } else {
|
|
|
+ return `<i class="highlight-text">${
|
|
|
+ Object.keys(vipSelectedProvince).length
|
|
|
+ }</i>个省`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ keyMaxLength() {
|
|
|
+ // 免费和省份订阅包用户为10,超级订阅、大会员、商机管理为300
|
|
|
+ const vSwitch = this.vSwitch
|
|
|
+ if (vSwitch === 's' || vSwitch === 'm' || vSwitch === 'v') {
|
|
|
+ return 300
|
|
|
+ } else {
|
|
|
+ return 10
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ await this.userVipSwitchState()
|
|
|
+ this.getUserSubscribeSomeInfo()
|
|
|
+ this.getAppSwitchStatus()
|
|
|
+ await this.isCanEditArea()
|
|
|
+ this.pushHistoryState()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions('user', ['userVipSwitchState']),
|
|
|
+ popStateEvent() {
|
|
|
+ this.$router.replace('/tabbar/home')
|
|
|
+ },
|
|
|
+ onClickLeft() {
|
|
|
+ this.$router.replace('/tabbar/home')
|
|
|
+ },
|
|
|
+ // 获取用户订阅信息
|
|
|
+ async getUserSubscribeSomeInfo() {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ data = {},
|
|
|
+ error_code: code = 0,
|
|
|
+ error_msg: msg
|
|
|
+ } = await getUserSubscribeSomeInfo(this.restfulApiUserTypeWitchVSwitch)
|
|
|
+ if (code === 0 && data) {
|
|
|
+ const { subsetinfo: subInfo } = data
|
|
|
+ this.someInfo.areaCount = subInfo?.areacount
|
|
|
+ this.someInfo.area = subInfo?.area
|
|
|
+ this.someInfo.district = subInfo?.district
|
|
|
+ this.someInfo.key = subInfo?.key || []
|
|
|
+ // 免费用户且不是省份订阅包用户(areacount=1是免费;大于1是省份订阅包)
|
|
|
+ if (this.isFree && subInfo?.areacount === 1) {
|
|
|
+ this.freeSelectedProvince = subInfo?.area
|
|
|
+ ? Object.keys(JSON.parse(subInfo?.area))
|
|
|
+ : []
|
|
|
+ this.flatAreaResult = this.freeSelectedProvince
|
|
|
+ } else {
|
|
|
+ // 付费、省份订阅包用户
|
|
|
+ const area = subInfo?.area ? JSON.parse(subInfo?.area) : ''
|
|
|
+ const district = subInfo?.district
|
|
|
+ ? JSON.parse(subInfo?.district)
|
|
|
+ : ''
|
|
|
+ this.vipSelectedProvince = this.formatRegionLevel2ToLevel3(
|
|
|
+ area,
|
|
|
+ district
|
|
|
+ )
|
|
|
+ this.getFlatAreaResult(this.vipSelectedProvince)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error(msg)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ } finally {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 企业分发是否可以修改地区
|
|
|
+ async isCanEditArea() {
|
|
|
+ const { data } = await getMySelectEntInfo()
|
|
|
+ const { vip_power, member_power, user_power } = data
|
|
|
+ if (vip_power === 1 || member_power === 1 || user_power === 1) {
|
|
|
+ const { data: noSet } = await getUserRule()
|
|
|
+ if (noSet) {
|
|
|
+ this.canSetArea = false
|
|
|
+ } else {
|
|
|
+ this.canSetArea = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onExpandArea() {
|
|
|
+ this.expand = true
|
|
|
+ },
|
|
|
+ nextHandle() {
|
|
|
+ if (!this.nextDisabled) return this.$toast('请选择关注地区')
|
|
|
+ const isFreeEmpty = this.isFree && this.freeSelectedProvince.length === 0
|
|
|
+ const vipFreeEmpty = !this.isFree && !this.vipSelectedProvince
|
|
|
+ if (this.active === 0) {
|
|
|
+ if (isFreeEmpty || vipFreeEmpty) {
|
|
|
+ this.$toast('请选择关注地区')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.active = 1
|
|
|
+ if (this.flatAreaResult.length > 0) {
|
|
|
+ this.calcRegionTagStyle()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onChangeCheckbox(val) {
|
|
|
+ this.flatAreaResult = val
|
|
|
+ },
|
|
|
+ getFlatAreaResult() {
|
|
|
+ const areaMap = this.vipSelectedProvince
|
|
|
+ const result = []
|
|
|
+ if (areaMap === -1) {
|
|
|
+ this.flatAreaResult = []
|
|
|
+ } else {
|
|
|
+ if (Object.keys(areaMap).length) {
|
|
|
+ for (const key in areaMap) {
|
|
|
+ if (Object.keys(areaMap[key]).length === 0) {
|
|
|
+ result.push(key)
|
|
|
+ } else {
|
|
|
+ const cityMap = areaMap[key]
|
|
|
+ for (const cKey in cityMap) {
|
|
|
+ if (Object.keys(cityMap[cKey]).length === 0) {
|
|
|
+ result.push(cKey)
|
|
|
+ } else {
|
|
|
+ result.push(...cityMap[cKey])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Object.keys(areaMap).length === 0 ? result.push('全国') : ''
|
|
|
+ }
|
|
|
+ this.flatAreaResult = result
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onChangeArea() {
|
|
|
+ if (!this.canSetArea) {
|
|
|
+ return this.$dialog
|
|
|
+ .alert({
|
|
|
+ title: '不支持修改区域',
|
|
|
+ message: '如需修改区域,请联系企业管理员修改分发设置区域。',
|
|
|
+ className: 'j-confirm-dialog',
|
|
|
+ confirmButtonText: '我知道了'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // on close
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.popup.area = true
|
|
|
+ },
|
|
|
+ popupReset() {
|
|
|
+ this.vipSelectedProvince = -1
|
|
|
+ },
|
|
|
+ popupConfirm() {
|
|
|
+ this.popup.area = false
|
|
|
+ this.getFlatAreaResult()
|
|
|
+ },
|
|
|
+ // 超出省份提示
|
|
|
+ areaExceedLimit(parent, child) {
|
|
|
+ const { areaCount } = this.someInfo
|
|
|
+ const selectedCount =
|
|
|
+ this.vipSelectedProvince !== -1
|
|
|
+ ? Object.keys(this.vipSelectedProvince).length
|
|
|
+ : 0
|
|
|
+ // 全国(无限制)
|
|
|
+ if (areaCount < 0) {
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ // 非全国(省份有限制)
|
|
|
+ if (parent.parentName && parent.parentName === '全国') {
|
|
|
+ this.$toast(`超出可选省份数量,\n可选${areaCount}个省`)
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ if (selectedCount >= areaCount) {
|
|
|
+ // 已选择过的省份列表
|
|
|
+ const selectedProvinceList = []
|
|
|
+ const sourceFirstCount =
|
|
|
+ this.$refs.areaThreeSidebar.sourceFirstCount || []
|
|
|
+ for (const key in sourceFirstCount) {
|
|
|
+ selectedProvinceList.push(key)
|
|
|
+ }
|
|
|
+ // 已经选中过的可勾选掉
|
|
|
+ if (
|
|
|
+ parent.parentName &&
|
|
|
+ selectedProvinceList.indexOf(parent.parentName) > -1
|
|
|
+ ) {
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ this.$toast(`超出可选省份数量,\n可选${areaCount}个省`)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取app总开关状态
|
|
|
+ getAppSwitchStatus() {
|
|
|
+ if (this.$env.platform === 'app') {
|
|
|
+ if (
|
|
|
+ JyObj.checkNoticePermission() === 1 ||
|
|
|
+ JyObj.checkNoticePermission() === '1'
|
|
|
+ ) {
|
|
|
+ this.app_switch = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onEditArea() {
|
|
|
+ this.active = 0
|
|
|
+ },
|
|
|
+ // 设置更多条件
|
|
|
+ setMore() {
|
|
|
+ this.saveSubscribeGuide(() => {
|
|
|
+ if (this.vSwitch === 's') {
|
|
|
+ openLinkOfOther(
|
|
|
+ '/page_entniche_new/page/subsetting/sub_entrance.html',
|
|
|
+ { type: 'replace' }
|
|
|
+ )
|
|
|
+ } else if (this.vSwitch === 'v' || this.vSwitch === 'm') {
|
|
|
+ // 超级订阅/大会员
|
|
|
+ openAppOrWxPage(LINKS.订阅管理页面, {
|
|
|
+ query: {
|
|
|
+ vSwitch: this.vSwitch
|
|
|
+ },
|
|
|
+ type: 'replace'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ openAppOrWxPage(LINKS.订阅管理页面, { type: 'replace' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 完成
|
|
|
+ onFinish() {
|
|
|
+ this.saveSubscribeGuide(() => {
|
|
|
+ this.$router.replace('/tabbar/subscribe')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 完成订阅
|
|
|
+ async saveSubscribeGuide(callback) {
|
|
|
+ if (!this.finishDisabled) {
|
|
|
+ return this.$toast('请先设置主营产品')
|
|
|
+ }
|
|
|
+ const areParams =
|
|
|
+ this.vSwitch === 'f'
|
|
|
+ ? this.formatArrayToMap(this.freeSelectedProvince)
|
|
|
+ : this.formatRegionLevel3ToLevel2(this.vipSelectedProvince)
|
|
|
+ const { area, district } = areParams
|
|
|
+ const params = {
|
|
|
+ area: area ? JSON.stringify(area) : '',
|
|
|
+ district: district ? JSON.stringify(district) : '',
|
|
|
+ keywords: this.someInfo.key,
|
|
|
+ app_switch: this.app_switch
|
|
|
+ }
|
|
|
+ const loading = this.$toast.loading({
|
|
|
+ message: '订阅中...',
|
|
|
+ forbidClick: true
|
|
|
+ })
|
|
|
+ const { error_code: code, error_msg: msg } = await saveSubscribeGuide(
|
|
|
+ this.restfulApiUserTypeWitchVSwitch,
|
|
|
+ params
|
|
|
+ )
|
|
|
+ if (code === 0) {
|
|
|
+ window.history.replaceState(
|
|
|
+ '',
|
|
|
+ '剑鱼标讯官网 - 全国招标采购大数据平台',
|
|
|
+ '/jy_mobile/tabbar/home'
|
|
|
+ )
|
|
|
+ loading.clear()
|
|
|
+ setTimeout(() => {
|
|
|
+ callback && callback()
|
|
|
+ }, 200)
|
|
|
+ } else {
|
|
|
+ this.$toast(msg.replace(/[^\u4E00-\u9FA5]/g, ''))
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 动态隐藏已修改地区超出一行的元素
|
|
|
+ calcRegionTagStyle() {
|
|
|
+ const parent = document.querySelector(
|
|
|
+ '.already-selected .selected-province'
|
|
|
+ )
|
|
|
+ // parent.classList.add('no-wrap')
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const position = document.querySelector('.more-placeholder')
|
|
|
+ const { left: pLeft } = position.getBoundingClientRect()
|
|
|
+ const allTags = parent.querySelectorAll('.selected-province-item')
|
|
|
+ position.classList.remove('opacity0')
|
|
|
+ const hiddenTags = []
|
|
|
+ allTags.forEach((v) => {
|
|
|
+ v.classList.remove('hidden')
|
|
|
+ const { right } = v.getBoundingClientRect()
|
|
|
+ if (right > pLeft) {
|
|
|
+ v.classList.add('hidden')
|
|
|
+ hiddenTags.push(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const hasHidden = hiddenTags.includes(true)
|
|
|
+ // 如果没用隐藏元素即为没有超出一行 则隐藏...占位元素
|
|
|
+ if (!hasHidden) {
|
|
|
+ position.classList.add('opacity0')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ formatArrayToMap(array) {
|
|
|
+ if (!array || array.length === 0) return
|
|
|
+ const areaStr = array.toString()
|
|
|
+ const obj = {}
|
|
|
+ obj[areaStr] = []
|
|
|
+ return {
|
|
|
+ area: obj,
|
|
|
+ district: undefined
|
|
|
+ }
|
|
|
+ },
|
|
|
+ formatRegionLevel3ToLevel2(regionMap) {
|
|
|
+ if (regionMap === -1 || !regionMap) return
|
|
|
+ let area = {}
|
|
|
+ const district = {}
|
|
|
+ if (Object.keys(regionMap).length === 0) {
|
|
|
+ area = {}
|
|
|
+ } else {
|
|
|
+ for (const key in regionMap) {
|
|
|
+ if (Object.keys(regionMap[key]).length === 0) {
|
|
|
+ area[key] = []
|
|
|
+ } else {
|
|
|
+ const cities = regionMap[key]
|
|
|
+ const cityArr = []
|
|
|
+ for (const city in cities) {
|
|
|
+ cityArr.push(city)
|
|
|
+ area[key] = cityArr
|
|
|
+ if (cities[city].length > 0) {
|
|
|
+ district[city] = cities[city]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { area, district }
|
|
|
+ },
|
|
|
+ formatRegionLevel2ToLevel3(area, district) {
|
|
|
+ if (!area) return -1
|
|
|
+ // 原二级数据结构为{福建:['福州', '厦门', '宁德']}
|
|
|
+ // 现数据结构为三级 需进行处理
|
|
|
+ if (Object.keys(area).length > 0) {
|
|
|
+ const obj = {}
|
|
|
+ for (const province in area) {
|
|
|
+ let cityMap = {}
|
|
|
+ if (Array.isArray(area[province])) {
|
|
|
+ area[province].forEach((city) => {
|
|
|
+ for (const d in district) {
|
|
|
+ if (d === city) {
|
|
|
+ cityMap[city] = district[d]
|
|
|
+ } else {
|
|
|
+ cityMap[city] = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ cityMap = area[province]
|
|
|
+ }
|
|
|
+ obj[province] = cityMap
|
|
|
+ }
|
|
|
+ return obj
|
|
|
+ } else {
|
|
|
+ return area
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.area-result {
|
|
|
+ padding: 0 16px 8px;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 24px;
|
|
|
+ color: #5f5e64;
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.subscribe-guide {
|
|
|
+ .hidden {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
+ .no-wrap {
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+ .opacity0 {
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+ .step-container {
|
|
|
+ padding: 12px 64px;
|
|
|
+ background: #fff;
|
|
|
+ }
|
|
|
+ .module-title {
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 24px;
|
|
|
+ color: #171826;
|
|
|
+ }
|
|
|
+ .module-note {
|
|
|
+ font-size: 12px;
|
|
|
+ line-height: 24px;
|
|
|
+ color: #5f5e64;
|
|
|
+ }
|
|
|
+ .module-action {
|
|
|
+ flex-shrink: 0;
|
|
|
+ color: $color_main;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 20px;
|
|
|
+ }
|
|
|
+ .region-container {
|
|
|
+ margin: 12px;
|
|
|
+ padding: 12px;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 8px;
|
|
|
+ .region-header {
|
|
|
+ padding-bottom: 6px;
|
|
|
+ }
|
|
|
+ .other-province {
|
|
|
+ margin-top: 6px;
|
|
|
+ color: $color_main;
|
|
|
+ }
|
|
|
+ .j-button-choose {
|
|
|
+ height: 36px;
|
|
|
+ margin-top: 6px;
|
|
|
+ color: $color_main;
|
|
|
+ border: 1px solid $color_main;
|
|
|
+ background: transparent;
|
|
|
+ border-radius: 4px;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep {
|
|
|
+ .jy-checkbox-group .jy-checkbox {
|
|
|
+ width: calc((100% - 24px) / 3);
|
|
|
+ margin-right: 12px;
|
|
|
+ text-align: center;
|
|
|
+ &:nth-child(3n) {
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .keywords-container {
|
|
|
+ .already-selected {
|
|
|
+ margin: 12px;
|
|
|
+ padding: 12px;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+ .keyword-input {
|
|
|
+ margin-top: 12px;
|
|
|
+ }
|
|
|
+ .more-placeholder {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 50%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 28px;
|
|
|
+ height: 28px;
|
|
|
+ background: linear-gradient(#e1fdff, #deefff00);
|
|
|
+ border: 1px solid rgba(0, 0, 0, 0.05);
|
|
|
+ color: #5f5e64;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 20px;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .selected-province-item {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 4px 8px;
|
|
|
+ margin: 6px 12px 6px 0;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 20px;
|
|
|
+ color: #5f5e64;
|
|
|
+ border-radius: 2px;
|
|
|
+ background: linear-gradient(#e1fdff, #deefff00);
|
|
|
+ border: 1px solid rgba(0, 0, 0, 0.05);
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep {
|
|
|
+ .van-steps {
|
|
|
+ overflow: unset;
|
|
|
+ }
|
|
|
+ .van-steps--horizontal {
|
|
|
+ padding: 5px 0;
|
|
|
+ }
|
|
|
+ .van-steps__items {
|
|
|
+ padding-bottom: 12px;
|
|
|
+ }
|
|
|
+ .van-step__title {
|
|
|
+ position: absolute;
|
|
|
+ top: 10px;
|
|
|
+ white-space: nowrap;
|
|
|
+ line-height: 18px;
|
|
|
+ }
|
|
|
+ .van-step__line {
|
|
|
+ top: 0;
|
|
|
+ }
|
|
|
+ .van-step__circle-container {
|
|
|
+ top: 0;
|
|
|
+ left: unset;
|
|
|
+ padding: 0 2px;
|
|
|
+ }
|
|
|
+ .van-step__circle {
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
+ background: #e6e6e6;
|
|
|
+ }
|
|
|
+ .van-step--horizontal:first-child .van-step__title {
|
|
|
+ left: -28px;
|
|
|
+ }
|
|
|
+ .van-step:last-child .van-step__title {
|
|
|
+ right: -24px;
|
|
|
+ }
|
|
|
+ .van-step__icon--active,
|
|
|
+ .van-step__title--active,
|
|
|
+ .van-step__icon--finish,
|
|
|
+ .van-step__title--finish,
|
|
|
+ .van-step--finish {
|
|
|
+ color: $color_main;
|
|
|
+ }
|
|
|
+ .van-step--finish .van-step__circle,
|
|
|
+ .van-step--finish .van-step__line {
|
|
|
+ background: $color_main;
|
|
|
+ }
|
|
|
+ .van-step__icon--active {
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
+ background: $color_main;
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ .van-icon-checked {
|
|
|
+ &::before {
|
|
|
+ content: '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|