Quellcode durchsuchen

完善兑换大厅、盲豆明细

hwb0 vor 3 Jahren
Ursprung
Commit
caf49eeb00

+ 1 - 1
components/pay-popup/pay-popup.vue

@@ -71,7 +71,7 @@
 			},
 
 			toCoupon() {
-				return
+				// return
 				uni.navigateTo({
 					url: '/pages/coupon/index'
 				})

+ 94 - 28
pages/bean/index.vue

@@ -2,40 +2,96 @@
 	<view>
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"></u-navbar>
 		<view class="bean">
-			<view class="bean-balance">500</view>
+			<view class="flex bean-balance">
+				<image src="../../static/icon/bean.png" mode="aspectFill"></image>
+				<view class="bean-balance-num">{{ initData.coinNum }}</view>
+			</view>
 			<view class="bean-list">
-				<view class="flex bean-list-item">
-					<view class="flex left">
-						<view class="title">商品兑换</view>
-						<view class="date">2021-11-29 14:10:22</view>
-					</view>
-					<view class="flex right">
-						<view class="amt">-200</view>
-						<view class="balance">余额:234</view>
-					</view>
-				</view>
-				<view class="flex bean-list-item">
+				<view class="flex bean-list-item" v-for="(item, index) in list" :key="index">
 					<view class="flex left">
-						<view class="title">商品兑换</view>
-						<view class="date">2021-11-29 14:10:22</view>
+						<view class="title">{{ item.logText }}</view>
+						<view class="date">{{ $parseTime(item.createdTime) }}</view>
 					</view>
 					<view class="flex right">
-						<view class="amt">-200</view>
-						<view class="balance">余额:234</view>
+						<view class="amt">{{ item.logMoney }}</view>
+						<view class="balance">余额:{{ item.money }}</view>
 					</view>
 				</view>
 			</view>
+			<view class="flex empty" v-if="!list.length">
+				<u-empty text="数据为空" mode="order" />
+			</view>
 		</view>
 	</view>
 </template>
 
 <script>
+	import $http from '@/utils/request.js'
 	export default {
 		data() {
 			return {
-
+				initData: {},
+				pageNum: 1,
+				total: 0,
+				list: [],
 			};
-		}
+		},
+		onShow() {
+			this.getBean()
+			this.pageList()
+		},
+		methods: {
+			getBean() {
+				uni.showLoading({
+					title: '加载中'
+				});
+				$http.post('/api/v1/mp/user/mine/init', {}).then(res => {
+					uni.hideLoading();
+					if (res.code == 0) {
+						this.initData = res.data
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+
+			getList() {
+				uni.showLoading({
+					title: '加载中'
+				});
+				$http.post(`/api/v1/mp/user/mine/coin/log/list?pageNum=${this.pageNum}&pageSize=50`, {}).then(res => {
+					uni.hideLoading();
+					if (res.code == 0) {
+						res.rows.forEach(item => {
+							item.type = item.type ? JSON.parse(item.type) : ''
+						})
+						this.total = res.total
+						this.list = this.list.concat(res.rows)
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+
+			pageList() {
+				this.pageNum = 1
+				this.total = 0
+				this.list = []
+				this.getList()
+			}
+		},
+		
+		onReachBottom() {
+			// 判断是否有数据
+			if (this.total > this.pageNum * 50) {
+				setTimeout(() => {
+					++this.pageNum
+					this.getList()
+				}, 500)
+			} else {
+				uni.$u.toast('没有更多数据了')
+			}
+		},
 	}
 </script>
 
@@ -44,6 +100,7 @@
 		margin: 20rpx 10rpx;
 
 		&-balance {
+			justify-content: flex-start;
 			height: 230rpx;
 			line-height: 230rpx;
 			border-radius: 10rpx;
@@ -52,6 +109,12 @@
 			padding-left: 180rpx;
 			font-weight: bold;
 			margin-bottom: 20rpx;
+
+			image {
+				width: 50rpx;
+				height: 50rpx;
+				margin-right: 16rpx;
+			}
 		}
 
 		&-list {
@@ -62,30 +125,30 @@
 				justify-content: space-between;
 				padding: 24rpx 0;
 				border-bottom: 1px solid rgba(236, 236, 236, 100);
-				
-				.left{
+
+				.left {
 					flex-direction: column;
 					justify-content: space-between;
 					align-items: flex-start;
 				}
-				
-				.right{
+
+				.right {
 					flex-direction: column;
 					justify-content: space-between;
 					align-items: flex-end;
 				}
-				
-				.title{
+
+				.title {
 					font-size: 32rpx;
 					font-weight: bold;
 					margin-bottom: 32rpx;
 				}
-				
-				.amt{
+
+				.amt {
 					margin-bottom: 32rpx;
 				}
-				
-				.balance{
+
+				.balance {
 					color: #606060;
 				}
 			}
@@ -95,4 +158,7 @@
 			}
 		}
 	}
+	.empty{
+		height: 60vh;
+	}
 </style>

+ 11 - 5
pages/core/index.vue

@@ -14,7 +14,7 @@
 					</view>
 					<view class="title">{{ item.title }}</view>
 					<view class="bean">
-						<image src="../../static/logo.png" mode=""></image>
+						<image src="../../static/icon/bean.png" mode="aspectFill"></image>
 						<view>x{{ item.exchangePrice }}</view>
 					</view>
 				</navigator>
@@ -43,11 +43,9 @@
 				list: [],
 			};
 		},
-		onLoad(opthios) {
-			this.getList()
-		},
+		
 		onShow() {
-
+			this.pageList()
 		},
 		methods: {
 			getList() {
@@ -56,6 +54,7 @@
 				});
 				let data = {
 					categoryId: '',
+					noToken: true
 				}
 				$http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
 					res => {
@@ -72,6 +71,13 @@
 					uni.hideLoading();
 				})
 			},
+			
+			pageList(){
+				this.pageNum = 1
+				this.total = 0
+				this.list = []
+				this.getList()
+			}
 		},
 		
 		onReachBottom() {

+ 14 - 21
pages/coupon/index.vue

@@ -1,9 +1,9 @@
 <template>
 	<view>
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券"></u-navbar>
-		<view class="coupon-title">可用代金券:1</view>
+		<view class="coupon-title">可用代金券:0</view>
 		<view class="coupon-list">
-			<view class="flex coupon-list-item">
+			<!-- <view class="flex coupon-list-item">
 				<view class="flex coupon-list-item-info">
 					<image src="../../static/logo.png" mode=""></image>
 					<view class="flex content">
@@ -20,25 +20,11 @@
 						<view class="action" v-if="actionIndex == 0"></view>
 					</view>
 				</view>
-			</view>
-			<view class="flex coupon-list-item">
-				<view class="flex coupon-list-item-info">
-					<image src="../../static/logo.png" mode=""></image>
-					<view class="flex content">
-						<view class="txt">xx盲票代金券</view>
-						<view class="txt">使用期限:2022.03.02-2022.04.01</view>
-						<view class="txt">适用范围:指定盲票</view>
-					</view>
-					<view class="money">
-						<view class="">¥<text>10</text></view>
-					</view>
-				</view>
-				<view class="checked">
-					<view class="flex circle">
-						<view class="action" v-if="actionIndex == 1"></view>
-					</view>
-				</view>
-			</view>
+			</view> -->
+		</view>
+		
+		<view class="flex empty" v-if="!list.length">
+			<u-empty text="数据为空" mode="order" />
 		</view>
 		
 		<view class="footer-fixed">
@@ -55,6 +41,9 @@
 			return {
 				checked: false,
 				actionIndex: 0,
+				pageNum: 1,
+				total: 0,
+				list: [],
 			};
 		},
 		methods:{
@@ -127,6 +116,10 @@
 		}
 	}
 	
+	.empty{
+		height: 60vh;
+	}
+	
 	.footer-fixed {
 		position: fixed;
 		bottom: var(--window-bottom);

+ 167 - 42
pages/goods/detail.vue

@@ -3,12 +3,12 @@
 		<u-navbar title="兑换详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
 		<view class="detail">
 			<view class="detail-top">
-				<u-swiper :list="picUrlArr" height="348" :indicator="true" :circular="true"></u-swiper>
+				<u-swiper :list="picUrlArr" height="348" radius="0" :indicator="true" :circular="true"></u-swiper>
 			</view>
 			<view class="detail-title">
 				<view class="txt">{{ info.title }}</view>
 				<view class="coin">
-					<image src="../../static/logo.png" mode=""></image>
+					<image src="../../static/icon/bean.png" mode=""></image>
 					<view>x {{ info.exchangePrice }}</view>
 				</view>
 			</view>
@@ -33,10 +33,10 @@
 					<view class="info">
 						<view class="info-title">{{ info.title }}</view>
 						<view class="info-coin">
-							<image src="../../static/logo.png" mode=""></image>
-							<view>x {{ info.value }}</view>
+							<image src="../../static/icon/bean.png" mode=""></image>
+							<view>x {{ payInfo.exValue }}</view>
 						</view>
-						<view class="info-stock">库存:{{ info.quantity }}</view>
+						<view class="info-stock">库存:{{ payInfo.quantity }}</view>
 					</view>
 				</view>
 				<view class="sku" v-for="(item, index) in skuList" :key="index">
@@ -44,30 +44,45 @@
 					<view class="flex sku-list">
 						<view
 							:class="{'action': item.actionIndex == indexs, 'sku-list-item': item.actionIndex != indexs}"
-							v-for="(ele, indexs) in item.vals" :key="indexs" @click="getSku(ele, item, indexs)">
-							{{ ele }}</view>
+							v-for="(ele, indexs) in item.value" :key="indexs" @click="getSku(ele, item, indexs)">
+							{{ ele }}
+						</view>
 					</view>
 				</view>
 				<view class="flex quantity">
 					<view class="quantity-title">兑换数量</view>
 					<view class="quantity-title">
-						<u-number-box v-model="value" :min="1" :disabledInput="true" @change="valChange"></u-number-box>
+						<u-number-box v-model="orderNum" :min="1" :disabledInput="true"
+							@change="valChange($event, payInfo)"></u-number-box>
 					</view>
 				</view>
 				<view class="flex btn">
 					<view class="flex btn-left">
 						<view class="title">应付:</view>
 						<view class="flex coin">
-							<image src="../../static/logo.png" mode=""></image>
-							<view>x {{ info.value }}</view>
+							<image src="../../static/icon/bean.png" mode=""></image>
+							<view>x {{ payInfo.value }}</view>
 						</view>
 					</view>
 					<view class="btn-right">
-						<view class="confirm">立即兑换</view>
+						<view class="confirm" @click="confirmPrize">立即兑换</view>
 					</view>
 				</view>
 			</view>
 		</u-popup>
+		
+		<u-popup :show="tipShow" mode="center">
+		        <view class="tip-show">
+		            <view class="flex tip-show-title">
+						<u-icon name="checkmark-circle" color="#EB7009" size="24"></u-icon>
+						<text>兑换成功,已放入奖品库</text>
+					</view>
+					<view class="flex tip-show-btn">
+						<view class="close" @click="tipShow = false">关闭</view>
+						<navigator class="prize" :url="`/pages/prize/index`" hover-class="navigator-hover" @click="tipShow = false">前往查看</navigator>
+					</view>
+		        </view>
+			</u-popup>
 	</view>
 </template>
 
@@ -77,24 +92,38 @@
 	export default {
 		data() {
 			return {
+				goodsId: '',
 				boxId: '',
 				picUrlArr: [],
 				info: {},
 				prizeList: [],
 				description: '',
 				choiceShow: false,
-				value: 1,
-				skuList: []
+				initData: {},
+				orderNum: 1,
+				skuList: [],
+				skuListInit: [],
+				payInfo: {},
+				tipShow: false
 			};
 		},
 		onLoad(opthios) {
-			this.getDetail(opthios.id)
+			this.goodsId = opthios.id
+		},
+		onShow(){
+			this.getDetail()
+			this.getBean()
 		},
 		methods: {
-			getDetail(id) {
+			getDetail() {
+				uni.showLoading({
+					title: '加载中'
+				});
 				$http.post('/api/v1/mp/user/exchange/goods/detail', {
-					goodsId: id
+					goodsId: this.goodsId,
+					noToken: true
 				}).then(res => {
+					uni.hideLoading();
 					if (res.code == 0) {
 						this.info = res.data
 						let picUrlArr = res.data.picUrl.split(',')
@@ -103,31 +132,49 @@
 						})
 						// 处理富文本
 						this.description = this.formatRichText(res.data.description);
-
-						let specObj = {}
-						res.data.skuList.forEach(item => {
-							item.properties.split(';').forEach(p => {
-								const key = p.split(':')[0]
-								// console.log(specObj[key] instanceof Array)
-								if (!specObj[key]) {
-									specObj[key] = []
-									// console.log(specObj[key])
-								}
-								specObj[key].push(p.split(':')[1])
+						this.skuListInit = res.data.skuList
+						if (res.data.skuList.length) {
+							let skuProp = JSON.parse(res.data.skuProp)
+							skuProp.forEach(item => {
+								item.actionIndex = 0,
+									item.txt = `${item.name}:${item.value[0]}`
 							})
-						})
-						this.skuList = Object.keys(specObj).map(key => {
-							return {
-								name: key,
-								vals: [...new Set(specObj[key])],
-								actionVals: false,
-								actionIndex: 0
+							let actionSku = skuProp.map(item => {
+								return item.txt
+							}).join(';')
+							let sku = res.data.skuList.find(item => {
+								return item.properties == actionSku
+							})
+							this.payInfo = {
+								...sku,
+								exValue: sku.value,
+								picUrl: env.filePublic + sku.picUrl
 							}
-						})
+							this.skuList = skuProp
+						} else {
+							this.payInfo = {
+								...res.data,
+								exValue: this.info.value,
+								picUrl: this.picUrlArr[0]
+							}
+						}
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
 
-						console.log(this.skuList);
-						// console.log(this.info);
+			getBean() {
+				uni.showLoading({
+					title: '加载中'
+				});
+				$http.post('/api/v1/mp/user/mine/init', {}).then(res => {
+					uni.hideLoading();
+					if (res.code == 0) {
+						this.initData = res.data
 					}
+				}).catch(() => {
+					uni.hideLoading();
 				})
 			},
 
@@ -139,16 +186,52 @@
 				this.choiceShow = false
 			},
 
-			valChange(e) {
-				console.log(e);
+			valChange(e, item) {
+				let value = e.value
+				this.$set(item, 'value', value * item.exValue)
+				console.log(value, item);
 			},
 
 			getSku(e, item, indexs) {
 				this.$set(item, 'txt', `${item.name}:${e}`)
 				this.$set(item, 'actionIndex', indexs)
-				console.log(e);
-				console.log(item);
-				console.log(indexs);
+				this.orderNum = 1
+				let actionSku = this.skuList.map(item => {
+					return item.txt
+				}).join(';')
+				let sku = this.skuListInit.find(item => {
+					return item.properties == actionSku
+				})
+				this.payInfo = {
+					...sku,
+					exValue: sku.value,
+					picUrl: env.filePublic + sku.picUrl
+				}
+			},
+
+			confirmPrize() {
+				uni.showLoading({
+					title: '兑换中'
+				});
+				let data = {
+					goodsId: this.payInfo.goodsId,
+					skuId: this.payInfo.skuId,
+					orderNum: this.orderNum,
+				}
+				console.log(data);
+				if (this.initData.coinNum < this.payInfo.value) {
+					uni.$u.toast('盲豆余额不足');
+					return
+				}
+				$http.post('/api/v1/mp/user/exchange/submit', data).then(res=>{
+					uni.hideLoading();
+					if(res.code == 0){
+						this.choiceShow = false
+						this.tipShow = true
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
 			},
 
 			/**
@@ -365,6 +448,48 @@
 			}
 		}
 	}
+	
+	.tip-show{
+		width: 80vw;
+		background-color: #FFFFFF;
+		border-radius: 10rpx;
+		padding: 60rpx 40rpx;
+		
+		&-title{
+			margin-bottom: 64rpx;
+			text{
+				margin-left: 20rpx;
+			}
+		}
+		
+		&-btn{
+			justify-content: space-around;
+			
+			.close{
+				width: 160rpx;
+				height: 60rpx;
+				line-height: 60rpx;
+				border-radius: 8rpx;
+				color: rgba(235, 112, 9, 100);
+				font-size: 28rpx;
+				text-align: center;
+				border: 1px solid rgba(235, 112, 9, 100);
+			}
+			
+			.prize{
+				width: 160rpx;
+				height: 60rpx;
+				line-height: 60rpx;
+				border-radius: 8rpx;
+				color: rgba(235, 112, 9, 100);
+				font-size: 28rpx;
+				text-align: center;
+				background-color: rgba(235, 112, 9, 100);
+				color: rgba(255, 255, 255, 100);
+				font-size: 14px;
+			}
+		}
+	}
 
 	.footer-fixed {
 		position: fixed;

+ 1 - 1
pages/order/detail.vue

@@ -100,7 +100,7 @@
 				list: [],
 			};
 		},
-		onLoad(opthios) {
+		onShow(opthios) {
 			this.orderId = opthios.id
 			this.getDetail()
 		},

+ 12 - 17
pages/prize/coupon.vue

@@ -16,7 +16,7 @@
 		<!-- 已使用 -->
 		<view class="prize-coupon">
 			<view class="prize-coupon-list">
-				<view class="flex prize-coupon-list-item">
+				<!-- <view class="flex prize-coupon-list-item">
 					<image src="../../static/logo.png" mode=""></image>
 					<view class="flex info">
 						<view class="flex desc">
@@ -29,24 +29,12 @@
 						</view>
 						<view class="state">已使用</view>
 					</view>
-				</view>
-
-				<view class="flex prize-coupon-list-item">
-					<image src="../../static/logo.png" mode=""></image>
-					<view class="flex info">
-						<view class="flex desc">
-							<view class="title">200元代金券</view>
-							<view class="txt">使用期限:2022.03.02-2022.04.01</view>
-							<view class="txt">适用范围:星巴克xxx店</view>
-						</view>
-						<view class="flex btn">
-							<view class="amt"><text>¥</text>100</view>
-						</view>
-						<view class="state">已过期</view>
-					</view>
-				</view>
+				</view> -->
 			</view>
 		</view>
+		<view class="flex empty" v-if="!list.length">
+			<u-empty text="数据为空" mode="order" />
+		</view>
 	</view>
 </template>
 
@@ -60,6 +48,9 @@
 					name: '已过期',
 				}],
 				state: 0,
+				pageNum: 1,
+				total: 0,
+				list: [],
 			};
 		},
 		methods: {
@@ -159,4 +150,8 @@
 			}
 		}
 	}
+	
+	.empty{
+		height: 60vh;
+	}
 </style>

+ 0 - 1
pages/prize/index.vue

@@ -126,7 +126,6 @@
 						})
 						_this.total = res.total
 						_this.list = _this.list.concat(res.rows)
-						console.log(_this.list);
 					}
 				}).catch(() => {
 					uni.hideLoading();

+ 1 - 1
pages/prizeGoods/detail.vue

@@ -3,7 +3,7 @@
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="奖品详情"></u-navbar>
 		<view class="detail">
 			<view class="detail-top">
-				<u-swiper :list="picUrlArr" height="320" :indicator="true" :circular="true"></u-swiper>
+				<u-swiper :list="picUrlArr" height="320" radius="0" :indicator="true" :circular="true"></u-swiper>
 			</view>
 			<view class="detail-info">
 				<view class="content">零跑C11电动汽车新能源车整车国产中型SUV C11性能版</view>

+ 1 - 1
pages/ticketBox/detail.vue

@@ -3,7 +3,7 @@
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
 		<view class="detail">
 			<view class="detail-top">
-				<u-swiper :list="picUrlArr" height="320" :indicator="true" :circular="true"></u-swiper>
+				<u-swiper :list="picUrlArr" height="320" radius="0" :indicator="true" :circular="true"></u-swiper>
 			</view>
 			<view class="flex detail-info">
 				<view class="detail-info__left">

+ 1 - 1
pages/user/index.vue

@@ -182,7 +182,7 @@
 		align-items: center;
 		height: 230rpx;
 		padding: 0 36rpx;
-		background: url(https://file02.16sucai.com/d/file/2014/1103/1b73e5346d5579badbc83cb15586f0a8.jpg) center no-repeat;
+		background: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%);
 	}
 
 	.account {

BIN
static/icon/bean.png