Files
lucky_shop/pages_tool/member/point.vue
ZF sun 2e535b9d93 refactor(member pages): unify onShow login redirect logic
1. extract common onShow login check to dedicated method redirectTologinOnShowLifecycle
2. add fallback callback for login failure to navigate back on wechat mini program
3. update all page login redirect calls to use the new unified method
4. add debug logs for redirect and auth flow tracing
2026-06-27 18:25:53 +08:00

161 lines
4.7 KiB
Vue

<template>
<view :style="themeColor" class="point">
<!-- #ifdef MP-WEIXIN -->
<view class="custom-navbar" :style="{
'padding-top': menuButtonBounding.top + 'px',
'height': menuButtonBounding.height + 'px'
}"
>
<view class="navbar-wrap">
<text class="iconfont icon-back_light back" @tap="$util.redirectTo($util.MEMBER_PAGE_URL)"></text>
<view class="navbar-title">
{{ $lang('member.point.title') }}
</view>
</view>
</view>
<!-- #endif -->
<view class="head-wrap" :style="{ background: 'url(' + $util.img('public/uniapp/point/point_bg.png') + ') no-repeat right bottom/ auto 340rpx, linear-gradient(314deg, #F16914 0%, #FEAA4C 100%)' }">
<view class="point price-font">{{ pointInfo.point }}</view>
<view class="title">{{ $lang('member.point.currentPoints') }}</view>
<view class="flex-box">
<view class="flex-item">
<view class="num price-font">{{ pointInfo.totalPoint }}</view>
<view class="font-size-tag">{{ $lang('member.point.totalPoints') }}</view>
</view>
<view class="flex-item">
<view class="num price-font">{{ pointInfo.totalConsumePoint }}</view>
<view class="font-size-tag">{{ $lang('member.point.totalConsume') }}</view>
</view>
<view class="flex-item">
<view class="num price-font">{{ pointInfo.todayPoint }}</view>
<view class="font-size-tag">{{ $lang('member.point.todayEarned') }}</view>
</view>
</view>
</view>
<view class="menu-wrap">
<view class="menu-item" @click="$util.redirectTo('/pages_tool/member/point_detail')">
<view class="icon">
<image :src="$util.img('public/uniapp/point/point_detail_icon.png')" mode="widthFix"></image>
</view>
<text class="title">{{ $lang('member.point.pointDetail') }}</text>
</view>
<view class="menu-item" @click="$util.redirectTo('/pages_promotion/point/list')">
<view class="icon">
<image :src="$util.img('public/uniapp/point/point_shop.png')" mode="widthFix" show-menu-by-longpress></image>
</view>
<text class="title">{{ $lang('member.point.pointMall') }}</text>
</view>
</view>
<!--
<view class="task-wrap">
<view class="title">做任务赚积分</view>
<view class="task-item" @click="toSign">
<view class="icon"><text class="iconfont icon-qiandao1"></text></view>
<view class="wrap">
<view class="title">每日签到</view>
<view class="desc color-tip font-size-tag">连续签到可获得更多积分</view>
</view>
<view class="btn">去签到</view>
</view>
<view class="task-item" @click="$util.redirectTo('/pages/index/index')">
<view class="icon"><text class="iconfont icon-shangpin"></text></view>
<view class="wrap">
<view class="title">购买商品</view>
<view class="desc color-tip font-size-tag">购买商品可获得积分</view>
</view>
<view class="btn">去下单</view>
</view>
</view> -->
<ns-login ref="login"></ns-login>
<loading-cover ref="loadingCover"></loading-cover>
</view>
</template>
<script>
export default {
data() {
return {
pointInfo: {
point: 0,
totalPoint: 0,
totalConsumePoint: 0,
todayPoint: 0
},
menuButtonBounding: {} // 小程序胶囊属性
};
},
onShow() {
if (!this.storeToken) {
this.redirectTologinOnShowLifecycle('/pages_tool/member/point');
return;
}
this.getMemberPoint();
},
onLoad() {
// #ifdef MP
this.menuButtonBounding = uni.getMenuButtonBoundingClientRect();
// #endif
},
methods: {
toSign() {
this.$util.redirectTo('/pages_tool/member/signin');
},
getMemberPoint() {
this.$api.sendRequest({
url: '/api/memberaccount/point',
data: {
},
success: res => {
if (res.code == 0) {
this.pointInfo.point = parseInt(res.data.point);
this.pointInfo.totalPoint = parseInt(res.data.point_all);
this.pointInfo.totalConsumePoint = parseInt(res.data.point_use);
this.pointInfo.todayPoint = parseInt(res.data.point_today);
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
/**
* 获取充值提现配置
*/
getMemberrechargeConfig() {
this.$api.sendRequest({
url: '/memberrecharge/api/memberrecharge/config',
success: res => {
if (res.code >= 0 && res.data) {
this.memberrechargeConfig = res.data;
}
}
});
}
},
onBackPress(options) {
if (options.from === 'navigateBack') {
return false;
}
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, 'reLaunch');
return true;
},
watch: {
storeToken: function(nVal, oVal) {
if (nVal) {
this.getMemberPoint();
}
}
}
};
</script>
<style lang="scss">
@import './public/css/point.scss';
</style>