tmp: 部分代码与UnishopV5结合,但是代码有严重缺陷

This commit is contained in:
2025-12-20 15:30:39 +08:00
parent ed5181b382
commit e263a616f6
183 changed files with 31316 additions and 18590 deletions

View File

@@ -1,125 +1,127 @@
<template>
<view :data-theme="themeStyle">
<mescroll-uni @getData="getBrandList" ref="mescroll" size="20">
<block slot="list">
<ns-adv keyword="NS_BRAND" class-name="adv-wrap"></ns-adv>
<view class="brand-content" v-if="brandList.length > 0">
<uni-grid :column="3" @change="change" :showBorder="!1">
<uni-grid-item v-for="(item, index) in brandList" :key="index" index="index">
<image class="brand-pic" :src="$util.img(item.image_url)" mode="widthFix"></image>
<view class="brand_name">{{ item.brand_name }}</view>
</uni-grid-item>
</uni-grid>
</view>
<view v-if="brandList.length == 0"><ns-empty text="暂无更多品牌,去首页看看吧"></ns-empty></view>
</block>
</mescroll-uni>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import uniGrid from '@/components/uni-grid/uni-grid.vue';
import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue';
import nsAdv from '@/components/ns-adv/ns-adv.vue';
export default {
components: {
uniGrid,
uniGridItem,
nsAdv
},
data() {
return {
brandList: [],
siteId: 0
};
},
onLoad(options) {
if (options.site_id) this.siteId = options.site_id;
},
onShow() {},
methods: {
change(e) {
this.$util.redirectTo('/pages/goods/list', {
brand_id: this.brandList[e.detail.index].brand_id
});
},
getBrandList(mescroll) {
this.$api.sendRequest({
url: '/api/goodsbrand/page',
data: {
page_size: mescroll.size,
page: mescroll.num,
site_id: this.siteId
},
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 (mescroll.num == 1) this.brandList = []; //如果是第一页需手动制空列表
this.brandList = this.brandList.concat(newArr); //追加新数据
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail() {
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
}
},
onShareAppMessage(res) {
var title = '你想要的大牌都在这里';
var path = '/pages_tool/goods/brand';
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
}
};
</script>
<style lang="scss">
/deep/ .uni-grid-item {
width: calc((100vw - (#{$margin-both} * 2)) / 3) !important;
}
.adv-wrap {
margin: $margin-updown $margin-both;
width: auto;
}
.brand-content {
padding: $padding 0;
box-sizing: border-box;
background: #ffffff;
margin: $margin-updown $margin-both 0;
.brand-pic {
width: 60%;
height: 50%;
}
.brand_name {
width: 70%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
}
}
<template>
<view :data-theme="themeStyle">
<mescroll-uni @getData="getBrandList" ref="mescroll" size="20">
<block slot="list">
<ns-adv keyword="NS_BRAND" class-name="adv-wrap"></ns-adv>
<view class="brand-content" v-if="brandList.length > 0">
<uni-grid :column="3" @change="change" :showBorder="!1">
<uni-grid-item v-for="(item, index) in brandList" :key="index" index="index">
<image class="brand-pic" :src="$util.img(item.image_url)" mode="widthFix"></image>
<view class="brand_name">{{ item.brand_name }}</view>
</uni-grid-item>
</uni-grid>
</view>
<view v-if="brandList.length == 0"><ns-empty text="暂无更多品牌,去首页看看吧"></ns-empty></view>
</block>
</mescroll-uni>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import uniGrid from '@/components/uni-grid/uni-grid.vue';
import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue';
import nsAdv from '@/components/ns-adv/ns-adv.vue';
export default {
components: {
uniGrid,
uniGridItem,
nsAdv
},
data() {
return {
brandList: [],
siteId: 0
};
},
onLoad(options) {
if (options.site_id) this.siteId = options.site_id;
},
onShow() {},
methods: {
change(e) {
this.$util.redirectTo('/pages/goods/list', {
brand_id: this.brandList[e.detail.index].brand_id
});
},
getBrandList(mescroll) {
this.$api.sendRequest({
url: '/api/goodsbrand/page',
data: {
page_size: mescroll.size,
page: mescroll.num,
site_id: this.siteId
},
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 (mescroll.num == 1) this.brandList = []; //如果是第一页需手动制空列表
this.brandList = this.brandList.concat(newArr); //追加新数据
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail() {
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
}
},
onShareAppMessage(res) {
var title = '你想要的大牌都在这里';
var path = '/pages_tool/goods/brand';
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
}
};
</script>
<style lang="scss">
/deep/ .uni-grid-item {
width: calc((100vw - (#{$margin-both} * 2)) / 3) !important;
}
.adv-wrap {
margin: $margin-updown $margin-both;
width: auto;
}
.brand-content {
padding: $padding 0;
box-sizing: border-box;
background: #ffffff;
margin: $margin-updown $margin-both 0;
.brand-pic {
width: 60%;
height: 50%;
}
.brand_name {
width: 70%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
}
}
</style>

View File

@@ -6,7 +6,7 @@
<view @click="changeSort(1)"><text :class="sort == 1 ? 'color-base-text active color-base-border-bottom' : ''">全部</text></view>
<view @click="changeSort(2, 'reward')"><text :class="sort == 2 ? 'color-base-text active color-base-border-bottom' : ''">满减券</text></view>
<view @click="changeSort(3, 'discount')"><text :class="sort == 3 ? 'color-base-text active color-base-border-bottom' : ''">折扣券</text></view>
<!-- <view @click="changeSort(4, 'no_threshold')"><text :class="sort == 4 ? 'color-base-text active color-base-border-bottom' : ''">无门槛券</text></view> -->
<view @click="changeSort(4, 'no_threshold')"><text :class="sort == 4 ? 'color-base-text active color-base-border-bottom' : ''">无门槛券</text></view>
</view>
</view>
@@ -32,28 +32,31 @@
<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 }">指定商品</view>
<view class="max_price" v-else :class="{ disabled: item.useState == 2 }">全场商品</view>
<view class="max_price" :class="{ disabled: item.useState == 2 }">{{item.goods_type_name}}</view>
<view class="max_price" v-if="item.discount_limit != '0.00'">
(最大优惠{{ 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 }">
<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>
<view class="use_time" v-if="item.validity_type == 0">
有效期{{ $util.timeStampTurnTime(item.end_time) }}</view>
<view class="use_time" v-else-if="item.validity_type == 1">
有效期领取之日起{{ item.fixed_term }}日内有效</view>
<view class="use_time" v-if="item.validity_type == 0">有效期{{ $util.timeStampTurnTime(item.end_time) }}</view>
<view class="use_time" v-else-if="item.validity_type == 1">有效期领取之日起{{ item.fixed_term }}日内有效</view>
<view class="use_time" v-else>有效期长期有效</view>
</view>
<view class="item-btn">
<view v-if="item.useState == 0" @click.stop="receiveCoupon(item, index)">领取</view>
<view v-if="item.useState == 0" @click.stop="receiveCoupon(item, index)">领取</view>
<view class="to-use" v-if="item.useState == 1" @click.stop="toGoodsList(item, index)">去使用</view>
<view v-if="item.useState == 2" class="disabled">已抢光</view>
<view v-if="item.useState == 3" class="disabled">已失效</view>
<view v-if="item.useState == 4" class="disabled">已使用</view>
<!-- <view v-if="item.useState == 0" @click.stop="receiveCoupon(item, index)">领取</view>
<view v-if="item.useState == 1" @click.stop="toGoodsList(item, index)">去使用</view>
<view v-if="item.receivedType == 'out'" class="disabled">已抢光</view>
<view v-if="item.receivedType == 'expire'" class="disabled">过期</view>
<view v-if="item.receivedType == 'limit'" class="disabled">达上限</view>
<view v-if="!item.received_type && item.useState == 2" class="disabled">已抢光</view>
<view v-if="item.received_type == 'out'" class="disabled">抢光</view>
<view v-if="item.received_type == 'expire'" class="disabled">过期</view>
<view v-if="item.received_type == 'limit'" class="disabled">已达上限</view> -->
</view>
</view>
</view>
@@ -62,6 +65,8 @@
</mescroll-uni>
<loading-cover ref="loadingCover"></loading-cover>
<ns-login ref="login"></ns-login>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
@@ -142,11 +147,12 @@
this.$refs.mescroll.refresh(false);
},
liClick(item, index) {
if(['limit', 'expire', 'out'].includes(item.receivedType)) return false;
// if(['limit', 'expire', 'out'].includes(item.received_type)) return false;
if(item.useState == 2) return false;
if (item.useState == 0) this.receiveCoupon(item, index);
else if(item.useState == 3 || item.useState == 4) this.$util.redirectTo('/pages_tool/member/coupon',{state: item.useState == 4 ? 2 : item.useState})
else this.toGoodsList(item, index);
},
//领取优惠券
receiveCoupon(item, index) {
if (this.couponBtnSwitch) return;
@@ -173,7 +179,7 @@
} 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].received_type = res.data.type;
list[i].useState = 2;
}
}
@@ -214,9 +220,20 @@
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(v.received_type && v.received_type == 'expire'){
// v.useState = 2;
// }
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;
else if (v.max_fetch == 0 || (v.max_fetch != 0 && !v.member_coupon_num) || (v.max_fetch != 0 && v.member_coupon_num && v.max_fetch > v.member_coupon_num)) v.useState = 0;
else if (v.wait_coupon_num) v.useState = 1
else if (v.lose_coupon_num) v.useState = 3;
else if (v.use_coupon_num) v.useState = 4;
});
}
//设置列表数据
@@ -367,6 +384,12 @@
background: #dedede !important;
color: #909399 !important;
}
&.to-use{
border: 2rpx solid var(--bg-color);
background: transparent;
color: var(--bg-color);
}
}
&::after {

View File

@@ -30,6 +30,8 @@
</view>
<loading-cover ref="loadingCover"></loading-cover>
<ns-login ref="login"></ns-login>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->

View File

@@ -4,7 +4,7 @@
<view class="content">
<view class="cate-search">
<view class="search-box">
<input class="uni-input" maxlength="50" v-model="inputValue" confirm-type="search" @focus="inputFocus" focus @confirm="search()" :placeholder="searchWords ? searchWords : ''" />
<input class="uni-input" maxlength="50" v-model="inputValue" confirm-type="search" @focus="inputFocus" focus @confirm="search()" :placeholder="searchWords ? searchWords : $lang('inputPlaceholder')" />
<text class="iconfont icon-sousuo3" @click="search()"></text>
</view>
</view>
@@ -13,7 +13,7 @@
<view class="history" v-if="historyList.length">
<view class="history-box">
<view class="history-top">
<view class="title">历史搜索</view>
<view class="title">{{ $lang('history') }}</view>
<view class="icon iconfont icon-icon7" @click="deleteHistoryList"></view>
</view>
<view class="history-bottom " id="history-list" :style="{ maxHeight: !isAllHistory ? '100%' : '168rpx' }">
@@ -31,7 +31,7 @@
<view class="history" v-if="hotList.length">
<view class="history-box">
<view class="history-top">
<view class="title">热门搜索</view>
<view class="title">{{ $lang('hot') }}</view>
</view>
<view class="history-bottom">
<view class="history-li" v-for="(item, index) in hotList" :key="index" @click="otherSearch(item)" @longtap="deleteItem(item)">
@@ -137,7 +137,6 @@
},
//搜索
search() {
if (this.inputValue.trim() != '') {
// 对历史搜索处理,判断有无,最近搜索显示在最前
@@ -163,7 +162,7 @@
});
} else {
this.$util.redirectTo('/pages/goods/list', {
//keyword: this.searchWords
keyword: this.searchWords
});
}
}
@@ -171,12 +170,11 @@
// 获取元素高度
getHistoryHeight() {
const query = uni.createSelectorQuery().in(this);
query.select('#history-list')
.boundingClientRect(data => {
if (data && data.height > uni.upx2px(70) * 2 + uni.upx2px(35) * 2) {
this.isAllHistory = true;
}
}).exec();
query.select('#history-list').boundingClientRect(data => {
if (data && data.height > uni.upx2px(70) * 2 + uni.upx2px(35) * 2) {
this.isAllHistory = true;
}
}).exec();
}
}
};