Browse Source

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

guhongwei 2 years ago
parent
commit
39539a5d9d
4 changed files with 162 additions and 55 deletions
  1. 52 39
      components/discount/index.vue
  2. 17 4
      pagesHome/order/order.vue
  3. 89 5
      pagesMy/discount/index.vue
  4. 4 7
      pagesMy/order/index.vue

+ 52 - 39
components/discount/index.vue

@@ -6,12 +6,16 @@
 				<view class="money">¥{{item.money||'0'}}</view>
 				<view class="man">满{{item.discount_money||'0'}}可以</view>
 			</view>
-			<view class="center">
-				<view class="type"><text>{{item.type||'暂无'}}</text> {{item.name||'暂无'}}</view>
-				<view class="date">有效期{{item.start_time||'暂无'}}-{{item.end_time||'暂无'}}</view>
-			</view>
 			<view class="right">
-				<button type="default" size="mini" @click="toDiscount(item)">确认</button>
+				<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>
+				<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>
+				</view>
 			</view>
 		</view>
 	</view>
@@ -23,6 +27,9 @@
 			couponList: {
 				type: Array,
 			},
+			Style: {
+				type: Object,
+			},
 		},
 		data() {
 			return {
@@ -33,9 +40,7 @@
 			// 选择优惠劵
 			toDiscount(e) {
 				const that = this;
-				that.$emit('toDiscount', {
-					e
-				})
+				that.$emit('toDiscount', e)
 			},
 		}
 	}
@@ -52,8 +57,8 @@
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
-			width: 94vw;
-			margin: 0 2vw 1vw 2vw;
+			width: 96vw;
+			margin: 0 2vw 2vw 2vw;
 			border-radius: 3vw;
 
 			.left {
@@ -73,45 +78,53 @@
 				}
 			}
 
