lilei 4 vuotta sitten
vanhempi
commit
418ab46e51
2 muutettua tiedostoa jossa 201 lisäystä ja 30 poistoa
  1. 199 29
      pagesA/luckDraw/luckDraw.vue
  2. 2 1
      pagesA/taskList/taskList.vue

+ 199 - 29
pagesA/luckDraw/luckDraw.vue

@@ -22,6 +22,9 @@
 				:canvasHeight="canvasData.height"
 				:canvasMargin="canvasData.margin"
 			/>
+			<view class="nodata" v-else>
+				{{nodata}}
+			</view>
 			<view class="synums">
 				<view v-if="reTimes">
 					抽奖剩余次数:
@@ -85,7 +88,29 @@
 			</view>
 		</view>
 		<!-- 更多任务 -->
-		<view class="taskBar" @click="toTaskList">做任务,赚更多抽奖次数</view>
+		<view class="taskBar" v-if="hasLogin" @click="toTaskList">做任务,赚更多抽奖次数</view>
+		<!-- 任务列表弹框 -->
+		<u-popup v-model="showTask" :duration="10" mode="bottom" closeable :border-radius="30" width="500rpx" height="450rpx">
+			<view class="task-popue">
+				<view class="task-title">做任务赚抽奖次数</view>
+				<view class="task-list-cons">
+					<view class="task-list" v-for="(item,index) in tasklist" :key="index">
+						<view class="task-l">
+							<u-image width="80rpx" height="80rpx" :src="`/static/${item.taskCode}.png`"></u-image>
+							<view class="task-l-info">
+								<view class="task-l-title">{{item.taskCodeDictValue}}</view>
+								<view class="task-l-desc">赚<text>{{item.giveTimes}}</text>次抽奖 <u-image width="22rpx" height="22rpx" src="/static/zpIcon.png"></u-image></view>
+							</view>
+						</view>
+						<view class="task-r">
+							<u-button size="medium" v-if="item.state==1||item.taskCode=='NEW_CUSTOMER'" :custom-style="{padding:'6px 10px',width:'100%',background:'#989898',color:'#ffffff'}">已完成</u-button>
+							<u-button size="medium" v-else-if="item.state==0 && item.taskCode=='SHARE_FRIEND'" open-type="share" :custom-style="{padding:'6px 10px',width:'100%',background:'#02c9b2',color:'#ffffff'}">立即分享</u-button>
+							<u-button size="medium" v-else @click="showYdao" :custom-style="{padding:'6px 10px',width:'100%',background:'#02c9b2',color:'#ffffff'}">立即前往</u-button>
+						</view>
+					</view>
+				</view>
+			</view>
+		</u-popup>
 		<!-- 抽奖活动弹框 -->
 		<u-popup v-model="showLottery" :duration="50" mode="center" close-icon-color="#ffffff" closeable :border-radius="30" width="500rpx" height="450rpx">
 			<view class="lottery-content win_0" v-if="winTypes == 'win_0'">
@@ -136,13 +161,24 @@
 				</view>
 			</view>
 		</u-popup>
+		<!-- 查看使用指南 -->
+		<u-popup v-model="showYd" mode="center" close-icon-color="#ffffff" closeable :border-radius="30" width="500rpx" height="550rpx">
+			<view class="lottery-content yindao">
+				<view class="lottery-title">
+					<image src="/static/tdsm.jpg"></image>
+				</view>
+				<view @click="toViewZn" class="lottery-confrim-btn">
+					查看使用指南
+				</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
 <script>
 import AlmostLottery from '@/components/almost-lottery/almost-lottery.vue';
 import { clearCacheFile } from '@/almost-utils/almost-utils.js';
