WIN-2CJ8FMUT9OF\Administrator 7 mesiacov pred
rodič
commit
2a15fdee52

+ 1 - 1
api/member.js

@@ -1,6 +1,6 @@
 import {request} from '../service/ajax.js'
 
-const newsUrl = '/api/member/'
+const newsUrl = 'api/member/'
 // 用户注册登陆
 export const appletLogin = (data) => request(newsUrl + 'appletLogin', 'post', { ...data },false)
 

+ 1 - 1
api/shop.js

@@ -1,6 +1,6 @@
 import {request} from '../service/ajax.js'
 
-const newsUrl = '/api/shop/'
+const newsUrl = 'api/shop/'
 // 获取置顶商家
 export const shopTop = (data) => request(newsUrl + 'top', 'post', { ...data },false)
 

+ 2 - 1
api/shopping.js

@@ -8,8 +8,9 @@ export const shoppingSave = (data) => request(newsUrl + 'save', 'post', { ...dat
 // 删除购物车
 export const setShopIngDel = (data) => request(newsUrl + 'del', 'post', { ...data },false)
 
-// 购物车列表
+// 获取购物车列表
 export const getShopIngList = (data) => request(newsUrl + 'list', 'post', { ...data },false)
+
 ///////////////////////////////
 // 购物车 添加
 export const setShopIngAdd = (data) => request(newsUrl + 'add', 'post', { ...data },false)

+ 175 - 248
pages-takeout/new-shop.vue

@@ -22,11 +22,11 @@
 
 		<view class="bgc-f box-border-box plr-32 mb-32 shop-info">
 			<view class="shop-info-box bgc-f box-border-box p-24 z-3 b-rad-20">
-				<view class="fs-40 fw-600 text-overflow-ellipsis mb-16">
-					{{shopsInfo.shop_name || "山海鲜熬老灶麻辣火锅辣火锅辣火11 世家匠心传承店川"}}
+				<view class="fs-40 fw-600 text-overflow-ellipsis">
+					{{shopsInfo.shop_name}}
 				</view>
-				<view class="fs-24 fw-400 fc-9 text-overflow-ellipsis-one">
-					公告:{{shopsInfo.notice||"第二份半价是同时下相同商品的第二份可享受半价受"}}
+				<view class="fs-24 fw-400 fc-9 text-overflow-ellipsis-one pt-15" v-if="shopsInfo.notice">
+					公告:{{shopsInfo.notice || '暂无公告'}}
 				</view>
 			</view>
 		</view>
@@ -42,7 +42,7 @@
 			<view class="align-items-center">
 				<image class="zh-icon mr-8" src="@/static/img/order-food/zh-icon.png" mode="aspectFill"></image>
 				<view class="fw-600 fs-32 fc-3">
-					桌号:17
+					桌号:{{table_number}}
 				</view>
 			</view>
 		</view>
@@ -55,9 +55,9 @@
 					<view class="menu-box-left-box pb-130 box-border-box"
 						:style="{height: menuLeftType?`calc(100vh - ${newNavHeight}rpx - ${68}rpx)`:''}">
 						<view class="menu-type-list fs-26 box-border-box align-items-center flex-justify-center"
-							v-for="(item,i) in categoryData" :key="i" @click="selectType(item)"
-							:class="type ===  item.type?'bgc-f fc-3 fw-600':'fc-6 fw-400'"
-							:id="'left-scroll'+ item.type">
+							v-for="(item,i) in categoryList" :key="i" @click="selectType(item)"
+							:class="type ===  item.category_id?'bgc-f fc-3 fw-600':'fc-6 fw-400'"
+							:id="'left-scroll'+ item.category_id">
 							{{item.name}}
 							<view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}
 							</view>
@@ -66,7 +66,7 @@
 				</view>
 
 				<view class="menu-box-only bgc-f pb-130 box-border-box">
-					<view class="" v-for="(item,i) in categoryData" :key="i" :id="'scroll'+ item.type">
+					<view class="" v-for="(item,i) in goodsList" :key="i" :id="'scroll'+ item.type">
 						<view class="fs-28 fw-600 fc-3 sticky-nav bgc-f p-20 box-border-box"
 							:style="{top: newNavHeight + 'rpx'}">
 							{{item.name}}
@@ -115,7 +115,7 @@
 				</view>
 			</view>
 
-			<ShopInfo style="height: 100%;" :shopId='shop_id' v-else-if="shopType === 2"></ShopInfo>
+			<ShopInfo style="height: 100%;" v-else-if="shopType === 2"></ShopInfo>
 
 		</view>
 
@@ -150,16 +150,18 @@
 						<view class="fs-28 fw-400 fc-9">清空</view>
 					</view>
 				</view>
-				<view class="scroll-view-css bgc-ECECEC box-border-box p-32">
-					<view class="buy-card-item display-flex" v-for="(goods,i) in cartData.goods_list" :key="i">
+				<view class="scroll-view-css bgc-ECECEC box-border-box car-scroll-box">
+					<view class="buy-card-item bgc-f b-rad-20 display-flex p-20 box-border-box"
+						v-for="(goods,i) in cartData.goods_list" :key="i">
 						<image class="goods_img" :src="goods.goods_image" mode="scaleToFill"></image>
-						<view class="flex-1">
-							<view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-12">
-								{{goods.goods_name}}
-							</view>
-							<view class="w-514 text-overflow-ellipsis-one fs-24 fw-400 mb-18"
-								:class="goods.status_str?'fc-FD5C02':'fc-9'">
-								{{goods.status_str?goods.status_str:goods.goods_attr}}
+						<view class="flex-1 flex-direction flex-justify-space">
+							<view class="">
+								<view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-8">
+									{{goods.goods_name}}
+								</view>
+								<view class="fc-6">
+									{{goods.goods_attr}}
+								</view>
 							</view>
 							<view class="flex-justify-space">
 								<view class="">
@@ -168,12 +170,12 @@
 								</view>
 								<view class="display-flex align-items-center">
 									<image class="wh-44" @click.stop="setShoppingSave(goods,2)"
-										src="@/static/img/takeout/j.png" mode="">
+										src="@/static/img/order-food/reduce-img.png" mode="">
 									</image>
 									<view class="right-only-right-2 text-align-center fs-28 fw-400">
 										{{goods.goods_number}}
 									</view>
-									<image class="wh-44" src="@/static/img/takeout/add.png"
+									<image class="wh-44" src="/static/img/order-food/add-img.png"
 										@click.stop="setShoppingSave(goods,1)" mode=""></image>
 								</view>
 							</view>
@@ -211,6 +213,10 @@
 	import ShopInfo from './shop-mod/info.vue';
 	import tools from "@/service/tools";
 	import EnBlank from "@/components/en-utils/en-blank/en-blank";
+	import {
+		getGoodsCategory,
+		getGoodsGoods
+	} from '@/api/goods.js'
 	import {
 		receiveCoupon
 	} from "@/api/coupon.js"
@@ -241,6 +247,7 @@
 					name: "商家",
 					id: 2
 				}],
