Browse Source

抽奖app端代码上传

user5 2 years ago
parent
commit
b54daa1e48

+ 18 - 0
api/test/luckyDraw/LuckyDrawEventsService.js

@@ -0,0 +1,18 @@
+import request from "../../../common/request"
+
+export default class LuckyDrawEventsService {
+	list (inputForm) {
+	  return request({
+	    url: '/luckyDraw/events/list',
+	    method: 'get',
+	    data: inputForm
+	  })
+	}
+	queryById (id) {
+	  return request({
+	    url: '/luckyDraw/events/queryById',
+	    method: 'get',
+	    params: {id: id}
+	  })
+	}
+}

+ 11 - 0
api/test/luckyDraw/LuckyDrawMembersService.js

@@ -0,0 +1,11 @@
+import request from "../../../common/request"
+
+export default class LuckyDrawMembersService {
+	save (data) {
+	  return request({
+	    url: '/luckyDraw/member/save',
+	    method: 'post',
+	    data: data
+	  })
+	}
+}

+ 1 - 1
common/graceChecker.js

@@ -72,7 +72,7 @@ module.exports = {
 					if (!reg.test(value)) { this.error = rule[i].errorMsg || rule[i].name + '不是合法的邮箱格式!'; return false; }
 				break;
 				case 'isMobile':
-					var reg = /^1[0-9]{10,10}$/;
+					var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
 					if (!reg.test(value)) { this.error = rule[i].errorMsg || rule[i].name + '不是合法的手机号码!'; return false; }
 				break;
 				case 'isUrl':

+ 4 - 0
pages.json

@@ -274,6 +274,10 @@
 		  {
 		      "path" : "pages/test/luckyDraw/LuckyDrawLottery",
 		      "style" : {}
+		  },
+		  {
+		      "path" : "pages/test/luckyDraw/LuckyDrawEvents_pc",
+		      "style" : {}
 		  }
     ],
 	"globalStyle": {

+ 1 - 1
pages/apps/apps.vue

@@ -88,7 +88,7 @@
 					</navigator>
 				</view>
 				<view class="padding-sm">
-					<navigator hover-class="none" url="/pages/test/luckyDraw/LuckyDrawList" >
+					<navigator hover-class="none" url="/pages/test/luckyDraw/LuckyDrawEvents_pc" >
 						<view class="padding radius text-center shadow-blur bg-white">
 							<text class="lg font-size-35 text-blue cuIcon-safe"></text>
 							<view class="margin-top-sm text-Abc">抽奖</view>

+ 48 - 49
pages/test/luckyDraw/LuckyDrawEvents.vue

@@ -1,68 +1,43 @@
 <template>
 	<view>
-		<cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText">返回</block><block slot="content">活动中心</block></cu-custom>
+		<cu-custom bgColor="bg-gradual-blue" ><block slot="content">活动中心</block></cu-custom>
 
-		<!-- <view class="cu-bar bg-white solid-bottom margin-top">
-			<view class="action">
-				<text class="cuIcon-titles text-orange "></text> 文章类卡片
-			</view>
-			<view class="action">
-				<switch :class="isCard?'checked':''" :checked="isCard?true:false" @change="IsCard"></switch>
-			</view>
-		</view> -->
-		<view class="cu-card article" :class="isCard?'no-card':''">
-			<view class="cu-item shadow" @click="aaa()">
-				<view class="title"><view class="text-cut"> 活动名称三 </view></view>
-				<view class="content">
-					<image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big91012.jpg"
-					 mode="aspectFill"></image>
-					<view class="desc">
-						<view class="text-content"> 活动详情活动详情活动详情活动详情活动详情活动详情活动详 </view>
-						<view>
-							<view class="cu-tag bg-grey light sm ">未开始</view>
-						</view>
-					</view>
+		<view class="cu-card article">
+			<view class="cu-item shadow" v-for="item in dataList" @click="detail(item.id, item.switchFlag)">
+				<view class="title">
+					<view class="text-cut"> {{item.name}} </view>
 				</view>
-			</view>
-			<view class="cu-item shadow">
-				<view class="title"><view class="text-cut"> 活动名称一 </view></view>
 				<view class="content">
-					<image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big39000.jpg"
+					<image src="/static/lucky_draw_events.png"
 					 mode="aspectFill"></image>
 					<view class="desc">
-						<view class="text-content"> 活动详情活动详情活动详情活动详情活动详情活动详情活动详 </view>
+						<view class="text-content"> {{item.detail}} </view>
 						<view>
-							<view class="cu-tag bg-green light sm ">进行中</view>
+							<view :class="item.switchFlag === '1' ? 'cu-tag bg-green light sm' : 'cu-tag bg-grey light sm' ">
+								{{item.switchFlag === '1' ? '进行中' : '未开始'}}
+							</view>
 						</view>
 					</view>
 				</view>
 			</view>
-			<view class="cu-item shadow">
-				<view class="title"><view class="text-cut"> 活动名称二 </view></view>
-				<view class="content">
-					<image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg"
-					 mode="aspectFill"></image>
-					<view class="desc">
-						<view class="text-content"> 活动详情活动详情活动详情活动详情活动详情活动详情活动详 </view>
-						<view>
-							<view class="cu-tag bg-red light sm ">已结束</view>
-						</view>
-					</view>
-				</view>
-			</view>
-			
 		</view>
 	</view>
 </template>
 
 <script>
-import { create } from 'lodash';
+import LuckyDrawEventsService from '@/api/test/luckyDraw/LuckyDrawEventsService'
 	export default {
 		data() {
 			return {
-				isCard: false
+				dataList: [],
+				loading: false,
+				searchForm: {},
+				tablePage: {
+					total: ''
+				}
 			};
 		},
+		luckyDrawEventsService: null,
 		onLoad(option) {
 			let { is_sucess } = option
 			if (is_sucess == '200') {
@@ -72,15 +47,39 @@ import { create } from 'lodash';
 					duration: 1500
 				})
 			}
+			this.luckyDrawEventsService = new LuckyDrawEventsService()
+			this.refreshList()
 		},
 		methods: {
-			IsCard(e) {
-				this.isCard = e.detail.value
-			},
-			aaa() {
-				uni.navigateTo({
-				  url: '/pages/test/luckyDraw/LuckyDrawEventsDetail'
+			refreshList() {
+			  this.loading = true
+			  this.luckyDrawEventsService.list({
+				  'current': '1',
+				  'size': '-1',
+				  ...this.searchForm
+				}).then(({data}) => {
+				  this.dataList = data.records
+				  this.tablePage.total = data.total
+				  this.loading = false
 				})
+				
+			},
+			// 跳转活动详情页面
+			detail(id, switchFlag) {
+				if (switchFlag === '1') {
+					// 活动进行中
+					uni.navigateTo({
+					  url: '/pages/test/luckyDraw/LuckyDrawEventsDetail?eventId='+id
+					})
+				} else {
+					// 活动未开始
+					uni.showToast({
+						title: '活动未开始,请选择进行中的项目参与',
+						icon: 'none',
+						duration: 1500
+					})
+				}
+				
 			}
 		}
 	}

+ 30 - 97
pages/test/luckyDraw/LuckyDrawEventsDetail.vue

@@ -4,32 +4,28 @@
 			<cu-custom :isBack="true" bgColor="bg-gradual-blue">
 				<block slot="backText">返回</block>
 				<block slot="content">活动详情</block>
-				<block slot="right" >
+				<!-- <block slot="right" >
 					<view  @click="bm()">
 						报名
 					</view>
-				</block>
+				</block> -->
 			</cu-custom>
 		</view>
 		<view class="cu-card article">
 			<view class="cu-item shadow">
+				<!-- 活动名称 -->
 				<view class="title">
-					<view class="text-center"> 活动名称三 </view>
+					<view class="text-center"> {{dataDetail.name}} </view>
 				</view>
-
+				<!-- 活动详情 -->
 				<view class="content">
-
 					<view class="desc">
-						<view class="text-content"> 活动详情活动详情活动详情活动详情活动详情活动详情活动详 </view>
-						<!-- <view>
-							<view class="cu-tag bg-grey light sm ">未开始</view>
-						</view> -->
+						<view class="text-content"> {{dataDetail.detail}} </view>
 					</view>
-
 				</view>
+				<!-- 图片 -->
 				<view class="content">
-					<image style="width: 100%;" src="https://ossweb-img.qq.com/images/lol/web201310/skin/big91012.jpg"
-						mode="widthFix"></image>
+					<image style="width: 100%;" src="/static/lucky_draw_events.png" mode="widthFix"></image>
 				</view>
 				
 				<view class=" padding-lr" :key="'00'" :id="'00'">
@@ -42,7 +38,7 @@
 						</view>
 					</view>
 				</view>
-				<view class="padding-top padding-lr" v-for="(item,index) in awards" :key="index" :id="'main-'+index">
+				<view class="padding-top padding-lr" v-for="(item,index) in dataDetail.luckyDrawAwardsDTOList" :key="index" :id="'main-'+index">
 					<view class="cu-bar solid-bottom bg-white">
 						<view class="action">
 							<text class="cuIcon-present text-green"></text>
@@ -58,114 +54,51 @@
 						</view>
 					</view>
 				</view>
+				<view class=" margin-top" style="padding-left: 10px;padding-right: 10px;">
+					<button style="width: 100%;" class='cu-btn lg bg-gradual-blue shadow ' @click="signUp()">报名</button>
+				</view>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script>
+	import LuckyDrawEventsService from '@/api/test/luckyDraw/LuckyDrawEventsService'
 	export default {
 		data() {
 			return {
 				list: [],
-				tabCur: 0,
-				mainCur: 0,
-				verticalNavTop: 0,
-				load: true,
-				awards: [{
-						name: '奖项一',
-						number: 15,
-						prizeName: 'iphone14 pro'
-					},
-					{
-						name: '奖项二',
-						number: 20,
-						prizeName: '金士顿电饭锅'
-					},
-					{
-						name: '奖项三',
-						number: 25,
-						prizeName: '海盗船电动牙刷'
-					}
-				]
+				dataDetail: {}
 			};
 		},
-		onLoad() {
-			uni.showLoading({
-				title: '加载中...',
-				mask: true
-			});
-			let list = [{}];
-			for (let i = 0; i < 3; i++) {
-				list[i] = {};
-				list[i].name = String.fromCharCode(65 + i);
-				list[i].id = i;
-			}
-			this.list = list;
-			this.listCur = list[0];
+		luckyDrawEventsService: null,
+		onLoad(option) {
+			this.luckyDrawEventsService = new LuckyDrawEventsService()
+			let { eventId } = option
+			this.init(eventId)
 		},
 		onReady() {
-			uni.hideLoading()
 		},
 		methods: {
-			bm() {
+			// 数据初始化方法
+			init(id) {
+				this.luckyDrawEventsService.queryById(id).then(({data}) => {
+				  this.dataDetail = data
+				})
+			},
+			// 跳转活动报名页面   参数eventId为活动id
+			signUp() {
 				uni.navigateTo({
-				  url: '/pages/test/luckyDraw/LuckyDrawRegister'
+				  url: '/pages/test/luckyDraw/LuckyDrawRegister?eventId='+this.dataDetail.id
 				})
 			},
+			// 跳转活动中奖信息页面   参数eventId为活动id
 			toLottery() {
 				uni.navigateTo({
-				  url: '/pages/test/luckyDraw/LuckyDrawLottery'
+				  url: '/pages/test/luckyDraw/LuckyDrawShowList?eventId='+this.dataDetail.id
 				})
 			}
 		},
 	}
 </script>
 
-<style>
-	.fixed {
-		position: fixed;
-		z-index: 99;
-	}
-
-	.VerticalNav.nav {
-		width: 200upx;
-		white-space: initial;
-	}
-
-	.VerticalNav.nav .cu-item {
-		width: 100%;
-		text-align: center;
-		background-color: #fff;
-		margin: 0;
-		border: none;
-		height: 50px;
-		position: relative;
-	}
-
-	.VerticalNav.nav .cu-item.cur {
-		background-color: #f1f1f1;
-	}
-
-	.VerticalNav.nav .cu-item.cur::after {
-		content: "";
-		width: 8upx;
-		height: 30upx;
-		border-radius: 10upx 0 0 10upx;
-		position: absolute;
-		background-color: currentColor;
-		top: 0;
-		right: 0upx;
-		bottom: 0;
-		margin: auto;
-	}
-
-	.VerticalBox {
-		display: flex;
-	}
-
-	.VerticalMain {
-		background-color: #f1f1f1;
-		flex: 1;
-	}
-</style>

+ 90 - 0
pages/test/luckyDraw/LuckyDrawEvents_pc.vue

@@ -0,0 +1,90 @@
+<template>
+	<view>
+		<cu-custom bgColor="bg-gradual-blue" ><block slot="content">活动中心</block></cu-custom>
+
+		<view class="cu-card article">
+			<view class="cu-item shadow" v-for="item in dataList" @click="detail(item.id, item.switchFlag)">
+				<view class="title">
+					<view class="text-cut"> {{item.name}} </view>
+				</view>
+				<view class="content">
+					<image src="/static/lucky_draw_events.png"
+					 mode="aspectFill"></image>
+					<view class="desc">
+						<view class="text-content"> {{item.detail}} </view>
+						<view>
+							<view :class="item.switchFlag === '1' ? 'cu-tag bg-green light sm' : 'cu-tag bg-grey light sm' ">
+								{{item.switchFlag === '1' ? '进行中' : '未开始'}}
+							</view>
+						</view>
+					</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+import LuckyDrawEventsService from '@/api/test/luckyDraw/LuckyDrawEventsService'
+	export default {
+		data() {
+			return {
+				dataList: [],
+				loading: false,
+				searchForm: {},
+				tablePage: {
+					total: ''
+				}
+			};
+		},
+		luckyDrawEventsService: null,
+		onLoad(option) {
+			let { is_sucess } = option
+			if (is_sucess == '200') {
+				uni.showToast({
+					title: '报名成功',
+					icon: 'sucess',
+					duration: 1500
+				})
+			}
+			this.luckyDrawEventsService = new LuckyDrawEventsService()
+			this.refreshList()
+		},
+		methods: {
+			refreshList() {
+			  this.loading = true
+			  this.luckyDrawEventsService.list({
+				  'current': '1',
+				  'size': '-1',
+				  ...this.searchForm
+				}).then(({data}) => {
+				  this.dataList = data.records
+				  this.tablePage.total = data.total
+				  this.loading = false
+				})
+				
+			},
+			// 跳转活动详情页面
+			detail(id, switchFlag) {
+				if (switchFlag === '1') {
+					// 活动进行中
+					uni.navigateTo({
+					  url: '/pages/test/luckyDraw/LuckyDrawList?eventId='+id
+					})
+				} else {
+					// 活动未开始
+					uni.showToast({
+						title: '活动未开始,请选择进行中的项目参与',
+						icon: 'none',
+						duration: 1500
+					})
+				}
+				
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>

+ 6 - 4
pages/test/luckyDraw/LuckyDrawList.vue

@@ -81,9 +81,10 @@
       }
     },
     testMobileService: null,
-	onLoad() {
+	onLoad(option) {
 	  this.testMobileService = new TestMobileService()
-	  this.refreshList()
+			let { eventId } = option
+	  this.refreshList(eventId)
 	},
     methods: {
 	  // 新增
@@ -112,19 +113,20 @@
 	  						title: data.msg,
 	  						icon:"success"
 	  					})
-	  					this.refreshList()
+	  					this.refreshList(id)
 	  				})
 	  			}
 	  		}
 	  	});
 	  },
 	  /*获取数据列表 */
