瀏覽代碼

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/point-app

guhongwei 2 年之前
父節點
當前提交
20f800fd14
共有 4 個文件被更改,包括 161 次插入16 次删除
  1. 33 9
      components/discount/index.vue
  2. 117 5
      pagesHome/exchange/index.vue
  3. 1 0
      pagesHome/order/order.vue
  4. 10 2
      pagesMy/discount/index.vue

+ 33 - 9
components/discount/index.vue

@@ -1,20 +1,33 @@
 <template>
 	<view class="main">
-		<view class="pre_one">优惠劵({{couponList.length}})</view>
+		<view class="pre_one">优惠劵({{couponList.length}})</view>
 		<view class="pre_two" v-for="(item,index) in couponList" :key="index">
 			<view class="left">
-				<view class="money">¥{{item.money||'0'}}</view>
-				<view class="man">满{{item.discount_money||'0'}}可以</view>
+				<view v-if="item.discount_config.limit=='nolimit'" class="money">不限</view>
+				<view v-else class="money">¥{{item.discount_config.limit||'0'}}</view>
+				<view class="man">满{{item.discount_config.min||'0'}}可用</view>
 			</view>
 			<view class="right">
 				<view class="other">
-					<view class="type"><text>{{item.type||'暂无'}}</text> {{item.coupon.name||'暂无'}}</view>
-					<view class="date">有效期{{item.start_time||'暂无'}}-{{item.end_time||'暂无'}}</view>
+					<view class="type"><text>{{item.discount_type_label||'暂无'}}</text>
+						{{item.name||'暂无'}}
+					</view>
+					<view v-if="item.expire_type=='days'" class="date">{{item.expire_time||'暂无'}}天内有效</view>
+					<view v-if="item.expire_type=='fixed'" class="date">{{item.expire_time||'暂无'}}</view>
+					<view v-if="item.get_limit=='max'" class="date">
+						{{item.use_limit_label||'暂无'}}-{{item.expire_type_label}}-{{item.get_limit_label||'暂无'}}领取{{item.get_limit_config.max}}张
+					</view>
+					<view v-if="item.get_limit=='nolimit'" class="date">
+						{{item.use_limit_label||'暂无'}}-{{item.expire_type_label}}-{{item.get_limit_label||'暂无'}}
+					</view>
 				</view>
 				<view class="btn">
 					<button v-if="Style&&Style.btn||false" type="default" size="mini"
 						@click="toDiscount(item)">确认</button>
-					<button v-else type="default" size="mini">{{item.status=='0'?'未使用':item.status=='1'?'已使用':'已过期'}}</button>
+					<button v-if="Style&&Style.status||false" type="default"
+						size="mini">{{item.status=='0'?'未使用':item.status=='1'?'已使用':'已过期'}}</button>
+					<button v-if="Style&&Style.receive||false" type="default" size="mini"
+						@click="toReceive(item)">领取</button>
 				</view>
 			</view>
 		</view>
@@ -42,6 +55,11 @@
 				const that = this;
 				that.$emit('toDiscount', e)
 			},
+			// 领取优惠劵
+			toReceive(e) {
+				const that = this;
+				that.$emit('toReceive', e)
+			},
 		}
 	}
 </script>