+				table_number: '',
 				shopType: 1, //组件类型
 				shopTypeBsLeft: 12,
 				shop_id: '',
@@ -267,121 +274,17 @@
 				topHeight: '',
 				idMark: '', //滚动自适应参数
 				idMarkTwo: '', //滚动自适应参数
-				type: 0, //分类标识
-				typeList: [],
-				categoryData: [{
-						type: 0,
-						name: '测试1',
-						list: [{
-							goods_id: 1,
-							goods_name: '测试商品1-1',
-							price: '10',
-							spec_type: 1,
-							goods_number: 0,
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}, {
-							goods_id: 2,
-							goods_name: '测试商品1-2',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}, {
-							goods_id: 3,
-							goods_name: '测试商品1-3',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					}, {
-						type: 1,
-						name: '测试2',
-						list: [{
-							goods_id: 4,
-							goods_name: '测试商品2-1',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}, {
-							goods_id: 5,
-							goods_name: '测试商品2-2',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}, {
-							goods_id: 6,
-							goods_name: '测试商品2-3',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					}, {
-						type: 2,
-						name: '测试3',
-						list: [{
-							goods_id: 7,
-							goods_name: '测试商品3',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					}, {
-						type: 3,
-						name: '测试4',
-						list: [{
-							goods_id: 8,
-							goods_name: '测试商品4',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					}, {
-						type: 4,
-						name: '测试5',
-						list: [{
-							goods_id: 9,
-							goods_name: '测试商品5',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					},
-					{
-						type: 5,
-						name: '测试6',
-						list: [{
-							goods_id: 10,
-							goods_name: '测试商品6',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					},
-					{
-						type: 6,
-						name: '测试7',
-						list: [{
-							goods_id: 11,
-							goods_name: '测试商品7',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					},
-					{
-						type: 7,
-						name: '测试8',
-						list: [{
-							goods_id: 12,
-							goods_name: '测试商品8',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					},
-					{
-						type: 8,
-						name: '测试9',
-						list: [{
-							goods_id: 13,
-							goods_name: '测试商品9',
-							price: '10',
-							goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-						}]
-					},
-				],
+				type: '', //默认分类标识
+				categoryList: [],
+				goodsList: []
 			}
 		},
-		onShow() {},
-		onLoad(e) {},
+		onShow() {
+			this.getShopIngList()
+		},
+		onLoad(e) {
+			this.getshopInfo()
+		},
 		mounted() {},
 		onReachBottom(e) {},
 		// 监听页面滚动
@@ -402,6 +305,103 @@
 			}
 		},
 		methods: {
+			shopInfo() {
+				// 获取商家详情
+				shopInfo().then((res) => {
+					if (res.code === 1) {
+						this.shopsInfo = res.data
+					}
+				})
+			},
+			getGoodsCategory() {
+				//获取商家分类
+				getGoodsCategory().then((res) => {
+					if (res.code === 1) {
+						this.categoryList = res.data
+						this.type = res.data[0].category_id
+					}
+				})
+			},
+			getGoodsGoods() {
+				//获取商家商品列表
+				getGoodsGoods().then((res) => {
+					if (res.code === 1) {
+						// 初始化商品列表
+						this.goodsList = res.data
+						// 从购物车数据中回显每个商品的数量
+						this.updateGoodsNumFromCart()
+					}
+				})
+			},
+			getShopIngList() {
+				// 获取购物车列表
+				getShopIngList().then(res => {
+					if (res.code === 1) {
+						this.cartData = res.data
+						// 同步更新商品列表中的数量
+						this.updateGoodsNumFromCart()
+					}
+				})
+			},
+			getshopInfo() {
+				this.table_number = uni.getStorageSync('table_number')
+				this.shopInfo()
+				this.getGoodsCategory()
+				this.getGoodsGoods()
+			},
+			updateGoodsNumFromCart() {
+				// 从购物车数据同步商品数量
+				if (!this.goodsList || !this.cartData.goods_list) {
+					return
+				}
+
+				// 创建购物车商品的映射,按goods_id分组,累加数量
+				  const cartGoodsMap = {}
+				  this.cartData.goods_list.forEach(cartItem => {
+				    const goodsId = cartItem.goods_id
+				    if (!cartGoodsMap[goodsId]) {
+				      cartGoodsMap[goodsId] = 0
+				    }
+				    // 累加同一个商品不同规格的数量
+				    cartGoodsMap[goodsId] += cartItem.goods_number || 0
+				  })
+				  
+				  // 更新商品列表中的数量
+				  this.goodsList.forEach(category => {
+				    if (category.list && category.list.length > 0) {
+				      category.list.forEach(goods => {
+				        // 从购物车映射中获取该商品的总数量
+				        goods.num = cartGoodsMap[goods.goods_id] || 0
+				      })
+				    }
+				  })
+
+				// 更新分类列表中的商品数量
+				this.updateCategoryNum()
+			},
+			updateCategoryNum() {
+				// 更新分类的商品总数
+				if (!this.categoryList || !this.goodsList) {
+					return
+				}
+
+				this.categoryList.forEach(categoryItem => {
+					// 找到对应的商品分类
+					const goodsCategory = this.goodsList.find(
+						category => category.type === categoryItem.category_id
+					)
+
+					if (goodsCategory && goodsCategory.list) {
+						// 计算该分类下所有商品的总数量
+						const totalNum = goodsCategory.list.reduce((sum, goods) => {
+							return sum + (goods.num || 0)
+						}, 0)
+						categoryItem.num = totalNum
+					} else {
+						categoryItem.num = 0
+					}
+				})
+			},
 			goToOrder() {
 				uni.navigateTo({
 					url: 'pages/order/index'
@@ -413,16 +413,16 @@
 				})
 			},
 			selectType(item, itemTwo) {
-				if (this.type != item.type) {
-					this.type = item.type;
-					this.idMark = 'scroll' + item.type
+				if (this.type != item.category_id) {
+					this.type = item.category_id;
+					this.idMark = 'scroll' + item.category_id
 
 					// 立即更新
 					this.$forceUpdate();
 
 					// 延迟执行滚动
 					setTimeout(() => {
-						this.scrollToCategorySimple(item.type);
+						this.scrollToCategorySimple(item.category_id);
 					}, 100);
 				}
 			},
@@ -455,26 +455,6 @@
 							console.log('滚动完成');
 						}
 					});
-					// 获取当前滚动位置
-					// query.selectViewport().scrollOffset(res => {
-					//   // 计算目标滚动位置
-					//   // 减去固定元素的高度:导航栏 + 店铺信息 + 分类栏
-					//   const navHeight = this.newNavHeight ? uni.upx2px(this.newNavHeight) : 0;
-					//   const fixedOffset = navHeight + 200 + 100; // 可以根据实际情况调整
-
-					//   const targetScrollTop = res.scrollTop + rect.top - fixedOffset;
-
-					//   console.log('当前scrollTop:', res.scrollTop, '目标scrollTop:', targetScrollTop);
-
-					//   // 滚动到目标位置
-					//   uni.pageScrollTo({
-					//     scrollTop: targetScrollTop,
-					//     duration: 300,
-					//     success: () => {
-					//       console.log('滚动完成');
-					//     }
-					//   });
-					// }).exec();
 				}).exec();
 			},
 			addred(type, item) {
@@ -486,54 +466,37 @@
 					// 减
 					--item.num;
 					if (item.num >= 0) {
-						this.addShoppingSave(item, item.num, type)
+						this.shoppingSave(item, item.num)
 					} else {
 						this.isAjax = false
 					}
 				} else if (type === 2) {
 					// 加
 					++item.num;
-					if (item.is_infinite === 0 && item.num > item.stock) {
-						--item.num
-						this.isAjax = false
-					} else if (item.is_quota > 0 && item.num > item.quota_num) {
-						--item.num
-						this.isAjax = false
-					} else {
-						this.addShoppingSave(item, item.num, type)
-					}
-
+					this.shoppingSave(item, item.num)
 				} else if (type === 3) {
 					// 选规格
+					this.isAjax = false
 					uni.navigateTo({
-						url: 'pages-takeout/new-specs-info'
+						url: `pages-takeout/new-specs-info?goods_id=${item.goods_id}&category_id=${item.category_id}`
 					})
-				} else {
-					let data = JSON.parse(JSON.stringify(this.popData))
-					this.selectedSpecification.push(data)
-					console.log(this.popData, "666666666666666666")
-					console.log('1', this.popData.goods_id, this.shop_id, this.popData.goodsItem.category_id, this.popData
-						.spec_key, this.popData.num);
-					this.setShoppingSave()
-					this.isAjax = false
 				}
 			},
-			addShoppingSave(item, num, type) {
+			shoppingSave(item, num) {
 				shoppingSave({
-					type: 1,
 					goods_id: item.goods_id,
-					shop_id: this.shop_id,
 					category_id: item.category_id,
-					goods_spec_id: '',
+					goods_spec_id: item.goods_spec_id,
 					number: num
 				}).then((res) => {
 					if (res.code === 1) {
-						if (type === 1) {
-							tools.success('操作成功')
-						} else {
-							tools.success(res.msg)
-						}
+						tools.success(res.msg)
 						this.isAjax = false
+						// 直接更新当前商品的数量(即时反馈)
+						const goods = this.findGoodsInList(item.goods_id)
+						if (goods) {
+							goods.num = num
+						}
 						this.getShopIngList()
 					} else {
 						this.isAjax = false
@@ -541,17 +504,17 @@
 					}
 				})
 			},
-			getHeight() {
-				const query = uni.createSelectorQuery();
-				query.select('.shop-info').boundingClientRect(data => {
-					this.heightOne = data.height;
-					console.log(this.heightOne, '0000000000');
-				}).exec();
-				query.select('.shop-type-box').boundingClientRect(data => {
-					this.heightTwo = data.height;
-					this.topHeight = this.heightOne + this.heightTwo + this.newNavHeight
-					console.log(this.topHeight, '111111');
-				}).exec();
+			findGoodsInList(goodsId) {
+				// 在商品列表中查找指定商品
+				for (let category of this.goodsList) {
+					if (category.list) {
+						const goods = category.list.find(item => item.goods_id === goodsId)
+						if (goods) {
+							return goods
+						}
+					}
+				}
+				return null
 			},
 			navHeight(e) {
 				this.newNavHeight = e
@@ -570,10 +533,7 @@
 					success: (res) => {
 						console.log(res)
 						if (res.confirm) {
-							setShopIngDel({
-								'shop_id': this.shop_id,
-								'type': 1,
-							}).then((res) => {
+							setShopIngDel().then((res) => {
 								if (res.code === 1) {
 									tools.success(res.msg)
 									this.getShopIngList()
@@ -587,53 +547,14 @@
 				});
 			},
 			setShoppingSave(item, type) {
-				console.log(item, '11111111');
 				if (type === 1) {
 					// 加
 					item.goods_number = item.goods_number + 1
 				} else {
 					// 减
-					if (item.goods_number < 0) {
-						return
-					}
 					item.goods_number = item.goods_number - 1
 				}
-				return
-				if (this.isAjax) {
-					return
-				}
-				this.isAjax = true
-				shoppingSave({
-					'type': 1,
-					'goods_id': item.goods_id,
-					'shop_id': this.shop_id,
-					'category_id': item.category_id,
-					'goods_spec_id': item.goods_spec_id,
-					'number': item.goods_number,
-				}).then(res => {
-					if (res.code == 1) {
-						this.isAjax = false
-						this.getShopIngList()
-					}
-				}).catch(() => {
-					this.isAjax = false
-				})
-			},
-			getShopIngList() {
-				getShopIngList({
-					'shop_id': 111,
-				}).then(res => {
-					if (res.code === 1) {
-						this.cartData = res.data
-						if (this.shopType === 1) {
-							setTimeout(() => {
-								console.log('我的数据执行了')
-								// this.$refs.goodsMenu.setShopIngList(this.cartData)
-							}, 1000)
-
-						}
-					}
-				})
+				this.shoppingSave(item, item.goods_number)
 			},
 			setCartData(cartData) {
 				this.cartData = cartData
@@ -719,6 +640,10 @@
 </script>
 
 <style scoped lang="scss">
+	.car-scroll-box {
+		padding: 12rpx 24rpx calc(env(safe-area-inset-bottom) + 48rpx);
+	}
+
 	.zh-icon {
 		width: 32rpx;
 		height: 32rpx;
@@ -967,7 +892,7 @@
 	}
 
 	.buy-card {
-		height: 920rpx;
+		height: 60vh;
 		border-radius: 24rpx 24rpx 0rpx 0rpx;
 	}
 
@@ -980,7 +905,7 @@
 
 	.buy-card-item {
 		width: 100%;
-		height: 176rpx;
+		// height: 176rpx;
 		margin-bottom: 32rpx;
 	}
 
@@ -1100,6 +1025,7 @@
 
 	.menu-box-left-box {
 		overflow-y: auto;
+		
 	}
 
 	.menu-type-list {
@@ -1108,6 +1034,7 @@
 		padding: 18rpx 28rpx;
 		position: relative;
 		z-index: 10;
+		border-radius: 0rpx 20rpx 20rpx 0rpx;
 
 		.menu-type-num {
 			position: absolute;
@@ -1118,7 +1045,7 @@
 			height: 32rpx;
 			text-align: center;
 			line-height: 32rpx;
-			background: #FB3D03;
+			background: #FE6B2C;
 			border-radius: 50%;
 		}
 	}
@@ -1126,7 +1053,6 @@
 	.menu-type-list-f {
 		// width: 160rpx;
 		background-color: #007AFF;
-
 		width: 100%;
 		height: 100%;
 		overflow-y: auto;
@@ -1175,15 +1101,16 @@
 
 				.selectedNum {
 					position: absolute;
-					right: 2rpx;
+					right: -10rpx;
 					top: -22rpx;
 					font-size: 24rpx;
 					color: #fff;
 					width: 32rpx;
 					height: 32rpx;
 					line-height: 32rpx;
-					background: #FB3D03;
+					background: #FE6B2C;
 					border-radius: 50%;
+					border: 1rpx solid #FFFFFF;
 				}
 			}
 

+ 43 - 87
pages-takeout/new-specs-info.vue

@@ -11,15 +11,15 @@
 				</view>
 			</view>
 		</newNav>
-		<image class="goods-img" src="/pages-buy/static/fl-bg.png" mode="aspectFill"></image>
+		<image class="goods-img" :src="infoData.goods_image" mode="aspectFill"></image>
 		<view class="image-box" :style="{height: `calc(41vh - ${newNavHeight}rpx)`}"></view>
 		<view class="goods-name-box">
 			<view class="goods-name b-rad-24-24-0-0 p-32-32-0 box-border-box bgc-f">
 				<view class="fs-36 fw-600 fc-3">
-					红烧牛肉面红烧牛111面11牛肉面牛肉面牛肉 红烧牛肉面红烧牛111面11牛肉面牛
+					{{infoData.goods_name || ''}}
 				</view>
-				<view class="pt-20 fs-28 fc-6">
-					商品描述商品描述商品描述
+				<view class="pt-20 fs-28 fc-6" v-if="infoData.goods_desc">
+					{{infoData.goods_desc}}
 				</view>
 			</view>
 		</view>
@@ -95,85 +95,21 @@
 	import {
 		getGoodsGoodsSpec
 	} from "@/api/goods.js"
+	import {
+		shoppingSave
+	} from "@/api/shopping.js"
+	import tools from "@/service/tools"
 	export default {
 		components: {},
 		data() {
 			return {
 				infoData: {},
 				newNavHeight: '',
-				specsData: [{
-					sku_name: '口味',
-					sku_id: 8,
-					sku_type: 1, //1:单选, 2:多选
-					affect_quantity: 0, //是否影响购物车数量: 0-不影响, 1-影响
-					spec_list: [{
-						spec_name: '不辣',
-						spec_price: 8,
-						spec_id: 0
-					}, {
-						spec_name: '微辣',
-						spec_price: 8,
-						spec_id: 1
-					}, {
-						spec_name: '中辣',
-						spec_price: 8,
-						spec_id: 2
-					}, {
-						spec_name: '特辣',
-						spec_price: 8,
-						spec_id: 3
-					}]
-				},{
-					sku_name: '粗细',
-					sku_id: 10,
-					sku_type: 1, //1:单选, 2:多选
-					affect_quantity: 0, //是否影响购物车数量: 0-不影响, 1-影响
-					spec_list: [{
-						spec_name: '特细',
-						spec_price: 0,
-						spec_id: 11
-					}, {
-						spec_name: '细',
-						spec_price: 0,
-						spec_id: 12
-					}, {
-						spec_name: '粗',
-						spec_price: 0,
-						spec_id: 13
-					}, {
-						spec_name: '韭叶',
-						spec_price: 0,
-						spec_id: 14
-					}]
-				}
-				, {
-					sku_name: '小料',
-					sku_type: 2,
-					sku_id: 9,
-					affect_quantity: 1, //是否影响购物车数量: 0-不影响, 1-影响
-					spec_list: [{
-						spec_name: '煎蛋',
-						spec_price: 3,
-						spec_id: 4
-					}, {
-						spec_name: '酱牛肉',
-						spec_price: 8,
-						spec_id: 5
-					}, {
-						spec_name: '卤蛋',
-						spec_price: 2,
-						spec_id: 6
-					}, {
-						spec_name: '卤鸡腿',
-						spec_price: 2,
-						spec_id: 7
-					}]
-				}],
+				specsData: [],
 				spec_key: [],
 				total_price: 0,
 				spec_text: '请选择规格',
 				postData: {
-					shop_id: '',
 					goods_id: '',
 					category_id: '',
 					goods_spec: [],
@@ -196,7 +132,11 @@
 			}
 		},
 		onLoad(data) {
-			this.addSpecNum()
+			if (data) {
+				this.postData.goods_id = data.goods_id
+				this.postData.category_id = data.category_id
+				this.getGoodsGoodsSpec(data.goods_id)
+			}
 		},
 		mounted() {},
 		methods: {
@@ -217,7 +157,6 @@
 				let basePrice = 0; // 假设商品基础价格,可以从接口获取
 				let specPrice = 0;
 				let specArray = [];
-
 				// 遍历所有规格组
 				this.specsData.forEach(group => {
 					group.spec_list.forEach(spec => {
@@ -225,10 +164,8 @@
 						if (this.spec_key.includes(spec.spec_id)) {
 							// 获取规格数量
 							let specNum = group.affect_quantity === 1 ? spec.spec_num : 1;
-
 							// 累加价格
 							specPrice += spec.spec_price * specNum;
-
 							// 构建规格文字
 							let specName = spec.spec_name;
 							if (group.sku_type === 2 && specNum > 1) {
@@ -250,7 +187,24 @@
 				// this.$forceUpdate();
 			},
 			addShoppingCart() {
-				console.log(this.postData, "提交数据");
+				// console.log(this.postData, "提交数据");
+				this.shoppingSave()
+			},
+			shoppingSave() {
+				shoppingSave(this.postData).then((res) => {
+					if (res.code === 1) {
+						tools.success(res.msg)
+						this.isAjax = false
+						setTimeout(() => {
+							uni.navigateBack({
+								delta: 1
+							})
+						}, 1000)
+					} else {
+						this.isAjax = false
+						tools.error(res.msg)
+					}
+				})
 			},
 			setNum(item, info, type) {
 				if (type === 0) {
@@ -271,6 +225,17 @@
 				}
 				this.$forceUpdate();
 			},
+			getGoodsGoodsSpec(goods_id) {
+				getGoodsGoodsSpec({
+					goods_id: goods_id
+				}).then((res) => {
+					if (res.code * 1 === 1) {
+						this.specsData = res.data.sku
+						this.infoData = res.data.goods
+						this.addSpecNum()
+					}
+				})
+			},
 			addSpecNum() {
 				this.specsData.forEach((v, k) => {
 					if (v.affect_quantity === 1) {
@@ -282,15 +247,6 @@
 					}
 				})
 			},
-			getGoodsGoodsSpec() {
-				getGoodsGoodsSpec({
-					goods_id: '5354'
-				}).then((res) => {
-					if (res.code * 1 === 1) {
-						console.log(res);
-					}
-				})
-			},
 			navHeight(e) {
 				this.newNavHeight = e
 			},

+ 1 - 3
pages-takeout/shop-mod/info.vue

@@ -53,9 +53,7 @@
 				array: ''
 			}
 		},
-		onShow() {
-
-		},
+		onShow() {},
 		mounted() {
 			this.shopInfo()
 		},

+ 99 - 89
pages/index/index.vue

@@ -1,102 +1,112 @@
 <template>
-  <view class="flex-common-css">
-    <Nav :leftShow='false' :customNav='true' title="" bgckgroundBox='#EF1F0C'></Nav>
-    <view class="flex-1 flex-direction iPhone-bottom box-border-box">
-      <image class="qd-bg" src="@/static/img/order-food/qd-bg.png" mode=""></image>
-      <view class="order-food-box p-0-32 box-border-box">
-        <view class="order-food p-32 box-border-box bgc-f b-rad-24" @click="login()">
-          <view class="b-FFD7CC bc-FFEDE9-FFF1EE b-rad-24 p-20-32 box-border-box align-items-center flex-justify-space">
-            <view class="flex-direction">
-              <view class="align-items-center mb-8">
-                <view class="fs-36 fc-3 fw-600">
-                  堂食扫码点餐
-                </view>
-                <image class="right-h" src="@/static/img/order-food/right-h.png" mode=""></image>
-              </view>
-              <view class="fs-28 fc-9">
-                自助下单方便快捷
-              </view>
-            </view>
-            <image class="zh-img" src="@/static/img/order-food/zh-img.png" mode=""></image>
-          </view>
-        </view>
-      </view>
-    </view>
-  </view>
+	<view class="flex-common-css">
+		<Nav :leftShow='false' :customNav='true' title="" bgckgroundBox='#EF1F0C'></Nav>
+		<view class="flex-1 flex-direction iPhone-bottom box-border-box">
+			<image class="qd-bg" src="@/static/img/order-food/qd-bg.png" mode=""></image>
+			<view class="order-food-box p-0-32 box-border-box">
+				<view class="order-food p-32 box-border-box bgc-f b-rad-24" @click="goToUrl()">
+					<view
+						class="b-FFD7CC bc-FFEDE9-FFF1EE b-rad-24 p-20-32 box-border-box align-items-center flex-justify-space">
+						<view class="flex-direction">
+							<view class="align-items-center mb-8">
+								<view class="fs-36 fc-3 fw-600">
+									堂食扫码点餐
+								</view>
+								<image class="right-h" src="@/static/img/order-food/right-h.png" mode=""></image>
+							</view>
+							<view class="fs-28 fc-9">
+								自助下单方便快捷
+							</view>
+						</view>
+						<image class="zh-img" src="@/static/img/order-food/zh-img.png" mode=""></image>
+					</view>
+				</view>
+			</view>
+		</view>
+	</view>
 </template>
 
 <script>
-  import {
-    appletLogin
-  } from "@/api/member";
-  import tools from "@/service/tools";
+	import {
+		appletLogin
+	} from "@/api/member";
+	import tools from "@/service/tools";
 
-  export default {
-    components: {},
-    data() {
-      return {}
-    },
-    onLoad(data) {
-      this.login()
-    },
-    mounted() {},
-    methods: {
-      login() {
-        uni.login({
-          provider: "weixin",
-          success: (loginRes) => {
-            this.appletLogin(loginRes.code);
-          },
-          fail: (loginRes) => {
-            this.isAjax = false;
-            tools.error("获取授权信息失败");
-          },
-        });
-      },
-      appletLogin(code) {
-        appletLogin({
-          'code': code
-        }).then(res => {
-          this.goToUrl()
-        })
-      },
-      goToUrl(shop_id) {
-        uni.reLaunch({
-          url: '/pages-takeout/shop?shop_id=' + shop_id
-        });
-      }
-    }
-  }
+	export default {
+		components: {},
+		data() {
+			return {}
+		},
+		onLoad(data) {
+			// if (data) {
+			// 	uni.setStorageSync('shop_id', data.shop_id)
+			// }
+			uni.setStorageSync('shop_id', 111)
+			uni.setStorageSync('table_number', 1)
+			this.login()
+		},
+		mounted() {},
+		methods: {
+			login() {
+				uni.login({
+					provider: "weixin",
+					success: (loginRes) => {
+						this.appletLogin(loginRes.code);
+					},
+					fail: (loginRes) => {
+						this.isAjax = false;
+						tools.error("获取授权信息失败");
+					},
+				});
+			},
+			appletLogin(code) {
+				appletLogin({
+					'code': code
+				}).then(res => {
+					if (res.code === 1) {
+						uni.setStorageSync('token', res.data.token)
+						uni.setStorageSync('m_id', res.data.m_id)
+						// this.goToUrl()
+					}
+				})
+			},
+			goToUrl(shop_id) {
+				uni.reLaunch({
+					url: '/pages-takeout/new-shop?shop_id=' + shop_id
+				});
+			}
+		}
+	}
 </script>
 
 <style lang="scss" scoped>
-  .qd-bg {
-    width: 100%;
-    height: 696rpx;
-  }
+	.qd-bg {
+		width: 100%;
+		height: 696rpx;
+	}
 
-  .order-food-box {
-    position: relative;
-  }
+	.order-food-box {
+		position: relative;
+	}
 
-  .order-food {
-    width: calc(100% - 64rpx);
-    position: absolute;
-    left: 32rpx;
-    top: -90rpx;
-  }
+	.order-food {
+		width: calc(100% - 64rpx);
+		position: absolute;
+		left: 32rpx;
+		top: -90rpx;
+	}
 
-  .bc-FFEDE9-FFF1EE {
-    background: linear-gradient(90deg, #FFEDE9 0%, #FFF1EE 100%);
-  }
+	.bc-FFEDE9-FFF1EE {
+		background: linear-gradient(90deg, #FFEDE9 0%, #FFF1EE 100%);
+	}
 
-  .zh-img {
-    width: 148rpx;
-    height: 148rpx;
-  }
+	.zh-img {
+		width: 148rpx;
+		height: 148rpx;
+	}
 
-  .right-h {
-    width: 40rpx;
-    height: 40rpx;
-  }
-</style>
+	.right-h {
+		width: 40rpx;
+		height: 40rpx;
+	}
+</style>

+ 66 - 93
pages/index/search-record.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="flex-common-css iPhone-bottom box-border-box bgc-f">
 		<image class="order-bg" src="@/static/img/order-food/ss-bg.png" mode=""></image>
-		<newNav textName="提交订单" class="mb-20" titleColor='#333' leftIconColor='#333'></newNav>
+		<newNav textName="搜索商品" class="mb-20" titleColor='#333' leftIconColor='#333'></newNav>
 
 		<view class="plr-24 box-border-box">
 			<view class="s-input box-border-box bgc-f align-items-center flex-justify-space b-rad-200 z-3">
@@ -22,7 +22,7 @@
 		<view class="scroll-view-css bgc-f seacrh-info box-border-box p-32" v-if="goodsList.length<=0">
 			<view class="flex-justify-space mb-32">
 				<view class="fs-32 fw-600 fc-3">搜索历史</view>
-				<view class="align-items-center" v-if="list.length > 0 && historyType">
+				<view class="align-items-center" v-if="list.length > 0">
 					<view @click="isOpen=!isOpen" class="">{{!isOpen?'收起':'展开'}}</view>
 					<view @click="isOpen=!isOpen" :class="!isOpen?'down':'up'">
 						<uni-icons type="right" size="14" color="#999"></uni-icons>
@@ -38,43 +38,40 @@
 		</view>
 
 		<view class="scroll-view-css bgc-F5F4F9 p-32 box-border-box" v-else>
-			<view class="" v-for="(item,i) in goodsList" :key="i">
-				<view class="menu-list flex-justify-space bgc-f p-24 box-border-box b-rad-20 mb-16" v-for="(info,k) in item.list" :key="k"
-					:id="'goods_id'+ info.goods_id">
-					<image class="flex-shrink0 goods_img mr-20" :src="info.goods_image" mode="scaleToFill"></image>
-					<view class="menu-list-right flex-direction flex-justify-space">
-						<view class="mb-8">
-							<view class="mb-4 goods-name text-overflow-ellipsis fs-32 fw-600">
-								{{info.goods_name}}
-							</view>
-							<view class="text-overflow-ellipsis-one fw-400 fc-9 fs-24 mb-2 goods-name"
-								v-if="info.spec_type == 1">
-								{{info.goods_desc?info.goods_desc:''}}
-							</view>
+			<view class="menu-list flex-justify-space bgc-f p-24 box-border-box b-rad-20 mb-16"
+				v-for="(info,k) in goodsList" :key="k" :id="'goods_id'+ info.goods_id">
+				<image class="flex-shrink0 goods_img mr-20" :src="info.goods_image" mode="scaleToFill"></image>
+				<view class="menu-list-right flex-direction flex-justify-space">
+					<view class="mb-8">
+						<view class="mb-4 goods-name text-overflow-ellipsis fs-32 fw-600">
+							{{info.goods_name}}
 						</view>
-						<view class="flex-justify-space align-items-flex-end">
-							<view class="">
-								<span class="fs-24 fw-400 fc-3">¥</span>
-								<span
-									class="fs-36 fw-b fc-3">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
-									<span class="fs-24 fc-9">/份起</span>
+						<view class="text-overflow-ellipsis-one fw-400 fc-9 fs-24 mb-2 goods-name"
+							v-if="info.spec_type == 1">
+							{{info.goods_desc?info.goods_desc:''}}
+						</view>
+					</view>
+					<view class="flex-justify-space align-items-flex-end">
+						<view class="">
+							<span class="fs-24 fw-400 fc-3">¥</span>
+							<span class="fs-36 fw-b fc-3">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
+							<span class="fs-24 fc-9">/份起</span>
+						</view>
+						<view class="display-flex align-items-center" v-if="info.spec_type == 1">
+							<image v-show="info.num > 0" class="wh-44" @click="addred(1,info)"
+								src="@/static/img/order-food/reduce-img.png" mode=""></image>
+							<view v-show="info.num > 0" class="right-only-right-2 text-align-center fs-28 fw-400">
+								{{info.num}}
 							</view>
-							<view class="display-flex align-items-center" v-if="info.spec_type == 1">
-								<image v-show="info.num > 0" class="wh-44" @click="addred(1,info)"
-									src="@/static/img/order-food/reduce-img.png" mode=""></image>
-								<view v-show="info.num > 0" class="right-only-right-2 text-align-center fs-28 fw-400">
-									{{info.num}}
-								</view>
-								<image class="wh-44" src="@/static/img/order-food/add-img.png" @click="addred(2,info)"
-									mode=""></image>
+							<image class="wh-44" src="@/static/img/order-food/add-img.png" @click="addred(2,info)"
+								mode=""></image>
+						</view>
+						<view v-else class="right-only-right text-align-center b-rad-200" @click="addred(3,info)">
+							<view class="fw-500 fs-28 fc-f">
+								选规格
 							</view>
-							<view v-else class="right-only-right text-align-center b-rad-200" @click="addred(3,info)">
-								<view class="fw-500 fs-28 fc-f">
-									选规格
-								</view>
-								<view class="selectedNum" v-if="info.num>0">
-									{{info.num}}
-								</view>
+							<view class="selectedNum" v-if="info.num>0">
+								{{info.num}}
 							</view>
 						</view>
 					</view>
@@ -106,6 +103,7 @@
 <script>
 	import tools from "@/service/tools";
 	import {
+		getSearch,
 		getSearchList,
 		delSearch
 	} from '@/api/goods.js';
@@ -116,53 +114,41 @@
 				isOpen: false,
 				showClearIcon: false,
 				list: [],
-				goodsList: [{
-					type: 0,
-					name: '测试1',
-					list: [{
-						goods_id: 1,
-						goods_name: '测试商品1-1',
-						price: '10',
-						spec_type: 1,
-						goods_number: 0,
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}, {
-						goods_id: 2,
-						goods_name: '测试商品1-2',
-						price: '10',
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}, {
-						goods_id: 3,
-						goods_name: '测试商品1-3',
-						price: '10',
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}]
-				}, {
-					type: 1,
-					name: '测试2',
-					list: [{
-						goods_id: 4,
-						goods_name: '测试商品2-1',
-						price: '10',
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}, {
-						goods_id: 5,
-						goods_name: '测试商品2-2',
-						price: '10',
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}, {
-						goods_id: 6,
-						goods_name: '测试商品2-3',
-						price: '10',
-						goods_image: 'https://qcloud.dpfile.com/pc/JvY4fMzO0Km80S9Sn-tNxYin28jkvrNMJV-pUo8YwCctS4AHLKPXFhGyuI2dCwk8.jpg'
-					}]
-				}],
-				historyType: false
+				goodsList: [],
+				historyType: false,
+				total: '',
+				page: 1
 			}
 		},
+		onLoad() {
+			this.getList()
+		},
 		onShow() {},
 		mounted() {},
 		methods: {
+			toList(name) {
+				let search = '';
+				if (name) {
+					search = name;
+					this.search = name
+				} else {
+					search = this.search;
+				}
+				this.page = 1
+				this.goodsList = []
+				this.getSearch(search)
+			},
+			getSearch(search) {
+				// 搜索商品列表
+				getSearch({
+					search: search,
+					page: this.page
+				}).then((res) => {
+					if (res.code * 1 === 1) {
+						this.goodsList = [...this.goodsList, ...res.data.items]
+					}
+				})
+			},
 			clearIcon() {
 				this.search = '';
 				this.showClearIcon = false;
@@ -185,26 +171,13 @@
 					.exec();
 			},
 			getList() {
+				// 获取搜索历史内容
 				getSearchList().then((res) => {
 					if (res.code === 1) {
 						this.list = res.data.my_search;
 					}
 				})
 			},
-			toList(name) {
-				let search = '';
-				if (name) {
-					search = name;
-				} else {
-					search = this.search;
-				}
-				if (!search) {
-					return tools.error('请输入搜索内容')
-				}
-				uni.navigateTo({
-					url: "pages/index/search-list?search=" + search
-				})
-			},
 			delList() {
 				delSearch().then((res) => {
 					if (res.code === 1) {
@@ -371,7 +344,7 @@
 			.right-only-right {
 				width: 116rpx;
 				height: 44rpx;
-				background: linear-gradient( 270deg, #FF3333 0%, #FE6122 100%);
+				background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
 				line-height: 44rpx;
 				position: relative;
 

+ 9 - 38
pages/login/index.vue

@@ -74,54 +74,25 @@
 				// #endif
 			},
 			login() {
-				uni.setStorageSync('token', 165165165156)
-				uni.setStorageSync('m_id', 88)
-				uni.reLaunch({
-					url: "/pages/index/index",
-				});
-				return
+				// uni.setStorageSync('token', 165165165156)
+				// uni.setStorageSync('m_id', 88)
+				// uni.reLaunch({
+				// 	url: "/pages/index/index",
+				// });
+				// return
 				if (this.isAjax) {
 					return false;
 				}
 				this.isAjax = true;
-				uni.login({
-					//#ifdef MP-WEIXIN
-					provider: "weixin",
-					//#endif
-					//#ifdef MP-QQ
-					provider: "qq",
-					//#endif
-					success: (loginRes) => {
-						this.from.code = loginRes.code;
-					},
-					fail: (loginRes) => {
-						this.isAjax = false;
-						tools.error("获取授权信息失败");
-					},
+				uni.switchTab({
+					url: "/pages/index/index",
 				});
 			},
 			noLogin() {
 				uni.switchTab({
 					url: "/pages/index/index",
 				});
-			},
-			async getUserInfo() {
-				this.from.invite_code = uni.getStorageSync('iCode');
-				const res = await membeRphoneLogin(this.from);
-				if (res.code == 1) {
-					uni.setStorageSync('token', res.data.token)
-					uni.setStorageSync('m_id', res.data.m_id)
-					tools.success("授权成功");
-					setTimeout(() => {
-						uni.switchTab({
-							url: "/pages/index/index",
-						});
-					}, 1000);
-				} else {
-					this.isAjax = false;
-					tools.error(res.msg);
-				}
-			},
+			}
 		},
 	};
 </script>

+ 1 - 0
service/ajax.js

@@ -11,6 +11,7 @@ export const request = (url, method, data, show = false) => {
   let token = uni.getStorageSync('token')
   data.token = token;
   data.m_id = uni.getStorageSync('m_id')
+  data.shop_id = uni.getStorageSync('shop_id')
   // data.school_id = uni.getStorageSync('school_id');
   // data.operate_id = uni.getStorageSync('operate_id');
   // data.system_type = uni.getStorageSync('system_type');