Browse Source

特产

master
jiazhipeng 5 months ago
parent
commit
0d1884770c
  1. 2
      components/cartData.vue
  2. 7
      static/js/request.js
  3. 163
      subPackages/techan/index.vue

2
components/cartData.vue

@ -137,7 +137,7 @@
this.cartData = data this.cartData = data
this.setAllSelect() this.setAllSelect()
} else { } else {
this.Post({},'/api/shopping/getShoppingList').then(res => { this.Post({noForceLogin: true},'/api/shopping/getShoppingList').then(res => {
if (res) { if (res) {
this.cartData = (res.data || []).map(v=>{return {...v, isSelected:selectedData.includes(v.specifications_id)}}) this.cartData = (res.data || []).map(v=>{return {...v, isSelected:selectedData.includes(v.specifications_id)}})
this.setAllSelect() this.setAllSelect()

7
static/js/request.js

@ -18,8 +18,8 @@ const getToken = () => {
return store.state.user.userInfo.token; return store.state.user.userInfo.token;
}; };
// 定义错误处理函数 // 定义错误处理函数 noForceLogin 不强制登录
const handleError = (res, reject) => { const handleError = (res, reject, noForceLogin) => {
setTimeout(() => { setTimeout(() => {
uni.showToast({ uni.showToast({
title: res.data?.msg || res.msg, title: res.data?.msg || res.msg,
@ -28,6 +28,7 @@ const handleError = (res, reject) => {
reject(res); reject(res);
}, 0); }, 0);
if (res.data?.code === 401) { if (res.data?.code === 401) {
if (noForceLogin) { return }
store.commit('changeLoginPath'); store.commit('changeLoginPath');
} }
}; };
@ -67,7 +68,7 @@ Vue.prototype.Post = (params = {}, apiurl) => {
fail: (err) => { fail: (err) => {
console.log('err', err); console.log('err', err);
uni.hideLoading() uni.hideLoading()
handleError(err, reject); handleError(err, reject, params.noForceLogin);
} }
}); });
}); });

163
subPackages/techan/index.vue

@ -4,25 +4,26 @@
<uni-icons type="left" size="20" @click="goBack" style="flex-shrink: 0;"></uni-icons> <uni-icons type="left" size="20" @click="goBack" style="flex-shrink: 0;"></uni-icons>
<view class="input-model"> <view class="input-model">
<uni-icons style="height: 1.4rem;line-height: 1.4rem;" type="search" size="15" color="#ABAAAD" ></uni-icons> <uni-icons style="height: 1.4rem;line-height: 1.4rem;" type="search" size="15" color="#ABAAAD" ></uni-icons>
<input class="input-text" placeholder="请输入商品名称" v-model="searchText"></text> <input class="input-text" placeholder="请输入商品名称" v-model="searchText" @confirm="search()" @keyup.enter="search()"></text>
</view> </view>
</view> </view>
<div :style="{'height':height+'px'}"></div> <div :style="{'height':height+'px','flex-shrink':0}"></div>
<!-- 正常产品 -->
<template v-if="searchText.trim().length<=0">
<img :src="showImg(headImg)" class="topImg" /> <img :src="showImg(headImg)" class="topImg" />
<view class="goods-container"> <view class="goods-container">
<scroll-view class="left-container no-scrollbar" :scroll-y="true"> <scroll-view class="left-container no-scrollbar" :scroll-y="true">
<view :class="['type-item',typeIndex==i?'active':'']" <view :class="['type-item',typeIndex==i?'active':'']"
v-for="(item,i) in typeParam" :key="i"> v-for="(item,i) in typeParam" :key="i" @click="changeType(item,i)">
| WEI | WEI
<view class="active-type-bar" v-if="typeIndex==i"></view> <view class="active-type-bar" v-if="typeIndex==i"></view>
</view> </view>
<view style="height: 148rpx;width: 1rpx;"></view> <view style="height: 148rpx;width: 1rpx;"></view>
</scroll-view> </scroll-view>
<scroll-view class="right-container no-scrollbar" :scroll-y="true"> <scroll-view class="right-container no-scrollbar" :scroll-y="true" @scrolltolower="scrollLow()">
<view class="item" v-for="item in list" :key="item.goods.id" @click="viewDetail(item.goods)"> <view class="item" v-for="item in list" :key="item.goods.id" @click="viewDetail(item.goods)">
<image class="item-img" :src="showImg(item.goods.image)" mode=""></image> <image class="item-img" :src="showImg(item.goods.image)" mode=""></image>
<view class="content"> <view class="content">
@ -32,9 +33,7 @@
{{item.goods.money/100}} {{item.goods.money/100}}
</view> </view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)"> <view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
<image :src="showImg('/uploads/20241104/0ac7eb782b73e60e3cfc8200b7934a4a.png')"></image>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -43,6 +42,55 @@
</scroll-view> </scroll-view>
</view> </view>
</template>
<!-- 搜索 -->
<view v-else>
<view v-if="searchList.length<=0" class="flex-center" style="width: 100%;height: 100%;flex-direction: column;">
<!-- <image style="width: 328rpx;height: 450.67rpx;"></image> -->
<view style="font-weight: 500;font-size: 28rpx;color: #666666;
text-align: center;margin-top: 67rpx;">暂无搜索结果</view>
</view>
<view style="padding:0 26rpx;background: #FFFFFF;" v-else>
<view class="flex" style="justify-content: space-between;">
<view class="search-result" >
<view v-for="(item,i) in searchList" >
<view v-if="i%2==1" class="search-item" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view>
<view class="flex-between" style="padding-top: 20rpx;">
<view>
<text class="price">{{item.goods.money/100}}</text>
<text class="oldPrice">{{item.goods.price/100}}</text>
</view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
</view>
</view>
</view>
</view>
</view>
<view class="search-result" >
<view v-for="(item,i) in searchList">
<view class="search-item" v-if="i%2==0" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view>
<view class="flex-between" style="padding-top: 20rpx;">
<view>
<text class="price">{{item.goods.money/100}}</text>
<text class="oldPrice">{{item.goods.price/100}}</text>
</view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view style="height: 148rpx;width: 1rpx;"></view>
</view>
<!-- 购物车 --> <!-- 购物车 -->
<view class="btn-bottom" > <view class="btn-bottom" >
@ -139,14 +187,13 @@
headImg: null, headImg: null,
typeParam: [ typeParam: [
{id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''}, {id: 60, title: ''},{id: 59, title: ''},{id: 60, title: ''},
{id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''}, {id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''},
{id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''}, {id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''},
{id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''}, {id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''},
{id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''}, {id: 1, title: ''},{id: 1, title: ''},{id: 1, title: ''},
], ],
typeIndex: 0, typeIndex: 0,
list:[], list:[],
finished: false, finished: false,
@ -159,7 +206,8 @@
cartDataVueShow: false, cartDataVueShow: false,
searchText: '', searchText: '',
searchList: [] searchList: [],
searchFinish: false,
} }
}, },
onLoad(options) { onLoad(options) {
@ -178,10 +226,10 @@
this.height = sysInfo.statusBarHeight + 40 this.height = sysInfo.statusBarHeight + 40
}, },
changeType (typeName, value) { changeType (item, i) {
if (this[typeName]!==value) { if (this.typeIndex!== i) {
this[typeName]=value this.typeIndex=i
this.finished = false
this.list = [] this.list = []
this.getList() this.getList()
} }
@ -190,7 +238,7 @@
// //
getList(){ getList(){
this.Post({ this.Post({
tag_id: 60, tag_id: this.typeParam[this.typeIndex].id,
offset: this.list.length, offset: this.list.length,
limit: 10, limit: 10,
},'/api/tag/getGoodsByTagId').then(res => { },'/api/tag/getGoodsByTagId').then(res => {
@ -200,6 +248,11 @@
} }
}) })
}, },
scrollLow () {
if (!this.finished) {
this.getList()
}
},
viewDetail(item) { viewDetail(item) {
// this.goOtherDetail(item) // this.goOtherDetail(item)
if(!item.link_type) { if(!item.link_type) {
@ -312,11 +365,20 @@
this.$refs.cartDataVueRef.goCartOrder() this.$refs.cartDataVueRef.goCartOrder()
}, },
//
search () {
this.searchFinish = false
this.searchList = []
// todo
this.searchList = [...this.list,...this.list,...this.list,...this.list]
},
}, },
onReachBottom() { onReachBottom() {
setTimeout(() => { if (!this.searchFinish) {
if (!this.finished) this.getList() this.search()
},1000) }
console.log(1)
} }
} }
</script> </script>
@ -357,6 +419,7 @@
padding-left: 14rpx; padding-left: 14rpx;
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 24rpx;
color: #030000;
} }
} }
@ -452,16 +515,19 @@
font-size: 24rpx; font-size: 24rpx;
} }
} }
.buy-cart{
width: 44rpx;
height: 44rpx;
image{
width: 100%;
height: 100%;
}
}
} }
} }
.buy-cart{
width: 44rpx;
height: 44rpx;
color: #FFFFFF;
background: #74A5AA;
line-height: 44rpx;
font-size: 30rpx;
text-align: center;
border-radius: 50%;
}
.btn-list { .btn-list {
z-index: 99; z-index: 99;
@ -676,5 +742,48 @@
} }
} }
.search-result{
display: flex;
flex-direction: column;
width: 100%;
flex: 1;
flex-shrink: 0;
.search-item{
width: 337rpx;
box-shadow: 0rpx 0rpx 9rpx 0rpx rgba(153,153,153,0.33);
border-radius: 13rpx;
flex-shrink: 0;
margin-bottom: 20rpx;
height: fit-content;
image{
width: 100%;
border-radius: 13rpx;
}
.search-container{
padding: 20rpx;
.title{
font-weight: 500;
font-size: 27rpx;
color: #000000;
}
.price{
font-weight: 400;
font-size: 33rpx;
color: #D70000;
}
.price:before{
content: "¥";
font-size: 23rpx;
}
.oldPrice{
font-weight: 400;
font-size: 21rpx;
color: #999999;
text-decoration-line: line-through;
padding-left: 12rpx;
}
}
}
}
</style> </style>

Loading…
Cancel
Save