|
|
@@ -2,6 +2,7 @@
|
|
|
店铺分类页(合并花材 + 花束)
|
|
|
用途:商城消费者在一个页面浏览花材/花束分类、公告、广告与商品;
|
|
|
顶部搜索框点搜索/键盘确认后跳转商品列表页,并带上 searchText 关键词
|
|
|
+ 未登录:可浏览分类与商品列表,不弹登录;公告详情/列表、加购与去结算弹 wangCg
|
|
|
路由:pages/home/shop-category?account=xxx&hdId=xxx
|
|
|
-->
|
|
|
<template>
|
|
|
@@ -230,10 +231,10 @@
|
|
|
:offVerifyRepertory="true"
|
|
|
:bigCount="getSelectItemById(productItem.id, activeItemClassId).bigCount"
|
|
|
:smallCount="getSelectItemById(productItem.id, activeItemClassId).smallCount"
|
|
|
- @customNum="customNum"
|
|
|
- @add="addEvent"
|
|
|
- @addOneEvent="addCustomNumEvent"
|
|
|
- @del="delEvent"
|
|
|
+ @customNum="onItemCustomNum"
|
|
|
+ @add="onItemAdd"
|
|
|
+ @addOneEvent="onItemAddOne"
|
|
|
+ @del="onItemDel"
|
|
|
@showBigCover="showItemBigCover"
|
|
|
/>
|
|
|
</view>
|
|
|
@@ -332,18 +333,23 @@
|
|
|
</view>
|
|
|
|
|
|
<shop-tab-bar current="category" :account="shopAccount" :hd-id="hdId" :cart-count="cartBadgeCount" />
|
|
|
- <wangCg :loginStyle.sync="globalLoginStyle" @goToLogin="loginTo" @loginSuccess="loginSuccess" />
|
|
|
+ <!-- 加购/结算/公告等需登录时按需弹出;默认隐藏不影响浏览 -->
|
|
|
+ <wangCg
|
|
|
+ :loginStyle.sync="cartLoginStyle"
|
|
|
+ @goToLogin="goLoginPage"
|
|
|
+ @loginSuccess="onCartLoginSuccess"
|
|
|
+ />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
-import wangCg from '@/components/wangCg'
|
|
|
import AppWrapperEmpty from '@/components/app-wrapper-empty'
|
|
|
import ShopTabBar from '@/pages/home/components/shop-tab-bar.vue'
|
|
|
import Commondity from '@/pages/item/components/subItem'
|
|
|
import FooterCart from '@/components/item/module/app-footer-cart'
|
|
|
import ModalModule from '@/components/item/plugin/modal'
|
|
|
+import wangCg from '@/components/wangCg'
|
|
|
import allMoreSelectInputMins from '@/mixins/allMoreSelectInput'
|
|
|
import productMins from '@/mixins/cgProduct'
|
|
|
import { getClass, getList } from '@/api/category'
|
|
|
@@ -361,12 +367,12 @@ const NOTICE_POSITION_CATEGORY = 2
|
|
|
export default {
|
|
|
name: 'shopCategory',
|
|
|
components: {
|
|
|
- wangCg,
|
|
|
AppWrapperEmpty,
|
|
|
ShopTabBar,
|
|
|
Commondity,
|
|
|
FooterCart,
|
|
|
- ModalModule
|
|
|
+ ModalModule,
|
|
|
+ wangCg
|
|
|
},
|
|
|
mixins: [list, share, productMins, allMoreSelectInputMins],
|
|
|
data() {
|
|
|
@@ -376,6 +382,8 @@ export default {
|
|
|
isGhsProduct: true,
|
|
|
isFocus: false,
|
|
|
isModel: false,
|
|
|
+ /** wangCg:1=隐藏,0=显示;加购等操作未登录时置 0 */
|
|
|
+ cartLoginStyle: 1,
|
|
|
customData: {
|
|
|
bigCount: 0,
|
|
|
smallCount: 0
|
|
|
@@ -465,6 +473,18 @@ export default {
|
|
|
modalTitle() {
|
|
|
const name = this.customData && this.customData.itemName
|
|
|
return name ? String(name) : ''
|
|
|
+ },
|
|
|
+ /** 有 vuex 用户信息视为已登录;未登录可浏览分类,不弹登录层 */
|
|
|
+ isLoggedIn() {
|
|
|
+ return !this.$util.isEmpty(this.loginInfo)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ /** 登录成功后自动收起加购登录层 */
|
|
|
+ loginInfo(val) {
|
|
|
+ if (!this.$util.isEmpty(val)) {
|
|
|
+ this.cartLoginStyle = 1
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
@@ -478,18 +498,6 @@ export default {
|
|
|
path
|
|
|
}
|
|
|
},
|
|
|
- onShow() {
|
|
|
- this.syncLoginStyle()
|
|
|
- },
|
|
|
- watch: {
|
|
|
- loginInfo: {
|
|
|
- deep: true,
|
|
|
- handler() {
|
|
|
- this.syncLoginStyle()
|
|
|
- },
|
|
|
- immediate: true
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
init() {
|
|
|
this.hdId = this.option.hdId
|
|
|
@@ -509,8 +517,55 @@ export default {
|
|
|
this.loadPageData()
|
|
|
})
|
|
|
},
|
|
|
- syncLoginStyle() {
|
|
|
- this.globalLoginStyle = this.$util.isEmpty(this.loginInfo) ? 0 : 1
|
|
|
+ /**
|
|
|
+ * 未登录则弹出手机号登录层(wangCg),不跳转登录页以免打断浏览
|
|
|
+ * @returns {boolean} true=已登录可继续
|
|
|
+ */
|
|
|
+ requireLogin() {
|
|
|
+ if (this.isLoggedIn) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ this.cartLoginStyle = 0
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ /** wangCg 备用:进入登录页 */
|
|
|
+ goLoginPage() {
|
|
|
+ this.$util.pageTo({
|
|
|
+ url: '/pages/login/index',
|
|
|
+ query: { needBack: 1, account: this.shopAccount }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 登录成功后收起弹层 */
|
|
|
+ onCartLoginSuccess() {
|
|
|
+ this.cartLoginStyle = 1
|
|
|
+ },
|
|
|
+ /** 花材加购:未登录先弹登录层 */
|
|
|
+ onItemAdd(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.addEvent(info)
|
|
|
+ },
|
|
|
+ /** 花材自定义数量加购入口 */
|
|
|
+ onItemAddOne(info, params) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.addCustomNumEvent(info, params)
|
|
|
+ },
|
|
|
+ /** 花材减购也需登录,避免未登录改本地车 */
|
|
|
+ onItemDel(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.delEvent(info)
|
|
|
+ },
|
|
|
+ /** 打开扎数弹窗前校验登录 */
|
|
|
+ onItemCustomNum(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.customNum(info)
|
|
|
},
|
|
|
/**
|
|
|
* 同步搜索框内容(不用 v-model,与首页 topNav 一致,避免小程序端取值不稳)
|
|
|
@@ -736,6 +791,9 @@ export default {
|
|
|
this.currentNoticeIndex = e.detail.current || 0
|
|
|
},
|
|
|
openNoticeDetail() {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
const item = this.noticeList[this.currentNoticeIndex]
|
|
|
if (!item || !item.id) return
|
|
|
this.$util.pageTo({
|
|
|
@@ -745,6 +803,9 @@ export default {
|
|
|
},
|
|
|
/** 点击右侧 ›:进入公告列表(全部上架公告) */
|
|
|
openNoticeList() {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$util.pageTo({
|
|
|
url: '/pages/home/shop-notice-list',
|
|
|
query: {
|
|
|
@@ -813,10 +874,14 @@ export default {
|
|
|
if (!item || !item.id) {
|
|
|
return
|
|
|
}
|
|
|
+ // 多规格先进详情,浏览不强制登录
|
|
|
if (Number(item.goodsStyle) === 1 || Number(item.specEnabled) === 1) {
|
|
|
this.toBouquetDetail(item)
|
|
|
return
|
|
|
}
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (Number(item.priceType) === 0) {
|
|
|
this.$msg('请向商家咨询价格')
|
|
|
return
|
|
|
@@ -874,18 +939,27 @@ export default {
|
|
|
return `超出限购${info.currentBuyNum + info.exceedNum}份`
|
|
|
},
|
|
|
addCurrent(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (info.$orig) {
|
|
|
info = info.$orig
|
|
|
}
|
|
|
this.addEvent(info)
|
|
|
},
|
|
|
delCurrent(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (info.$orig) {
|
|
|
info = info.$orig
|
|
|
}
|
|
|
this.delEvent(info)
|
|
|
},
|
|
|
customUpdate(info) {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (info.$orig) {
|
|
|
info = info.$orig
|
|
|
}
|
|
|
@@ -945,6 +1019,9 @@ export default {
|
|
|
},
|
|
|
/** 选好了:校验限购后跳转确认页 */
|
|
|
confirmSelectEvent() {
|
|
|
+ if (!this.requireLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!this.selectList.length) {
|
|
|
this.$msg('请选择花材')
|
|
|
return
|
|
|
@@ -1017,17 +1094,6 @@ export default {
|
|
|
if (pre > 0) return this.formatPrice(pre)
|
|
|
if (sk > 0) return this.formatPrice(sk)
|
|
|
return '0'
|
|
|
- },
|
|
|
- loginTo() {
|
|
|
- this.$util.pageTo({
|
|
|
- url: '/pages/login/index',
|
|
|
- query: { needBack: 1, account: this.shopAccount }
|
|
|
- })
|
|
|
- },
|
|
|
- loginSuccess() {
|
|
|
- this.loadShopInfo().then(() => {
|
|
|
- this.loadPageData()
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|