处理城市切换
This commit is contained in:
8
App.vue
8
App.vue
@ -45,7 +45,7 @@ export default {
|
|||||||
...mapGetters(['site_statistic'])
|
...mapGetters(['site_statistic'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['getSystemInfo', 'getUser', 'initLocationFunc']),
|
...mapActions(['getSystemInfo', 'getUser']),
|
||||||
...mapMutations(['setConfig']),
|
...mapMutations(['setConfig']),
|
||||||
async getConfigFun() {
|
async getConfigFun() {
|
||||||
const { code, data } = await getConfig()
|
const { code, data } = await getConfig()
|
||||||
@ -63,12 +63,6 @@ export default {
|
|||||||
document.head.appendChild(favicon)
|
document.head.appendChild(favicon)
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP
|
|
||||||
if (data.is_open_nearby) {
|
|
||||||
// 获取定位
|
|
||||||
this.initLocationFunc()
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async bindCode(options) {
|
async bindCode(options) {
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@ -55,8 +55,6 @@ export default {
|
|||||||
...mapGetters(["appConfig"]),
|
...mapGetters(["appConfig"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["initLocationFunc"]),
|
|
||||||
|
|
||||||
handleOpen() {
|
handleOpen() {
|
||||||
wx.openPrivacyContract({
|
wx.openPrivacyContract({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -74,9 +72,6 @@ export default {
|
|||||||
},
|
},
|
||||||
handleAgreePrivacyAuthorization() {
|
handleAgreePrivacyAuthorization() {
|
||||||
this.$emit("input", false);
|
this.$emit("input", false);
|
||||||
if (this.appConfig.is_open_nearby) {
|
|
||||||
this.initLocationFunc();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<view class="category-row flex-1">
|
<view class="category-row flex-1">
|
||||||
<mescroll-body
|
<mescroll-uni
|
||||||
ref="mescrollRef"
|
ref="mescrollRef"
|
||||||
@init="mescrollInit"
|
@init="mescrollInit"
|
||||||
:height="meScrollH"
|
:height="meScrollH"
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<view class="bg-white">
|
<view class="bg-white">
|
||||||
<goods-list :list="goodsList" type="one"></goods-list>
|
<goods-list :list="goodsList" type="one"></goods-list>
|
||||||
</view>
|
</view>
|
||||||
</mescroll-body>
|
</mescroll-uni>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -200,6 +200,8 @@
|
|||||||
|
|
||||||
.category-row {
|
.category-row {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,7 +170,8 @@
|
|||||||
<!-- 会员价 -->
|
<!-- 会员价 -->
|
||||||
<view class="goods-info bg-white bg-vip" v-if="!goodsType && goodsDetail.member_price">
|
<view class="goods-info bg-white bg-vip" v-if="!goodsType && goodsDetail.member_price">
|
||||||
<view class="vip-name">
|
<view class="vip-name">
|
||||||
<view class="line1"> {{ userInfo.level_name }}价</view>
|
<!-- <view class="line1"> {{ userInfo.level_name }}价</view> -->
|
||||||
|
<view class="line1">会员价</view>
|
||||||
</view>
|
</view>
|
||||||
<view style="padding: 0 11rpx" class="flex col-baseline">
|
<view style="padding: 0 11rpx" class="flex col-baseline">
|
||||||
<price-format
|
<price-format
|
||||||
|
|||||||
661
pages/index/index copy.vue
Normal file
661
pages/index/index copy.vue
Normal file
@ -0,0 +1,661 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view v-if="shopInfo.is_freeze === 1 || shopInfo.is_expire === 1 || shopInfo.is_run === 0">
|
||||||
|
<shop-stop
|
||||||
|
:is_freeze="shopInfo.is_freeze"
|
||||||
|
:is_expire="shopInfo.is_expire"
|
||||||
|
:is_run="shopInfo.is_run"
|
||||||
|
></shop-stop>
|
||||||
|
</view>
|
||||||
|
<view class="store-index" v-else>
|
||||||
|
<view
|
||||||
|
class="store-header"
|
||||||
|
:style="{
|
||||||
|
'background-image': `url(${
|
||||||
|
shopInfo.background
|
||||||
|
? shopInfo.background
|
||||||
|
: $getImageUri('/static/common/image/default/shopindex.png')
|
||||||
|
})`
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<u-navbar
|
||||||
|
:border-bottom="false"
|
||||||
|
:background="{
|
||||||
|
'background-image': `url(${shopInfo.background})`,
|
||||||
|
'background-repeat': 'no-repeat',
|
||||||
|
'background-size': '100% auto'
|
||||||
|
}"
|
||||||
|
:back-bg="'rgba(255, 255, 255, 0.45)'"
|
||||||
|
:back-icon-color="'rgb(255,255,255)'"
|
||||||
|
:is-fixed="true"
|
||||||
|
:is-back="false"
|
||||||
|
>
|
||||||
|
<view class="flex-1 flex">
|
||||||
|
<!-- 城市 -->
|
||||||
|
<!-- <router-link
|
||||||
|
v-if="appConfig.is_open_nearby"
|
||||||
|
class="m-l-16 flex white row-center flex-none"
|
||||||
|
to="/bundle_b/pages/city/city"
|
||||||
|
>
|
||||||
|
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
|
||||||
|
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
|
||||||
|
</router-link> -->
|
||||||
|
<view class="store-search flex-1" @click="handleSerach">
|
||||||
|
<u-search
|
||||||
|
v-model="keyword"
|
||||||
|
bg-color="white"
|
||||||
|
shape="round"
|
||||||
|
placeholder="搜索店内商品"
|
||||||
|
wrap-bg-color="transparent"
|
||||||
|
@search="refresh"
|
||||||
|
>
|
||||||
|
</u-search>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-navbar>
|
||||||
|
<view
|
||||||
|
class="store-info m-t-20"
|
||||||
|
:style="{ 'padding-bottom': '200rpx' }"
|
||||||
|
>
|
||||||
|
<view class="flex row-between">
|
||||||
|
<view class="flex">
|
||||||
|
<u-image
|
||||||
|
width="100rpx"
|
||||||
|
height="100rpx"
|
||||||
|
border-radius="50%"
|
||||||
|
:src="shopInfo.logo"
|
||||||
|
/>
|
||||||
|
<view class="m-l-20 flex-col col-top">
|
||||||
|
<router-link
|
||||||
|
:to="{
|
||||||
|
path: '/pages/store_detail/store_detail',
|
||||||
|
query: { id: shopInfo.id }
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<view class="lg white line-1 bold" style="width: 340rpx">
|
||||||
|
{{ shopInfo.name }}
|
||||||
|
<u-icon name="arrow-right"></u-icon>
|
||||||
|
</view>
|
||||||
|
</router-link>
|
||||||
|
<view class="flex m-t-10">
|
||||||
|
<view class="store-tag xxs white" v-if="shopInfo.type == 1">
|
||||||
|
自营
|
||||||
|
</view>
|
||||||
|
<view class="white xs m-l-5">
|
||||||
|
{{ shopInfo.visited_num }}人进店
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="flex-none">
|
||||||
|
<view
|
||||||
|
class="flex row-center white br60 sm flex-none switch-btn"
|
||||||
|
@tap="switchFlagship"
|
||||||
|
v-if="cityInfo && cityInfo.id !== 0 && shopInfo.id !== 1"
|
||||||
|
>
|
||||||
|
茶址甄选茶仓
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="flex row-center white br60 sm flex-none switch-btn"
|
||||||
|
@tap="switchLocal"
|
||||||
|
v-else-if="appConfig.is_open_nearby && cityInfo && cityInfo.id === 0"
|
||||||
|
>
|
||||||
|
切换当地店
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- <view
|
||||||
|
class="flex row-center white br60 sm flex-none subscribe-btn"
|
||||||
|
:class="{ gray: shopInfo.shop_follow_status === 1 }"
|
||||||
|
@tap="changeShopFollowFun"
|
||||||
|
>
|
||||||
|
{{ shopInfo.shop_follow_status === 1 ? '已关注' : '+ 关注' }}
|
||||||
|
</view> -->
|
||||||
|
</view>
|
||||||
|
<view class="p-t-20 p-b-20">
|
||||||
|
<!-- <u-tabs
|
||||||
|
:current="tabcurrent"
|
||||||
|
:list="[{ name: '精选' }, { name: '商品' }, { name: '领券' }]"
|
||||||
|
:is-scroll="false"
|
||||||
|
@change="tabChange"
|
||||||
|
bg-color="transparent"
|
||||||
|
active-color="white"
|
||||||
|
inactive-color="white"
|
||||||
|
></u-tabs> -->
|
||||||
|
<u-tabs
|
||||||
|
:current="tabcurrent"
|
||||||
|
:list="[{ name: '精选' }, { name: '商品' }]"
|
||||||
|
:is-scroll="false"
|
||||||
|
@change="tabChange"
|
||||||
|
bg-color="transparent"
|
||||||
|
active-color="white"
|
||||||
|
inactive-color="white"
|
||||||
|
></u-tabs>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 精选商城 -->
|
||||||
|
<view class="content" v-if="tabcurrent == 0">
|
||||||
|
<view v-if="shopInfo.ad.mobile.length">
|
||||||
|
<u-swiper
|
||||||
|
:list="shopInfo.ad.mobile"
|
||||||
|
height="700"
|
||||||
|
@click="handleAdclick"
|
||||||
|
></u-swiper>
|
||||||
|
</view>
|
||||||
|
<view class="content-wrap" v-if="shopInfo.goods_list.length">
|
||||||
|
<view class="store-hot-goods bg-white m-t-20">
|
||||||
|
<view class="store-hot-header flex">
|
||||||
|
<view class="column-line m-r-20" />
|
||||||
|
<view class="md" style="font-weight: 500"> 店铺推荐 </view>
|
||||||
|
<view class="md" style="margin-left: auto" @click="handlemore">
|
||||||
|
更多</view
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="store-hot-content">
|
||||||
|
<scroll-view :scroll-x="true">
|
||||||
|
<view class="goods p-l-20 p-r-20">
|
||||||
|
<goods-list :list="shopInfo.goods_list" type="row"></goods-list>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="goods-display flex bg-body">
|
||||||
|
<view class="category-row flex-1">
|
||||||
|
<u-sticky
|
||||||
|
bg-color="rgba(255, 255, 255, 0)"
|
||||||
|
:enable="enableFix"
|
||||||
|
:offset-top="navHeight"
|
||||||
|
:h5-nav-height="0"
|
||||||
|
>
|
||||||
|
<sort-nav
|
||||||
|
v-model="sortConfig"
|
||||||
|
:show-type="false"
|
||||||
|
:showCreate="true"
|
||||||
|
></sort-nav>
|
||||||
|
</u-sticky>
|
||||||
|
<mescroll-body
|
||||||
|
ref="mescrollRef"
|
||||||
|
@init="mescrollInit"
|
||||||
|
:height="meScrollH"
|
||||||
|
@down="downCallback"
|
||||||
|
@up="upCallback"
|
||||||
|
:up="upOption"
|
||||||
|
:down="{ use: false }"
|
||||||
|
>
|
||||||
|
<view class="bg-white">
|
||||||
|
<goods-list :list="goodsList" width="315rpx"></goods-list>
|
||||||
|
</view>
|
||||||
|
</mescroll-body>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 商城商品 -->
|
||||||
|
<view v-if="tabcurrent == 1" style="margin-top: -200rpx">
|
||||||
|
<view class="goods-display flex bg-body">
|
||||||
|
<view class="category-row flex-1">
|
||||||
|
<u-sticky
|
||||||
|
bg-color="rgba(255, 255, 255, 0)"
|
||||||
|
:enable="enableFix"
|
||||||
|
:offset-top="navHeight"
|
||||||
|
:h5-nav-height="0"
|
||||||
|
>
|
||||||
|
<sort-nav v-model="sortConfig" :show-type="false"></sort-nav>
|
||||||
|
</u-sticky>
|
||||||
|
<mescroll-body
|
||||||
|
ref="mescrollRef"
|
||||||
|
@init="mescrollInit"
|
||||||
|
:height="meScrollH"
|
||||||
|
@down="downCallback"
|
||||||
|
@up="upCallback"
|
||||||
|
:up="upOption"
|
||||||
|
:down="{ use: false }"
|
||||||
|
>
|
||||||
|
<view class="bg-white">
|
||||||
|
<goods-list :list="goodsList"></goods-list>
|
||||||
|
</view>
|
||||||
|
</mescroll-body>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 优惠券 -->
|
||||||
|
<view v-if="tabcurrent == 2" style="margin-top: -200rpx">
|
||||||
|
<coupon-list
|
||||||
|
:list="couponlists"
|
||||||
|
@refresh="getGoodsCouponFun"
|
||||||
|
:btn-type="3"
|
||||||
|
v-if="couponlists.length"
|
||||||
|
></coupon-list>
|
||||||
|
<view class="coupon-container" v-else>
|
||||||
|
<view style="font-weight: 500">优惠券</view>
|
||||||
|
<view class="muted coupon"> 当前暂无可领取的优惠券 </view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<loading-view v-if="isFirstLoading"></loading-view>
|
||||||
|
</view>
|
||||||
|
<tabbar></tabbar>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
|
import { getShopInfo, getShopGoodsCategory, changeShopFollow, getCityShops, getCityGoodsCategory } from '@/api/shop'
|
||||||
|
import { getShopLive } from '@/api/live'
|
||||||
|
import { getGoodsList } from '@/api/store'
|
||||||
|
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js'
|
||||||
|
import { getCouponList } from '@/api/activity'
|
||||||
|
import { strToParams } from '../../utils/tools'
|
||||||
|
import { scanHome } from '@/api/user'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [MescrollMixin], // 使用mixin
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tabcurrent: 0,
|
||||||
|
isFirstLoading: true,
|
||||||
|
navOpacity: 0,
|
||||||
|
shopInfo: {
|
||||||
|
goods_list: [],
|
||||||
|
ad: {
|
||||||
|
mobile: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category: [],
|
||||||
|
active: -1,
|
||||||
|
upOption: {
|
||||||
|
auto: false,
|
||||||
|
empty: {
|
||||||
|
icon: '/static/images/goods_null.png',
|
||||||
|
tip: '暂无商品'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
goodsList: [],
|
||||||
|
categoodsList: [],
|
||||||
|
sortConfig: {
|
||||||
|
priceSort: '',
|
||||||
|
saleSort: '',
|
||||||
|
sort_by_create: ''
|
||||||
|
},
|
||||||
|
couponlists: [],
|
||||||
|
keyword: '',
|
||||||
|
sys: {},
|
||||||
|
enableFix: true,
|
||||||
|
id: '',
|
||||||
|
shopLive: {},
|
||||||
|
superiorUserId: 0,
|
||||||
|
hasHandleSuperior: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onLoad() {
|
||||||
|
if (this.$Route.query && this.$Route.query.scene) {
|
||||||
|
const params = strToParams(this.$Route.query.scene)
|
||||||
|
this.superiorUserId = params.user_id || 0
|
||||||
|
}
|
||||||
|
console.log("🚀 ~ this.superiorUserId:", this.superiorUserId)
|
||||||
|
console.log("🚀 ~ this.$Route.query:", this.$Route.query)
|
||||||
|
this.sys = uni.getSystemInfoSync()
|
||||||
|
await this.getShopInfoFun()
|
||||||
|
await this.getShopGoodsCategoryFun()
|
||||||
|
this.getCurrentCity()
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
this.getShopLiveFun()
|
||||||
|
// #endif
|
||||||
|
this.isFirstLoading = false
|
||||||
|
this.mescroll.resetUpScroll()
|
||||||
|
this.handleSuperiorUser()
|
||||||
|
},
|
||||||
|
onHide() {
|
||||||
|
// #ifdef H5
|
||||||
|
this.enableFix = false
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
// #ifdef H5
|
||||||
|
this.enableFix = true
|
||||||
|
// #endif
|
||||||
|
this.handleSuperiorUser()
|
||||||
|
},
|
||||||
|
onShareAppMessage() {
|
||||||
|
return {
|
||||||
|
title: this.shopInfo.name,
|
||||||
|
path: `pages/store_index/store_index?invite_code=${this.inviteCode}&id=${this.id}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(['initLocationFunc']),
|
||||||
|
|
||||||
|
switchFlagship() {
|
||||||
|
this.$store.commit('setCityInfo', { id: 0, name: '旗舰店' })
|
||||||
|
},
|
||||||
|
|
||||||
|
switchLocal() {
|
||||||
|
this.initLocationFunc() // This sets cityInfo which triggers the watcher to refresh content due to id > 0
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSuperiorUser() {
|
||||||
|
console.log("🚀 ~ this.superiorUserId:", this.superiorUserId)
|
||||||
|
console.log("🚀 ~ this.hasHandleSuperior:", this.hasHandleSuperior)
|
||||||
|
if (this.superiorUserId > 0 && !this.hasHandleSuperior) {
|
||||||
|
if (!this.isLogin) {
|
||||||
|
this.$Router.push('/pages/login/login')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.hasHandleSuperior = true
|
||||||
|
this.scanHomeFun()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async scanHomeFun() {
|
||||||
|
try {
|
||||||
|
const { code, msg } = await scanHome({
|
||||||
|
user_id: this.superiorUserId
|
||||||
|
})
|
||||||
|
if (code === 1) {
|
||||||
|
console.log('scanHome success:', msg)
|
||||||
|
} else {
|
||||||
|
console.log('scanHome error:', msg)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('scanHome error:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCurrentCity() {
|
||||||
|
if (!this.appConfig.is_open_nearby) return
|
||||||
|
this.initLocationFunc()
|
||||||
|
},
|
||||||
|
handleAdclick(index) {
|
||||||
|
const { link, link_query } = this.shopInfo.ad.mobile[index]
|
||||||
|
console.log(link)
|
||||||
|
this.$Router.push({
|
||||||
|
path: link,
|
||||||
|
query: link_query
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getGoodsCouponFun() {
|
||||||
|
console.log(this.goodsId)
|
||||||
|
const { data, code } = await getCouponList({
|
||||||
|
shop_id: this.id,
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
||||||
|
})
|
||||||
|
console.log(data)
|
||||||
|
if (code == 1) {
|
||||||
|
this.couponlists = data.lists
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tabChange(value) {
|
||||||
|
this.tabcurrent = value
|
||||||
|
if (value == 2) {
|
||||||
|
this.getGoodsCouponFun()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
async getShopLiveFun() {
|
||||||
|
const { data, code } = await getShopLive({
|
||||||
|
shop_id: this.id,
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
||||||
|
})
|
||||||
|
if (code == 1) {
|
||||||
|
this.shopLive = data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//#endif
|
||||||
|
async changeShopFollowFun() {
|
||||||
|
if (!this.isLogin) return this.$Router.push('/pages/login/login')
|
||||||
|
const { code, msg } = await changeShopFollow({
|
||||||
|
shop_id: this.id,
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
||||||
|
})
|
||||||
|
if (code == 1) {
|
||||||
|
this.$toast({
|
||||||
|
title: msg
|
||||||
|
})
|
||||||
|
this.getShopInfoFun()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getShopInfoFun() {
|
||||||
|
const { data, code } = await getCityShops({
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0
|
||||||
|
})
|
||||||
|
|
||||||
|
if (code == 1) {
|
||||||
|
this.shopInfo = data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getShopGoodsCategoryFun() {
|
||||||
|
const { data, code } = await getCityGoodsCategory({
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0
|
||||||
|
})
|
||||||
|
if (code == 1) {
|
||||||
|
this.category = data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changeActive(index) {
|
||||||
|
this.active = index
|
||||||
|
this.refresh()
|
||||||
|
},
|
||||||
|
refresh() {
|
||||||
|
this.goodsList = []
|
||||||
|
if (
|
||||||
|
!(
|
||||||
|
this.shopInfo.is_freeze === 1 ||
|
||||||
|
this.shopInfo.is_expire === 1 ||
|
||||||
|
this.shopInfo.is_run === 0
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.mescroll.resetUpScroll()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleSerach() {
|
||||||
|
this.$Router.push({
|
||||||
|
path: '/bundle/pages/shop_search/shop_search',
|
||||||
|
query: { id: this.id, is_recommend: 0 }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handlemore() {
|
||||||
|
this.$Router.push({
|
||||||
|
path: '/bundle/pages/shop_search/shop_search',
|
||||||
|
query: { id: this.id, is_recommend: 1 }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
|
||||||
|
upCallback(page) {
|
||||||
|
//联网加载数据
|
||||||
|
let {
|
||||||
|
goodsList,
|
||||||
|
keyword,
|
||||||
|
sortConfig: { priceSort, saleSort, sort_by_create },
|
||||||
|
active,
|
||||||
|
category
|
||||||
|
} = this
|
||||||
|
const pageNum = page.num // 页码, 默认从1开始
|
||||||
|
const pageSize = page.size // 页长, 默认每页10条
|
||||||
|
const cateId = active == -1 ? '' : category[active].id
|
||||||
|
setTimeout(() => {
|
||||||
|
getGoodsList({
|
||||||
|
page_size: pageSize,
|
||||||
|
page_no: pageNum,
|
||||||
|
shop_id: this.id,
|
||||||
|
sort_by_price: priceSort,
|
||||||
|
sort_by_sales: saleSort,
|
||||||
|
sort_by_create: sort_by_create,
|
||||||
|
keyword,
|
||||||
|
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
||||||
|
}).then(({ data }) => {
|
||||||
|
let curPageData = data.lists
|
||||||
|
let curPageLen = curPageData.length
|
||||||
|
let hasNext = !!data.more
|
||||||
|
if (page.num == 1) this.goodsList = []
|
||||||
|
this.goodsList = this.goodsList.concat(curPageData)
|
||||||
|
this.mescroll.endSuccess(curPageLen, hasNext)
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['sysInfo', 'appConfig', 'cityInfo', 'isLogin']),
|
||||||
|
navHeight() {
|
||||||
|
return this.sysInfo.navHeight + 'px'
|
||||||
|
},
|
||||||
|
aslideH() {
|
||||||
|
const { windowHeight, navHeight, safeArea } = this.sys
|
||||||
|
if (!safeArea) return 0
|
||||||
|
console.log(this.sysInfo)
|
||||||
|
return windowHeight - this.sysInfo.navHeight - 100
|
||||||
|
},
|
||||||
|
meScrollH() {
|
||||||
|
return this.aslideH - uni.upx2px(80) + 'px'
|
||||||
|
},
|
||||||
|
// 获取图片域名
|
||||||
|
$getImageUri() {
|
||||||
|
return (url) => this.$store.state.app.config.base_domain + url
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'cityInfo.id': {
|
||||||
|
async handler(val, oldVal) {
|
||||||
|
if (val !== undefined && val !== oldVal) {
|
||||||
|
await this.getShopInfoFun()
|
||||||
|
await this.getShopGoodsCategoryFun()
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
this.getShopLiveFun()
|
||||||
|
// #endif
|
||||||
|
this.mescroll.resetUpScroll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sortConfig: {
|
||||||
|
deep: true,
|
||||||
|
handler(val) {
|
||||||
|
console.log(val)
|
||||||
|
this.refresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-index {
|
||||||
|
.store-header {
|
||||||
|
// padding-bottom: 60rpx;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 100% auto;
|
||||||
|
.store-info {
|
||||||
|
padding-right: 30rpx;
|
||||||
|
padding-left: 24rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.store-tag {
|
||||||
|
background: linear-gradient(267deg, #ff2c3c 0%, #f52e99 100%);
|
||||||
|
border-radius: 6rpx;
|
||||||
|
padding: 4rpx 9rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subscribe-btn {
|
||||||
|
background: linear-gradient(97deg, #ff5784 0%, #ff2c3c 100%);
|
||||||
|
height: 52rpx;
|
||||||
|
width: 128rpx;
|
||||||
|
&.gray {
|
||||||
|
background: #ccc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-btn {
|
||||||
|
background: linear-gradient(97deg, #ff5784 0%, #ff2c3c 100%);
|
||||||
|
height: 52rpx;
|
||||||
|
width: 190rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
margin-top: -200rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
.content-wrap {
|
||||||
|
// margin-top: 30rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
}
|
||||||
|
.store-hot-goods {
|
||||||
|
overflow: hidden;
|
||||||
|
.store-hot-header {
|
||||||
|
padding: 20rpx;
|
||||||
|
|
||||||
|
.column-line {
|
||||||
|
width: 6rpx;
|
||||||
|
height: 32rpx;
|
||||||
|
background-color: $-color-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-hot-content {
|
||||||
|
.goods {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.hot-goods-item {
|
||||||
|
width: 200rpx;
|
||||||
|
|
||||||
|
.hot-goods-info {
|
||||||
|
.hot-goods-price {
|
||||||
|
margin-top: 5rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-display {
|
||||||
|
.category-row {
|
||||||
|
align-self: flex-start;
|
||||||
|
width: 630rpx;
|
||||||
|
|
||||||
|
.sort-tool-bar {
|
||||||
|
.sort-item {
|
||||||
|
flex: 1;
|
||||||
|
height: 80rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-lists {
|
||||||
|
padding: 20rpx;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
width: 285rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:nth-of-type(2n) {
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-info {
|
||||||
|
padding: 10rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.coupon-container {
|
||||||
|
background-color: white;
|
||||||
|
height: 1000rpx;
|
||||||
|
margin: 0 20rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
.coupon {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -90,17 +90,17 @@
|
|||||||
<view class="flex-none">
|
<view class="flex-none">
|
||||||
<view
|
<view
|
||||||
class="flex row-center white br60 sm flex-none switch-btn"
|
class="flex row-center white br60 sm flex-none switch-btn"
|
||||||
@tap="switchFlagship"
|
@tap="switchWarehouse"
|
||||||
v-if="cityInfo && cityInfo.id !== 0 && shopInfo.id !== 1"
|
v-if="showSwitchToLocalBtn"
|
||||||
>
|
>
|
||||||
茶址甄选茶仓
|
切换本地仓
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="flex row-center white br60 sm flex-none switch-btn"
|
class="flex row-center white br60 sm flex-none switch-btn"
|
||||||
@tap="switchLocal"
|
@tap="switchWarehouse"
|
||||||
v-else-if="appConfig.is_open_nearby && cityInfo && cityInfo.id === 0"
|
v-else-if="showSwitchToCuratedBtn"
|
||||||
>
|
>
|
||||||
切换当地店
|
切换甄选仓
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view
|
<!-- <view
|
||||||
@ -238,7 +238,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions, mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { getShopInfo, getShopGoodsCategory, changeShopFollow, getCityShops, getCityGoodsCategory } from '@/api/shop'
|
import { getShopInfo, getShopGoodsCategory, changeShopFollow, getCityShops, getCityGoodsCategory } from '@/api/shop'
|
||||||
import { getShopLive } from '@/api/live'
|
import { getShopLive } from '@/api/live'
|
||||||
import { getGoodsList } from '@/api/store'
|
import { getGoodsList } from '@/api/store'
|
||||||
@ -280,29 +280,30 @@ export default {
|
|||||||
keyword: '',
|
keyword: '',
|
||||||
sys: {},
|
sys: {},
|
||||||
enableFix: true,
|
enableFix: true,
|
||||||
|
curatedShopId: 0,
|
||||||
|
localShopId: 5,
|
||||||
|
requestCuratedCityId: 5,
|
||||||
|
requestLocalCityId: 0,
|
||||||
|
defaultShopId: null,
|
||||||
|
requestCityId: null,
|
||||||
|
hasManualToggle: false,
|
||||||
|
scanEntryCityId: null,
|
||||||
|
scanEntryCityName: '',
|
||||||
|
isSwitchingWarehouse: false,
|
||||||
id: '',
|
id: '',
|
||||||
shopLive: {},
|
shopLive: {},
|
||||||
superiorUserId: 0,
|
superiorUserId: 0,
|
||||||
hasHandleSuperior: false
|
hasHandleSuperior: false,
|
||||||
|
isPageInitializing: false,
|
||||||
|
pendingLoginRefresh: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
if (this.$Route.query && this.$Route.query.scene) {
|
uni.$on('loginSuccess', this.onLoginSuccess)
|
||||||
const params = strToParams(this.$Route.query.scene)
|
await this.initHomePage()
|
||||||
this.superiorUserId = params.user_id || 0
|
},
|
||||||
}
|
onUnload() {
|
||||||
console.log("🚀 ~ this.superiorUserId:", this.superiorUserId)
|
uni.$off('loginSuccess', this.onLoginSuccess)
|
||||||
console.log("🚀 ~ this.$Route.query:", this.$Route.query)
|
|
||||||
this.sys = uni.getSystemInfoSync()
|
|
||||||
await this.getShopInfoFun()
|
|
||||||
await this.getShopGoodsCategoryFun()
|
|
||||||
this.getCurrentCity()
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
this.getShopLiveFun()
|
|
||||||
// #endif
|
|
||||||
this.isFirstLoading = false
|
|
||||||
this.mescroll.resetUpScroll()
|
|
||||||
this.handleSuperiorUser()
|
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
@ -322,14 +323,175 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['initLocationFunc']),
|
async initHomePage(reinitAfterLogin = false) {
|
||||||
|
if (this.isPageInitializing) {
|
||||||
|
if (reinitAfterLogin) {
|
||||||
|
this.pendingLoginRefresh = true
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.isPageInitializing = true
|
||||||
|
|
||||||
switchFlagship() {
|
try {
|
||||||
this.$store.commit('setCityInfo', { id: 0, name: '旗舰店' })
|
const entryParams = this.getEntryParams()
|
||||||
|
this.superiorUserId = entryParams.user_id || 0
|
||||||
|
this.sys = uni.getSystemInfoSync()
|
||||||
|
|
||||||
|
if (reinitAfterLogin) {
|
||||||
|
this.hasManualToggle = false
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.getShopInfoFun(reinitAfterLogin)
|
||||||
|
await this.getShopGoodsCategoryFun()
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
await this.getShopLiveFun()
|
||||||
|
// #endif
|
||||||
|
this.goodsList = []
|
||||||
|
if (this.mescroll) {
|
||||||
|
this.mescroll.resetUpScroll()
|
||||||
|
}
|
||||||
|
this.handleSuperiorUser()
|
||||||
|
} finally {
|
||||||
|
this.isFirstLoading = false
|
||||||
|
this.isPageInitializing = false
|
||||||
|
if (this.pendingLoginRefresh) {
|
||||||
|
this.pendingLoginRefresh = false
|
||||||
|
await this.initHomePage(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
switchLocal() {
|
onLoginSuccess() {
|
||||||
this.initLocationFunc() // This sets cityInfo which triggers the watcher to refresh content due to id > 0
|
this.initHomePage(true)
|
||||||
|
},
|
||||||
|
|
||||||
|
getEntryParams() {
|
||||||
|
const query = this.$Route.query || {}
|
||||||
|
const sceneParams = query.scene ? strToParams(decodeURIComponent(query.scene)) : {}
|
||||||
|
const userId = Number(query.user_id || sceneParams.user_id || this.superiorUserId || 0)
|
||||||
|
const inviteCode = query.invite_code || sceneParams.invite_code || ''
|
||||||
|
|
||||||
|
return {
|
||||||
|
user_id: userId,
|
||||||
|
invite_code: inviteCode
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
isScanEntry() {
|
||||||
|
const { user_id, invite_code } = this.getEntryParams()
|
||||||
|
return user_id > 0 || !!invite_code
|
||||||
|
},
|
||||||
|
|
||||||
|
isOtherCityShop() {
|
||||||
|
return this.defaultShopId !== null
|
||||||
|
&& this.defaultShopId !== this.curatedShopId
|
||||||
|
&& this.defaultShopId !== this.localShopId
|
||||||
|
},
|
||||||
|
|
||||||
|
initWarehouseFromShop(data, force = false) {
|
||||||
|
if (this.hasManualToggle && !force) return
|
||||||
|
|
||||||
|
const shopId = Number(data.id)
|
||||||
|
this.defaultShopId = shopId
|
||||||
|
|
||||||
|
if (shopId === this.curatedShopId) {
|
||||||
|
// 返回 id=0 甄选仓,默认传 5
|
||||||
|
this.requestCityId = this.requestCuratedCityId
|
||||||
|
} else if (shopId === this.localShopId) {
|
||||||
|
// 返回 id=5 上海店,默认也传 5
|
||||||
|
this.requestCityId = this.localShopId
|
||||||
|
} else {
|
||||||
|
this.requestCityId = null
|
||||||
|
if (data.city_id) {
|
||||||
|
this.scanEntryCityId = data.city_id
|
||||||
|
this.scanEntryCityName = data.city_name || data.city || ''
|
||||||
|
this.$store.commit('setCityInfo', {
|
||||||
|
id: data.city_id,
|
||||||
|
name: data.city_name || data.city || ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
normalizeRequestCityId() {
|
||||||
|
if (this.requestCityId === null || this.requestCityId === '') {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return Number(this.requestCityId)
|
||||||
|
},
|
||||||
|
|
||||||
|
getShopCityParams() {
|
||||||
|
const cityId = this.normalizeRequestCityId()
|
||||||
|
if (cityId !== null) {
|
||||||
|
return { city_id: cityId }
|
||||||
|
}
|
||||||
|
|
||||||
|
const { user_id, invite_code } = this.getEntryParams()
|
||||||
|
const params = {}
|
||||||
|
|
||||||
|
if (user_id > 0) params.user_id = user_id
|
||||||
|
if (invite_code) params.invite_code = invite_code
|
||||||
|
|
||||||
|
return params
|
||||||
|
},
|
||||||
|
|
||||||
|
getRequestCityParams() {
|
||||||
|
const cityId = this.normalizeRequestCityId()
|
||||||
|
if (cityId !== null) {
|
||||||
|
return { city_id: cityId }
|
||||||
|
}
|
||||||
|
if (this.isOtherCityShop() && this.scanEntryCityId !== null) {
|
||||||
|
return { city_id: this.scanEntryCityId }
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
|
||||||
|
async refreshShopData(showLoading = false, skipShopInfo = false) {
|
||||||
|
if (showLoading) {
|
||||||
|
this.isSwitchingWarehouse = true
|
||||||
|
uni.showLoading({
|
||||||
|
title: '切换中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!skipShopInfo) {
|
||||||
|
await this.getShopInfoFun()
|
||||||
|
}
|
||||||
|
await this.getShopGoodsCategoryFun()
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
await this.getShopLiveFun()
|
||||||
|
// #endif
|
||||||
|
this.goodsList = []
|
||||||
|
this.mescroll.resetUpScroll()
|
||||||
|
} finally {
|
||||||
|
if (showLoading) {
|
||||||
|
this.isSwitchingWarehouse = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async switchWarehouse() {
|
||||||
|
if (this.isSwitchingWarehouse) return
|
||||||
|
this.hasManualToggle = true
|
||||||
|
|
||||||
|
const cityId = this.normalizeRequestCityId()
|
||||||
|
|
||||||
|
if (this.isOtherCityShop()) {
|
||||||
|
if (cityId === this.requestLocalCityId) {
|
||||||
|
this.requestCityId = null
|
||||||
|
} else {
|
||||||
|
this.requestCityId = this.requestLocalCityId
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 上海/初始用户:5 与 0 互切
|
||||||
|
this.requestCityId = cityId === this.requestCuratedCityId
|
||||||
|
? this.requestLocalCityId
|
||||||
|
: this.requestCuratedCityId
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.refreshShopData(true, true)
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuperiorUser() {
|
handleSuperiorUser() {
|
||||||
@ -360,10 +522,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentCity() {
|
getShopCityInfoParams() {
|
||||||
if (!this.appConfig.is_open_nearby) return
|
return this.getShopCityParams()
|
||||||
this.initLocationFunc()
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleAdclick(index) {
|
handleAdclick(index) {
|
||||||
const { link, link_query } = this.shopInfo.ad.mobile[index]
|
const { link, link_query } = this.shopInfo.ad.mobile[index]
|
||||||
console.log(link)
|
console.log(link)
|
||||||
@ -376,7 +538,7 @@ export default {
|
|||||||
console.log(this.goodsId)
|
console.log(this.goodsId)
|
||||||
const { data, code } = await getCouponList({
|
const { data, code } = await getCouponList({
|
||||||
shop_id: this.id,
|
shop_id: this.id,
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
...this.getRequestCityParams(),
|
||||||
})
|
})
|
||||||
console.log(data)
|
console.log(data)
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
@ -393,7 +555,7 @@ export default {
|
|||||||
async getShopLiveFun() {
|
async getShopLiveFun() {
|
||||||
const { data, code } = await getShopLive({
|
const { data, code } = await getShopLive({
|
||||||
shop_id: this.id,
|
shop_id: this.id,
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
...this.getRequestCityParams(),
|
||||||
})
|
})
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
this.shopLive = data
|
this.shopLive = data
|
||||||
@ -404,7 +566,7 @@ export default {
|
|||||||
if (!this.isLogin) return this.$Router.push('/pages/login/login')
|
if (!this.isLogin) return this.$Router.push('/pages/login/login')
|
||||||
const { code, msg } = await changeShopFollow({
|
const { code, msg } = await changeShopFollow({
|
||||||
shop_id: this.id,
|
shop_id: this.id,
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
...this.getRequestCityParams(),
|
||||||
})
|
})
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
this.$toast({
|
this.$toast({
|
||||||
@ -413,19 +575,16 @@ export default {
|
|||||||
this.getShopInfoFun()
|
this.getShopInfoFun()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getShopInfoFun() {
|
async getShopInfoFun(forceReinit = false) {
|
||||||
const { data, code } = await getCityShops({
|
const { data, code } = await getCityShops(this.getShopCityInfoParams())
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0
|
|
||||||
})
|
|
||||||
|
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
this.shopInfo = data
|
this.shopInfo = data
|
||||||
|
this.initWarehouseFromShop(data, forceReinit)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getShopGoodsCategoryFun() {
|
async getShopGoodsCategoryFun() {
|
||||||
const { data, code } = await getCityGoodsCategory({
|
const { data, code } = await getCityGoodsCategory(this.getRequestCityParams())
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0
|
|
||||||
})
|
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
this.category = data
|
this.category = data
|
||||||
}
|
}
|
||||||
@ -480,7 +639,7 @@ export default {
|
|||||||
sort_by_sales: saleSort,
|
sort_by_sales: saleSort,
|
||||||
sort_by_create: sort_by_create,
|
sort_by_create: sort_by_create,
|
||||||
keyword,
|
keyword,
|
||||||
city_id: (this.cityInfo && this.cityInfo.id) || 0,
|
...this.getRequestCityParams(),
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
let curPageData = data.lists
|
let curPageData = data.lists
|
||||||
let curPageLen = curPageData.length
|
let curPageLen = curPageData.length
|
||||||
@ -509,21 +668,27 @@ export default {
|
|||||||
// 获取图片域名
|
// 获取图片域名
|
||||||
$getImageUri() {
|
$getImageUri() {
|
||||||
return (url) => this.$store.state.app.config.base_domain + url
|
return (url) => this.$store.state.app.config.base_domain + url
|
||||||
|
},
|
||||||
|
showSwitchToLocalBtn() {
|
||||||
|
const cityId = this.normalizeRequestCityId()
|
||||||
|
if (this.isOtherCityShop()) {
|
||||||
|
return cityId === this.requestLocalCityId
|
||||||
|
}
|
||||||
|
// id=0 且当前传5 → 切换本地仓;id=5 且当前传0 → 切回本地仓
|
||||||
|
return (this.defaultShopId === this.curatedShopId && cityId === this.requestCuratedCityId)
|
||||||
|
|| (this.defaultShopId === this.localShopId && cityId === this.requestLocalCityId)
|
||||||
|
},
|
||||||
|
showSwitchToCuratedBtn() {
|
||||||
|
const cityId = this.normalizeRequestCityId()
|
||||||
|
if (this.isOtherCityShop()) {
|
||||||
|
return cityId === null
|
||||||
|
}
|
||||||
|
// id=0 且当前传0 → 切回甄选仓;id=5 且当前传5 → 切换甄选仓
|
||||||
|
return (this.defaultShopId === this.curatedShopId && cityId === this.requestLocalCityId)
|
||||||
|
|| (this.defaultShopId === this.localShopId && cityId === this.requestCuratedCityId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'cityInfo.id': {
|
|
||||||
async handler(val, oldVal) {
|
|
||||||
if (val !== undefined && val !== oldVal) {
|
|
||||||
await this.getShopInfoFun()
|
|
||||||
await this.getShopGoodsCategoryFun()
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
this.getShopLiveFun()
|
|
||||||
// #endif
|
|
||||||
this.mescroll.resetUpScroll()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sortConfig: {
|
sortConfig: {
|
||||||
deep: true,
|
deep: true,
|
||||||
handler(val) {
|
handler(val) {
|
||||||
|
|||||||
@ -89,10 +89,8 @@ export async function wxMnpLogin() {
|
|||||||
if (inviteCode) {
|
if (inviteCode) {
|
||||||
bindSuperior({code: inviteCode})
|
bindSuperior({code: inviteCode})
|
||||||
Cache.remove(INVITE_CODE)
|
Cache.remove(INVITE_CODE)
|
||||||
}
|
}
|
||||||
// 刷新页面
|
uni.$emit('loginSuccess')
|
||||||
onLoad && onLoad(options)
|
|
||||||
onShow && onShow()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const toLogin = trottle(_toLogin, 1000)
|
export const toLogin = trottle(_toLogin, 1000)
|
||||||
|
|||||||
Reference in New Issue
Block a user