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