Files
lucky_shop/pages_tool/goods/coupon.vue
ZF sun 2a2161c9d9 refactor: 整理多页面语言包调用路径,统一翻译键层级
1. 调整品牌专区、商品评价、搜索、优惠券等页面的语言翻译引用,将零散翻译项归类到对应模块下
2. 优化auth.js中的语言包路径引用,修正模块命名空间
3. 清理zh-cn/en-us品牌语言包的冗余嵌套结构
2026-07-03 11:23:05 +08:00

474 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view :style="themeColor">
<view class="cf-container color-line-border">
<view class="tab">
<view @click="changeSort(1)"><text
:class="sort == 1 ? 'color-base-text active color-base-border-bottom' : ''">{{ $lang('goods.coupon.tabAll') }}</text></view>
<view @click="changeSort(2, 'reward')"><text
:class="sort == 2 ? 'color-base-text active color-base-border-bottom' : ''">{{ $lang('goods.coupon.tabReward') }}</text></view>
<view @click="changeSort(3, 'discount')"><text
:class="sort == 3 ? 'color-base-text active color-base-border-bottom' : ''">{{ $lang('goods.coupon.tabDiscount') }}</text></view>
<!-- <view @click="changeSort(4, 'no_threshold')"><text :class="sort == 4 ? 'color-base-text active color-base-border-bottom' : ''">无门槛券</text></view> -->
</view>
</view>
<mescroll-uni ref="mescroll" top="100" @getData="getMemberCouponList" :style="tabBarPagePaddingStyle">
<block slot="list">
<view class="coupon-listone">
<view class="item" v-for="(item, index) in list" :key="index" @click="liClick(item, index)"
:style="{ backgroundColor: item.useState == 2 ? '#F2F2F2' : 'var(--main-color-shallow)' }">
<view class="item-base" :class="{ disabled: item.useState == 2 }">
<image class="coupon-line" mode="heightFix"
:src="$util.img('public/uniapp/coupon/coupon_line.png')" show-menu-by-longpress></image>
<view>
<view class="use_price price-font" v-if="item.type == 'reward'"
:class="{ disabled: item.useState == 2 }">
<text>¥</text>
{{ parseFloat(item.money) }}
</view>
<view class="use_price price-font" v-else-if="item.type == 'discount'"
:class="{ disabled: item.useState == 2 }">
{{ $lang('goods.coupon.discountText', { discount: parseFloat(item.discount) }) }}
</view>
<view class="use_condition font-size-tag" v-if="item.at_least > 0"
:class="{ disabled: item.useState == 2 }">{{ $lang('goods.coupon.minSpendAvailable', { atLeast: item.at_least }) }}</view>
<view class="use_condition font-size-tag" v-else
:class="{ disabled: item.useState == 2 }">{{ $lang('goods.coupon.noThresholdCoupon') }}</view>
</view>
</view>
<view class="item-info">
<view class="use_title">
<view class="title">{{ item.coupon_name }}</view>
<view class="max_price" v-if="item.goods_type == 2 || item.goods_type == 3"
:class="{ disabled: item.useState == 2 }">{{ $lang('goods.coupon.specifiedGoods') }}</view>
<view class="max_price" v-else :class="{ disabled: item.useState == 2 }">{{ $lang('goods.coupon.allGoods') }}</view>
<view class="max_price" v-if="item.discount_limit != '0.00'">
{{ $lang('goods.coupon.maxDiscount', { amount: item.discount_limit }) }}
</view>
<view class="max_price" :class="{ disabled: item.useState == 2 }">{{
item.use_channel_name }}</view>
<!-- <view class="max_price truncate" v-if="item.use_channel!='online'" :class="{ disabled: item.useState == 2 }">
{{ item.use_store==='all'?'适用门店:全部门店': '适用门店:'+item.use_store_name}}
</view> -->
</view>
<view class="use_time" v-if="item.validity_type == 0">
{{ $lang('goods.coupon.validPeriodDate', { date: $util.timeStampTurnTime(item.end_time) }) }}</view>
<view class="use_time" v-else-if="item.validity_type == 1">
{{ $lang('goods.coupon.validPeriodDays', { days: item.fixed_term }) }}</view>
<view class="use_time" v-else>{{ $lang('goods.coupon.validPeriodLong') }}</view>
</view>
<view class="item-btn">
<view v-if="item.useState == 0" @click.stop="receiveCoupon(item, index)">{{ $lang('goods.coupon.receive') }}</view>
<view v-if="item.useState == 1" @click.stop="toGoodsList(item, index)">{{ $lang('goods.coupon.useNow') }}</view>
<view v-if="item.receivedType == 'out'" class="disabled">{{ $lang('goods.coupon.soldOut') }}</view>
<view v-if="item.receivedType == 'expire'" class="disabled">{{ $lang('goods.coupon.expired') }}</view>
<view v-if="item.receivedType == 'limit'" class="disabled">{{ $lang('goods.coupon.limitReached') }}</view>
</view>
</view>
</view>
<view v-if="list.length == 0"><ns-empty :text="$lang('goods.coupon.emptyText')" :isIndex="false"></ns-empty></view>
</block>
</mescroll-uni>
<loading-cover ref="loadingCover"></loading-cover>
<ns-login ref="login"></ns-login>
<!-- 隐私弹窗 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- 底部tabBar -->
<view id="tab-bar">
<diy-bottom-nav></diy-bottom-nav>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list: [],
sort: 1,
types: '',
couponBtnSwitch: false,
//分享建立上下级id
mpShareData: null //小程序分享数据
};
},
onLoad(option) {
setTimeout(() => {
if (!this.addonIsExist.coupon) {
this.$util.showToast({
title: this.$lang('goods.coupon.merchantNotEnabled'),
mask: true,
duration: 2000
});
setTimeout(() => {
this.$util.redirectTo(this.$util.INDEX_PAGE_URL);
}, 2000);
}
}, 1000);
//小程序分享接收source_member
if (option.source_member) {
uni.setStorageSync('source_member', option.source_member);
}
// 小程序扫码进入,接收source_member
if (option.scene) {
var sceneParams = decodeURIComponent(option.scene);
sceneParams = sceneParams.split('&');
if (sceneParams.length) {
sceneParams.forEach(item => {
if (item.indexOf('sku_id') != -1) this.skuId = item.split('-')[1];
if (item.indexOf('m') != -1) uni.setStorageSync('source_member', item.split('-')[1]);
if (item.indexOf('is_test') != -1) uni.setStorageSync('is_test', 1);
});
}
}
},
onShow() {
//记录分享关系
if (this.storeToken && uni.getStorageSync('source_member')) {
this.$util.onSourceMember(uni.getStorageSync('source_member'));
}
//小程序分享
// #ifdef MP-WEIXIN
this.$util.getMpShare().then(res => {
this.mpShareData = res;
});
// #endif
},
//分享给好友
onShareAppMessage() {
return this.mpShareData.appMessage;
},
//分享到朋友圈
onShareTimeline() {
return this.mpShareData.timeLine;
},
methods: {
changeSort(sort, types) {
this.list = [];
this.sort = sort;
this.types = types;
this.$refs.mescroll.refresh(false);
},
liClick(item, index) {
if (['limit', 'expire', 'out'].includes(item.receivedType)) return false;
if (item.useState == 0) this.receiveCoupon(item, index);
else this.toGoodsList(item, index);
},
//领取优惠券
receiveCoupon(item, index) {
if (this.couponBtnSwitch) return;
this.couponBtnSwitch = true;
if (this.storeToken) {
this.$api.sendRequest({
url: '/coupon/api/coupon/receive',
data: {
coupon_type_id: item.coupon_type_id,
get_type: 2 //获取方式:1订单2.直接领取3.活动领取
},
success: res => {
this.couponBtnSwitch = false;
let msg = this.$lang('goods.coupon.receiveSuccess');
let list = this.list;
if (res.code < 0) msg = res.message;
if (res.data.is_exist == 1) {
for (let i = 0; i < list.length; i++) {
if (list[i].coupon_type_id == item.coupon_type_id) {
list[i].useState = 1;
}
}
} else {
for (let i = 0; i < list.length; i++) {
if (list[i].coupon_type_id == item.coupon_type_id) {
list[i].receivedType = res.data.type;
list[i].useState = 2;
}
}
}
this.$util.showToast({
title: msg
});
},
fail: res => {
this.couponBtnSwitch = false;
}
});
} else {
this.couponBtnSwitch = false;
this.redirectTologin('/pages_tool/goods/coupon');
return;
}
},
//获取优惠券列表
getMemberCouponList(mescroll) {
this.$api.sendRequest({
url: '/coupon/api/coupon/typepagelists',
data: {
page: mescroll.num,
page_size: mescroll.size,
sort: this.sort,
type: this.types
},
success: res => {
let newArr = [];
let msg = res.message;
if (res.code == 0 && res.data) {
newArr = res.data.list;
} else {
this.$util.showToast({
title: msg
});
}
mescroll.endSuccess(newArr.length);
if (newArr.length) {
newArr.forEach(v => {
if (v.count == v.lead_count) v.useState = 2;
else if (v.max_fetch != 0 && v.member_coupon_num && v.member_coupon_num >= v.max_fetch) v.useState = 1;
else v.useState = 0;
});
}
//设置列表数据
if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
this.list = this.list.concat(newArr); //追加新数据
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail() {
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
imageError(index) {
this.list[index].logo = this.$util.getDefaultImage().goods;
this.$forceUpdate();
},
couponImageError(index) {
this.list[index].image = this.$util.img('public/uniapp/goods/coupon.png');
this.$forceUpdate();
},
toGoodsList(item) {
if (item.goods_type != 1) {
this.$util.redirectTo('/pages_goods/list', {
coupon: item.coupon_type_id
});
} else {
this.$util.redirectTo('/pages_goods/list', {});
}
}
}
};
</script>
<style lang="scss">
.coupon-head {
padding: 20rpx 50rpx;
display: flex;
background: #fff;
.sort {
border: 2rpx solid #c5c5c5;
padding: 1rpx 20rpx;
border-radius: $border-radius;
cursor: pointer;
margin-right: 15rpx;
}
}
.coupon-listone {
padding: 0 30rpx;
.item {
display: flex;
background-color: #fff2f0;
background-size: 100% 100%;
border-radius: 20rpx;
align-items: stretch;
margin-top: $padding;
overflow: hidden;
.item-base {
position: relative;
width: 197rpx;
min-width: 197rpx;
text-align: center;
background: linear-gradient(to left, var(--bg-color), var(--bg-color-shallow));
background-repeat: no-repeat;
background-size: 100% 100%;
padding: 38rpx 10rpx 38rpx 18rpx;
&.disabled {
background: #dedede;
}
.coupon-line {
position: absolute;
right: 0;
top: 0;
height: 100%;
}
>view {
height: auto;
position: relative;
top: 50%;
transform: translate(0, -50%);
}
.use_price {
font-size: 60rpx;
line-height: 1;
color: #fff;
text {
font-size: $font-size-toolbar;
}
&.disabled {
color: $color-tip;
}
}
.use_condition {
color: #fff;
margin-top: $padding;
&.margin_top_none {
margin-top: 0;
}
&.disabled {
color: $color-tip;
}
}
&::after {
position: absolute;
content: '';
background-color: #f8f8f8;
left: 0;
top: 50%;
transform: translate(0, -50%);
height: 30rpx;
width: 15rpx;
border-radius: 0 30rpx 30rpx 0;
}
}
.item-btn {
width: 160rpx;
min-width: 160rpx;
align-self: center;
position: relative;
view {
width: 100rpx;
height: 50rpx;
border-radius: $border-radius;
line-height: 50rpx;
margin: auto;
text-align: center;
background-image: linear-gradient(to right, var(--bg-color), var(--bg-color-shallow));
color: var(--btn-text-color);
font-size: $font-size-tag;
&.disabled {
background: #dedede !important;
color: #909399 !important;
}
}
&::after {
position: absolute;
content: '';
background-color: #f8f8f8;
right: 0;
top: 50%;
transform: translate(0, -50%);
height: 30rpx;
width: 15rpx;
border-radius: 30rpx 0 0 30rpx;
}
}
.item-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
margin-left: 20rpx;
overflow: hidden;
background-repeat-x: no-repeat;
background-repeat-y: repeat;
.use_time {
padding: 20rpx 0;
border-top: 2rpx dashed #cccccc;
font-size: $font-size-activity-tag;
color: #909399;
}
.use_title {
font-size: $font-size-base;
font-weight: 500;
padding: 20rpx 0;
// height:80rpx;
.title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.max_price {
font-weight: 400;
font-size: $font-size-tag;
}
}
}
}
}
.empty {
margin-top: 200rpx;
}
.cf-container {
background: #fff;
overflow: hidden;
}
.tab {
display: flex;
justify-content: space-between;
height: 86rpx;
>view {
text-align: center;
width: 33%;
height: 86rpx;
text {
display: inline-block;
line-height: 86rpx;
height: 80rpx;
font-size: 30rpx;
}
}
}
.active {
border-bottom: 4rpx solid;
}
.truncate {
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>