cmy %!s(int64=2) %!d(string=hai) anos
pai
achega
585bfd22df
Modificáronse 5 ficheiros con 202 adicións e 25 borrados
  1. 9 0
      api/water.js
  2. 12 2
      pages.json
  3. 3 23
      pages/home/index.vue
  4. 8 0
      pages/water/waterDetail.vue
  5. 170 0
      pages/water/waterList.vue

+ 9 - 0
api/water.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+// 微信分享信息
+export function waterList(data) {
+	return request({
+		url: '/api/certificate/list',
+		method: 'get',
+		data
+	});
+}

+ 12 - 2
pages.json

@@ -66,6 +66,16 @@
 		}
 	],
 	"subPackages": [{
+			"root": "pages/water",
+			"name": "water",
+			"pages": [{
+				"path": "/waterList",
+				"style": {
+					"navigationBarTitleText": "充水票"
+				}
+			}]
+		},
+		{
 			"root": "pages/order",
 			"name": "order",
 			"pages": [{
@@ -498,13 +508,13 @@
 				"text": "分类"
 			},
 			{
-				"pagePath": "pages/cart/cart",
+				"pagePath": "pages/home/cart",
 				"iconPath": "static/tabBar/tab-cart.png",
 				"selectedIconPath": "static/tabBar/tab-cart-current.png",
 				"text": "购物车"
 			},
 			{
-				"pagePath": "pages/cart/cart",
+				"pagePath": "pages/home/order",
 				"iconPath": "static/tabBar/tab-order.png",
 				"selectedIconPath": "static/tabBar/tab-order-current.png",
 				"text": "订单"

+ 3 - 23
pages/home/index.vue

@@ -47,7 +47,7 @@
 				</view>
 				<view class="item-title">联系客服</view>
 			</view>
-			<view class="cate-item flex" @click="navto('/pages/user/shareQrCode',1)">
+			<view class="cate-item flex" @click="navto('/pages/water/waterList')">
 				<view class="img-wrapper flex">
 					<image src="../../static/icon/index5.png" mode=""></image>
 				</view>
@@ -66,7 +66,7 @@
 			<view></view>
 		</view>
 		<view class="good-list">
-			<view class="good flex" v-for="item in goodList" @click="navTo('/pages/product/product?id=' + item.id)">
+			<view class="good flex" v-for="item in goodList">
 				<image :src="item.image" mode="" class="good-image"></image>
 				<view class="right">
 					<view class="good-name ">
@@ -75,7 +75,7 @@
 						</view>
 					</view>
 					<view class="good-key">
-						鸿运开来 为成功喝彩
+						<!-- 鸿运开来 为成功喝彩 -->
 					</view>
 					<view class="good-price flex">
 						<view class="price">
@@ -199,7 +199,6 @@
 		//#ifndef
 		onReachBottom() {
 			console.log('到底')
-			// this.getGoodList()
 		},
 		onLoad: function(option) {
 			// #ifdef MP
@@ -217,28 +216,9 @@
 			// #endif
 		},
 		onShow: function() {
-			// this.getGoodList()
 			this.loadData();
 		},
 		methods: {
-			getGoodList() {
-				let obj = this
-				if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
-					return
-				}
-				obj.loadingType = 'loading'
-				getProducts({
-					page: 1,
-					limit: 50,
-				}).then(res => {
-					obj.goodList = obj.goodList.concat(res.data)
-					if (obj.limit == res.data.length) {
-						obj.loadingType = 'more'
-					} else {
-						obj.loadingType = 'noMore'
-					}
-				})
-			},
 			navto(url) {
 				uni.navigateTo({
 					url,

+ 8 - 0
pages/water/waterDetail.vue

@@ -0,0 +1,8 @@
+<template>
+</template>
+
+<script>
+</script>
+
+<style>
+</style>

+ 170 - 0
pages/water/waterList.vue

@@ -0,0 +1,170 @@
+<template>
+	<view class="good-list">
+		<view class="good flex" v-for="item in navList[tabCurrentIndex].orderList" @click="navTo('/pages/product/product?id=' + item.id)">
+			<image :src="item.image" mode="" class="good-image"></image>
+			<view class="right">
+				<view class="good-name ">
+					<view class="clamp2">
+						{{item.store_name}}
+					</view>
+				</view>
+				<view class="good-key">
+					{{item.keyword}}
+				</view>
+				<view class="good-price flex">
+					<view class="price">
+						¥{{item.price}}/{{item.unit_name}}
+					</view>
+					<view class="xl" @click="navto('/pages/product/product?id='+item.id)">
+						立即购买
+					</view>
+				</view>
+			</view>
+		</view>
+		<uni-load-more :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
+	</view>
+</template>
+
+<script>
+	import {
+		waterList
+	} from '@/api/water.js';
+	export default {
+		data() {
+			return {
+				tabCurrentIndex: 0,
+				navList: [{
+					state: 0,
+					text: '全部',
+					loadingType: 'more',
+					orderList: [],
+					page: 1, //当前页数
+					limit: 10 //每次信息条数
+				}]
+			};
+		},
+		onReachBottom() {
+			this.getGoodList();
+		},
+		onLoad: function(option) {
+			this.getGoodList();
+		},
+		methods: {
+			// 加载数据
+			getGoodList(source) {
+				//这里是将订单挂载到tab列表下
+				let index = this.tabCurrentIndex;
+				let navItem = this.navList[index];
+				let state = navItem.state;
+				console.log(navItem, '数据');
+				if (source === 'tabChange' && navItem.loaded === true) {
+					//tab切换只有第一次需要加载数据
+					return;
+				}
+				if (navItem.loadingType === 'loading') {
+					//防止重复加载
+					return;
+				}
+				if (navItem.loadingType === 'noMore') {
+					//防止重复加载
+					return;
+				}
+				// 修改当前对象状态为加载中
+				navItem.loadingType = 'loading';
+
+				waterList({
+						car_number: this.id,
+						page: navItem.page,
+						limit: navItem.limit
+					})
+					.then(({
+						data
+					}) => {
+						let arr = data.data.map(e => {
+							return e;
+						});
+						navItem.orderList = navItem.orderList.concat(arr);
+						// console.log(navItem.orderList);
+						navItem.page++;
+						if (navItem.limit == arr.length) {
+							//判断是否还有数据, 有改为 more, 没有改为noMore
+							navItem.loadingType = 'more';
+							return;
+						} else {
+							//判断是否还有数据, 有改为 more, 没有改为noMore
+							navItem.loadingType = 'noMore';
+						}
+						uni.hideLoading();
+						this.$set(navItem, 'loaded', true);
+					})
+					.catch(e => {
+						console.log(e);
+					});
+			},
+		}
+	};
+</script>
+
+
+<style lang="scss">
+	.good-list {
+		padding: 20rpx 28rpx;
+		width: 750rpx;
+		.good {
+			background: #FFFFFF;
+			box-shadow: 0px 0px 20px 0px rgba(50,50,52,0.06);
+			width: 100%;
+			border-radius: 14rpx;
+			margin-bottom: 20rpx;
+			position: relative;
+			padding: 20rpx;
+			
+			.good-image {
+				width: 180rpx;
+				height: 180rpx;
+				background-color: #eee;
+				border-radius: 10rpx;
+				flex-shrink: 0;
+				
+			}
+			.right{
+				height: 180rpx;
+				position: relative;
+				
+				.good-name {
+					font-size: 28rpx;
+					font-weight: bold;
+					color: #333333;
+					padding-left: 20rpx;
+				}
+				
+				.good-key {
+					font-size: 22rpx;
+					font-weight: 500;
+					color: #999999;
+					padding-left: 20rpx
+				}
+				
+				.good-price {
+					display: flex;
+					justify-content: space-between;
+					align-items: flex-end;
+					font-size: 28rpx;
+					font-weight: bold;
+					color: #FF1A1A;
+					position: absolute;
+					bottom: 0rpx;
+					padding: 0 20rpx;
+					left: 0;
+					right:0rpx;
+					.xl {
+						background: linear-gradient(90deg, #3C82E6, #5395F5);
+						border-radius: $font-base;
+						padding: 10rpx 20rpx ;
+						color: #fff;
+					}
+				}
+			}
+		}
+	}
+</style>