-	  refreshList() {
+	  refreshList(eventId) {
 	    this.loading = true
 	    this.testMobileService.list({
 	  	  'current': this.tablePage.currentPage,
 	  	  'size': this.tablePage.pageSize,
 	  	  'orders': this.tablePage.orders,
+	  	  'id': eventId,
 	  	  ...this.searchForm
 	  	}).then(({data}) => {
 	  	  this.dataList = data.records

+ 60 - 19
pages/test/luckyDraw/LuckyDrawRegister.vue

@@ -4,42 +4,83 @@
 			<block slot="backText">返回</block>
 			<block slot="content">活动报名</block>
 		</cu-custom>
-		<form>
+		<form @submit="formSubmit()">
 			<view class="cu-form-group margin-top">
-				<view class="title">姓名</view>
-				<input placeholder="请输入姓名" name="name"></input>
+				<view class="title"><text class="red-color ">* </text>姓名</view>
+				<input placeholder="请输入姓名" name="name" v-model="inputForm.name"></input>
 			</view>
-			<view class="cu-form-group margin-top">
-				<view class="title">部门</view>
-				<input placeholder="请输入部门" name="officeName"></input>
+			<view class="cu-form-group ">
+				<view class="title"><text class="red-color ">* </text>部门</view>
+				<picker @change="changeOffice" :value="officeIndex" :range="officeList">
+					<view class="picker">
+						{{officeIndex>-1?officeList[officeIndex]:'请选择'}}
+					</view>
+				</picker>
 			</view>
-			<view class="cu-form-group margin-top">
-				<view class="title">电话号码</view>
-				<input placeholder="请输入电话号码" name="mobile"></input>
+			<view class="cu-form-group ">
+				<view class="title"><text class="red-color ">* </text>电话号码</view>
+				<input placeholder="请输入电话号码" name="phone" v-model="inputForm.phone"></input>
 			</view>
-			<view class=" margin-top" style="padding-left: 10px;padding-right: 10px;">
-				<button style="width: 100%;" class='cu-btn lg bg-green shadow ' @click="submit()">提交</button>
+			<view class=" margin-top" style="padding-left: 7px;padding-right: 7px;">
+				<button style="width: 100%;" class='cu-btn lg bg-gradual-blue shadow ' form-type="submit">提交</button>
 			</view>
 		</form>
 	</view>
 </template>
 
 <script>
+	var  graceChecker = require("@/common/graceChecker.js");
+	import LuckyDrawMembersService from '@/api/test/luckyDraw/LuckyDrawMembersService.js'
 	export default {
 		data() {
 			return {
-				isCard: false
+				eventId: '',
+				inputForm: {
+					name: '',
+					officeName: '',
+					mobile: '',
+					eventId: ''
+				},
+				officeList: [
+					'工程一部','工程二部','工程三部','工程四部','工程五部','其他'
+				],
+				officeIndex: -1
 			};
 		},
+		luckyDrawMembersService: null,
+		onLoad(option) {
+			this.luckyDrawMembersService = new LuckyDrawMembersService()
+			let { eventId } = option
+			this.inputForm.eventId = eventId
+		},
 		methods: {
-			IsCard(e) {
-				this.isCard = e.detail.value
+			formSubmit: function(e) {
+				//定义表单规则
+				var rule = [
+					  {name:"name", checkType : "notnull", checkRule:"",  errorMsg:"姓名不能为空"},
+					  {name:"officeName", checkType : "notnull", checkRule:"",  errorMsg:"部门不能为空"},
+					  {name:"phone", checkType : "notnull", checkRule:"",  errorMsg:"电话号码不能为空"},
+					  {name:"phone", checkType : "isMobile", checkRule:"",  errorMsg:"电话号码格式不正确"}
+				];
+				//进行表单检查
+				var formData = this.inputForm;
+				var checkRes = graceChecker.check(formData, rule);
+				if(checkRes){
+					uni.showLoading()
+					this.luckyDrawMembersService.save(this.inputForm).then(({data}) => {
+						uni.showToast({title:data, icon:"success"});
+						uni.navigateTo({
+						  url: '/pages/test/luckyDraw/LuckyDrawEvents?is_sucess='+'200'
+						})
+					}).catch((e)=>{
+					})
+				}else{
+					uni.showToast({ title: graceChecker.error, icon: "none" });
+				}
 			},
-			submit() {
-				let is_sucess = '200'
-				uni.navigateTo({
-				  url: '/pages/test/luckyDraw/LuckyDrawEvents?is_sucess=200'
-				})
+			changeOffice(e){
+				this.officeIndex = e.target.value;
+				this.inputForm.officeName = this.officeList[this.officeIndex]
 			}
 		}
 	}

+ 8 - 43
pages/test/luckyDraw/LuckyDrawShowList.vue

@@ -1,9 +1,9 @@
 <template>
 	<view>
-		<!-- <cu-custom bgColor="bg-blue" :isBack="true">
+		<cu-custom :isBack="true" bgColor="bg-gradual-blue">
 			<block slot="backText">返回</block>
-			<block slot="content"> 测试移动表单</block>
-		</cu-custom> -->
+			<block slot="content">中奖清单</block>
+		</cu-custom>
 		<view>
 			<view class="uni-container">
 				<uni-table ref="table" :loading="loading" stripe  emptyText="暂无更多数据" @selection-change="selectionChange">
@@ -75,50 +75,20 @@
       }
     },
     testMobileService: null,
-	onLoad() {
+	onLoad(option) {
 	  this.testMobileService = new TestMobileService()
-	  this.refreshList()
+		let { eventId } = option
+	  this.refreshList(eventId)
 	},
     methods: {
-	  // 新增
-	  add (){
-	  	uni.navigateTo({
-	  	  url: '/pages/test/mobile/TestMobileForm'
-	  	})
-	  },
-	  // 修改
-	  edit (id) {
-	  	uni.navigateTo({
-	  	  url: '/pages/test/mobile/TestMobileForm?id='+id
-	  	})
-	  },
-      // 删除
-	  LuckyDraw (id,number,awardId) {
-	  	uni.showModal({
-	  		title: '提示',
-	  		content: '您确认要对该奖项进行抽奖吗',
-	  		showCancel: true,
-	  		success: (res) => {
-	  			if (res.confirm) {
-	  				this.testMobileService.LuckyDraw(id,number,awardId).then(({data})=>{
-						console.log(data)
-	  					uni.showToast({
-	  						title: data.msg,
-	  						icon:"success"
-	  					})
-	  					this.refreshList()
-	  				})
-	  			}
-	  		}
-	  	});
-	  },
 	  /*获取数据列表 */
-	  refreshList() {
+	  refreshList(eventId) {
 	    this.loading = true
 	    this.testMobileService.list({
 	  	  'current': this.tablePage.currentPage,
 	  	  'size': this.tablePage.pageSize,
 	  	  'orders': this.tablePage.orders,
+	  	  'id': eventId,
 	  	  ...this.searchForm
 	  	}).then(({data}) => {
 	  	  this.dataList = data.records
@@ -139,11 +109,6 @@
 	  searchChangeHandle (column) {
 		this.searchForm[column.property] = column.filter
 		this.refreshList()
-	  },
-	// 分页触发
-	  currentChangeHandle (e) {
-		this.tablePage.currentPage = e.current
-		this.refreshList()
 	  }
     }
   }

BIN
static/lucky_draw_events.png