首页添加本地店铺和旗舰店的切换功能
This commit is contained in:
@ -295,9 +295,12 @@ export function withdrawReceive(data) {
|
||||
return request.post('withdraw/receive', data)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 分销推广扫码进入的提交申请
|
||||
export function scanSubmit(data) {
|
||||
return request.post('distribution/wxCodeApply', data)
|
||||
}
|
||||
|
||||
// 扫码进入首页需要请求的接口
|
||||
export function scanHome(data) {
|
||||
return request.post('distribution/wxCode', data)
|
||||
}
|
||||
|
||||
@ -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="xs flex">
|
||||
上级分销商:{{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">填写
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -155,15 +155,16 @@
|
||||
<u-icon class="m-l-10" name="arrow-right" size="28rpx" color="#666" />
|
||||
</view>
|
||||
</router-link>
|
||||
|
||||
|
||||
</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="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}}
|
||||
<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>
|
||||
<view class="usual-tools-box bg-white m-t-20">
|
||||
@ -258,7 +259,9 @@
|
||||
inviteStatus: false,
|
||||
showRegion: false,
|
||||
regionLists: area,
|
||||
distributionInfo: {},
|
||||
distributionInfo: {
|
||||
user: {}
|
||||
},
|
||||
isScanEntry: false
|
||||
};
|
||||
},
|
||||
@ -427,6 +430,7 @@
|
||||
this.$toast({
|
||||
title: msg
|
||||
});
|
||||
this.getDistributionFun();
|
||||
this.veryfiyDistributeFun();
|
||||
this.applyDetailFun();
|
||||
}
|
||||
@ -465,6 +469,13 @@
|
||||
copy(this.userInfo.user.distribution_code)
|
||||
},
|
||||
|
||||
previewImage() {
|
||||
uni.previewImage({
|
||||
urls: [this.distributionInfo.user.url],
|
||||
current: 0
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@ -479,8 +490,6 @@
|
||||
.user-info {
|
||||
.user-avatar {
|
||||
position: relative;
|
||||
|
||||
|
||||
}
|
||||
.avatar-tag {
|
||||
display: inline-block;
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTextStyle": "white",
|
||||
"disableScroll": true,
|
||||
"app-plus": {
|
||||
"bounce": "none"
|
||||
}
|
||||
|
||||
@ -87,6 +87,14 @@
|
||||
</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
|
||||
class="flex row-center white br60 sm flex-none subscribe-btn"
|
||||
:class="{ gray: shopInfo.shop_follow_status === 1 }"
|
||||
@ -228,6 +236,8 @@ 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
|
||||
@ -264,11 +274,17 @@ export default {
|
||||
enableFix: true,
|
||||
id: '',
|
||||
shopLive: {},
|
||||
|
||||
superiorUserId: 0,
|
||||
hasHandleSuperior: false
|
||||
}
|
||||
},
|
||||
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()
|
||||
await this.getShopInfoFun()
|
||||
await this.getShopGoodsCategoryFun()
|
||||
@ -278,6 +294,7 @@ export default {
|
||||
// #endif
|
||||
this.isFirstLoading = false
|
||||
this.mescroll.resetUpScroll()
|
||||
this.handleSuperiorUser()
|
||||
},
|
||||
onHide() {
|
||||
// #ifdef H5
|
||||
@ -288,6 +305,7 @@ export default {
|
||||
// #ifdef H5
|
||||
this.enableFix = true
|
||||
// #endif
|
||||
this.handleSuperiorUser()
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
@ -297,6 +315,43 @@ export default {
|
||||
},
|
||||
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()
|
||||
@ -430,7 +485,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['sysInfo', 'appConfig', 'cityInfo']),
|
||||
...mapGetters(['sysInfo', 'appConfig', 'cityInfo', 'isLogin']),
|
||||
navHeight() {
|
||||
return this.sysInfo.navHeight + 'px'
|
||||
},
|
||||
@ -451,7 +506,7 @@ export default {
|
||||
watch: {
|
||||
'cityInfo.id': {
|
||||
async handler(val, oldVal) {
|
||||
if (val && val !== oldVal) {
|
||||
if (val !== undefined && val !== oldVal) {
|
||||
await this.getShopInfoFun()
|
||||
await this.getShopGoodsCategoryFun()
|
||||
// #ifdef MP-WEIXIN
|
||||
@ -500,6 +555,13 @@ page {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.switch-btn {
|
||||
background: linear-gradient(97deg, #ff5784 0%, #ff2c3c 100%);
|
||||
height: 52rpx;
|
||||
padding: 0 16rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user