细节补充

This commit is contained in:
邝军华 2025-04-15 20:33:17 +08:00
parent fb537b8bcd
commit 2076d86ee4
29 changed files with 813 additions and 375 deletions

View File

@ -99,10 +99,6 @@
} }
api_skudetail(specTypes,ids); api_skudetail(specTypes,ids);
} }
//
defineExpose({
addCart
})
// //
const api_frontcartcount=()=>{ const api_frontcartcount=()=>{
frontcartcount().then(({data}) => {cartcount.value = data.count;}) frontcartcount().then(({data}) => {cartcount.value = data.count;})
@ -132,10 +128,7 @@
} }
// //
const choose = (name,value)=>{ const choose = (name,value)=>{
selectedSpecs.value = { selectedSpecs.value = {...selectedSpecs.value,[name]: value }
...selectedSpecs.value,
[name]: value
}
const valuesArray = Object.values(selectedSpecs.value).toString(); const valuesArray = Object.values(selectedSpecs.value).toString();
specValue.value = valuesArray; specValue.value = valuesArray;
productValue.value.forEach(item=>{ productValue.value.forEach(item=>{
@ -200,6 +193,8 @@
} }
// //
onMounted(() => {}); onMounted(() => {});
//
defineExpose({ addCart})
</script> </script>
<style lang="scss"> <style lang="scss">
@ -359,13 +354,13 @@
} }
.border_l{ .border_l{
border-left: 1px solid #E9E9E9; border-left: 1px solid #E9E9E9;
border-top-left-radius: 50rpx; border-top-left-radius: 10rpx;
border-bottom-left-radius: 50rpx; border-bottom-left-radius: 10rpx;
} }
.border_r{ .border_r{
border-right: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9;
border-top-right-radius: 50rpx; border-top-right-radius: 10rpx;
border-bottom-right-radius: 50rpx; border-bottom-right-radius: 10rpx;
} }
} }
.multishop_data_number{ .multishop_data_number{
@ -380,7 +375,7 @@
} }
} }
.footer_multi_btn{ .footer_multi_btn{
margin: 0 28rpx 0 28rpx; margin: 0 15rpx 0 15rpx;
height:84rpx; height:84rpx;
background-color: #FD3F3F; background-color: #FD3F3F;
display: flex; display: flex;

View File

@ -78,7 +78,7 @@
</block> </block>
</view> </view>
</view> </view>
<view class="load_desc">{{decs}}</view> <view class="load_desc">{{decs_com}}</view>
</view> </view>
</template> </template>
@ -94,10 +94,10 @@
//使piniastoreToRefs(使) //使piniastoreToRefs(使)
const { token } = storeToRefs(counterStore); const { token } = storeToRefs(counterStore);
const shopList = ref([]); const shopList = ref([]);
const total = ref(0); const total_com = ref(0);
const decs = ref(''); const decs_com = ref('');
const pages = ref(0); const pages_com = ref(0);
const limits = ref(10); const limits_com = ref(10);
// 1. // 1.
const emit = defineEmits(['add-message']); const emit = defineEmits(['add-message']);
const props = defineProps({ const props = defineProps({
@ -107,24 +107,24 @@
} }
}) })
const api_product=()=>{ const api_product=()=>{
pages.value = pages.value + 1; pages_com.value = pages_com.value + 1;
decs.value = "—— 加载中... ——"; decs_com.value = "—— 加载中... ——";
const params = { const params = {
page:pages.value, page:pages_com.value,
limit:limits.value limit:limits_com.value
} }
return frontproduct(props.apiType,params).then(({data}) => { return frontproduct(props.apiType,params).then(({data}) => {
total.value = data.total; total_com.value = data.total;
decs.value = '—— 上拉加载更多 ——' decs_com.value = '—— 上拉加载更多 ——'
data.list.forEach((item,index)=>{ data.list.forEach((item,index)=>{
item.isEven = index % 2 === 0 item.isEven = index % 2 === 0
}) })
if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——';
}
shopList.value = shopList.value.concat(data.list); shopList.value = shopList.value.concat(data.list);
if(data.list.length < 10){
decs_com.value = '—— 嗷呜,已经到底啦 ——';
}
}).catch(({message}) => { }).catch(({message}) => {
decs.value = `—— ${message||'网络异常'} ——`; decs_com.value = `—— ${message||'网络异常'} ——`;
}) })
} }
@ -159,9 +159,9 @@
}); });
onPullDownRefresh(()=>{ onPullDownRefresh(()=>{
shopList.value = []; shopList.value = [];
total.value = 0; total_com.value = 0;
decs.value = ''; decs_com.value = '';
pages.value = 0; pages_com.value = 0;
api_product(); api_product();
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}) })

View File

@ -50,6 +50,12 @@
</view> </view>
<view v-else class="load_desc">{{decs}}</view> <view v-else class="load_desc">{{decs}}</view>
</view> </view>
<view class="service">
<view class="service_cont">
<image class="service_img" src="../../static/serv.png" mode="widthFix"></image>
<view class="service_name">客服</view>
</view>
</view>
</view> </view>
</template> </template>
@ -113,9 +119,14 @@ const api_orderlist=()=>{
} }
}) })
list.value = list.value.concat(data.list); list.value = list.value.concat(data.list);
if(pages.value == 1 && !data.list.length){ if(!list.value.length){
img_err.value = "../../static/Empty/order_lisr_img.png" if(active.value == 0){
decs.value = "—— 暂无售后记录 ——" img_err.value = "../../static/Empty/cart.png"
decs.value =`仅48小时内签收的订单支持退款哦`
}else{
img_err.value = "../../static/Empty/order_lisr_img.png"
decs.value ="—— 暂无售后记录 ——"
}
}else if(data.list.length < 10){ }else if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——'; decs.value = '—— 嗷呜,已经到底啦 ——';
} }

View File

@ -236,6 +236,7 @@ page{
font-size: 28rpx; font-size: 28rpx;
color: #aaaaaa; color: #aaaaaa;
text-align: center; text-align: center;
margin: 0 70rpx 0 70rpx;
} }
.empty_cont_btn{ .empty_cont_btn{
margin: 0 auto; margin: 0 auto;
@ -251,4 +252,31 @@ page{
margin-top: 40rpx; margin-top: 40rpx;
} }
} }
}
.service{
position: fixed;
right: 20rpx;
bottom: 300rpx;
width: 95rpx;
height: 95rpx;
background: rgba(230,7,3,0.1);
border-radius: 50rpx;
display: flex;
align-items: center;
justify-content: center;
.service_cont{
.service_img{
width: 50rpx;
height: 50rpx;
margin: 0 auto;
display: block;
}
.service_name{
font-size: 20rpx;
color: #E60703;
text-align: center;
margin-top: 5rpx;
}
}
} }

View File

@ -74,6 +74,7 @@
</view> </view>
</view> </view>
<view style="height: 200rpx;"></view> <view style="height: 200rpx;"></view>
<view class="footer"> <view class="footer">
<view class="footer_btn" :class="!btnShow ? 'opy':''" @click="api_returnreturnApply()">{{!count?"退款数量必须有一项大于0":"提交(共退款"+count+")"}}</view> <view class="footer_btn" :class="!btnShow ? 'opy':''" @click="api_returnreturnApply()">{{!count?"退款数量必须有一项大于0":"提交(共退款"+count+")"}}</view>
</view> </view>

