Przeglądaj źródła

Merge branch 'dev' of maopiao/mp-ui-user into test

lsx 2 lat temu
rodzic
commit
69d9cbb54c

+ 164 - 0
src/packagePrize/bean/components/transfer.vue

@@ -0,0 +1,164 @@
+<template>
+	<view>
+		<u-popup :show="popupShow" :round="10" mode="center" :safeAreaInsetBottom="false" @touchmove.prevent.stop>
+			<view class="set-turn">
+				<view class="set-turn-title">请输入对方手机号码:</view>
+				<view class="set-turn-input">
+					<u-input placeholder="请输入手机号码" type="number" border="surround" v-model="mobile" @change="change" />
+				</view>
+				<view class="set-turn-title" style="display: inline-block;">对方用户昵称:</view>
+				<view style="display: inline-block;">
+					<view class="" v-if="info && info.nickName ">{{ info.nickName }}</view>
+					<view class="red" v-else-if="!info">未查询到用户</view>
+					<view class="" v-else>-</view>
+				</view>
+				<view class="set-turn-title">请输入盲豆转赠数量:</view>
+				<view class="set-turn-input">
+					<u-input placeholder="请输入转赠数量" type="number" border="surround" v-model="beanNum" />
+				</view>
+				<view class="loss">
+					<view>盲豆转增折损说明:</view>
+					<view>(20个盲豆起转,每次扣除10盲豆)</view>
+				</view>
+				<view class="flex set-turn-btn">
+					<view class="btn close" @click="close">取消</view>
+					<view class="btn confirm" @click="confirm">确认</view>
+				</view>
+			</view>
+		</u-popup>
+	</view>
+</template>
+
+<script> 
+	import $http from '@/utils/request.js'
+	export default {
+		name: "set-turn",
+		props: {
+			popupShow: {
+				type: [Boolean],
+				default: false
+			},
+			coinNum: {
+				type: [String, Number],
+				default: ''
+			}
+		},
+		data() {
+			return {
+				mobile: '',
+				info: {},
+				beanNum: '',
+			};
+		},
+		methods: {
+			change(e) {
+				if(!e) { this.info = {} }
+				if(e.length < 11) {
+					this.info = {}
+				}
+				if(e.length > 11) { 
+					uni.$u.toast('请输入正确的手机号') 
+					this.info = {}
+				}
+				if(e.length != 11) return
+				$http.post(`/api/v1/mp/user/mine/sysUser/mobile/${ e }`, {}).then(res => {
+					this.info = res && res.data
+				})
+				
+			},
+			
+			close() {
+				this.$emit('close')
+			},
+			
+			confirm() {
+				if(this.info == null) {
+					uni.$u.toast('未查询到用户')
+					return
+				}
+				if(Object.keys(this.info).length  == 0) {
+					uni.$u.toast('请确认转让用户')
+					return
+				}
+				if(!this.beanNum) {
+					uni.$u.toast('请输入盲豆数量')
+					return
+				}
+				if(this.beanNum < 20) {
+					uni.$u.toast('每次转增盲豆不少于20')
+					return
+				}
+				if(this.beanNum > 1000) {
+					uni.$u.toast('每次最多转增1000')
+					return
+				}
+				if(this.beanNum > this.coinNum) {
+					uni.$u.toast('超过现有盲豆数量')
+					return
+				}
+				$http.post('/api/v1/mp/user/mine/coin/transfer/save', {
+					phone: this.mobile,
+					transferCoin: this.beanNum,
+				}).then( res => {
+					if(res.code == 0){
+						this.close()
+						this.$emit('confirm')
+						setTimeout(()=>{
+							uni.$u.toast('转让成功')
+						},500)
+					}
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.set-turn {
+		width: 75vw;
+		padding: 40rpx;
+		background-color: #FFFFFF;
+		border-radius: 10rpx;
+
+		&-title {
+			margin-bottom: 30rpx;
+			color: #666666;
+			font-size: 28rpx
+		}
+
+		&-input {
+			padding-bottom: 30rpx;
+		}
+		
+		.red {
+			color: red;
+		}
+		
+		&-btn {
+			justify-content: space-around;
+			margin-top: 20rpx;
+			
+			.btn {
+				width: 160rpx;
+				height: 60rpx;
+				line-height: 60rpx;
+				border-radius: 8rpx;
+				text-align: center;
+			}
+			
+			.close {
+				border: 1px solid rgba(187, 187, 187, 100);
+			}
+			
+			.confirm {
+				color: #FFFFFF;
+				background-color: $uni-bg-color;
+			}
+		}
+		.loss {
+			padding: 5px 0 10px 0;
+			font-size: 26rpx;
+			color: #999999;
+		}
+	}
+</style>

+ 272 - 230
src/packagePrize/bean/index.vue

@@ -1,243 +1,285 @@
-<template>
-	<view>
-		<!-- #ifdef MP-ALIPAY -->
-		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"  leftIconSize="0"></u-navbar>
-		<!-- #endif -->
-		<!-- #ifdef MP-WEIXIN -->
-		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"></u-navbar>
-		<!-- #endif -->
-		<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
-		<view v-if="pagesNum > 1">
-			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆" />
-		</view>
-		<view v-else>
-			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="我的盲豆">
-				<view class="nav-left flex" slot="left" @click="$toIndex()">
-					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
-				</view>
-			</u-navbar>
-		</view>
-		<!-- #endif -->
-		
-		<view class="bean">
-			<!-- 盲豆数 -->
-			<view class="bean-balance flex">
-				<view class="bean-balance-num">{{ initData.coinNum }}</view>
-				<view class="bean-balance-title">盲豆余额</view>
-				<view class="bean-balance-btn flex" @click="toCore">立即兑换</view>
-			</view>
-			
-			<!-- 盲豆流水 -->
-			<view class="bean-list">
-				<view class="flex bean-list-item" v-for="(item, index) in list" :key="index">
-					<view class="flex left">
-						<view class="date">{{ $parseTime(item.createdTime) }}</view>
-						<view class="title">{{ item.logText }}</view>
-					</view>
-					<view class="flex right">
-						<view class="amt">{{ item.logMoney > 0 ? '+' : '' }}{{ item.logMoney }}</view>
+<template>
+	<view>
+		<!-- #ifdef MP-ALIPAY -->
+		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"
+			leftIconSize="0"></u-navbar>
+		<!-- #endif -->
+		<!-- #ifdef MP-WEIXIN -->
+		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"></u-navbar>
+		<!-- #endif -->
+		<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
+		<view v-if="pagesNum > 1">
+			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆" />
+		</view>
+		<view v-else>
+			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="我的盲豆">
+				<view class="nav-left flex" slot="left" @click="$toIndex()">
+					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
+				</view>
+			</u-navbar>
+		</view>
+		<!-- #endif -->
+
+		<view class="bean">
+			<!-- 盲豆数 -->
+			<view class="bean-balance flex">
+				<view class="bean-balance-num">{{ initData.coinNum }}</view>
+				<view class="bean-balance-title">盲豆余额</view>
+				<view class="">
+					<view class="bean-balance-btn flex" @click="toCore">立即兑换</view>
+					<view class="bean-balance-btn flex" @click="onTransfer">盲豆转赠</view>
+				</view>
+			</view>
+
+			<!-- 盲豆流水 -->
+			<view class="bean-list">
+				<view class="flex bean-list-item" v-for="(item, index) in list" :key="index">
+					<view class="flex left">
+						<view class="date">{{ $parseTime(item.createdTime) }}</view>
+						<view class="title">{{ item.logText.split('|')[1] ? item.logText.split('|')[0] : item.logText }}</view>
+						<view class="beanNum" v-if="item.logText.split('|')[1]">{{ item.logText.split('|')[1] }}</view>
+					</view>
+					<view class="flex right">
+						<view class="amt">{{ item.logMoney > 0 ? '+' : '' }}{{ item.logMoney }}</view>
 						<view class="balance">余额:{{ item.money }}</view>
+						<view class="beanNum" v-if="item.logText.split(',')[1]">-</view>
 					</view>
-				</view>
-			</view>
-			<u-loadmore :line="true" v-if="list.length>7" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
-			<view class="flex empty" v-if="!list.length">
-				<view class="center">
-					<image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_6.png" mode="scaleToFill"></image>
-					<view class="center-font">还没有记录</view>
-				</view>
-			</view>
+				</view>
+			</view>
+			<u-loadmore :line="true" v-if="list.length>7" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
+			<view class="flex empty" v-if="!list.length">
+				<view class="center">
+					<image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_6.png"
+						mode="scaleToFill"></image>
+					<view class="center-font">还没有记录</view>
+				</view>
+			</view>
 		</view>
-	</view>
-</template>
-
-<script>
-	import $http from '@/utils/request.js'
-	export default {
-		data() {
-			return {
-				status: 'nomore',//上拉刷新状态
-				initData: {},
-				pageNum: 1,
-				total: 0,
-				list: [],
+		<Transfer :popup-show="popupShow" @close="close" @confirm="confirm" :coin-num="coinNum"
+					v-if="popupShow" />
+	</view>
+</template>
+
+<script>
+	import $http from '@/utils/request.js'
+	import Transfer from './components/transfer.vue'
+	export default {
+		components: {
+			Transfer
+		},
+		data() {
+			return {
+				status: 'nomore', //上拉刷新状态
+				initData: {},
+				pageNum: 1,
+				total: 0,
+				list: [],
 				pagesNum: '',
-			};
-		},
-		onShow() {
-			this.pagesNum = getCurrentPages().length
-			this.getBean()
-			this.pageList()
-		},
-		methods: {
-			getBean() {
-				$http.post('/api/v1/mp/user/mine/init', {}).then(res => {
-					if (res.code == 0) {
+				popupShow: false,
+				coinNum: 0,
+			};
+		},
+		onShow() {
+			this.pagesNum = getCurrentPages().length
+			this.getBean()
+			this.pageList()
+		},
+		methods: {
+			getBean() {
+				$http.post('/api/v1/mp/user/mine/init', {}).then(res => {
+					if (res.code == 0) {
 						this.initData = res.data
-					}
-				}).catch(() => {
-				})
-			},
-
-			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()
+						this.coinNum = this.initData.coinNum
+					}
+				}).catch(() => {})
+			},
+
+			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()
 			},
 			
-			toCore(){
-				uni.switchTab({
-					url:"/pages/core/index"
-				})
-			}
-		},
-
-		onReachBottom() {
-			if(this.total < this.pageNum * 50) return ;
-			this.status = 'loading';
-			++this.pageNum
-			if(this.total < this.pageNum * 50) this.status = 'nomore';
-				else this.status = 'loading';
-			this.getList()
-		},
-	}
-</script>
-
-<style lang="scss" scoped>
-	.bean {
-		margin: 34rpx 34rpx;
-		padding-bottom: 100rpx;
-
-		// 盲豆数
-		&-balance {
-			height: 264rpx;
-			flex-direction: column;
-			justify-content: flex-start;
-			background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/coin_bkg.png) center center no-repeat;
-			background-size: calc(100vw - 68rpx) 264rpx;
-			margin-bottom: 34rpx;
-			
-			&-num {
-				font-size: 52rpx;
-				line-height: 52rpx;
-				font-weight: bold;
-				color: #FFFFFF;
-				margin: 36rpx 0 16rpx;
-			}
+			//盲票转增
+			onTransfer() {
+				this.popupShow = true
+			},
 			
-			&-title {
-				font-size: 26rpx;
-				line-height: 26rpx;
-				margin-bottom: 24rpx;
-				font-weight: 500;
-				color: #FFFFFF;
-				opacity: 0.72;
-			}
+			close() {
+				this.popupShow = false
+			},
 			
-			&-btn {
-				width: 200rpx;
-				height: 70rpx;
-				line-height: 70rpx;
-				font-size: 30rpx;
-				text-align: center;
-				background: #fff;
-				border-radius: 16rpx;
-				
-				image {
-					width: 56rpx;
-					height: 56rpx;
-					margin-right: 10rpx;
-				}
-			}
-		}
-
-		// 盲豆流水
-		&-list {
-			background-color: #FFFFFF;
-			padding: 0 34rpx;
-			border-radius: 22rpx;
-
-			&-item {
-				justify-content: space-between;
-				padding: 40rpx 0;
-				border-bottom: 1px solid #eee;
-
-				.left {
-					flex-direction: column;
-					justify-content: space-between;
-					align-items: flex-start;
-					
-					.date {
-						color: #AAAAAA;
-						line-height: 24rpx;
-						margin-bottom: 28rpx;
-					}
-					
-					.title {
-						font-size: 30rpx;
-						line-height: 30rpx;
+			confirm() {
+				//刷新盲豆记录
+				this.pageList()
+			},
+
+			toCore() {
+				uni.switchTab({
+					url: "/pages/core/index"
+				})
+			},
+		},
+
+		onReachBottom() {
+			if (this.total < this.pageNum * 50) return;
+			this.status = 'loading';
+			++this.pageNum
+			if (this.total < this.pageNum * 50) this.status = 'nomore';
+			else this.status = 'loading';
+			this.getList()
+		},
+	}
+</script>
+
+<style lang="scss" scoped>
+	.bean {
+		margin: 34rpx 34rpx;
+		padding-bottom: 100rpx;
+
+		// 盲豆数
+		&-balance {
+			height: 264rpx;
+			flex-direction: column;
+			justify-content: flex-start;
+			background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/coin_bkg.png) center center no-repeat;
+			background-size: calc(100vw - 68rpx) 264rpx;
+			margin-bottom: 34rpx;
+
+			&-num {
+				font-size: 52rpx;
+				line-height: 52rpx;
+				font-weight: bold;
+				color: #FFFFFF;
+				margin: 36rpx 0 16rpx;
+			}
+
+			&-title {
+				font-size: 26rpx;
+				line-height: 26rpx;
+				margin-bottom: 24rpx;
+				font-weight: 500;
+				color: #FFFFFF;
+				opacity: 0.72;
+			}
+
+			&-btn {
+				display: inline-block;
+				margin: 0 20px;
+				width: 200rpx;
+				height: 70rpx;
+				line-height: 70rpx;
+				font-size: 30rpx;
+				text-align: center;
+				background: #fff;
+				border-radius: 16rpx;
+
+				image {
+					width: 56rpx;
+					height: 56rpx;
+					margin-right: 10rpx;
+				}
+			}
+		}
+
+		// 盲豆流水
+		&-list {
+			background-color: #FFFFFF;
+			padding: 0 34rpx;
+			border-radius: 22rpx;
+
+			&-item {
+				justify-content: space-between;
+				padding: 40rpx 0;
+				border-bottom: 1px solid #eee;
+
+				.left {
+					flex-direction: column;
+					justify-content: space-between;
+					align-items: flex-start;
+
+					.date {
+						color: #AAAAAA;
+						line-height: 24rpx;
+						margin-bottom: 28rpx;
+					}
+
+					.title {
+						font-size: 30rpx;
+						line-height: 30rpx;
 					}
-				}
-
-				.right {
-					flex-direction: column;
-					justify-content: space-between;
-					align-items: flex-end;
 					
-					.amt {
-						color: #FF4208;
-						font-size: 30rpx;
-						line-height: 30rpx;
-						margin-bottom: 28rpx;
-					}
-					
-					.balance {
+					.beanNum {
+						margin-top: 20rpx;
 						color: #AAAAAA;
 					}
-				}
-			}
-
-			&-item:last-child {
-				border-bottom: none;
-			}
-		}
-	}
-
-	.empty {
-		height: 60vh;
-		.center {
-			text-align: center;
-			
-			&-img {
-				width: 228rpx;
-				height: 320rpx;
-			}
-			
-			&-font {
-				font-size: 30rpx;
-				font-weight: 400;
-				color: #999999;
-				margin-bottom: 250rpx;
-			}
-		}
-	}
-</style>
+					
+				}
+
+				.right {
+					flex-direction: column;
+					justify-content: space-between;
+					align-items: flex-end;
+
+					.amt {
+						color: #FF4208;
+						font-size: 30rpx;
+						line-height: 30rpx;
+						margin-bottom: 28rpx;
+					}
+
+					.balance {
+						color: #AAAAAA;
+					}
+					.beanNum{
+						margin-top: 20rpx;
+						color: #fff;
+					}
+				}
+			}
+
+			&-item:last-child {
+				border-bottom: none;
+			}
+		}
+	}
+
+	.empty {
+		height: 60vh;
+
+		.center {
+			text-align: center;
+
+			&-img {
+				width: 228rpx;
+				height: 320rpx;
+			}
+
+			&-font {
+				font-size: 30rpx;
+				font-weight: 400;
+				color: #999999;
+				margin-bottom: 250rpx;
+			}
+		}
+	}
+</style>