Преглед изворни кода

feat:对接我的页面接口

wangsisi пре 1 месец
родитељ
комит
c0b0349fea
4 измењених фајлова са 203 додато и 124 уклоњено
  1. 14 0
      api/mine.js
  2. 68 30
      pages/tabBar/mine/subPages/exchange.vue
  3. 31 25
      pages/tabBar/mine/subPages/order.vue
  4. 90 69
      pages/tabBar/shopping/shopping.vue

+ 14 - 0
api/mine.js

@@ -0,0 +1,14 @@
+
+import http from '@/utils/http'
+import config from './config'
+
+export default {
+	//礼物兑换
+  myGift(data) {
+    return http.get('mini/z_sample_lighten_card/myGift',data)
+  },
+  // 优惠券
+  couponList(data) {
+    return http.get('mini/z_farm_buy_coupon/list',data)
+  },
+}

+ 68 - 30
pages/tabBar/mine/subPages/exchange.vue

@@ -6,32 +6,39 @@
 					v-for="(item,index) in tabs" :key="index">{{item}}</view>
 			</view>
 			<view class="list" v-show="active === 0">
-				<view class="item" v-for="(item,index) in 3" :key="index">
-					<view class="item-info">
-						<image class="img" :src="`${config.BASIC_IMG}home/fruit.png`"></image>
-						<view class="cont">
-							<up-text bold text="牛乳蜂蜜饼干一份"></up-text>
-							<up-text size="12" color="#999999" text="有限期:2025.06.05至2025.06.23"></up-text>
+				<template v-if="giftData.length">
+					<view class="item" v-for="(item,index) in giftData" :key="index">
+						<view class="item-info">
+							<image class="img" :src="item.icon"></image>
+							<view class="cont">
+								<up-text bold :text="item.remark"></up-text>
+								<up-text size="12" color="#999999"
+									:text="`有限期:${item.startDate}至${item.endDate}`"></up-text>
+							</view>
 						</view>
+						<view class="button">去兑换</view>
 					</view>
-					<view class="button">去兑换</view>
-				</view>
+				</template>
+				<up-empty v-else mode="list" marginTop="50"></up-empty>
 			</view>
 			<view class="list" v-show="active === 1">
-				<view class="item" v-for="(item,index) in 3" :key="index">
-					<view class="item-info">
-						<view class="money">
-							<view class="sum"><text class="unit">¥</text>50</view>
-							<view class="tips">满100可用</view>
-						</view>
-						<view class="cont">
-							<up-text bold text="仙桃荔全场优惠券"></up-text>
-							<up-text bold text="满100减50"></up-text>
-							<up-text size="12" color="#999999" text="有限期:2025.06.05至2025.06.23"></up-text>
+				<template v-if="couponData.length">
+					<view class="item" v-for="(item,index) in couponData" :key="index">
+						<view class="item-info">
+							<view class="money">
+								<view class="sum"><text class="unit">¥</text>50</view>
+								<view class="tips">满100可用</view>
+							</view>
+							<view class="cont">
+								<up-text bold text="仙桃荔全场优惠券"></up-text>
+								<up-text bold text="满100减50"></up-text>
+								<up-text size="12" color="#999999" text="有限期:2025.06.05至2025.06.23"></up-text>
+							</view>
 						</view>
+						<view class="button">去使用</view>
 					</view>
-					<view class="button">去使用</view>
-				</view>
+				</template>
+				<up-empty v-else mode="coupon" marginTop="50"></up-empty>
 			</view>
 		</view>
 	</view>
@@ -41,17 +48,46 @@
 	import config from "@/api/config.js"
 	import {
 		ref
-	} from 'vue';
-	import { onLoad } from '@dcloudio/uni-app'
-	
-	onLoad(({type})=>{
-		active.value = Number(type)
+	} from 'vue';
+	import {
+		onLoad
+	} from '@dcloudio/uni-app'
+	import MINE from '@/api/mine.js'
+
+	onLoad(({
+		type
+	}) => {
+		active.value = Number(type)
+		handleTab(active.value)
 	})
 
+	const giftData = ref([])
+	const getMyGift = () => {
+		MINE.myGift({
+			farmId: 766
+		}).then((res => {
+			giftData.value = res.data.useList.filter(item => item.use === 0)
+		}))
+	}
+
+	const couponData = ref([])
+	const getCouponList = () => {
+		MINE.couponList({
+			farmId: 766
+		}).then((res => {
+			couponData.value = res.data || []
+		}))
+	}
+
 	const active = ref(0)
 	const tabs = ["守护兑换", "优惠券"]
 	const handleTab = (index) => {
 		active.value = index
+		if (index) {
+			getCouponList()
+		} else {
+			getMyGift()
+		}
 	}
 </script>
 
@@ -151,10 +187,12 @@
 				}
 			}
 		}