View File

@ -186,7 +186,7 @@ const api_orderlist=()=>{
item.openShow = false; item.openShow = false;
}) })
shop_orderlist.value = shop_orderlist.value.concat(data.list); shop_orderlist.value = shop_orderlist.value.concat(data.list);
if(pages.value == 1 && !data.list.length){ if(!shop_orderlist.value.length){
img_err.value = "../../static/Empty/order_lisr_img.png" img_err.value = "../../static/Empty/order_lisr_img.png"
if(type.value == 0){ if(type.value == 0){
decs.value = "—— 暂无待支付记录 ——" decs.value = "—— 暂无待支付记录 ——"

View File

@ -116,7 +116,7 @@ const api_orderReplylist=()=>{
} }
}) })
replyList.value = replyList.value.concat(data.list); replyList.value = replyList.value.concat(data.list);
if(pages.value == 1 && !data.list.length){ if(!replyList.value.length){
img_err.value = "../../static/Empty/order_lisr_img.png" img_err.value = "../../static/Empty/order_lisr_img.png"
decs.value = "—— 抱歉,该页面没有相关内容 ——" decs.value = "—— 抱歉,该页面没有相关内容 ——"
}else if(data.list.length < 10){ }else if(data.list.length < 10){

View File

@ -39,7 +39,8 @@
"style": { "style": {
"navigationBarTitleText": "我的", "navigationBarTitleText": "我的",
"navigationBarBackgroundColor": "#f2f5f7", "navigationBarBackgroundColor": "#f2f5f7",
"navigationStyle": "custom" "navigationStyle": "custom",
"enablePullDownRefresh": true
} }
} }
], ],
@ -182,6 +183,13 @@
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{
"path": "useredit/useredit",
"style": {
"navigationBarTitleText": "个人资料",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{ {
"path": "SearchProduct/SearchProduct", "path": "SearchProduct/SearchProduct",
"style": { "style": {
@ -195,7 +203,8 @@
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"navigationBarBackgroundColor": "#FFFFFF", "navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom" "navigationStyle": "custom",
"enablePullDownRefresh": true
} }
}, },
{ {

View File

@ -205,13 +205,13 @@ const api_frontproducts = (e,i) => {
return frontproducts(params).then(({data})=>{ return frontproducts(params).then(({data})=>{
if(i == 1){uni.hideLoading()} if(i == 1){uni.hideLoading()}
decs.value = '—— 上拉加载更多 ——' decs.value = '—— 上拉加载更多 ——'
if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——';
}
data.list.forEach((item,index)=>{ data.list.forEach((item,index)=>{
item.isEven = index % 2 === 0 item.isEven = index % 2 === 0
}) })
productList.value = productList.value.concat(data.list); productList.value = productList.value.concat(data.list);
if(productList.value.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——';
}
}) })
.catch(({message}) => { .catch(({message}) => {
if(i == 1){uni.hideLoading()} if(i == 1){uni.hideLoading()}

View File

@ -285,9 +285,10 @@ page{
top:0; top:0;
z-index:99; z-index:99;
.nav_head{ .nav_head{
border-bottom-left-radius: 20px; border-bottom-left-radius: 10px;
border-bottom-right-radius: 20px; border-bottom-right-radius: 10px;
background: linear-gradient(180deg,#FCF0F1 0%,#FFFFFF 60%); background: linear-gradient(180deg,#FCF0F1 0%,#FFFFFF 60%);
padding-bottom: 8px;
.nav_head_class{ .nav_head_class{
margin: 0 10px 0 10px; margin: 0 10px 0 10px;
height: 50px; height: 50px;

View File

@ -129,7 +129,7 @@ page{
.grid_wrap_l{ .grid_wrap_l{
width: 338rpx; width: 338rpx;
height: 338rpx; height: 338rpx;
background-color: #999999; background-color: #000000;
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden; overflow: hidden;
position: relative; position: relative;

View File

@ -25,7 +25,7 @@
<image class="content_head_img" src="../../static/sidedish/flame.png"></image> <image class="content_head_img" src="../../static/sidedish/flame.png"></image>
<view class="content_head_title">{{list.title}}</view> <view class="content_head_title">{{list.title}}</view>
</view> </view>
<view class="content_head_btn"> <view class="content_head_btn" @click="api_cartbatchSave(list)">
<image class="content_head_btnimg" src="../../static/sidedish/addCart.png"></image> <image class="content_head_btnimg" src="../../static/sidedish/addCart.png"></image>
</view> </view>
</view> </view>
@ -70,7 +70,7 @@ import { computed,ref } from 'vue';
import { useCounterStore } from '@/store/counter'; // Pinia Store import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
import { onLoad,onShow,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app" import { onLoad,onShow,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app"
import { frontindex,frontType,frontHome } from '@/server/api'; import { frontindex,frontType,frontHome,cartbatchSave } from '@/server/api';
const counterStore = useCounterStore(); // 使 Store const counterStore = useCounterStore(); // 使 Store
const pageWidth = ref(0); const pageWidth = ref(0);
const navList = ref([]); const navList = ref([]);
@ -142,10 +142,10 @@ const api_frontHome = (e,i) => {
return frontHome(params).then(({data})=>{ return frontHome(params).then(({data})=>{
if(i == 1){uni.hideLoading()} if(i == 1){uni.hideLoading()}
decs.value = '—— 上拉加载更多 ——' decs.value = '—— 上拉加载更多 ——'
productList.value = productList.value.concat(data.list);
if(data.list.length < 10){ if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——'; decs.value = '—— 嗷呜,已经到底啦 ——';
} }
productList.value = productList.value.concat(data.list);
}) })
.catch(({message}) => { .catch(({message}) => {
if(i == 1){uni.hideLoading()} if(i == 1){uni.hideLoading()}
@ -155,6 +155,34 @@ const api_frontHome = (e,i) => {
}) })
}) })
} }
//
const api_cartbatchSave = (list) => {
// cartNum\productAttrUnique\productId
const request = list.items.map(item => ({
cartNum:1,
productAttrUnique:"",
productId:item.jumpIds
}));
const params = {
business:list.id,//(cartType=setmeal id)
cartType: "setmeal",//(default setmeal )
cartList:request
}
loads('', true)
return cartbatchSave(params).then(({message})=>{
uni.hideLoading()
uni.showToast({
title:'一键加购成功',
icon:'none'
})
}).catch(({message}) => {
if(i == 1){uni.hideLoading()}
uni.showModal({
content:message,
showCancel: false
})
})
}
// //
const JumpType=(item,type)=>{ const JumpType=(item,type)=>{
const { jumpUrl,jumpIds,jumpType } = item; const { jumpUrl,jumpIds,jumpType } = item;

View File

@ -16,13 +16,13 @@ page{
align-items: center; align-items: center;
.head_user_message_photo{ .head_user_message_photo{
width: 119rpx; width: 119rpx;
height: 112rpx; height: 119rpx;
border-radius: 100rpx; border-radius: 100rpx;
background-color: #666666; background-color: #f6f6f6;
overflow: hidden; overflow: hidden;
.head_user_message_photo_img{ .head_user_message_photo_img{
width: 112rpx; width: 119rpx;
height: 112rpx; height: 119rpx;
display: block; display: block;
} }
} }

View File

@ -3,13 +3,13 @@
<view class="head"> <view class="head">
<view :style="{'height':headerHeight+45+'px'}"></view> <view :style="{'height':headerHeight+45+'px'}"></view>
<view class="head_user_message"> <view class="head_user_message">
<view class="head_user_message_l"> <view class="head_user_message_l" @click="useredit()">
<view class="head_user_message_photo"> <view class="head_user_message_photo">
<image class="head_user_message_photo_img" src="" mode="widthFix"></image> <image class="head_user_message_photo_img" :src="user.avatar" mode="widthFix"></image>
</view> </view>
<view class="head_user_message_text"> <view class="head_user_message_text">
<view class="head_user_message_name">餐饮爱好者</view> <view class="head_user_message_name">{{user.nickname}}</view>
<view class="head_user_message_desc"><image class="head_user_message_desc_img" src="../../static/user/tel.png"></image>152****9869</view> <view class="head_user_message_desc" v-if="user.phone"><image class="head_user_message_desc_img" src="../../static/user/tel.png"></image>{{user.phone}}</view>
</view> </view>
</view> </view>
<image class="head_user_message_set" src="../../static/user/setting.png" mode="widthFix"></image> <image class="head_user_message_set" src="../../static/user/setting.png" mode="widthFix"></image>
@ -18,7 +18,7 @@
<view class="user_account"> <view class="user_account">
<view class="user_account_li" @click="goCoupon()"> <view class="user_account_li" @click="goCoupon()">
<view class="user_account_message"> <view class="user_account_message">
<view class="user_account_amount">5</view> <view class="user_account_amount">{{user.couponCount}}</view>
<view class="user_account_name">优惠券</view> <view class="user_account_name">优惠券</view>
</view> </view>
<image class="user_account_img" src="../../static/user/coupon.png" mode="widthFix"></image> <image class="user_account_img" src="../../static/user/coupon.png" mode="widthFix"></image>
@ -26,7 +26,7 @@
<view class="user_account_border"></view> <view class="user_account_border"></view>
<view class="user_account_li"> <view class="user_account_li">
<view class="user_account_message"> <view class="user_account_message">
<view class="user_account_amount">0.00</view> <view class="user_account_amount">{{user.nowMoney}}</view>
<view class="user_account_name">余额()</view> <view class="user_account_name">余额()</view>
</view> </view>
<image class="user_account_img" src="../../static/user/purse.png" mode="widthFix"></image> <image class="user_account_img" src="../../static/user/purse.png" mode="widthFix"></image>
@ -59,9 +59,10 @@
</template> </template>
<script setup> <script setup>
import { frontuser } from '@/server/api.js'
import recomGoods from '@/components/recomGoods/recomGoods.vue'; import recomGoods from '@/components/recomGoods/recomGoods.vue';
import multi from '@/components/multi/multi.vue' import multi from '@/components/multi/multi.vue'
import { computed,ref } from 'vue'; import { computed,ref,onMounted } from 'vue';
import { useCounterStore } from '@/store/counter'; // Pinia Store import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
import { onLoad,onShow,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app" import { onLoad,onShow,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app"
@ -69,6 +70,7 @@ const counterStore = useCounterStore(); // 使用 Store
//使piniastoreToRefs(使) //使piniastoreToRefs(使)
const { statusHeight,headerHeight,token } = storeToRefs(counterStore); const { statusHeight,headerHeight,token } = storeToRefs(counterStore);
const shopData = ref({}); const shopData = ref({});
const user = ref({});
const order = ref([ const order = ref([
{ {
id:1, id:1,
@ -86,7 +88,8 @@ const order = ref([
id:4, id:4,
imgUrl:'../../static/user/evaluate.png', imgUrl:'../../static/user/evaluate.png',
name:'待评价', name:'待评价',
url:'/order/orderevallist/orderevallist?type=0' url:'/order/orderList/orderList?type=4'
// url:'/order/orderevallist/orderevallist?type=0'
}, },
{ {
id:5, id:5,
@ -133,6 +136,17 @@ const contList = ref([
url:'/userserve/addressList/addressList' url:'/userserve/addressList/addressList'
} }
]) ])
const api_frontuser = () => {
return frontuser().then(({data})=>{
user.value = data;
}).catch(({message}) => {
uni.showModal({
content:message,
showCancel: false
})
})
}
// //
const addCart=(i,type)=>{ const addCart=(i,type)=>{
shopData.value.addCart(i,type); shopData.value.addCart(i,type);
@ -151,6 +165,11 @@ const goCoupon=()=>{
url:`/order/coupon/coupon` url:`/order/coupon/coupon`
}) })
}; };
const useredit=()=>{
uni.navigateTo({
url:`/userserve/useredit/useredit`
})
}
const goServe=(item,index)=>{ const goServe=(item,index)=>{
const { url } = item; const { url } = item;
uni.navigateTo({url}) uni.navigateTo({url})
@ -161,17 +180,10 @@ const orderList=(item)=>{
const { url } = item; const { url } = item;
uni.navigateTo({url}) uni.navigateTo({url})
} }
onLoad((options) => { onShow(() => {api_frontuser()});
});
onShow(() => {
});
onPullDownRefresh(()=>{ onPullDownRefresh(()=>{
api_frontuser();
}) uni.stopPullDownRefresh();
onReachBottom(()=>{
}) })
</script> </script>

View File

@ -276,3 +276,8 @@ export const frontcartcount = () => {
const data = {numType:1,type:'total'} const data = {numType:1,type:'total'}
return request({url:`/api/front/cart/count`,method:'GET',data}); return request({url:`/api/front/cart/count`,method:'GET',data});
} }
//购物车一键加购
export const cartbatchSave = (data) => {
return request({url:`/api/front/cart/batchSave`,method:'POST',data});
}

View File

@ -9,7 +9,7 @@ const type = 'dev'
* prod生产 * prod生产
*/ */
if(type === 'dev'){ if(type === 'dev'){
url = "http://56w4qa.natappfree.cc"; url = " http://i44vgg.natappfree.cc";
} }
if(type === 'test'){ if(type === 'test'){
url = "https://japiuat.3721zh.com/webapp"; url = "https://japiuat.3721zh.com/webapp";

View File

@ -74,8 +74,8 @@
</view> </view>
</view> </view>
<view class="footer_r"> <view class="footer_r">
<view class="footer_btn border_l">加入购物车</view> <view class="footer_btn footer_btn_bcg border_l" @click.stop="addCartShop()">加入购物车</view>
<view class="footer_btn footer_btn_bcg border_r" @click="orderConfirm">立即下单</view> <!-- <view class="footer_btn footer_btn_bcg border_r" @click="orderConfirm">立即下单</view> -->
</view> </view>
</view> </view>
</view> </view>
@ -162,18 +162,25 @@ const goCart=()=>{
url:`/pages/cart/cart` url:`/pages/cart/cart`
}) })
}; };
const addCartShop = () =>{
const item = {
image:productInfo.value.image,
storeName:productInfo.value.storeName,
price:productInfo.value.price,
otPrice:productInfo.value.otPrice,
specType:productInfo.value.specType,
id:productInfo.value.id
}
shopData.value.addCart(item,1);
}
// //
const addCart=(i,type)=>{ const addCart=(i,type)=>{
shopData.value.addCart(i,type); shopData.value.addCart(i,type);
} }
// //
const handleAddSuccess = (data) => { const handleAddSuccess = (data) => {}
}
// //
const handleAddError = (error) => { const handleAddError = (error) => {}
console.error('加入购物车失败回调:', error)
}
const handleBack = () => { const handleBack = () => {
if (getPages()) { if (getPages()) {
// //

View File

@ -203,7 +203,7 @@ page{
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.footer_li{ .footer_li{
width: 90rpx; width: 110rpx;
.footer_icon{ .footer_icon{
margin: 0 auto; margin: 0 auto;
width: 50rpx; width: 50rpx;
@ -256,6 +256,7 @@ page{
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-weight: 500; font-weight: 500;
flex: 1;
} }
.footer_btn_bcg{ .footer_btn_bcg{
color: #FFFFFF; color: #FFFFFF;
@ -263,7 +264,7 @@ page{
} }
.border_l{ .border_l{
border-radius: 50rpx; border-radius: 50rpx;
margin-right: 20rpx; // margin-right: 20rpx;
// border-top-left-radius: 20rpx; // border-top-left-radius: 20rpx;
// border-bottom-left-radius: 20rpx; // border-bottom-left-radius: 20rpx;
} }

View File

@ -32,29 +32,36 @@
<view class="footer_cont"> <view class="footer_cont">
<view class="footer_l"> <view class="footer_l">
<view class="footer_li"> <view class="footer_li">
<view class="footer_icon"> <view class="footer_icon" @click="favorite">
<image class="footer_icon_img" src="../../static/shopdetail/collect.png" mode="widthFix"></image> <image class="footer_icon_img" :src="productInfo.favor_img" mode="widthFix"></image>
</view> </view>
<view class="footer_name">收藏</view> <view class="footer_name">收藏</view>
</view> </view>
<view class="footer_li" @click="goCart()"> <view class="footer_li" @click="goCart()">
<view class="footer_icon"> <view class="footer_icon">
<view class="footer_amount">45</view> <view class="footer_amount" v-if="cartcount > 0">{{cartcount}}</view>
<image class="footer_icon_img" src="../../static/shopdetail/cart.png" mode="widthFix"></image> <image class="footer_icon_img" src="../../static/shopdetail/cart.png" mode="widthFix"></image>
</view> </view>
<view class="footer_name">购物车</view> <view class="footer_name">购物车</view>
</view> </view>
</view> </view>
<view class="footer_r"> <view class="footer_r">
<view class="footer_btn border_l">加入购物车</view> <view class="footer_btn footer_btn_bcg border_l" @click="addCartShop()">加入购物车</view>
<view class="footer_btn footer_btn_bcg border_r" @click="orderConfirm">立即下单</view> <!-- <view class="footer_btn footer_btn_bcg border_r" @click="orderConfirm">立即下单</view> -->
</view> </view>
</view> </view>
</view> </view>
<multi
ref="shopData"
@add-success="handleAddSuccess"
@add-error="handleAddError"
></multi>
</view> </view>
</template> </template>
<script setup> <script setup>
import { loads } from '@/utils/index.js'
import multi from '@/components/multi/multi.vue'
import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from 'vue'; import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from 'vue';
import { useCounterStore } from '@/store/counter'; // Pinia Store import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
@ -62,8 +69,8 @@ import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } fr
const counterStore = useCounterStore(); // 使 Store const counterStore = useCounterStore(); // 使 Store
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
//使piniastoreToRefs(使) //使piniastoreToRefs(使)
const {statusHeight,headerHeight,statusBartop,token } = storeToRefs(counterStore); const {statusHeight,headerHeight,statusBartop,token,cartcount } = storeToRefs(counterStore);
import { replyconfig,replylist } from '@/server/api' import { replyconfig,replylist,frontcartcount,frontdetail,collectcancel,collectadd } from '@/server/api'
const productId = ref('');//id const productId = ref('');//id
const havePics = ref('');//1 const havePics = ref('');//1
const latest = ref('');//1 const latest = ref('');//1
@ -78,6 +85,8 @@ const sumCount = ref('');
const decs = ref(''); const decs = ref('');
const List = ref([]); const List = ref([]);
const act = ref(0); const act = ref(0);
const productInfo = ref({})
const shopData = ref({});
const referClick=(item,index)=>{ const referClick=(item,index)=>{
if(act.value == index) return false; if(act.value == index) return false;
act.value = index; act.value = index;
@ -108,6 +117,44 @@ const referClick=(item,index)=>{
pages.value = 0; pages.value = 0;
api_replylist() api_replylist()
} }
const api_detail=()=>{
loads('', true);
return frontdetail(productId.value).then(({data}) => {
uni.hideLoading();
if(data.userCollect){
data.favor_img = "../../static/shopdetail/collect_acer.png"
}else{
data.favor_img = "../../static/shopdetail/collect.png"
}
productInfo.value = data;
})
.catch(({message}) => {
uni.hideLoading();
uni.showModal({
content:message,
showCancel: false
})
})
}
//
const api_frontcartcount=()=>{
frontcartcount().then(({data}) => {cartcount.value = data.count;})
}
const addCartShop = () =>{
const item = {
image:productInfo.value.image,
storeName:productInfo.value.storeName,
price:productInfo.value.price,
otPrice:productInfo.value.otPrice,
specType:productInfo.value.specType,
id:productInfo.value.id
}
shopData.value.addCart(item,1);
}
//
const handleAddSuccess = (data) => {}
//
const handleAddError = (error) => {}
const api_replyconfig=()=>{ const api_replyconfig=()=>{
return replyconfig(productId.value).then(({data}) => { return replyconfig(productId.value).then(({data}) => {
let arr = [ let arr = [
@ -131,6 +178,8 @@ const api_replyconfig=()=>{
sumCount.value = data.sumCount; sumCount.value = data.sumCount;
}) })
.then(()=>api_replylist()) .then(()=>api_replylist())
.then(()=>api_detail())
.then(()=>api_frontcartcount())
.catch(({message}) => { .catch(({message}) => {
uni.showModal({ uni.showModal({
content:message, content:message,
@ -201,6 +250,43 @@ const api_replylist=()=>{
}) })
}) })
} }
const favorite = ()=>{
if(productInfo.value.userCollect){
api_collectcancel();
}else{
api_collectadd();
}
}
const api_collectadd=()=>{
loads('', true);
let data = {
category:"store",
id:productInfo.value.id
}
return collectadd(data).then(({message}) => {
uni.hideLoading();
api_detail();
}).catch(({message}) => {
uni.hideLoading();
uni.showModal({
content:message,
showCancel: false
})
})
}
const api_collectcancel=()=>{
loads('', true);
return collectcancel(productInfo.value.id).then(({message}) => {
uni.hideLoading();
api_detail();
}).catch(({message}) => {
uni.hideLoading();
uni.showModal({
content:message,
showCancel: false
})
})
}
onLoad((options) => { onLoad((options) => {
if(options.productId){ if(options.productId){
productId.value = options.productId; productId.value = options.productId;

View File

@ -176,7 +176,7 @@ page{
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.footer_li{ .footer_li{
width: 90rpx; width: 110rpx;
.footer_icon{ .footer_icon{
margin: 0 auto; margin: 0 auto;
width: 50rpx; width: 50rpx;
@ -229,6 +229,7 @@ page{
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-weight: 500; font-weight: 500;
flex: 1;
} }
.footer_btn_bcg{ .footer_btn_bcg{
color: #FFFFFF; color: #FFFFFF;
@ -236,7 +237,7 @@ page{
} }
.border_l{ .border_l{
border-radius: 50rpx; border-radius: 50rpx;
margin-right: 20rpx; // margin-right: 20rpx;
// border-top-left-radius: 20rpx; // border-top-left-radius: 20rpx;
// border-bottom-left-radius: 20rpx; // border-bottom-left-radius: 20rpx;
} }

View File

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

BIN
static/addGroup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

BIN
static/serv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -10,128 +10,38 @@
<input class="head_search_input" type="text" v-model="searchtext" disabled="true" @click="handleBack()"/> <input class="head_search_input" type="text" v-model="searchtext" disabled="true" @click="handleBack()"/>
</view> </view>
</view> </view>
<view class="head_list">
<view class="head_item">价格</view>
<view class="head_item">销量</view>
<view class="head_item">折扣</view>
</view>
</view> </view>
<view class="cont" :style="{'padding-top':statusHeight+headerHeight+19+'px'}"> <view class="cont" :style="{'padding-top':statusHeight+headerHeight+50+'px'}">
<!-- 商品区域 --> <!-- 商品区域 -->
<view class="shop_view"> <view class="cont_item" v-for="(item,index) in searchList" :key="index" @click="JumpType(item.id,1)">
<view class="shop_view_ul"> <image class="item_imgUrl" :src="item.image" lazy-load="true" mode="widthFix"></image>
<view class="shop_view_li" @click="goDetail()"> <view class="item_r">
<view class="shop_view_img"> <view class="item_title"><text>{{item.storeName}}</text></view>
<view class="shop_view_tag"><text class="shop_view_tag_text">够辣</text></view> <view class="item_desc"><text>{{item.storeInfo}}</text></view>
<view class="shop_view_img_u"> <view class="item_bottom">
<image class="shop_view_img_url" src="../../static/Mask.png"></image> <view class="item_price">{{item.price}}<text class="item_otPrice">{{item.otPrice}}</text></view>
</view> <image class="item_addCart" src="../../static/addGroup.png" @click.stop="addCart(item,1)"></image>
</view>
<view class="shop_view_cont">
<view class="shop_view_cont_title">糖醋排骨</view>
<view class="shop_view_cont_desc">乡下土猪</view>
<view class="shop_view_cont_tag">
<view class="shop_view_cont_tag_text">仅剩3份</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
</view>
<view class="shop_view_cont_bottom">
<view class="shop_view_cont_price price">43.9<text class="market_name prices">59.9</text></view>
<view class="shop_view_cont_cart">
<image class="shop_view_cont_cart_img" src="../../static/oncatr02.png" mode="widthFix"></image>
</view>
</view>
</view>
</view> </view>
<view class="shop_view_li" @click="goDetail()">
<view class="shop_view_img">
<view class="shop_view_tag"><text class="shop_view_tag_text">够辣</text></view>
<view class="shop_view_img_u">
<image class="shop_view_img_url" src="../../static/Mask.png"></image>
</view>
</view>
<view class="shop_view_cont">
<view class="shop_view_cont_title">糖醋排骨</view>
<view class="shop_view_cont_desc">乡下土猪</view>
<view class="shop_view_cont_tag">
<view class="shop_view_cont_tag_text">仅剩3份</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
</view>
<view class="shop_view_cont_bottom">
<view class="shop_view_cont_price price">43.9<text class="market_name prices">59.9</text></view>
<view class="shop_view_cont_cart">
<image class="shop_view_cont_cart_img" src="../../static/oncatr02.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<view class="shop_view_li" @click="goDetail()">
<view class="shop_view_img">
<view class="shop_view_tag"><text class="shop_view_tag_text">香甜</text></view>
<view class="shop_view_img_u">
<image class="shop_view_img_url" src="../../static/Mask.png"></image>
</view>
</view>
<view class="shop_view_cont">
<view class="shop_view_cont_title">泡椒田鸡</view>
<view class="shop_view_cont_desc">超大只田鸡</view>
<view class="shop_view_cont_tag">
<view class="shop_view_cont_tag_text">仅剩3份</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
</view>
<view class="shop_view_cont_bottom">
<view class="shop_view_cont_price price">43.9<text class="market_name prices">59.9</text></view>
<view class="shop_view_cont_cart">
<image class="shop_view_cont_cart_img" src="../../static/oncatr02.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
</view>
<view class="shop_view_ul">
<view class="shop_view_li" @click="goDetail()">
<view class="shop_view_img">
<view class="shop_view_tag"><text class="shop_view_tag_text">热销</text></view>
<view class="shop_view_img_u">
<image class="shop_view_img_url" src="../../static/Mask.png"></image>
</view>
</view>
<view class="shop_view_cont">
<view class="shop_view_cont_title">泡椒田鸡</view>
<view class="shop_view_cont_desc">超大只田鸡</view>
<view class="shop_view_cont_tag">
<view class="shop_view_cont_tag_text">仅剩3份</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
</view>
<view class="shop_view_cont_bottom">
<view class="shop_view_cont_price price">43.9<text class="market_name prices">59.9</text></view>
<view class="shop_view_cont_cart">
<image class="shop_view_cont_cart_img" src="../../static/oncatr02.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<view class="shop_view_li" @click="goDetail()">
<view class="shop_view_img">
<view class="shop_view_tag"><text class="shop_view_tag_text">新鲜</text></view>
<view class="shop_view_img_u">
<image class="shop_view_img_url" src="../../static/Mask.png"></image>
</view>
</view>
<view class="shop_view_cont">
<view class="shop_view_cont_title">泡椒田鸡</view>
<view class="shop_view_cont_desc">超大只田鸡</view>
<view class="shop_view_cont_tag">
<view class="shop_view_cont_tag_text">仅剩3份</view>
<view class="shop_view_cont_tag_text">劲辣胃浓</view>
</view>
<view class="shop_view_cont_bottom">
<view class="shop_view_cont_price price">43.9<text class="market_name prices">59.9</text></view>
<view class="shop_view_cont_cart">
<image class="shop_view_cont_cart_img" src="../../static/oncatr02.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
</view> </view>
</view> </view>
<view class="empty" v-if="img_err && decs">
<view class="empty_cont">
<image class="empty_cont_img" :src="img_err" lazy-load="true" mode="widthFix"></image>
<view class="empty_cont_title">{{decs}}</view>
</view>
</view>
</view> </view>
<recomGoods :apiType="5" @add-message="addCart"></recomGoods>
<multi
ref="shopData"
@add-success="handleAddSuccess"
@add-error="handleAddError"
></multi>
</view> </view>
</template> </template>
@ -139,6 +49,8 @@
import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from 'vue'; import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from 'vue';
import { useCounterStore } from '@/store/counter'; // Pinia Store import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
import { frontproducts } from '@/server/api.js'
import multi from '@/components/multi/multi.vue'
import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app" import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app"
const counterStore = useCounterStore(); // 使 Store const counterStore = useCounterStore(); // 使 Store
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
@ -148,6 +60,20 @@ const {statusHeight,headerHeight,statusBartop,ButtonWidth,ButtonHeight } = store
const pageWidth = ref(0); const pageWidth = ref(0);
const searchtext = ref(''); const searchtext = ref('');
const searchList= ref([]); const searchList= ref([]);
const decs = ref('');
const pages = ref(0);
const limits = ref(10);
const type = ref("");
const img_err = ref("");
const shopData = ref({});
//
const addCart=(i,type)=>{
shopData.value.addCart(i,type);
}
//
const handleAddSuccess = (data) => {}
//
const handleAddError = (error) => {}
// //
const updatePageWidth = () => { const updatePageWidth = () => {
const systemInfo = uni.getSystemInfoSync(); const systemInfo = uni.getSystemInfoSync();
@ -173,20 +99,72 @@ const handleBack = () => {
}); });
} }
}; };
const api_frontproducts=()=>{
pages.value = pages.value + 1;
img_err.value = "";
decs.value = "—— 加载中... ——";
const params = {
page:pages.value,
limit:limits.value
}
if(searchtext.value){
params.keyword = searchtext.value
}
return frontproducts(params).then(({data}) => {
decs.value = '—— 上拉加载更多 ——';
searchList.value = searchList.value.concat(data.list);
if(!searchList.value.length){
img_err.value = "../../static/Empty/search.png"
decs.value = "抱歉,没有搜到相关商品"
}else if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——';
}
}).catch(({message}) => {
img_err.value = "../../static/Empty/err.png"
decs.value = `—— ${message||'网络异常'} ——`;
})
}
//
const JumpType=(item,type)=>{
if(type == 1){
uni.navigateTo({
url:`/shopProDetail/detail/detail?id=${item}`//
})
}else{
const { jumpUrl,jumpIds,jumpType } = item;
if(jumpType == 0 || jumpType == 2 || jumpType == 4) return false;
let url = "";
if(jumpType == 1){
uni.navigateTo({
url:`/shopProDetail/detail/detail?id=${jumpIds}`//
})
}else if(jumpType == 3){
uni.switchTab({
url:`/pages/classify/classify`//
})
}
}
}
onLoad((options) => { onLoad((options) => {
const { text } = options; const { text } = options;
if(searchtext){ if(searchtext){
searchtext.value = text; searchtext.value = text;
} }
updatePageWidth(); updatePageWidth();
api_frontproducts();
}); });
onShow(() => {}); onShow(() => {});
onReady(()=>{}) onReady(()=>{})
onPullDownRefresh(()=>{}) onPullDownRefresh(()=>{
onReachBottom(()=>{}) searchList.value = [];
decs.value = '';
pages.value = 0;
api_frontproducts();
uni.stopPullDownRefresh();
})
onReachBottom(()=>{
api_frontproducts();
})
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -52,126 +52,105 @@ page{
} }
} }
} }
.head_list{
display: flex;
justify-content:space-around;
align-items:center;
.head_item{
font-size: 28rpx;
color: #333333;
width: 200rpx;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
padding-top: 10px;
}
}
} }
.cont{ .cont{
// 商品区域样式 // 商品区域样式
.shop_view{ .cont_item{
margin-top: 10rpx; margin: 20rpx 20rpx 0 20rpx;
padding: 13rpx 20rpx 0rpx 20rpx; padding: 20rpx;
background: #FFFFFF;
border-radius: 16rpx;
display: flex; display: flex;
align-items: center;
justify-content: space-between; justify-content: space-between;
.shop_view_ul{ .item_imgUrl{
width: 346rpx; width: 200rpx;
.shop_view_li{ height: 200rpx;
background-color: #FFFFFF; border-radius: 10rpx;
border-radius: 20rpx; }
width: 100%; .item_r{
box-shadow: 0 4rpx 8rpx rgba(0,0,0,.05); width: 450rpx;
margin-bottom: 20rpx; .item_title{
.shop_view_li_swiper{ color: #333333;
width: 100%; font-size: 28rpx;
height: 504rpx; font-weight: 500;
.shop_view_li_swiper_item{ min-height: 80rpx;
width: 100%;
.shop_view_li_swiper_img_url{
width: 100%;
height: 504rpx;
display: block;
border-radius: 20rpx;
}
}
}
.shop_view_img{
width: 100%;
position: relative;
height: 320rpx;
.shop_view_tag{
width: 66rpx;
height: 42rpx;
position: absolute;
z-index: 2;
right: -15rpx;
top: 20rpx;
background: url(../../static/tag_img.png);
background-repeat: no-repeat;
background-size: 100% 100%;
.shop_view_tag_text{
font-size: 20rpx;
color: #FFFFFF;
height: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
.shop_view_img_u{
width: 300rpx;
position: absolute;
z-index: 1;
left: 20rpx;
top: 20rpx;
.shop_view_img_url{
width: 100%;
height: 300rpx;
display: block;
}
}
}
.shop_view_cont{
padding: 20rpx;
.shop_view_cont_title{
font-size: 28rpx;
font-weight: 500;
color: #000000;
min-height: 80rpx;
}
.shop_view_cont_desc{
color: #666666;
font-size: 24rpx;
}
.shop_view_cont_tag{
display: flex;
flex-wrap: wrap;
.shop_view_cont_tag_text{
border-radius: 6rpx;
border: 1px solid #FF6868;
padding: 0rpx 10rpx;
border-radius: 10rpx;
color: #ff6868;
font-size: 18rpx;
margin-top: 10rpx;
margin-right: 10rpx;
}
}
}
.shop_view_cont_bottom{
display: flex;
align-items: center;
justify-content: space-between;
.shop_view_cont_price{
font-size: 32rpx;
color: red;
font-weight: 500;
}
.shop_view_cont_cart{
width: 65rpx;
height: 65rpx;
display: flex;
align-items: center;
justify-content: flex-end;
.shop_view_cont_cart_img{
width: 40rpx;
height: 40rpx;
display: block;
}
}
}
} }
.shop_view_bcg{ .item_title text{
background-color: inherit; overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
word-break: break-all;
}
.item_desc{
font-size: 22rpx;
color: #999999;
margin-top: 10rpx;
}
.item_desc text{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
word-break: break-all;
}
.item_bottom{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
.item_price{
font-size: 32rpx;
color: #FF0000;
font-weight: 500;
.item_otPrice{
font-size:26rpx;
color: #999999;
font-weight: 400;
text-decoration: line-through;
margin-left: 5rpx;
}
.item_otPrice::before{
content: "¥";
font-size: 20rpx;
margin-right: 5rpx;
}
}
.item_price::before{
content: "¥";
font-size: 24rpx;
margin-right: 5rpx;
}
.item_addCart{
width: 48rpx;
height: 48rpx;
}
} }
} }
} }
} }
.price::before { .price::before {
content: '¥'; content: '¥';
@ -191,4 +170,45 @@ page{
margin-left: 5rpx; margin-left: 5rpx;
font-weight: 400; font-weight: 400;
} }
}
.load_desc{
font-size: 28rpx;
color: #aaa;
text-align: center;
padding-top: 30rpx;
padding-bottom: 30rpx;
}
.empty{
height:480rpx;
margin:20rpx 20rpx 0rpx 20rpx;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
.empty_cont{
.empty_cont_img{
margin: 0 auto;
width: 355rpx;
height: 280rpx;
display: flex;
}
.empty_cont_title{
font-size: 28rpx;
color: #aaaaaa;
text-align: center;
}
.empty_cont_btn{
margin: 0 auto;
width: 154rpx;
height: 46rpx;
border-radius: 30rpx;
border: 1rpx solid #FF0000;
color: #FF0000;
line-height: 30rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 40rpx;
}
}
} }

View File

@ -14,30 +14,23 @@
<view class="cont" :style="{'padding-top':statusHeight+headerHeight+19+'px'}"> <view class="cont" :style="{'padding-top':statusHeight+headerHeight+19+'px'}">
<block v-if="searchList.length"> <block v-if="searchList.length">
<view class="cont_ul"> <view class="cont_ul">
<view class="cont_li" v-for="(item,index) in searchList" :key="index" @click="onList(item.title)">{{item.title}}</view> <view class="cont_li" v-for="(item,index) in searchList" :key="index" @click="goSearch(item.storeName)">{{item.storeName}}</view>
</view> </view>
</block> </block>
<block v-else> <block v-else>
<view class="cont_title">历史搜索</view> <block v-if="searchStorage.length">
<view class="cont_keyword"> <view class="cont_title">历史搜索</view>
<view class="cont_keyword_item">排骨</view> <view class="cont_keyword">
<view class="cont_keyword_item">猪肉炖粉条</view> <view class="cont_keyword_item" v-for="(item,index) in searchStorage" :key="index" @click="goSearch(item)">{{item}}</view>
<view class="cont_keyword_item">蚂蚁上树</view> </view>
</view> </block>
<block v-if="keyList.length">
<view class="cont_title">搜索发现</view> <view class="cont_title">搜索发现</view>
<view class="cont_keyword"> <view class="cont_keyword">
<view class="cont_keyword_item">买1赠1起</view> <view class="cont_keyword_item" v-for="(item,index) in keyList" :key="index" @click="goSearch(item.title)">{{item.title}}</view>
<view class="cont_keyword_item">水果半价日</view> </view>
<view class="cont_keyword_item">海鲜5折抢</view> </block>
<view class="cont_keyword_item">春菜</view>
<view class="cont_keyword_item">青团</view>
<view class="cont_keyword_item"></view>
<view class="cont_keyword_item">牛奶</view>
<view class="cont_keyword_item">矿泉水</view>
</view>
</block> </block>
</view> </view>
</view> </view>
</template> </template>
@ -47,6 +40,7 @@ import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from '
import { useCounterStore } from '@/store/counter'; // Pinia Store import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app" import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app"
import { searchkeyword,frontproducts } from '@/server/api'
const counterStore = useCounterStore(); // 使 Store const counterStore = useCounterStore(); // 使 Store
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
//使piniastoreToRefs(使) //使piniastoreToRefs(使)
@ -56,6 +50,8 @@ const pageWidth = ref(0);
const focus = ref(false); const focus = ref(false);
const searchtext = ref(''); const searchtext = ref('');
const searchList= ref([]); const searchList= ref([]);
const keyList = ref([]);
const searchStorage = ref([])
// //
const updatePageWidth = () => { const updatePageWidth = () => {
const systemInfo = uni.getSystemInfoSync(); const systemInfo = uni.getSystemInfoSync();
@ -81,50 +77,71 @@ const handleBack = () => {
}); });
} }
}; };
const api_searchkeyword = () => {
const onKeyInput=()=>{ return searchkeyword().then(({data})=>{
if(searchtext.value){ keyList.value = data;
const list = [{ }).catch(({message}) => {
title:'啤酒' uni.showModal({
}, content:message,
{ showCancel: false
title:'雪花啤酒' })
}, })
{ }
title:'青岛啤酒装罐' const onKeyInput=(e)=>{
}, if(e.detail.value){
{ api_frontproducts()
title:'百威啤酒'
},
{
title:'原浆啤酒'
},
{
title:'进口啤酒'
},
{
title:'燕京啤酒'
}]
searchList.value = list;
}else{ }else{
searchList.value = []; searchList.value = []
} }
}; };
const onList=(name)=>{ const api_frontproducts=()=>{
const params = {
page:1,
limit:10,
keyword:searchtext.value||""
}
return frontproducts(params).then(({data}) => {searchList.value = data.list;})
}
const goSearch=(name)=>{
uni.navigateTo({ uni.navigateTo({
url:`/userserve/SearchList/SearchList?text=${name}` url:`/userserve/SearchList/SearchList?text=${name}`
}) })
}; }
const confirm=(e)=>{ const confirm=(e)=>{
let arr = searchStorage.value;
uni.navigateTo({ uni.navigateTo({
url:`/userserve/SearchList/SearchList?text=${searchtext.value}` url:`/userserve/SearchList/SearchList?text=${searchtext.value}`,
success: () => {
arr.forEach((item,index)=>{
if(e.detail.value == item){
arr.splice(index,1)
}
})
if(e.detail.value){
arr.unshift(e.detail.value)
uni.setStorage({
key: 'searchStorage',
data: arr
});
}
}
}) })
}; };
const StorageList=()=>{
let getlist = uni.getStorageSync('searchStorage');
if(getlist.length){
searchStorage.value = getlist;
}
}
onLoad((options) => { onLoad((options) => {
focus.value = true; focus.value = true;
updatePageWidth(); updatePageWidth();
}); });
onShow(() => {}); onShow(() => {
StorageList();
api_searchkeyword();
});
onReady(()=>{}) onReady(()=>{})
onPullDownRefresh(()=>{}) onPullDownRefresh(()=>{})
onReachBottom(()=>{}) onReachBottom(()=>{})

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="main"> <view class="main">
<view class="list" v-for="(item,index) in shop_list" :key="index"> <view class="list" v-for="(item,index) in shop_list" :key="index" @click="shopDetail(item)">
<view class="list_l"> <view class="list_l">
<image class="list_img" :src="item.image" mode="widthFix"></image> <image class="list_img" :src="item.image" mode="widthFix"></image>
</view> </view>
@ -12,7 +12,7 @@
</view> --> </view> -->
<view class="list_bottom"> <view class="list_bottom">
<view class="list_price price">{{item.price}}</view> <view class="list_price price">{{item.price}}</view>
<view class="list_shop_cart"> <view class="list_shop_cart" @click.stop="addCart(item,1)">
<image class="list_cart_img" src="../../static/oncatr01.png" mode="widthFix"></image> <image class="list_cart_img" src="../../static/oncatr01.png" mode="widthFix"></image>
</view> </view>
</view> </view>
@ -25,6 +25,11 @@
</view> </view>
</view> </view>
<view v-else class="load_desc">{{decs}}</view> <view v-else class="load_desc">{{decs}}</view>
<multi
ref="shopData"
@add-success="handleAddSuccess"
@add-error="handleAddError"
></multi>
</view> </view>
</template> </template>
@ -34,6 +39,7 @@ import { useCounterStore } from '@/store/counter'; // 引入 Pinia Store
import { storeToRefs } from 'pinia';// import { storeToRefs } from 'pinia';//
import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app" import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app"
import { collectuser } from "@/server/api.js" import { collectuser } from "@/server/api.js"
import multi from '@/components/multi/multi.vue'
const counterStore = useCounterStore(); // 使 Store const counterStore = useCounterStore(); // 使 Store
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const shop_list = ref([]) const shop_list = ref([])
@ -41,6 +47,7 @@ const img_err = ref("");
const decs = ref(''); const decs = ref('');
const pages = ref(0); const pages = ref(0);
const limits = ref(10); const limits = ref(10);
const shopData = ref({});
//使piniastoreToRefs(使) //使piniastoreToRefs(使)
const {statusHeight,headerHeight,statusBartop,ButtonWidth,ButtonHeight } = storeToRefs(counterStore); const {statusHeight,headerHeight,statusBartop,ButtonWidth,ButtonHeight } = storeToRefs(counterStore);
const api_collectuser=()=>{ const api_collectuser=()=>{
@ -54,8 +61,8 @@ const api_collectuser=()=>{
return collectuser(params).then(({data}) => { return collectuser(params).then(({data}) => {
decs.value = '—— 上拉加载更多 ——'; decs.value = '—— 上拉加载更多 ——';
shop_list.value = shop_list.value.concat(data.list); shop_list.value = shop_list.value.concat(data.list);
if(pages.value == 1 && !data.list.length){ if(!shop_list.value.length){
img_err.value = "../../static/Empty/order_lisr_img.png" img_err.value = "../../static/Empty/collect.png"
decs.value = "—— 暂无收藏记录 ——" decs.value = "—— 暂无收藏记录 ——"
}else if(data.list.length < 10){ }else if(data.list.length < 10){
decs.value = '—— 嗷呜,已经到底啦 ——'; decs.value = '—— 嗷呜,已经到底啦 ——';
@ -65,6 +72,19 @@ const api_collectuser=()=>{
decs.value = `—— ${message||'网络异常'} ——`; decs.value = `—— ${message||'网络异常'} ——`;
}) })
} }
//
const addCart=(i,type)=>{
shopData.value.addCart(i,type);
}
const shopDetail = (item) =>{
uni.navigateTo({
url:`/shopProDetail/detail/detail?id=${item.productId}`//
})
}
//
const handleAddSuccess = (data) => {}
//
const handleAddError = (error) => {}
onLoad((options) => { onLoad((options) => {
api_collectuser(); api_collectuser();
}); });

View File

@ -0,0 +1,218 @@
<template>
<view class="main">
<view class="list" @click="chooseImage()">
<view class="list_l">头像</view>
<view class="list_r list_arrow"><image class="list_img" :src="avatar" mode="widthFix"></image></view>
</view>
<view class="list">
<view class="list_l">昵称</view>
<view class="list_r">
<input class="list_input" type="text" v-model="nickname" placeholder="请输入昵称"/>
</view>
</view>
<view class="list">
<view class="list_l">手机号</view>
<view class="list_r">
<input class="list_input" type="text" v-model="phone" placeholder="请输入手机号"/>
</view>
</view>
<view class="footer">
<view class="footer_btn" @click="api_useredit()">保存</view>
</view>
</view>
</template>
<script setup>
import { url } from '@/server/config.js'
import { loads } from '@/utils/index.js'
import { frontuser,useredit } from '@/server/api.js'
import { computed,ref,onMounted } from 'vue';
import { useCounterStore } from '@/store/counter'; // Pinia Store
import { storeToRefs } from 'pinia';//
import { onLoad,onShow,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app"
const counterStore = useCounterStore(); // 使 Store
//使piniastoreToRefs(使)
const { statusHeight,headerHeight,token } = storeToRefs(counterStore);
const user = ref(false);
const avatar = ref("")
const nickname = ref("")
const phone = ref("");
const api_frontuser = () => {
return frontuser().then(({data})=>{
avatar.value = data.avatar;
nickname.value = data.nickname;
phone.value = data.phone;
}).catch(({message}) => {
uni.showModal({
content:message,
showCancel: false
})
})
}
//
const chooseImage = () => {
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'], //
sourceType: ['album', 'camera'], //
success: (res) => {
api_uploadimage(res.tempFilePaths);
},
fail: (err) => {
console.error('选择图片失败:', err);
}
});
}
//url
const api_uploadimage = (tempFilePaths) =>{
console.log('地址',url);
loads('上传中', true)
uni.uploadFile({
url:url+'/api/front/user/upload/image', //
filePath: tempFilePaths[0], //
name: 'multipart', //
header: {
'Authori-zation':token.value//
},
formData: { //
model: 'wechat',
pid: '8'
},
success: (res) => {
uni.hideLoading()
const data = JSON.parse(res.data); //
avatar.value = data.data.url;
},
fail: (err) => {
uni.hideLoading()
console.error('上传失败:', err);
}
})
}
const api_useredit = () => {
const params = {
avatar:avatar.value,
nickname:nickname.value,
phone:phone.value
}
loads('', true)
return useredit(params).then(({message})=>{
uni.hideLoading();
uni.showToast({
title:message,
icon:'success',
success: () => {
setTimeout(()=>{
uni.navigateBack({
delta:1
})
},1400)
}
})
}).catch(({message}) => {
uni.hideLoading();
uni.showModal({
content:message,
showCancel: false
})
})
}
//
onMounted(() => {
api_frontuser();
});
onLoad((options) => {
});
</script>
<style lang="scss">
page{
background-color: #f6f6f6;
}
.main{
margin: 20rpx 0 0 0;
background-color: #FFFFFF;
.list{
margin: 0 20rpx 0 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1rpx solid #f6f6f6;
padding-top: 15rpx;
padding-bottom: 15rpx;
.list_l{
font-size: 28rpx;
color: #333333;
height: 100%;
display: flex;
align-items: center;
}
.list_r{
.list_img{
width: 130rpx;
height: 130rpx;
background-color: #f6f6f6;
border-radius: 80rpx;
display: block;
}
.list_input{
width: 200rpx;
height: 80rpx;
display: flex;
align-items: center;
text-align: right;
}
}
.list_arrow{
margin-right: 20rpx;
position: relative;
}
.list_arrow::after{
content: "";
position: absolute;
top: 50%;
left: 100%;
transform: translate3d(0,-50%,0) rotate(45deg);
width: 20rpx;
height: 20rpx;
border-top: 3rpx solid #999999;
border-right: 3rpx solid #999999;
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(153, 153, 153);
border-right-width: 1px;
border-right-style: solid;
border-right-color: rgb(153, 153, 153);
}
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 160;
background: #FFFFFF;
font-size: 30rpx;
padding-bottom: env(safe-area-inset-bottom);
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
padding-left: 20rpx;
padding-right: 20rpx;
border-top: 1rpx solid #efefef;
.footer_btn {
width: 100%;
height: 85rpx;
background-color: #fd3f3f;
border-radius: 50rpx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
font-size: 28rpx;
}
}
}
</style>