lhl 3 years ago
parent
commit
070c46bb1a
4 changed files with 70 additions and 46 deletions
  1. 1 6
      pages.json
  2. 1 1
      pages/index/index.vue
  3. 67 38
      pages/prefecture/voucher.vue
  4. 1 1
      store/index.js

+ 1 - 6
pages.json

@@ -727,12 +727,7 @@
 		{
 			"path": "pages/prefecture/voucher",
 			"style": {
-				"navigationBarTitleText": "消费券兑换",
-				"app-plus": {
-					"titleNView": {
-						"type": "transparent"
-					}
-				}
+				"navigationBarTitleText": "消费券兑换"
 			}
 		}
 	],

+ 1 - 1
pages/index/index.vue

@@ -55,7 +55,7 @@
 					<text>每日签到</text>
 				</view>
 			</navigator> -->
-			<navigator url="/pages/prefecture/consumer">
+			<navigator url="/pages/prefecture/voucher">
 				<view class="cate-item">
 					<image src="/static/icon/c8.png"></image>
 					<text>消费券商城</text>

+ 67 - 38
pages/prefecture/voucher.vue

@@ -1,38 +1,49 @@
 <template>
-	<view class="container">
-		<view class="jg"></view>
-		<view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
-			<image :src="good.image" mode="" class="good-img"></image>
-			<view class="good-info flex">
-				<view class="tit clamp2">
-					{{good.store_name  }}
-				</view>
-				<view class="price-wrap">
-					<view class="old-price">
-						<text class="old">¥{{good.ot_price}}</text>
-						<template v-if="good.ot_price - good.price > 0">
-							<image src="../../static/icon/down.png" mode=""></image>
-							<text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text>
-						</template>
-					</view>
-					<view class="integral-wrap">
-						<image src="../../static/icon/jf.png" mode=""></image>
-						<text class="price">{{good.price}}</text>
-					</view>
-				</view>
-				<view class="btn" @click="nav(good.id)">
-					立即购买
-				</view>
-			</view>
-		</view>
-		<view class="jg"></view>
+	<view class="container">
+		<empty v-if="loaded === true && list.length === 0"></empty>
+		<template>
+			<view class="jg"></view>
+			<view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
+				<image :src="good.image" mode="" class="good-img"></image>
+				<view class="good-info flex">
+					<view class="tit clamp2">
+						{{good.store_name  }}
+					</view>
+					<view class="price-wrap">
+						<view class="old-price">
+							<text class="old">¥{{good.ot_price}}</text>
+							<template v-if="good.ot_price - good.price > 0">
+								<!-- <image src="../../static/icon/down.png" mode=""></image> -->
+								<!-- <text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text> -->
+							</template>
+						</view>
+						<view class="integral-wrap">
+							<image src="../../static/icon/jf.png" mode=""></image>
+							<text class="price">{{good.price}}</text>
+						</view>
+					</view>
+					<view class="btn" @click="nav(good.id)">
+						立即购买
+					</view>
+				</view>
+			</view>
+			<view class="jg"></view>
+			<uni-load-more :status="loadingType"></uni-load-more>
+		</template>
 	</view>
-	
 </template>
 
 <script>
-import { groomList } from '@/api/product.js';
-export default {
+import { groomList, getProducts } from '@/api/product.js';
+
+import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
+import empty from '@/components/empty';
+
+export default {
+	components: {
+		uniLoadMore,
+		empty
+	},
 	filters: {
 		toFixed: function(value) {
 			// 判断是否为整数
@@ -46,7 +57,10 @@ export default {
 	data() {
 		return {
 			list: [],
-			bannerImg: []
+			page: 1,
+			limit: 10,
+			loadingType: 'more',
+			loaded: false,
 		};
 	},
 	onLoad(option) {
@@ -73,17 +87,32 @@ export default {
 			});
 		},
 		// 请求载入数据
-		async loadData() {
-			groomList({}, 5)
-				.then(({ data }) => {
-					// 保存轮播图
-					this.bannerImg = data.banner;
+		loadData() {
+			let obj = this
+			if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
+				return
+			}
+			obj.loadingType = 'loading'
+			getProducts({
+				page:obj.page,
+				limit: obj.limit,
+				is_consumer: 1,
+			})
+				.then(({ data }) => {
+					console.log(data)
 					// 保存商品信息
-					this.list = data.list.map(e => {
+					obj.list = data.map(e => {
 						e.price = Number(e.price);
 						e.ot_price = Number(e.ot_price);
 						return e;
-					});
+					});
+					obj.page++
+					if(obj.limit == data.length) {
+						obj.loadingType = 'more'
+					}else {
+						obj.loadingType = 'noMore'
+					}
+					obj.loaded = true
 				})
 				.catch(e => {
 					console.log(e);

+ 1 - 1
store/index.js

@@ -5,7 +5,7 @@ Vue.use(Vuex)
 
 const store = new Vuex.Store({
 	state: {
-		baseURL:"https://yrh.liuniu946.com",//'http://eb.shuibo.net',//请求地址配置 
+		baseURL:"http://myc.frp.liuniu946.com",//'http://eb.shuibo.net',//请求地址配置 
 		// baseURL:"http://cys.liuniu946.com",//'http://eb.shuibo.net',//请求地址配置
 		loginInterceptor:true,//是否打开强制登录
 		urlFile:'/index',//项目部署所在文件夹