@@ -64,9 +82,10 @@
 			.left {
 				text-align: center;
 				border-radius: 3vw;
-				padding: 5vw 3vw;
+				padding: 6vw 3vw;
 				background-color: #FFFACD;
 				color: #8B4513;
+				border-right: 0.5vw dashed var(--fcColor);
 
 				.money {
 					font-size: var(--font18Szie);
@@ -84,13 +103,13 @@
 				align-items: center;
 				flex-grow: 1;
 				border-radius: 3vw;
-				padding: 5vw 3vw;
+				padding: 1.5vw 3vw;
 				background-color: var(--mainColor);
 
 				.other {
 					display: flex;
 					flex-direction: column;
-					width: 50vw;
+					width: 46vw;
 
 					.type {
 						overflow: hidden;
@@ -113,6 +132,11 @@
 					}
 
 					.date {
+						overflow: hidden;
+						text-overflow: ellipsis;
+						display: -webkit-box;
+						-webkit-line-clamp: 2;
+						-webkit-box-orient: vertical;
 						font-size: var(--font12Size);
 						color: var(--f99Color);
 					}

+ 117 - 5
pagesHome/exchange/index.vue

@@ -1,23 +1,135 @@
 <template>
 	<mobile-frame>
-		兑换中心
+		<view class="main">
+			<view class="one">
+				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
+					<view class="list-scroll-view">
+						<discount :Style="Style" :couponList="list" @toReceive="toReceive"></discount>
+					</view>
+				</scroll-view>
+			</view>
+		</view>
 	</mobile-frame>
 </template>
 
 <script>
+	import discount from '@/components/discount/index.vue';
 	export default {
+		components: {
+			discount
+		},
 		data() {
 			return {
-
+				Style: {
+					receive: true
+				},
+				user: {},
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 5,
+				page: 0
 			};
 		},
-		onShow: function() {},
+		onLoad: function(e) {
+			const that = this;
+			// 监听用户是否登录
+			that.watchLogin();
+		},
 		methods: {
-
+			// 领取优惠劵
+			async toReceive(e) {
+				const that = this;
+				const arr = await that.$api(`/userCoupon/getCoupon/${e._id}`, 'POST');
+				if (arr.errcode == '0') {
+					uni.showToast({
+						title: `领取成功`,
+						icon: 'none',
+						duration: 3000
+					})
+					uni.navigateBack({
+						detail: 1
+					})
+				} else {
+					uni.showToast({
+						title: arr.errmsg,
+						icon: 'none',
+						duration: 2000
+					});
+				}
+			},
+			// 监听用户是否登录
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: function(res) {
+						let user = that.$jwt(res.data);
+						if (user) that.$set(that, `user`, user);
+						that.search();
+					},
+					fail: function(err) {
+						uni.navigateTo({
+							url: `/pages/login/index`
+						})
+					}
+				});
+			},
+			// 查询列表
+			async search() {
+				const that = this;
+				let user = that.user;
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+				}
+				const res = await that.$api(`/coupon/userView`, 'GET', {
+					...info
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					that.$set(that, `list`, list)
+					that.$set(that, `total`, res.total)
+				} else {
+					uni.showToast({
+						title: res.errmsg,
+					});
+				}
+			},
+			// 分页
+			toPage(e) {
+				const that = this;
+				let list = that.list;
+				let limit = that.limit;
+				if (that.total > list.length) {
+					uni.showLoading({
+						title: '加载中',
+						mask: true
+					})
+					let page = that.page + 1;
+					that.$set(that, `page`, page)
+					let skip = page * limit;
+					that.$set(that, `skip`, skip)
+					that.search();
+					uni.hideLoading();
+				} else uni.showToast({
+					title: '没有更多数据了'
+				});
+			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `list`, [])
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 5)
+				that.$set(that, `page`, 0)
+			}
 		}
 	}
 </script>
 
 <style lang="scss">
-
+	.main {
+		background-color: var(--f5Color);
+	}
 </style>

+ 1 - 0
pagesHome/order/order.vue

@@ -514,6 +514,7 @@
 		flex-direction: column;
 		max-height: 100vw;
 		min-height: 100vw;
+		overflow-y: auto;
 		background-color: var(--f5Color);
 
 		.one {

+ 10 - 2
pagesMy/discount/index.vue

@@ -20,6 +20,9 @@
 		},
 		data() {
 			return {
+				Style: {
+					status: true
+				},
 				user: {},
 				list: [],
 				total: 0,
@@ -55,9 +58,14 @@
 			async search() {
 				const that = this;
 				let user = that.user;
-				const res = await that.$api(`/userCoupon`, 'GET', {
+				let info = {
+					// skip: that.skip,
+					// limit: that.limit,
 					customer: user._id
-				});
+				}
+				const res = await that.$api(`/userCoupon`, 'GET', {
+					...info
+				})
 				if (res.errcode == '0') {
 					let list = [...that.list, ...res.data];
 					that.$set(that, `list`, list)