修复分销中心绑定成功后不刷新的问题
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// 引入 request 文件
|
||||
import request from '@/common/api/request.js'
|
||||
import {prveUrl} from './config.js'
|
||||
import {
|
||||
prveUrl
|
||||
} from './config.js'
|
||||
|
||||
export const consumeDiscount = (data) => {
|
||||
return request({
|
||||
@@ -16,3 +18,11 @@ export const homeData = (data) => {
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 清除所有分销绑定关系
|
||||
export const distributionClear = (data) => {
|
||||
return request({
|
||||
url: prveUrl + '/user/distribution/clean',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<view class="u-flex align-center justify-between">
|
||||
<view class="u-flex align-center">
|
||||
<!-- <up-avatar size="62rpx" /> -->
|
||||
<text class="u-m-l-14 font-14 color-333 font-700">{{ state.shopName }}</text>
|
||||
<text class="u-m-l-14 font-14 color-333 font-700" @click="distributionClear">{{ state.shopName }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<template v-if="state.parentPhone">
|
||||
@@ -26,15 +26,12 @@
|
||||
<text class="color-333 font-700 u-m-r-6" v-if="state.distributionUser">
|
||||
{{ state.distributionUser.level }}级 {{ state.distributionUser.levelName }}
|
||||
</text>
|
||||
<up-icon name="question-circle" size="24rpx" color="#666"
|
||||
@click="questionClick('等级升级条件')" />
|
||||
<up-icon name="question-circle" size="24rpx" color="#666" @click="questionClick('等级升级条件')" />
|
||||
</view>
|
||||
<view class="u-m-t-28 u-flex align-center"
|
||||
v-if="juNextLvMoney && state.distributionUser && state.distributionUser.isAssignLevel == 0">
|
||||
<view class="u-m-t-28 u-flex align-center" v-if="juNextLvMoney && state.distributionUser && state.distributionUser.isAssignLevel == 0">
|
||||
<text class="color-666">距离下一级还差:</text>
|
||||
<text class="color-333 font-700 u-m-r-18">{{ juNextLvMoney }}</text>
|
||||
<text class="color-333 font-700 u-m-r-18">{{ config.upgradeType == 'cost' ? '元' : '人'
|
||||
}}</text>
|
||||
<text class="color-333 font-700 u-m-r-18">{{ config.upgradeType == 'cost' ? '元' : '人' }}</text>
|
||||
<!-- <up-icon
|
||||
name="question-circle"
|
||||
size="24rpx"
|
||||
@@ -46,22 +43,18 @@
|
||||
<view class="u-flex-1">
|
||||
<view class="u-flex align-center">
|
||||
<text class="u-m-r-10 font-12 color-666" @click="toShouyiDetail('')">总收益</text>
|
||||
<up-icon name="question-circle" size="24rpx" color="#666"
|
||||
@click="questionClick('总收益')" />
|
||||
<up-icon name="question-circle" size="24rpx" color="#666" @click="questionClick('总收益')" />
|
||||
</view>
|
||||
<view class="u-m-t-16 price" @click="toShouyiDetail('')" v-if="state.distributionUser">
|
||||
{{
|
||||
state.distributionUser.totalIncome }}</view>
|
||||
{{ state.distributionUser.totalIncome }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<view class="u-flex align-center">
|
||||
<text class="u-m-r-10 font-12 color-666" @click="toShouyiDetail('待入账')">待入账</text>
|
||||
<up-icon name="question-circle" size="24rpx" color="#666"
|
||||
@click="questionClick('待入账')" />
|
||||
<up-icon name="question-circle" size="24rpx" color="#666" @click="questionClick('待入账')" />
|
||||
</view>
|
||||
<view class="u-m-t-16 price" @click="toShouyiDetail('待入账')"
|
||||
v-if="state.distributionUser">{{
|
||||
state.distributionUser.pendingIncome }}</view>
|
||||
<view class="u-m-t-16 price" @click="toShouyiDetail('待入账')" v-if="state.distributionUser">{{ state.distributionUser.pendingIncome }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -73,8 +66,7 @@
|
||||
<view class="u-m-t-16 color-666 font-14">
|
||||
<view>需要邀请人数:{{ config.inviteCount }}人</view>
|
||||
<view>是否需要邀请人数下单:{{ config.inviteConsume ? '是' : '否' }}</view>
|
||||
<view>每人可获得的分销奖励次数:{{ config.rewardCount == -1 ? '永久' : config.rewardCount + '次' }}
|
||||
</view>
|
||||
<view>每人可获得的分销奖励次数:{{ config.rewardCount == -1 ? '永久' : config.rewardCount + '次' }}</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="config.openType == 'pay'">
|
||||
@@ -107,11 +99,8 @@
|
||||
</view>
|
||||
|
||||
<view class="tabs" v-if="false">
|
||||
<view class="tabs-item" :class="{ active: activeTab == 'distributor' }"
|
||||
@click="activeTab = 'distributor'">分销员
|
||||
</view>
|
||||
<view class="tabs-item" :class="{ active: activeTab == 'inviter' }" @click="activeTab = 'inviter'">邀请人
|
||||
</view>
|
||||
<view class="tabs-item" :class="{ active: activeTab == 'distributor' }" @click="activeTab = 'distributor'">分销员</view>
|
||||
<view class="tabs-item" :class="{ active: activeTab == 'inviter' }" @click="activeTab = 'inviter'">邀请人</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-48 font-14">
|
||||
@@ -121,8 +110,7 @@
|
||||
<view>邀请时间</view>
|
||||
</view>
|
||||
<view class="u-m-t-16">
|
||||
<view v-for="(item, index) in userList" :key="index"
|
||||
class="u-flex justify-between align-center recoder-item color-666 font-12">
|
||||
<view v-for="(item, index) in userList" :key="index" class="u-flex justify-between align-center recoder-item color-666 font-12">
|
||||
<view class="">
|
||||
<view class="u-line-1" style="max-width: 160rpx">
|
||||
<text>
|
||||
@@ -158,8 +146,7 @@
|
||||
<view>我的收益什么时候可以到账?</view>
|
||||
<view>分销的结算时长为{{ config.settlementDay || 0 }}天</view>
|
||||
</view>
|
||||
<template
|
||||
v-if="config.upgradeType != 'not_upgrade' && config.levelConfigList && config.levelConfigList.length >= 2">
|
||||
<template v-if="config.upgradeType != 'not_upgrade' && config.levelConfigList && config.levelConfigList.length >= 2">
|
||||
<view class="u-m-t-40">
|
||||
<view>怎么样才能升级分销员等级?</view>
|
||||
|
||||
@@ -191,9 +178,7 @@
|
||||
<view style="height: 240rpx"></view>
|
||||
</template>
|
||||
|
||||
<view class="tips u-m-t-32" v-if="state.distributionUser && state.distributionUser.status">
|
||||
您的分销员身份已取消,不再获得分成有疑问可联系商家
|
||||
</view>
|
||||
<view class="tips u-m-t-32" v-if="state.distributionUser && state.distributionUser.status">您的分销员身份已取消,不再获得分成有疑问可联系商家</view>
|
||||
|
||||
<view class="u-flex justify-center bottom-btn" v-if="showInviteCode">
|
||||
<view class="copy" @click="copyCode">
|
||||
@@ -205,25 +190,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="buy" v-if="config.openType == 'pay' && config.payAmount && !isActivated" @click="buy">付费{{
|
||||
config.payAmount
|
||||
}}元开通</view>
|
||||
<view class="buy" v-if="config.openType == 'pay' && config.payAmount && !isActivated" @click="buy">付费{{ config.payAmount }}元开通</view>
|
||||
|
||||
<bindShangji v-model="showBindShangji" @confirm="confirmBindShangji"></bindShangji>
|
||||
<sharePopup v-model="showSharePopup"
|
||||
<sharePopup
|
||||
v-model="showSharePopup"
|
||||
v-if="(state.distributionUser && state.distributionUser.inviteCode) || inviteCode"
|
||||
:inviteCode="state.distributionUser ? state.distributionUser.inviteCode : inviteCode"
|
||||
:shopUserInfo="shopUserInfo">
|
||||
</sharePopup>
|
||||
:shopUserInfo="shopUserInfo"
|
||||
></sharePopup>
|
||||
|
||||
<TipsPopup v-model="showPopup" :tips-type="tipsType"></TipsPopup>
|
||||
<commissionPopup :tipsType="commissionTipsType" v-model="showCommission" :config="config"
|
||||
:levelConfigList="config.levelConfigList || []"></commissionPopup>
|
||||
<commissionPopup :tipsType="commissionTipsType" v-model="showCommission" :config="config" :levelConfigList="config.levelConfigList || []"></commissionPopup>
|
||||
<rulePopup v-model="showRule" :config="config" :distributionUser="state.distributionUser"></rulePopup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { distributionClear } from '@/common/api/market';
|
||||
import { shareMixin, handleMixinOnLoad, returnQuery } from '@/utils/share.js';
|
||||
import bindShangji from './components/bind-shangji.vue';
|
||||
import sharePopup from './components/share-popup.vue';
|
||||
@@ -274,17 +258,16 @@ function back() {
|
||||
// uni.navigateBack({
|
||||
// delta: 1
|
||||
// });
|
||||
safeNavigateBack()
|
||||
safeNavigateBack();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修复版:安全的页面返回方法
|
||||
* 彻底避免 "cannot navigate back at first page" 报错
|
||||
* @param {Number} delta 返回的页面数,默认1
|
||||
* @param {Function} fallback 失败时的降级处理函数
|
||||
*/
|
||||
function safeNavigateBack(delta = 1, fallback) {
|
||||
function safeNavigateBack(delta = 1) {
|
||||
// 1. 立即获取页面栈,确保拿到最新状态(关键修复点)
|
||||
const pages = getCurrentPages();
|
||||
// 2. 严谨判断:页面栈长度必须大于 delta 才能返回
|
||||
@@ -299,7 +282,7 @@ function safeNavigateBack(delta = 1, fallback) {
|
||||
// 3. 如果不能返回,直接执行降级逻辑
|
||||
if (!canNavigateBack) {
|
||||
console.warn('当前是首页/页面栈不足,无法返回');
|
||||
handleFallback(fallback);
|
||||
handleFallback();
|
||||
return; // 终止后续执行,彻底避免调用 navigateBack
|
||||
}
|
||||
|
||||
@@ -312,12 +295,12 @@ function safeNavigateBack(delta = 1, fallback) {
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('navigateBack 执行失败:', err);
|
||||
handleFallback(fallback);
|
||||
handleFallback();
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('页面返回异常:', error);
|
||||
handleFallback(fallback);
|
||||
handleFallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,27 +308,15 @@ function safeNavigateBack(delta = 1, fallback) {
|
||||
* 统一处理降级逻辑
|
||||
* @param {Function} fallback 自定义降级函数
|
||||
*/
|
||||
function handleFallback(fallback) {
|
||||
if (typeof fallback === 'function') {
|
||||
fallback(); // 执行自定义降级
|
||||
} else {
|
||||
// 默认降级:返回首页(请替换为你的首页路径)
|
||||
uni.showToast({
|
||||
title: '已到首页,无法返回',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
// 如果需要强制跳首页,解开下面注释(根据你的业务选择)
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index',
|
||||
fail: () => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function handleFallback() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index',
|
||||
fail: () => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function confirmBindShangji(code) {
|
||||
@@ -419,6 +390,8 @@ async function init() {
|
||||
}
|
||||
content.value = res.config ? res.config.notActivatedPage : '';
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
const options = reactive({ type: '' });
|
||||
const imageStyle = computed(() => {
|
||||
@@ -588,18 +561,21 @@ onShareAppMessage(async (res) => {
|
||||
});
|
||||
|
||||
onLoad(async (opt) => {
|
||||
if (opt.q) {
|
||||
const q = decodeURIComponent(opt.q);
|
||||
const params = parseQueryString(q.split('?')[1]);
|
||||
await handleMixinOnLoad(params);
|
||||
Object.assign(options, params);
|
||||
} else {
|
||||
try {
|
||||
await handleMixinOnLoad(opt);
|
||||
Object.assign(options, opt);
|
||||
if (opt.q) {
|
||||
const q = decodeURIComponent(opt.q);
|
||||
const params = parseQueryString(q.split('?')[1]);
|
||||
Object.assign(options, params);
|
||||
} else {
|
||||
Object.assign(options, opt);
|
||||
}
|
||||
console.log(options);
|
||||
await init();
|
||||
getRecoders();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
console.log(options);
|
||||
await init();
|
||||
getRecoders();
|
||||
});
|
||||
|
||||
onReachBottom(async () => {
|
||||
@@ -668,7 +644,8 @@ onReachBottom(async () => {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.shouxufei {}
|
||||
.shouxufei {
|
||||
}
|
||||
|
||||
.shouyi {
|
||||
font-size: 24rpx;
|
||||
|
||||
@@ -34,7 +34,7 @@ if (envVersion === 'trial') {
|
||||
* @param {string} args.inviteCode - 邀请人的邀请码(必填,非空校验通过后才会执行绑定逻辑)
|
||||
* @returns {void} 无返回值
|
||||
*/
|
||||
export function bindInvite(args) {
|
||||
export async function bindInvite(args) {
|
||||
// 解构入参对象,获取需要的核心参数
|
||||
const {
|
||||
shopUserId,
|
||||
@@ -46,10 +46,10 @@ export function bindInvite(args) {
|
||||
if (!inviteCode || inviteCode === null || inviteCode === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const shopUserInfo=uni.cache.get('shopUserInfo')
|
||||
|
||||
const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
// 邀请码有效,调用自动绑定邀请人接口,传递绑定所需参数
|
||||
autoBindInviteUser({
|
||||
return await autoBindInviteUser({
|
||||
id: shopUserInfo.id,
|
||||
shopId,
|
||||
inviteCode
|
||||
@@ -185,9 +185,8 @@ export async function handleMixinOnLoad(opt, vm) {
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
|
||||
if (options.inviteCode) {
|
||||
bindInvite(options)
|
||||
return await bindInvite(options)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user