|
@@ -1,6 +1,7 @@
|
|
const WP = require('../../lib/wxParse/wxParse.js')
|
|
const WP = require('../../lib/wxParse/wxParse.js')
|
|
const { getLotteryDetail, drawLottery, invite } = require('../../utils/API.js')
|
|
const { getLotteryDetail, drawLottery, invite } = require('../../utils/API.js')
|
|
const USER_INFO = wx.getStorageSync('USER_INFO')
|
|
const USER_INFO = wx.getStorageSync('USER_INFO')
|
|
|
|
+const bus = require('../../utils/bus.js')
|
|
const NOTICE = `Lucky Maker作为提供抽奖服务的平台, 不对第三方发起人行为承担任何责任。活动奖品均由发起人提供并派发,Lucky Maker会在法律范围内尽可能地规范实行抽奖活动,感谢支持。`
|
|
const NOTICE = `Lucky Maker作为提供抽奖服务的平台, 不对第三方发起人行为承担任何责任。活动奖品均由发起人提供并派发,Lucky Maker会在法律范围内尽可能地规范实行抽奖活动,感谢支持。`
|
|
|
|
|
|
Page({
|
|
Page({
|
|
@@ -20,14 +21,15 @@ Page({
|
|
download_url:'', // 下载链接
|
|
download_url:'', // 下载链接
|
|
invited_user_avatars: [], // 我邀请的队友
|
|
invited_user_avatars: [], // 我邀请的队友
|
|
lottery_user_count: 0, // 抽奖参与总人数
|
|
lottery_user_count: 0, // 抽奖参与总人数
|
|
- lottery_user_avatars: 0, // 参与抽奖的用户头像
|
|
|
|
|
|
+ lottery_user_avatars: [], // 参与抽奖的用户头像
|
|
user_lottery_codes: [], // 用户的抽奖码
|
|
user_lottery_codes: [], // 用户的抽奖码
|
|
recommend_lottery: {}, // 推荐的抽奖
|
|
recommend_lottery: {}, // 推荐的抽奖
|
|
visit_count: 0, // 浏览数
|
|
visit_count: 0, // 浏览数
|
|
user_draw_state: 0, // 用户抽奖状态
|
|
user_draw_state: 0, // 用户抽奖状态
|
|
- isFold: true,
|
|
|
|
|
|
+ isFold: false, // 当前内容折叠状态
|
|
|
|
+ needFold: false, // 当前内容高度是否需要折叠
|
|
modalVisiable: false,
|
|
modalVisiable: false,
|
|
- notice: NOTICE
|
|
|
|
|
|
+ notice: NOTICE
|
|
},
|
|
},
|
|
swipeTo(ev) {
|
|
swipeTo(ev) {
|
|
const { index } = ev.target.dataset
|
|
const { index } = ev.target.dataset
|
|
@@ -43,15 +45,25 @@ Page({
|
|
toggleFold() {
|
|
toggleFold() {
|
|
this.setData({ isFold: !this.data.isFold })
|
|
this.setData({ isFold: !this.data.isFold })
|
|
},
|
|
},
|
|
|
|
+ // 根据抽奖内容多少判断是否需要折叠
|
|
|
|
+ _judgeContentHeight(){
|
|
|
|
+ wx.createSelectorQuery().select('.award-article').boundingClientRect(nodeRef => {
|
|
|
|
+ nodeRef.height > 1000 ? this.setData({needFold: true}) : this.setData({needFold: false})
|
|
|
|
+ }).exec()
|
|
|
|
+ },
|
|
// 点击抽奖按钮事件处理函数
|
|
// 点击抽奖按钮事件处理函数
|
|
handleDrawLottery() {
|
|
handleDrawLottery() {
|
|
const { id } = this.data
|
|
const { id } = this.data
|
|
drawLottery(id)
|
|
drawLottery(id)
|
|
.then(data => {
|
|
.then(data => {
|
|
|
|
+ const {user_lottery_codes, avatar_url} = data.data
|
|
wx.showToast({ title: data.msg })
|
|
wx.showToast({ title: data.msg })
|
|
this.setData({
|
|
this.setData({
|
|
- user_draw_state: 1
|
|
|
|
- })
|
|
|
|
|
|
+ user_draw_state: 1,
|
|
|
|
+ user_lottery_codes,
|
|
|
|
+ lottery_user_avatars: this.data.lottery_user_avatars.concat(avatar_url)
|
|
|
|
+ })
|
|
|
|
+ bus.emit('user_draw_lottery', id)
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
wx.showToast({ title: err.msg })
|
|
wx.showToast({ title: err.msg })
|
|
@@ -97,7 +109,7 @@ Page({
|
|
visit_count,
|
|
visit_count,
|
|
download_url,
|
|
download_url,
|
|
lottery_user_avatars
|
|
lottery_user_avatars
|
|
- } = data.data
|
|
|
|
|
|
+ } = data.data
|
|
this.setData({
|
|
this.setData({
|
|
cover_images,
|
|
cover_images,
|
|
title,
|
|
title,
|
|
@@ -108,8 +120,9 @@ Page({
|
|
winner_codes,
|
|
winner_codes,
|
|
state,
|
|
state,
|
|
invited_user_avatars: invited_user_avatars.slice(0, 24),
|
|
invited_user_avatars: invited_user_avatars.slice(0, 24),
|
|
- lottery_user_count,
|
|
|
|
- user_lottery_codes,
|
|
|
|
|
|
+ lottery_user_count,
|
|
|
|
+ // 抽奖结束时判断用户是否中奖
|
|
|
|
+ user_lottery_codes: state === '2' ? user_lottery_codes.map(code => ({code, isWin: winner_codes.includes(code)})) : user_lottery_codes.map(code => ({code, isWin: false})),
|
|
recommend_lottery,
|
|
recommend_lottery,
|
|
user_draw_state,
|
|
user_draw_state,
|
|
id,
|
|
id,
|
|
@@ -118,7 +131,8 @@ Page({
|
|
download_url,
|
|
download_url,
|
|
lottery_user_avatars
|
|
lottery_user_avatars
|
|
})
|
|
})
|
|
- WP.wxParse('article', 'html', body, this, 5)
|
|
|
|
|
|
+ WP.wxParse('article', 'html', body, this, 5)
|
|
|
|
+ this._judgeContentHeight()
|
|
})
|
|
})
|
|
},
|
|
},
|
|
seeAll() {
|
|
seeAll() {
|