-import { findEnable, findCustomerTimes, buyDrawTimes, takeOut, queryWinRecord } from '@/api/luckyDraw.js'
+import { findEnable, findCustomerTimes, buyDrawTimes, takeOut, queryWinRecord, doTask, findCustomerTask } from '@/api/luckyDraw.js'
 import { checkLogin, getUserInfo } from '@/api/login.js'
 import moment from 'moment'
 export default {
@@ -172,6 +208,9 @@ export default {
 	},
 	data() {
 		return {
+			nodata: '活动加载中...',
+			showYd: false,
+			showTask: false,
 			hasLogin: false,
 			userData: {},
 			focus: false,
@@ -179,6 +218,7 @@ export default {
 			timer: null,
 			scrollTextHeight: 0,
 			hjList: [], // 已获奖人员
+			tasklist: [], // 任务列表
 			showLottery: false, // 是否显示抽奖弹框
 			winTypes: '', // 抽奖弹框类型
 			payPws: '', // 支付密码
@@ -210,6 +250,19 @@ export default {
 		};
 	},
 	methods: {
+		toLogin(){
+			if(this.scene!=1154){
+				uni.showModal({
+					showCancel: false,
+					title: '请先登录后再抽奖!',
+					success() {
+						uni.redirectTo({
+							url: '/pages/login/login?path=/pagesA/luckDraw/luckDraw'
+						})
+					}
+				})
+			}
+		},
 		// 重置
 		handleInitCanvas() {
 			clearCacheFile();
@@ -237,11 +290,14 @@ export default {
 		},
 		// 获取奖品列表
 		getPrizeList() {
-			uni.showLoading({
-				title: '奖品准备中...'
-			});
+			if(this.hasLogin){
+				uni.showLoading({
+					title: '奖品准备中...'
+				});
+			}
 			findEnable().then(res => {
 				console.log(res,'getPrizeList')
+				let _this = this
 				if(res.status == 200 && res.data){
 					this.$u.vuex('vuex_LuckDraw',res.data)
 					this.luckDraw = res.data
@@ -252,12 +308,17 @@ export default {
 						this.getCustomerTimes()
 						// 查询亦获奖列表
 						this.getDrawList()
+						// 任务列表
+						this.getTaskList()
+						// 格式化数据
 						this.prizeList = this.requestPrizeList()
 					}else{
+						this.nodata = '活动已结束'
 						uni.showModal({
 							showCancel: false,
 							title: '活动已结束',
 							success() {
+								_this.$store.state.vuex_noLogin = true
 								uni.reLaunch({
 									url: '/pages/index/index'
 								})
@@ -265,10 +326,12 @@ export default {
 						})
 					}
 				}else{
+					this.nodata = '活动已结束'
 					uni.showModal({
 						showCancel: false,
 						title: '活动已结束',
 						success() {
+							_this.$store.state.vuex_noLogin = true
 							uni.reLaunch({
 								url: '/pages/index/index'
 							})
@@ -306,16 +369,40 @@ export default {
 		},
 		// 抽奖次数用完了
 		showPayWin(winTypes){
-			if(this.hasLogin){
-				this.showLottery = true
-				this.winTypes = winTypes
-				this.prizeIndex = -1
-				// clearCacheFile()
+			if(this.scene == 1154){
+				uni.showToast({
+					icon: 'none',
+					title: '请前往小程序使用完整服务',
+					duration: 15000,
+				})
+				return
 			}
+			if(!this.hasLogin){
+				this.toLogin()
+				return
+			}
+			
+			this.showLottery = true
+			this.winTypes = winTypes
+			this.prizeIndex = -1
+			// clearCacheFile()
 		},
 		// 本次抽奖开始
 		handleDrawStart() {
-			if(this.isSocktOut||this.scene==1154){
+			if(this.scene == 1154){
+				uni.showToast({
+					icon: 'none',
+					title: '请前往小程序使用完整服务',
+					duration: 15000,
+				})
+				return
+			}
+			if(!this.hasLogin){
+				this.toLogin()
+				return
+			}
+			// 正在抽奖中
+			if(this.isSocktOut){
 				return
 			}
 			this.targetName = '';
@@ -437,14 +524,48 @@ export default {
 		// 我的奖品
 		viewMyJp(){
 			this.showLottery=false
-			uni.navigateTo({
-				url: '/pagesA/luckDraw/myJp'
-			})
+			if(this.hasLogin&&this.scene != 1154){
+				uni.navigateTo({
+					url: '/pagesA/luckDraw/myJp'
+				})
+			}else{
+				this.toLogin()
+			}
 		},
-		// 任务列表
+		// 打开任务列表
 		toTaskList(){
-			uni.navigateTo({
-				url: '/pagesA/taskList/taskList?id='+this.luckDraw.luckyDrawNo
+			this.showTask = true
+		},
+		// 做任务
+		toDoTask(taskCode){
+			doTask({luckyDrawNo:this.luckDraw.luckyDrawNo,taskCode:taskCode}).then(res => {
+				if(res.status == 200){
+					uni.showToast({
+						icon: 'none',
+						title: '分享成功'
+					})
+					// 刷新列表
+					this.getTaskList()
+				}
+			})
+		},
+		// 获取任务列表
+		getTaskList () {
+			findCustomerTask({id:this.luckDraw.luckyDrawNo}).then(res =>{
+				if(res.status == 200) {
+					console.log(res)
+					this.tasklist = res.data
+				} else {
+					this.tasklist = []
+				}
+			})
+		},
+		showYdao(){
+			this.showYd = true
+		},
+		toViewZn(){
+			uni.redirectTo({
+				url: '/pages/userCenter/zhinan'
 			})
 		},
 	},
@@ -461,17 +582,6 @@ export default {
 		checkLogin().then(res => {
 			console.log(res,'checkLogin')
 			this.hasLogin = res.status == 200
-			if(this.scene!=1154&&!this.hasLogin){
-				uni.showModal({
-					showCancel: false,
-					title: '请先登录后再抽奖!',
-					success() {
-						uni.redirectTo({
-							url: '/pages/login/login?path=/pagesA/luckDraw/luckDraw'
-						})
-					}
-				})
-			}
 		})
 		
 		// 请求奖品数据
@@ -487,6 +597,7 @@ export default {
 		clearInterval(this.timer)
 	},
 	onShareAppMessage() {
+		this.toDoTask('SHARE_FRIEND')
 		return {
 		      title: '[乐色管家]参与垃圾分类,让城市更美丽!好运等你转出来!',
 		      path: '/pagesA/luckDraw/luckDraw',
@@ -494,6 +605,7 @@ export default {
 		    }
 	},
 	onShareTimeline() {
+		this.toDoTask('SHARE_FRIEND')
 		return {
 			title: '[乐色管家]参与垃圾分类,让城市更美丽!好运等你转出来!',
 			imageUrl:'/static/zpthumbr.jpg',
@@ -508,6 +620,11 @@ export default {
 	width: 100%;
 	background: #ffec59;
 	padding: 0;
+	.nodata{
+		text-align: center;
+		color: #fff;
+		font-size: 34rpx;
+	}
 	.luckwheel {
 		display: flex;
 		align-items: center;
@@ -637,6 +754,17 @@ export default {
 			font-size: 32rpx;
 		}
 	}
+	.yindao{
+		.lottery-title{
+			padding: 100rpx 50rpx;
+			display: flex;
+			text-align: center;
+			image{
+				width: 450rpx;
+				height: 320rpx;
+			}
+		}
+	}
 	.taskBar{
 		background: rgba(0, 180, 0, 0.8);
 		padding: 20rpx;
@@ -645,11 +773,53 @@ export default {
 		width: 80%;
 		left: 50%;
 		margin-left: -40%;
-		bottom: 24rpx;
+		bottom: 50rpx;
 		position: fixed;
 		color: #fff;
 		border-radius: 200rpx;
 	}
+	// 任务弹框
+	.task-popue{
+		display: flex;
+		flex-direction: column;
+		.task-title{
+			padding: 30rpx 50rpx;
+			border-bottom: 1px solid #eee;
+		}
+		.task-list-cons{
+			flex-grow: 1;
+			overflow: auto;
+		}
+		.task-list{
+			display: flex;
+			align-items: center;
+			padding: 20rpx 40rpx;
+			border-bottom: 1px solid #eee;
+			background-color: #FFFFFF;
+			.task-l{
+				width: 80%;
+				display: flex;
+				align-items: center;
+				.task-l-info{
+					flex-grow: 1;
+					padding: 0 15rpx;
+					.task-l-title{
+						font-weight: bold;
+					}
+					.task-l-desc{
+						display: flex;
+						align-items: center;
+						font-size: 24rpx;
+						color: #666;
+						margin-top: 5rpx;
+					}
+				}
+			}
+			.task-r{
+				width: 20%;
+			}
+		}
+	}
 	// 未中奖
 	.win_0{
 		.lottery-title{

+ 2 - 1
pagesA/taskList/taskList.vue

@@ -92,7 +92,8 @@
 			this.toDoTask('SHARE_FRIEND')
 			return {
 				title: '[乐色管家]参与垃圾分类,让城市更美丽!好运等你转出来!',
-				imageUrl:'/static/zpthumbr.jpg'
+				imageUrl:'/static/zpthumbr.jpg',
+				query: 'fromType=timeline'
 			}
 		}
 	}