From 385946bc856d2060d696b9cebb005ff8e4c2557e Mon Sep 17 00:00:00 2001
From: qian <1694319867@qq.com>
Date: Wed, 26 Oct 2022 22:08:52 +0800
Subject: [PATCH] =?UTF-8?q?v2.2.3=202022-10-26=201.=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BA=BA=E6=95=B0=E8=87=AA=E5=8A=A8=E5=BC=80?=
=?UTF-8?q?=E5=A5=96=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages.json | 4 +-
pages/mine/mine.vue | 5 +
.../choujiangzhushou/choujiangzhushou.vue | 57 ++-
.../choujiangzhushou/jiaruchoujiang.vue | 325 +++++++++++++++---
readme.md | 6 +-
5 files changed, 334 insertions(+), 63 deletions(-)
diff --git a/pages.json b/pages.json
index 7970b14..f54af4e 100644
--- a/pages.json
+++ b/pages.json
@@ -92,8 +92,8 @@
}, {
"path": "pages/subpages/choujiangzhushou/jiaruchoujiang",
"style": {
- "navigationBarTitleText": "",
- "enablePullDownRefresh": false
+ "navigationBarTitleText": "参与抽奖",
+ "enablePullDownRefresh": true
}
}
diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue
index ee758f8..2cee974 100644
--- a/pages/mine/mine.vue
+++ b/pages/mine/mine.vue
@@ -245,6 +245,11 @@
1.添加抽奖助手界面
v2.2.1 2022-10-24
1.完善抽奖助手子页面
+ v2.2.2 2022-10-25
+ 1.实现抽奖页面创建加入界面
+ 2.实现抽奖页面创建后台逻辑
+ v2.2.3 2022-10-26
+ 1.实现根据人数自动开奖的功能
`;
uni.navigateTo({
url: `/pages/utils/showText/showText?nodes=${log}`
diff --git a/pages/subpages/choujiangzhushou/choujiangzhushou.vue b/pages/subpages/choujiangzhushou/choujiangzhushou.vue
index 69d2709..3825967 100644
--- a/pages/subpages/choujiangzhushou/choujiangzhushou.vue
+++ b/pages/subpages/choujiangzhushou/choujiangzhushou.vue
@@ -85,13 +85,13 @@
picUrl: app.globalData.website + '/image/other/image_tool_choujiangzhushou.jpg',
sharePicUrl: app.globalData.website + '/image/share/image_tool_choujiangzhushou.jpg',
awardName: '',
- awardNum: 1,
+ awardNum: 0,
awardDetail: '',
openType: ['按时间自动开奖', '按人数自动开奖', '发起者手动开奖'],
typeIndex: 0,
date: currentDate,
time: currenTime,
- openNeedUsers: 1,
+ openNeedUsers: 0,
awardId: '',
isCreate: false,
giftList: []
@@ -148,10 +148,32 @@
// 发起抽奖
start() {
const that = this;
+ if(that.awardName=='') {
+ that.toast('奖品名称','error');
+ return;
+ }
+ if(that.awardNum == 0) {
+ that.toast('奖品数量','error');
+ return;
+ }
+ if(that.awardDetail == '') {
+ that.toast('奖品说明','error');
+ return;
+ }
+ if((that.typeIndex == 1)&&(that.openNeedUsers == 0)) {
+ that.toast('抽奖人数','error');
+ return;
+ }
+ if((that.typeIndex == 1)&&(that.awardNum >= that.openNeedUsers)) {
+ that.toast('奖品太多','error');
+ return;
+ }
const openDateTime = this.date + ' ' + this.time;
const startDateTime = this.getDate() + ' ' + this.getTime();
let rst = {
- openId: app.globalData.openId,
+ ownerId: app.globalData.openId,
+ ownerImage: app.globalData.userInfo.avatarUrl,
+ ownerNickName: app.globalData.userInfo.nickName,
awardImage: this.picUrl,
awardName: this.awardName,
awardNum: this.awardNum,
@@ -170,6 +192,7 @@
method: 'POST',
data: rst,
success(res) {
+ console.log(res);
if (res.data.err == 1) {
uni.hideLoading();
uni.showToast({
@@ -218,6 +241,12 @@
hour = hour > 9 ? hour : '0' + hour;
minute = minute > 9 ? minute : '0' + minute;
return `${hour}:${minute}`;
+ },
+ toast(title, icon) {
+ uni.showToast({
+ title: title,
+ icon: icon
+ })
}
},
onShareAppMessage() {
@@ -310,7 +339,7 @@
.count {
width: 68%;
text-align: right;
- padding-right: 0;
+ padding-right: 10px;
flex: 10;
float: inline-start;
}
@@ -329,6 +358,7 @@
/* 开奖方式选择器 */
.type-picker {
flex: 3;
+ /* background-color: red; */
}
/* 显示开奖方式 */
@@ -341,8 +371,27 @@
/* 时间选择器 */
.picker-date,
.picker-time {
+ display: block;
+ width: auto;
+ justify-content: space-between;
+ float:right;
+ /* background-color: red; */
margin-right: 10px;
}
+
+ .picker-date {
+ flex: 7;
+ text-align: right;
+ }
+ .picker-time {
+ flex: 1;
+ }
+
+ /* 开奖时间 */
+ .item-etip {
+ padding: 10px;
+ flex: 3;
+ }
/* 发起抽奖 */
/* 分享抽奖 */
diff --git a/pages/subpages/choujiangzhushou/jiaruchoujiang.vue b/pages/subpages/choujiangzhushou/jiaruchoujiang.vue
index 6853c59..94c3901 100644
--- a/pages/subpages/choujiangzhushou/jiaruchoujiang.vue
+++ b/pages/subpages/choujiangzhushou/jiaruchoujiang.vue
@@ -3,23 +3,19 @@
- 奖品:{{awardName}}x{{awardNum}}
- {{openType==0?openDateTime + ' ':(openType==1?'满' + openNeedUsers + '人':'')}}自动开奖
+ 奖品: {{awardName}} x {{awardNum}}份
+ {{openType==0?openDateTime + ' ':(openType==1?'满' + openNeedUsers + '人':'')}}自动开奖
+ 奖品详情
+ {{awardDetail}}
-
- 已有100人参与
+
+ 已有 {{joinCount}} 人参与
-
-
-
-
-
-
-
-
-
+
@@ -30,46 +26,227 @@
export default {
data() {
return {
- picUrl: 'https://www.lailab.cn/miniprogram/image/other/image_tool_bayinhe.jpg',
- awardName: 'test',
- awardNum: 100,
+ awardId: 0,
+ picUrl: 'https://www.lailab.cn/miniprogram/image/share/image_tool_choujiangzhushou.jpg',
+ awardName: '',
+ awardNum: 0,
+ awardDetail: '',
openType: 0,
openDateTime: '2000-01-01 00:00',
+ userId: 0,
+ joinList: [],
+ joinCount: 0,
+ isOpened: false,
+ isJoin: false,
+ isClick: false,
+ isLockyClover: false
}
},
onLoad(option) {
- // console.log(option);
- // uni.showModal({
- // title: "欢迎加入",
- // content: "id为"+option.awardId,
- // })
const that = this;
- uni.request({
- url: app.globalData.website + '/tools/choujiangzhushou/getAwardInfo.php',
- method: 'POST',
- data: {
- awardId: option.awardId
- },
- success(res) {
- if(res.data.result.length > 0){
- const rst = res.data.result[0];
- that.picUrl = rst.awardImage;
- that.awardName = rst.awardName;
- that.awardNum = rst.awardNum;
- that.openDateTime = rst.openDateTime;
- that.openType = rst.openType;
- that.openNeedUsers = rst.openNeedUsers;
- }else {
- uni.showToast({
- title:'加入失败',
- icon: 'error'
- })
- }
- }
- })
+ that.awardId = option.awardId;
+ that.refresh();
},
methods: {
-
+ join() {
+ const that = this;
+ uni.showLoading({
+ title: '正在加入',
+ icon: 'loading'
+ });
+ uni.request({
+ url: app.globalData
+ .website +
+ "/tools/choujiangzhushou/userJoin.php",
+ method: 'POST',
+ data: {
+ awardId: that.awardId,
+ userId: that.userId
+ },
+ success(res1) {
+ console.log('5.用户加入', res1);
+ uni.hideLoading();
+ if (res1.data.err == 0) {
+ uni.showToast({
+ title: '加入失败',
+ icon: 'error',
+ });
+ } else if (res1.data.err == 1) {
+ uni.showToast({
+ title: '加入成功',
+ icon: 'success'
+ })
+ that.isJoin = true;
+ } else if (res1.data.err == 2) {
+ that.isClick = false;
+ uni.showLoading({
+ title: '正在开奖中',
+ icon: 'loading'
+ });
+ // 是否中奖
+ that.checkLuckyClover();
+ } else if (res1.data.err == 3) {
+ that.isClick = false;
+ uni.showToast({
+ title: "开奖失败",
+ icon: 'error'
+ })
+ } else {
+ uni.showModal({
+ title: '提示',
+ content: res1.data.msg
+ })
+ }
+ that.refresh();
+ }
+ });
+ },
+ load() {
+ var msg = '条件';
+ if (this.openType == 0) {
+ msg += this.openDateTime + ' ';
+ } else if (this.openType == 1) {
+ msg += '满' + this.openNeedUsers + '人';
+ }
+ msg += '开奖未满足,请等待开奖!';
+ uni.showModal({
+ title: '等待开奖',
+ content: msg,
+ })
+ },
+ refresh() {
+ const that = this;
+ that.joinList = [];
+ that.isJoin = false;
+ that.isClick = false;
+ // 请求奖品信息
+ uni.request({
+ url: app.globalData.website + '/tools/choujiangzhushou/getAwardInfo.php',
+ method: 'POST',
+ data: {
+ awardId: that.awardId
+ },
+ success(res) {
+ console.log("1.通过奖品ID获取奖品信息", res);
+ if (res.data.result.length > 0) {
+ const rst = res.data.result[0];
+ that.picUrl = rst.awardImage;
+ that.awardName = rst.awardName;
+ that.awardNum = rst.awardNum;
+ that.awardDetail = rst.awardDetail;
+ that.openDateTime = rst.openDateTime;
+ that.openType = rst.openType;
+ that.openNeedUsers = rst.openNeedUsers;
+ that.isOpened = rst.isOpened==1;
+ } else {
+ uni.showToast({
+ title: '加载失败',
+ icon: 'error'
+ })
+ }
+ if (that.isOpened) {
+ that.isClick = false;
+ }
+ }
+ });
+ uni.request({
+ url: app.globalData.website + "/api/getUserInfo.php",
+ method: 'POST',
+ data: {
+ openId: app.globalData.openId
+ },
+ success(res) {
+ console.log('2.通过openId获取用户Id', res);
+ if (res.data.result) {
+ that.userId = res.data.result[0].id;
+ } else {
+ uni.hideLoading();
+ console.log(res);
+ uni.showToast({
+ title: '加载成功',
+ icon: 'success'
+ })
+ }
+ // 若开奖,查看是否中奖品,放这里因为这里产生userId
+ if(that.isOpened) {
+ // 检测是否中奖
+ that.checkLuckyClover();
+ }
+ }
+ });
+ // 通过奖品ID查询各种信息
+ uni.request({
+ url: app.globalData.website + '/tools/choujiangzhushou/userJoinInfo.php',
+ method: 'POST',
+ data: {
+ awardId: that.awardId
+ },
+ success(res) {
+ console.log('3.通过奖品Id获取参与用户ID', res);
+ const users = res.data.result;
+ that.joinCount = Number(users.length);
+ for (var i = 0; i < users.length; i++) {
+ const user = users[i];
+ uni.request({
+ url: app.globalData.website + '/api/getUserInfoById.php',
+ method: 'POST',
+ data: {
+ id: user.userId
+ },
+ success(res1) {
+ console.log('4.通过userId获取用户信息(图像)', res1);
+ for (var i = 0; i < res1.data.result.length; i++) {
+ that.joinList.push({
+ userImg: res1.data.result[0].avatarUrl
+ });
+ }
+ }
+ });
+ if (user.userId == that.userId) {
+ that.isJoin = true;
+ }
+ }
+ setTimeout(function() {
+ if(!that.isOpened){
+ that.isClick = true;
+ }
+ }, 1000);
+ },
+ fail(res) {
+ console.log('访问失败', res);
+ }
+ });
+ // 若开奖停用按钮
+ if (that.isLockyClover) {
+ that.isClick = false;
+ }
+ },
+ checkLuckyClover() {
+ const that = this;
+ uni.request({
+ url: app.globalData.website + '/tools/choujiangzhushou/isluckyClover.php',
+ method: 'POST',
+ data: {
+ awardId: that.awardId,
+ userId: that.userId
+ },
+ success(res) {
+ console.log('6.查看是否中奖', res);
+ uni.hideLoading();
+ if (res.data.result) {
+ that.isLockyClover = res.data.result[0].luckyClover == 1;
+ }
+ }
+ })
+ }
+ },
+ onPullDownRefresh() {
+ this.refresh();
+ setTimeout(function() {
+ uni.hideNavigationBarLoading();
+ //完成停止加载图标
+ uni.stopPullDownRefresh();
+ }, 1000);
},
onShareAppMessage() {
return {
@@ -90,7 +267,8 @@
.gift-show {
height: auto;
width: 100%;
- background-color: #f6f7f9;
+ background-color: #ffffff;
+ padding: 10px 0;
}
/* 奖品图片展示 */
@@ -102,20 +280,45 @@
/* 奖品名称 */
.gift-name {
display: block;
- font-size: 23px;
- line-height: 40px;
- padding-left: 10px;
+ font-size: 18px;
+ line-height: 30px;
+ padding-left: 20px;
+ color: #262626;
}
/* 奖品开奖信息 */
.gift-open {
display: block;
- font-size: 18px;
- line-height: 25px;
- padding-left: 10px;
+ font-size: 12px;
+ line-height: 15px;
+ padding-left: 20px;
+ margin: 5px 0 10px 0;
color: gray;
}
+ /* 奖品详情文字 */
+ .gift-detail-tip {
+ display: inline-block;
+ width: 100%;
+ /* background-color: green; */
+ border-top: 10px solid #f6f7f9;
+ font-size: 15px;
+ color: #262626;
+ line-height: 30px;
+ padding-left: 20px;
+ }
+
+ /* 奖品详细信息 */
+ .gift-detail {
+ width: 100%;
+ display: inline-block;
+ padding: 2px 20px 20px 20px;
+ font-size: 17px;
+ color: #262626;
+ border-top: 2px solid #f6f7f9;
+ border-bottom: 10px solid #f6f7f9;
+ }
+
/* 操作视图 */
.action-view {
height: auto;
@@ -126,7 +329,7 @@
/* 参与抽奖 */
.gift-add {
height: 45px;
- margin-top: 20px;
+ margin-top: 10px;
background-color: orangered;
color: white;
border: 0;
@@ -134,7 +337,18 @@
font-weight: bold;
box-shadow: 0 0 10px orangered;
}
-
+
+ /* 参与抽奖-不启用 */
+ .gift-add-disable {
+ height: 45px;
+ margin-top: 10px;
+ color: white;
+ border: 0;
+ border-radius: 20px;
+ font-weight: bold;
+ box-shadow: 0;
+ }
+
/* 参与人数 */
.gift-person {
line-height: 30px;
@@ -145,7 +359,6 @@
.handimgs {
height: auto;
width: 100%;
- /* background-color: red; */
text-align: center;
overflow: scroll;
}
@@ -156,6 +369,6 @@
width: 50px;
margin: 2px;
border-radius: 50%;
- background-color: green;
+ background-color: #F6F7F9;
}
diff --git a/readme.md b/readme.md
index 48f40cb..c0c01e6 100644
--- a/readme.md
+++ b/readme.md
@@ -30,4 +30,8 @@ v2.2.2 2022-10-25
1.实现抽奖页面创建加入界面
-2.实现抽奖页面创建后台逻辑
\ No newline at end of file
+2.实现抽奖页面创建后台逻辑
+
+v2.2.3 2022-10-26
+
+1.实现根据人数自动开奖的功能
\ No newline at end of file