-			.center {
+			.right {
+				display: flex;
+				justify-content: space-between;
+				align-items: center;
 				flex-grow: 1;
 				border-radius: 3vw;
-				border-top-right-radius: 0;
-				border-bottom-right-radius: 0;
-				padding: 5vw 2vw;
+				padding: 5vw 3vw;
 				background-color: var(--mainColor);
 
-				.type {
-					margin: 0 0 1vw 0;
+				.other {
+					display: flex;
+					flex-direction: column;
+					width: 50vw;
 
-					text {
-						border: 0.5vw solid red;
-						color: red;
-						padding: 0 1vw;
-						border-radius: 1vw;
-						font-size: var(--font12Size);
-						margin: 0 1vw 0 0;
-					}
+					.type {
+						overflow: hidden;
+						text-overflow: ellipsis;
+						display: -webkit-box;
+						line-height: 6vw;
+						-webkit-line-clamp: 1;
+						-webkit-box-orient: vertical;
+						font-size: var(--font14Size);
+						margin: 0 1vw 1vw 0;
 
-					font-size: var(--font16Size);
-				}
+						text {
+							margin: 0 1vw 0 0;
+							border: 0.5vw solid red;
+							color: red;
+							padding: 0 1vw;
+							border-radius: 1vw;
+							font-size: var(--font12Size);
+						}
+					}
 
-				.date {
-					font-size: var(--font12Size);
-					color: var(--f99Color);
+					.date {
+						font-size: var(--font12Size);
+						color: var(--f99Color);
+					}
 				}
-			}
 
-			.right {
-				padding: 7vw 3vw;
-				border-radius: 3vw;
-				border-top-left-radius: 0;
-				border-bottom-left-radius: 0;
-				background-color: var(--mainColor);
+				.btn {
+					width: 20vw;
 
-				button {
-					background-color: #FFD700;
-					font-weight: bold;
+					button {
+						background-color: #FFD700;
+						font-weight: bold;
+					}
 				}
 			}
 		}

+ 17 - 4
pagesHome/order/order.vue

@@ -61,7 +61,9 @@
 									</view>
 									<view class="other">
 										<view class="other_1">优惠劵</view>
-										<view class="other_2" @click="toCoupon" v-if="couponList.length">请选择优惠劵</view>
+										<view class="other_2" @click="toCoupon" v-if="couponList.length">
+											{{coupon_name||'请选择优惠劵'}}
+										</view>
 										<view class="other_2" v-else>暂无优惠劵使用</view>
 									</view>
 									<view class="other">
@@ -115,7 +117,7 @@
 				</view>
 			</view>
 			<view class="content" v-else>
-				<discount :couponList="couponList" @toDiscount="toDiscount"></discount>
+				<discount :Style="Style" :couponList="couponList" @toDiscount="toDiscount"></discount>
 			</view>
 		</uni-popup>
 	</mobile-frame>
@@ -129,6 +131,9 @@
 		},
 		data() {
 			return {
+				Style: {
+					btn: true
+				},
 				user: {},
 				key: '',
 				address: {},
@@ -141,6 +146,9 @@
 				addressList: [],
 				// 优惠劵
 				couponList: [],
+				coupon: [],
+				// 优惠劵名称
+				coupon_name: '',
 				type: '',
 			};
 		},
@@ -152,7 +160,10 @@
 		methods: {
 			// 使用优惠劵
 			toDiscount(e) {
-				console.log(e);
+				const that = this;
+				that.$set(that, 'coupon_name', e.coupon.name)
+				that.coupon.push(e._id)
+				that.$refs.popup.close();
 			},
 			// 选择收货地址
 			toChoose() {
@@ -171,6 +182,7 @@
 			toCoupon() {
 				const that = this;
 				that.$set(that, 'type', '1')
+				that.$set(that, 'coupon', [])
 				that.$refs.popup.open();
 			},
 			// 是否选中
@@ -221,7 +233,8 @@
 					let data = {
 						address: that.address,
 						goods: that.orderList,
-						total_detail: that.total_detail
+						total_detail: that.total_detail,
+						coupon: that.coupon
 					}
 					const arr = await that.$api(`/order`, 'POST', data)
 					console.log(arr)

+ 89 - 5
pagesMy/discount/index.vue

@@ -1,23 +1,107 @@
 <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"></discount>
+					</view>
+				</scroll-view>
+			</view>
+		</view>
 	</mobile-frame>
 </template>
 
 <script>
+	import discount from '@/components/discount/index.vue';
 	export default {
+		components: {
+			discount
+		},
 		data() {
 			return {
-
+				user: {},
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 5,
+				page: 0
 			};
 		},
-		onShow: function() {},
+		onLoad: function(e) {
+			const that = this;
+			// 监听用户是否登录
+			that.watchLogin();
+		},
 		methods: {
-
+			// 监听用户是否登录
+			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;
+				const res = await that.$api(`/userCoupon`, 'GET', {
+					customer: user._id
+				});
+				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>

+ 4 - 7
pagesMy/order/index.vue

@@ -50,7 +50,7 @@
 										<button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
 										<button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
 										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
-										<button class="toRefund" v-if="item.status=='3'" type="default" size="mini" @click="toRefund(item)">申请退款</button>
+										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
 									</view>
 								</view>
 								<view class="list_2 list_3" v-for="(item,index) in list" :key="index" v-else>
@@ -93,7 +93,7 @@
 										<button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
 										<button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
 										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
-										<button class="toRefund" v-if="item.status=='3'" type="default" size="mini" @click="toRefund(item)">申请退款</button>
+										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
 									</view>
 								</view>
 							</view>
@@ -315,16 +315,12 @@
 					fail: function(err) {}
 				})
 			},
-			// 申请售后
+			// 申请售后 申请退款
 			toAfter(e) {
 				uni.navigateTo({
 					url: `/pagesMy/order/service?id=${e._id}`
 				})
 			},
-			// 申请退款
-			toRefund(e) {
-				console.log(e);
-			},
 			// 选择选项卡
 			tabsChange(e) {
 				const that = this;
@@ -379,6 +375,7 @@
 					padding: 2vw;
 
 					.status {
+						color: var(--ff0Color);
 						text-align: right;
 						margin: 0 0 1vw 0;
 					}