ソースを参照

chore: 今日吃啥联调

yijianjun 1 週間 前
コミット
6f5416e12c

+ 49 - 30
mer_uniapp/pages/what_to_eat_today/index/index.vue

@@ -22,16 +22,16 @@
 				<img @click="onClose" src="../static/img/关闭.png" alt="" style="height: 49rpx;width: 49rpx;"
 					class="m-close" />
 				<view class="goods-items">
-					<view class="g-item" v-for="ite in 2" :key="ite">
+					<view class="g-item" v-for="ite in productList" :key="ite">
 						<img src="../static/img/甜点.png" alt="" style="height: 230rpx;width: 230rpx;" />
 						<view class="g-title">
-							张记煲仔饭套餐
+							{{ite.name||'-'}}
 						</view>
 						<view class="g-price">
-							¥18
+							¥{{ite.price||'-'}}
 						</view>
 						
-						<view class="choose-btn" @click="onChoose({id:23})">
+						<view class="choose-btn" @click="onChoose({id:ite.id})">
 							选择
 						</view>
 					</view>
@@ -42,6 +42,7 @@
 </template>
 
 <script>
+	import {whattodayeatApi,whattodayeatProductApi} from '../what_to_eat_today.js'
 	import navBar from '@/components/navBar';
 	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
 	let app = getApp();
@@ -57,27 +58,29 @@
 				navigationBarHeight: 0,
 				loading: false,
 				loadTitle: '',
-				items: [{
-						label: '我不挑食',
-						icon: require('../static/img/甜点.png'),
-						checked: true
-					},
-					{
-						label: '减肥套餐',
-						icon: require('../static/img/减肥餐.png'),
-						checked: true
-					},
-					{
-						label: '精致小食',
-						icon: require('../static/img/小食.png'),
-						checked: true
-					},
-					{
-						label: '豪华美食',
-						icon: require('../static/img/豪华餐.png'),
-						checked: true
-					}
-				]
+				productList:[],
+				items: []
+				// [{
+				// 		label: '我不挑食',
+				// 		icon: require('../static/img/甜点.png'),
+				// 		checked: true
+				// 	},
+				// 	{
+				// 		label: '减肥套餐',
+				// 		icon: require('../static/img/减肥餐.png'),
+				// 		checked: true
+				// 	},
+				// 	{
+				// 		label: '精致小食',
+				// 		icon: require('../static/img/小食.png'),
+				// 		checked: true
+				// 	},
+				// 	{
+				// 		label: '豪华美食',
+				// 		icon: require('../static/img/豪华餐.png'),
+				// 		checked: true
+				// 	}
+				// ]
 			}
 		},
 		//下拉刷新
@@ -86,30 +89,46 @@
 		},
 		onLoad(options) {
 			this.navH = 96;
+			whattodayeatApi().then(res => {
+				this.items = res.data.map((ite,i) => ({
+					label:ite.tagName,
+					icon:ite.icon,
+					checked:i==0,
+					...ite
+				}))
+			})
 		},
 		onShow() {
 
 		},
 		methods: {
 			handleCheck(i) {
-				this.items[i].checked = !this.items[i].checked
+				this.items.forEach(ite => ite.checked = false)
+				this.items[i].checked = true
 			},
 			handBack() {
 				uni.navigateBack({
 					delta: 1
 				})
 			},
-			onStartBtnClick() {
+		async onStartBtnClick() {
 				uni.showLoading()
-				this.$refs.activate.open()
-				uni.hideLoading()
+				let check = this.items.filter((ite) => ite.checked)
+				const params = {
+					latitude: uni.getStorageSync('user_latitude'),
+					longitude: uni.getStorageSync('user_longitude'),
+					tagId:check[0].id
+				}
+			const res =	await whattodayeatProductApi(params).finally(()=>uni.hideLoading())
+			this.productList = res.data.splice(0,1)
+			this.$refs.activate.open()
 			},
 			onClose() {
 				this.$refs.activate.close()
 			},
 			onChoose(data) {
 				uni.navigateTo({
-					url: `/pages/goods/goods_details/index?id=${data.id}&mt=0&type=4`,
+					url: `/pages/goods/goods_details/index?id=${data.id}&mt=0`,
 				})
 			}
 		},

+ 20 - 0
mer_uniapp/pages/what_to_eat_today/what_to_eat_today.js

@@ -0,0 +1,20 @@
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+import request from "@/utils/request.js";
+
+//获取今日吃啥标签
+export function whattodayeatApi(){
+  return request.get('whattodayeat/get/tag',{},{ noAuth : true});
+}
+
+//根据标签查询附近商品
+export function whattodayeatProductApi(params){
+  return request.get('whattodayeat/get/product',params,{ noAuth : true});
+}