首页添加本地店铺和旗舰店的切换功能

This commit is contained in:
wangxiaowei
2026-05-09 11:23:20 +08:00
parent a3edea96af
commit 6885e1679c
4 changed files with 90 additions and 17 deletions

View File

@ -295,9 +295,12 @@ export function withdrawReceive(data) {
return request.post('withdraw/receive', data) return request.post('withdraw/receive', data)
} }
// 分销推广扫码进入的提交申请 // 分销推广扫码进入的提交申请
export function scanSubmit(data) { export function scanSubmit(data) {
return request.post('distribution/wxCodeApply', data) return request.post('distribution/wxCodeApply', data)
} }
// 扫码进入首页需要请求的接口
export function scanHome(data) {
return request.post('distribution/wxCode', data)
}

View File

@ -16,9 +16,9 @@
<view class="avatar-tag white xxs text-center m-b-10" v-if="distributionInfo.level_name">{{distributionInfo.level_name}}</view> <view class="avatar-tag white xxs text-center m-b-10" v-if="distributionInfo.level_name">{{distributionInfo.level_name}}</view>
<view class="xs flex"> <view class="xs flex">
上级分销商:{{userInfo.leader.nickname ? userInfo.leader.nickname : '无'}} 上级分销商:{{userInfo.leader.nickname ? userInfo.leader.nickname : '无'}}
<view v-if="!userInfo.leader.nickname" <!-- <view v-if="!userInfo.leader.nickname"
class="br60 white write-btn flex row-center m-l-30 xxs" @tap="showInvitePop">填写 class="br60 white write-btn flex row-center m-l-30 xxs" @tap="showInvitePop">填写
</view> </view> -->
</view> </view>
</view> </view>
</view> </view>
@ -155,15 +155,16 @@
<u-icon class="m-l-10" name="arrow-right" size="28rpx" color="#666" /> <u-icon class="m-l-10" name="arrow-right" size="28rpx" color="#666" />
</view> </view>
</router-link> </router-link>
</view> </view>
<view class="my-invite-box m-t-20 bg-white flex-col col-center"> <view class="my-invite-box m-t-20 bg-white flex-col col-center" @tap="previewImage">
<view class="my-invite-title sm normal">我的邀请码</view> <view class="my-invite-title sm normal">我的邀请码</view>
<view class="flex bold m-t-20" style="font-size: 42rpx;line-height: 30rpx"> <view class="flex justify-center m-t-20 m-b-20" v-if="distributionInfo && distributionInfo.user && distributionInfo.user.url">
<image :src="distributionInfo.user.url" alt="" style="width: 200rpx;height: 200rpx;" show-menu-by-longpress></image>
</view>
<!-- <view class="flex bold m-t-20" style="font-size: 42rpx;line-height: 30rpx">
{{userInfo.user.distribution_code}} {{userInfo.user.distribution_code}}
<view class="invite-copy-btn m-l-10 xxs" @click="onCopy">点击复制</view> <view class="invite-copy-btn m-l-10 xxs" @click="onCopy">点击复制</view>
</view> </view> -->
<!-- <view class="row-center my-promote-banner bg-primary white">我的推广海报</view> --> <!-- <view class="row-center my-promote-banner bg-primary white">我的推广海报</view> -->
</view> </view>
<view class="usual-tools-box bg-white m-t-20"> <view class="usual-tools-box bg-white m-t-20">
@ -258,7 +259,9 @@
inviteStatus: false, inviteStatus: false,
showRegion: false, showRegion: false,
regionLists: area, regionLists: area,
distributionInfo: {}, distributionInfo: {
user: {}
},
isScanEntry: false isScanEntry: false
}; };
}, },
@ -427,6 +430,7 @@
this.$toast({ this.$toast({
title: msg title: msg
}); });
this.getDistributionFun();
this.veryfiyDistributeFun(); this.veryfiyDistributeFun();
this.applyDetailFun(); this.applyDetailFun();
} }
@ -465,6 +469,13 @@
copy(this.userInfo.user.distribution_code) copy(this.userInfo.user.distribution_code)
}, },
previewImage() {
uni.previewImage({
urls: [this.distributionInfo.user.url],
current: 0
})
},
} }
}; };
</script> </script>
@ -479,8 +490,6 @@
.user-info { .user-info {
.user-avatar { .user-avatar {
position: relative; position: relative;
} }
.avatar-tag { .avatar-tag {
display: inline-block; display: inline-block;

View File

@ -12,7 +12,6 @@
"navigationBarTitleText": "首页", "navigationBarTitleText": "首页",
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"disableScroll": true,
"app-plus": { "app-plus": {
"bounce": "none" "bounce": "none"
} }

View File

@ -87,6 +87,14 @@
</view> </view>
</view> </view>
</view> </view>
<view class="">
<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 <!-- <view
class="flex row-center white br60 sm flex-none subscribe-btn" class="flex row-center white br60 sm flex-none subscribe-btn"
:class="{ gray: shopInfo.shop_follow_status === 1 }" :class="{ gray: shopInfo.shop_follow_status === 1 }"
@ -228,6 +236,8 @@ import { getShopLive } from '@/api/live'
import { getGoodsList } from '@/api/store' import { getGoodsList } from '@/api/store'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js' import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js'
import { getCouponList } from '@/api/activity' import { getCouponList } from '@/api/activity'
import { strToParams } from '../../utils/tools'
import { scanHome } from '@/api/user'
export default { export default {
mixins: [MescrollMixin], // 使用mixin mixins: [MescrollMixin], // 使用mixin
@ -264,11 +274,17 @@ export default {
enableFix: true, enableFix: true,
id: '', id: '',
shopLive: {}, shopLive: {},
superiorUserId: 0,
hasHandleSuperior: false
} }
}, },
async onLoad() { async onLoad() {
// this.id = this.$Route.query.id 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() this.sys = uni.getSystemInfoSync()
await this.getShopInfoFun() await this.getShopInfoFun()
await this.getShopGoodsCategoryFun() await this.getShopGoodsCategoryFun()
@ -278,6 +294,7 @@ export default {
// #endif // #endif
this.isFirstLoading = false this.isFirstLoading = false
this.mescroll.resetUpScroll() this.mescroll.resetUpScroll()
this.handleSuperiorUser()
}, },
onHide() { onHide() {
// #ifdef H5 // #ifdef H5
@ -288,6 +305,7 @@ export default {
// #ifdef H5 // #ifdef H5
this.enableFix = true this.enableFix = true
// #endif // #endif
this.handleSuperiorUser()
}, },
onShareAppMessage() { onShareAppMessage() {
return { return {
@ -297,6 +315,43 @@ export default {
}, },
methods: { methods: {
...mapActions(['initLocationFunc']), ...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() { getCurrentCity() {
if (!this.appConfig.is_open_nearby) return if (!this.appConfig.is_open_nearby) return
this.initLocationFunc() this.initLocationFunc()
@ -430,7 +485,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['sysInfo', 'appConfig', 'cityInfo']), ...mapGetters(['sysInfo', 'appConfig', 'cityInfo', 'isLogin']),
navHeight() { navHeight() {
return this.sysInfo.navHeight + 'px' return this.sysInfo.navHeight + 'px'
}, },
@ -451,7 +506,7 @@ export default {
watch: { watch: {
'cityInfo.id': { 'cityInfo.id': {
async handler(val, oldVal) { async handler(val, oldVal) {
if (val && val !== oldVal) { if (val !== undefined && val !== oldVal) {
await this.getShopInfoFun() await this.getShopInfoFun()
await this.getShopGoodsCategoryFun() await this.getShopGoodsCategoryFun()
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
@ -500,6 +555,13 @@ page {
background: #ccc; background: #ccc;
} }
} }
.switch-btn {
background: linear-gradient(97deg, #ff5784 0%, #ff2c3c 100%);
height: 52rpx;
padding: 0 16rpx;
font-size: 24rpx;
}
} }
} }