-		/* #ifdef H5 */
-		.exchange-card{
-			height: calc(100vh - 14vh - 88rpx);
-		}
-		/* #endif */
+
+		/* #ifdef H5 */
+		.exchange-card {
+			height: calc(100vh - 14vh - 88rpx);
+		}
+
+		/* #endif */
 	}
 </style>

+ 31 - 25
pages/tabBar/mine/subPages/order.vue

@@ -1,25 +1,29 @@
 <template>
-	<view class="sub-base-container">
-		<view class="search-box">
-			<v-search @searchCallback="searchCallback" @clearCallback="clearCallback"></v-search>
+	<view class="sub-base-container">
+		<view class="search-box">
+			<v-search @searchCallback="searchCallback" @clearCallback="clearCallback"></v-search>
 		</view>
 		<view class="tabs">
 			<view :class="['tab-item',{active:active === index}]" v-for="(item,index) in tabsList" :key="index"
 				@click="handleTab(index)">{{item}}</view>
-		</view>
-		<shop-list :active="active"></shop-list>
+		</view>
+		<shop-list :active="active"></shop-list>
 	</view>
 </template>
 
 <script setup>
 	import {
 		ref
-	} from "vue"
-	import shopList from "../components/shopList.vue"
-	import { onLoad } from '@dcloudio/uni-app'
-	
-	onLoad(({status})=>{
-		active.value = Number(status)
+	} from "vue"
+	import shopList from "../components/shopList.vue"
+	import {
+		onLoad
+	} from '@dcloudio/uni-app'
+
+	onLoad(({
+		status
+	}) => {
+		active.value = Number(status)
 	})
 
 	const searchCallback = (e) => {
@@ -33,28 +37,30 @@
 	const tabsList = ["全部", "待付款", "待发货", "待收货", "待评价", "退款/售后"]
 	const handleTab = (index) => {
 		active.value = index
-	}
-	
-	// const shopList = [
-	// 	{
-	// 		status:0,
-	// 	}
+	}
+
+	// const shopList = [
+	// 	{
+	// 		status:0,
+	// 	}
 	// ]
 </script>
 
 <style lang="scss" scoped>
-	.sub-base-container {
-		padding: 0;
-		.search-box{
-			padding: 16rpx 24rpx 20rpx;
-			background: #fff;
+	.sub-base-container {
+		padding: 0;
+
+		.search-box {
+			padding: 16rpx 24rpx 20rpx;
+			background: #fff;
 		}
+
 		.tabs {
-			width: 100%;
-			padding: 0 24rpx 16rpx;
+			width: 100%;
+			padding: 0 24rpx 16rpx;
 			box-sizing: border-box;
 			display: flex;
-			overflow-x: auto;
+			overflow-x: auto;
 			background: #fff;
 
 			.tab-item {

+ 90 - 69
pages/tabBar/shopping/shopping.vue

@@ -1,37 +1,38 @@
 <template>
 	<view class="base-container">
 		<view class="search-wrap">
-			<up-search placeholder="日照香炉生紫烟" v-model="keyword"></up-search>
+			<v-search class="search" @searchCallback="searchCallback" @clearCallback="clearCallback"></v-search>
 			<text class="manage">管理</text>
 		</view>
 		<view class="shop-list">
-
 			<view class="shop-item" v-for="(item,index) in 3" :key="index">
 				<up-checkbox-group>
-					<up-checkbox v-model="shopChecked" shape="circle" label="从化荔博园店铺" labelColor="#000" labelSize="14"></up-checkbox>
+					<up-checkbox v-model="shopChecked" shape="circle" label="从化荔博园店铺" labelColor="#000"
+						labelSize="14"></up-checkbox>
 					<up-icon class="icon" name="arrow-right" color="rgba(137, 137, 137, 0.69)" size="12"></up-icon>
 				</up-checkbox-group>
 				<up-swipe-action>
 					<up-swipe-action-item v-for="(ele,idx) in 3" :key="idx" :options="options1">
-						<view class="commodity-item">
+						<view class="commodity-item">
 							<up-checkbox-group>
 								<up-checkbox v-model="commodityChecked" shape="circle"></up-checkbox>
 							</up-checkbox-group>
-							<view class="commodity-info">
-								<image class="commodity-img" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
-								<view class="commodity-cont">
-									<view class="name">
-										<text>海南妃子笑荔枝新鲜采摘</text>
-										<text>x1</text>
-									</view>
-									<up-text size="12" color="#717070" text="3斤装规格"></up-text>
-									<up-text size="12" color="#AFAFAF" text="坏单包退 包邮"></up-text>
-									<view class="total">
-										<text class="unit">¥</text>
-										<text class="sum">108</text>
-									</view>
-								</view>
-							</view>
+							<view class="commodity-info">
+								<image class="commodity-img"
+									src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+								<view class="commodity-cont">
+									<view class="name">
+										<text>海南妃子笑荔枝新鲜采摘</text>
+										<text>x1</text>
+									</view>
+									<up-text size="12" color="#717070" text="3斤装规格"></up-text>
+									<up-text size="12" color="#AFAFAF" text="坏单包退 包邮"></up-text>
+									<view class="total">
+										<text class="unit">¥</text>
+										<text class="sum">108</text>
+									</view>
+								</view>
+							</view>
 						</view>
 					</up-swipe-action-item>
 				</up-swipe-action>
@@ -55,16 +56,22 @@
 	import {
 		ref,
 		reactive
-	} from "vue"
+	} from "vue"
+	
+	const searchCallback = (e) => {
+		console.log('搜索', e)
+	}
+	const clearCallback = () => {
+		console.log('clear')
+	}
 
 	const options1 = reactive([{
-		text: '删除',
-		style: {  
-		      backgroundColor: '#f56c6c'  
-		    }  
+		text: '删除',
+		style: {
+			backgroundColor: '#f56c6c'
+		}
 	}]);
 
-	const keyword = ref("")
 	const shopChecked = ref(false)
 	const commodityChecked = ref(false)
 
@@ -73,7 +80,7 @@
 
 <style lang="scss" scoped>
 	.base-container {
-		padding: 0;
+		padding: 0;
 
 		.search-wrap {
 			background: #fff;
@@ -81,63 +88,77 @@
 			align-items: center;
 			padding: 16rpx 24rpx;
 			box-sizing: border-box;
-			.manage{
-				margin-left: 20rpx;
+			.search{
+				width: calc(100% - 64rpx - 30rpx);
+			}
+
+			.manage {
+				margin-left: 20rpx;
 			}
 		}
-		.shop-list {
-			height: calc(100vh - 100rpx - 120rpx);
-			overflow-y: auto;
+
+		.shop-list {
+			height: calc(100vh - 100rpx - 120rpx);
+			overflow-y: auto;
 			overflow: auto;
+
 			.shop-item {
 				background: #fff;
 				margin-top: 20rpx;
 				padding: 20rpx 24rpx;
 
-				.commodity-item {
-					width: 100%;
-					padding: 20rpx 0 20rpx 10rpx;
+				.commodity-item {
+					width: 100%;
+					padding: 20rpx 0 20rpx 10rpx;
 					box-sizing: border-box;
 					display: flex;
-					align-items: center;
-					.commodity-info{
-						width: 100%;
-						display: flex;
-						align-items: center;
-						.commodity-img{
-							width: 182rpx;
-							height: 182rpx;
-							margin-right: 10rpx;
-							border-radius: 10rpx;
-						}
-						.commodity-cont{
-							width: calc(100% - 182rpx - 10rpx);
-							.name{
-								display: flex;
-								align-items: center;
-								justify-content: space-between;
-								font-size: 28rpx;
-								font-weight: 500;
-							}
-							.total{
-								color: #FF7700;
-								font-size: 24rpx;
-								margin-top: 14rpx;
-								.sum{
-									font-weight: 500;
-									font-size: 38rpx;
-									margin-left: 2rpx;
-								}
-							}
-						}
+					align-items: center;
+
+					.commodity-info {
+						width: 100%;
+						display: flex;
+						align-items: center;
+
+						.commodity-img {
+							width: 182rpx;
+							height: 182rpx;
+							margin-right: 10rpx;
+							border-radius: 10rpx;
+						}
+
+						.commodity-cont {
+							width: calc(100% - 182rpx - 10rpx);
+
+							.name {
+								display: flex;
+								align-items: center;
+								justify-content: space-between;
+								font-size: 28rpx;
+								font-weight: 500;
+							}
+
+							.total {
+								color: #FF7700;
+								font-size: 24rpx;
+								margin-top: 14rpx;
+
+								.sum {
+									font-weight: 500;
+									font-size: 38rpx;
+									margin-left: 2rpx;
+								}
+							}
+						}
 					}
 				}
 			}
 		}
-		/* #ifdef H5 */
-		.shop-list{
-			height: calc(100vh - 100rpx - 120rpx - 188rpx);
-		}
+
+		/* #ifdef H5 */
+		.shop-list {
+			height: calc(100vh - 100rpx - 120rpx - 188rpx);
+		}
+
 		/* #endif */
 		.footer {
 			position: absolute;