This commit is contained in:
weipengfei 2024-01-24 16:44:33 +08:00
parent bcd7e001c4
commit c1c342d504
6 changed files with 110 additions and 51 deletions

View File

@ -302,7 +302,10 @@ export function storeActivityQrcode(data) {
// 活动商品专区
export function storeActivityProduct(data) {
return request.get(`storeActivity/product`, data, {
noAuth: true
});
return request.get(`storeActivity/product`, data);
}
// 活动区域列表
export function storeActivityDistrict(data) {
return request.get(`storeActivity/district`, data);
}

View File

@ -22,7 +22,7 @@
<view class="flex flex_end">
<view class="price"><text class="pro">{{leftPrice}}.</text>{{rightPrice}}
</view>
<view>订货价</view>
<!-- <view>订货价</view> -->
</view>
<view class="short_name">{{datas.store_name}}</view>
<view class="flex">

View File

@ -20,9 +20,13 @@
</view>
<view class="white_card">
<view class="flex flex_end">
<view class="price"><text class="pro">{{leftPrice}}.</text>{{rightPrice}}
</view>
<view>订货价</view>
<block v-if="datas.limited_price">
<view class="price"><text class="pro">{{leftPrice2}}.</text>{{rightPrice2}}
</view>
<view class="price" style="text-decoration: line-through;color: #999;font-weight: 400;font-size: 28rpx;">原价: <text>{{leftPrice}}.</text>{{rightPrice}}</view>
</block>
<view v-else class="price"><text>{{leftPrice}}.</text>{{rightPrice}}</view>
<!-- <view>订货价</view> -->
</view>
<view class="short_name">{{datas.store_name}}</view>
<view class="flex">
@ -56,11 +60,11 @@
</view>
</scroll-view>
<view class="button">
<view class="b_icon" @click="navgoCart()">
<!-- <view class="b_icon" @click="navgoCart()">
<image src="@/static/images/icon/car.png"></image>
<view>购物车</view>
<view class="badge" v-if="goodsNum">{{goodsNum}}</view>
</view>
</view> -->
<view class="btn" @click.stop="$u.throttle(addcart, 1500)"> {{isBuy?'立即购买':'加入购物车'}} </view>
</view>
</view>
@ -74,6 +78,7 @@
getProductDetail
} from '@/api/store.js';
import { Toast } from '../libs/uniApi';
import { data } from '../uni_modules/uview-ui/libs/mixin/mixin';
export default {
name: "shortPopup",
props: {
@ -120,6 +125,12 @@ import { Toast } from '../libs/uniApi';
},
rightPrice(){
return this.sku[this.changeSkuKey]?.price?.split('.')[1]||'00';
},
leftPrice2(){
return this.datas.limited_price.split('.')[0]||'0';
},
rightPrice2(){
return this.datas.limited_price.split('.')[1]||'00';
}
},
methods: {

View File

@ -231,7 +231,7 @@
}
},
navigatorBack(){
if(this.searchValue!==''&&this.searchValue!==undefined&&this.searchValue!==null){
if(this.searchValue!==undefined&&this.searchValue!==null){
uni.navigateBack({
success:()=> {
uni.$emit('searchValue', this.searchValue);

View File

@ -144,7 +144,7 @@
<activityCard @close="closeActivityCard"></activityCard>
</uni-popup>
<activityHome @click="navgo('/pages/newActivity/towPrice/towPrice?street_id='+street_id)"></activityHome>
<activityHome @click="navgo(`/pages/newActivity/towPrice/towPrice?street_id=${street_id}&townName=${street}`)"></activityHome>
<!-- <m-tabbar native>
<template v-slot:tabbar_index_2>
<view class="custom_style">
@ -229,12 +229,12 @@ import activityCard from "@/components/activityCard.vue"
where: {
category_id: 0,
page: 1,
limit: 10
limit: 30
},
where2: {
category_id: 0,
page: 1,
limit: 10
limit: 30
},
currentItemId: 69, // 0 || 69
@ -257,6 +257,7 @@ import activityCard from "@/components/activityCard.vue"
loadend2: false,
loading2: false,
loadTitle2: '加载更多',
}
},
onPullDownRefresh() {
@ -360,23 +361,29 @@ import activityCard from "@/components/activityCard.vue"
this.selfLocation()
},
shuffleArray(array) { //
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
let temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
},
//
list(isPage=false, id) {
if(!id||this.loadend) return this.list2(true, ''); // ,
let that = this;
if (that.loadend&&!isPage) return;
if (that.loading&&!isPage) return;
if (isPage === true) {
that.$set(that, 'productList', []);
if (isPage===true){
that.$set(that, 'where', {
category_id: 0,
page: 1,
limit: 10
limit: 30
})
}
that.$set(that, 'productList2', []);
that.loading = true;
that.loadTitle = '';
getProductslist({
@ -385,9 +392,15 @@ import activityCard from "@/components/activityCard.vue"
street_id: id,
type_id: '17,10',
location: `${this.latitude||''},${this.longitude||''}`
}).then(res => {
}).then(async (res) => {
if (isPage === true) {
that.$set(that, 'productList', []);
}
that.$set(that, 'productList2', []);
// await that.$nextTick();
// console.log(222)
let list = res.data.list;
if(list.length>0) list = this.shuffleArray(list);
if (res.data.count == 0 && isPage) {
that.list2(true, '');
}
@ -417,7 +430,7 @@ import activityCard from "@/components/activityCard.vue"
that.$set(that, 'where2', {
category_id: 0,
page: 1,
limit: 10
limit: 30
})
}
that.$set(that, 'productList', []);
@ -431,6 +444,7 @@ import activityCard from "@/components/activityCard.vue"
if(this.latitude&&this.longitude) query.location = this.latitude + ',' + this.longitude
spuRecommend(query).then(res => {
let list = res.data.list;
if(list.length>0) list = this.shuffleArray(list);
let productList = that.$util.SplitArray(list, that.productList2);
let loadend = list.length < that.where2.limit;
that.loadend2 = loadend;

View File

@ -8,27 +8,42 @@
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/uploads/new_activity/back.png"></image>
<view class="b_body">
<view class="b_content">
<view style="padding-bottom: 16rpx;">当前活动区域为 <text style="color: #f84221;margin-left: 5rpx;" @click="changeAddress">[ {{address.townName||'未选择'}} ] , 点击切换</text></view>
<view v-if="item.product" v-for="(item, index) in goodsList" class="short_item" @click="clickProduct(item)">
<image class="image" :src="item.product.image"></image>
<view class="short_item_right">
<view class="r_name">
<text v-if="item.mer_labels_name" class="mer-labels">{{item.mer_labels_name}}</text>{{item.product.store_name}}
</view>
<view style="display: flex;justify-content: flex-start;margin-top: 5rpx;">
<view class="r_street" v-if="item.merchant">{{item.merchant.street_name}}</view>
<view class="r_type" v-if="item.product.store_info||getSkuName(item)||item.unit_name">
<view v-if="getSkuName(item)">{{getSkuName(item)}}</view>
<view v-else-if="item.unit_name">{{item.unit_name}}</view>
<view style="padding-bottom: 16rpx;">
<picker :range="addressList" range-key="street_name" @change="changeAddress">
<block v-if="address.street_id">
当前活动区域为 <text style="color: #f84221;margin-left: 5rpx;">[ {{address.townName}} ] , 点击切换</text>
</block>
<block v-else>
<text style="color: #f84221;margin-left: 5rpx;">当前区域 [ {{address.townName}} ] 没有活动 , 点击切换</text>
</block>
</picker>
</view>
<block v-if="goodsList.length>0">
<view v-if="item.product" v-for="(item, index) in goodsList" class="short_item" @click="clickProduct(item)">
<image class="image" :src="item.product.image"></image>
<view class="short_item_right">
<view class="r_name">
<text v-if="item.mer_labels_name" class="mer-labels">{{item.mer_labels_name}}</text>{{item.product.store_name}}
</view>
<view style="display: flex;justify-content: flex-start;margin-top: 5rpx;">
<view class="r_street" v-if="item.merchant">{{item.merchant.street_name}}</view>
<view class="r_type" v-if="item.product.store_info||getSkuName(item)||item.unit_name">
<view v-if="getSkuName(item)">{{getSkuName(item)}}</view>
<view v-else-if="item.unit_name">{{item.unit_name}}</view>
</view>
</view>
<view class="r_btn" v-if="item.product && item.product.price">
<view style="color: #7f7f7f;"><text style="font-size: 33rpx;">{{ item.product.price.split('.')[0] }}.</text>{{item.product.price.split('.')[1]}} 限时特惠</view>
<view class="qiang" :class="{'no_qiang': !can_buy}">{{item.limited_price}} </view>
<!-- <image src="@/static/images/icon/plus.png" style="width: 40rpx;height: 40rpx;border-radius: 40rpx;"></image> -->
</view>
</view>
<view class="r_btn" v-if="item.product && item.product.price">
<view><text style="font-size: 33rpx;">{{ item.product.price.split('.')[0] }}.</text>{{item.product.price.split('.')[1]}} 限时特惠</view>
<view class="qiang" :class="{'no_qiang': !can_buy}"></view>
<!-- <image src="@/static/images/icon/plus.png" style="width: 40rpx;height: 40rpx;border-radius: 40rpx;"></image> -->
</view>
</view>
</view>
</block>
<block v-else>
<image style="width: 100%;" mode="widthFix" src="/static/img/no_short.f2ffcd1c.png"></image>
<view style="text-align: center;color: #999;">此区域没有找到活动商品切换其他地方试试呢</view>
</block>
</view>
</view>
</view>
@ -47,7 +62,7 @@
import authorize from "@/components/Authorize.vue";
import { getUserInfo } from '@/api/user.js';
import shortPopupActive from "@/components/shortPopupActive.vue"
import { storeActivityProduct } from "@/api/activity.js"
import { storeActivityProduct, storeActivityDistrict } from "@/api/activity.js"
import {
cloudWarehouse
} from '@/api/requesta.js'
@ -75,24 +90,31 @@
show: false,
isAuto: false, //
isShowAuth: false, //
addressList: [],
goodsList: [],
street_id: '',
goodsNum: 0,
can_buy: 0, // , 0, 1
}
},
onLoad(options) {
this.street_id = options.street_id;
this.address = {
street_id: options.street_id,
townName: options.townName
}
},
onShow() {
this.getUserInfo();
this.loadList();
this.cartFn();
this.address = this.$store.state.storage.address;
this.loadAddressList();
},
methods: {
changeAddress(){
changeAddress(e){
this.address = {
street_id: this.addressList[e.detail.value].street_code,
townName: this.addressList[e.detail.value].street_name
}
this.loadList();
},
back() {
uni.navigateBack()
@ -108,7 +130,7 @@
let location = '';
if(this.$store.state.storage.location.lat) location = this.$store.state.storage.location.lat + ',' + this.$store.state.storage.location.long;
storeActivityProduct({
street_code: this.$store.state.storage.address.street_id,
street_code: this.address.street_id,
activity_id: 2, //2
location: location,
source: 105
@ -119,6 +141,14 @@
Toast(e.msg||e.message||e)
})
},
loadAddressList(){
storeActivityDistrict().then(res=>{
this.addressList = res.data;
if(!this.addressList.find(item=>item.street_code==this.address.street_id)){
this.address.street_id = ''
}
})
},
//
getSkuName(item){
return Object.keys(item.sku).join('/')||null;
@ -229,8 +259,9 @@
.r_name {
width: 100%;
height: 64rpx;
line-height: 32rpx;
height: 80rpx;
font-size: 28rpx;
line-height: 40rpx;
text-overflow: ellipsis;
display: -webkit-box; /* 使用弹性盒子布局 */
-webkit-box-orient: vertical; /* 设置为垂直方向布局 */
@ -239,8 +270,8 @@
.mer-labels{
background-color: #f84221;
color: #fff;
font-size: 16rpx;
padding: 2rpx 6rpx;
font-size: 18rpx;
padding: 4rpx 8rpx;
border-radius: 5rpx;
margin-right: 8rpx;
}
@ -273,7 +304,7 @@
padding-left: 15rpx;
border-radius: 0 60rpx 60rpx 0;
.qiang{
width: 100rpx;
width: 160rpx;
height: 60rpx;
display: flex;
justify-content: center;