Commit e44907b9 by TengFengLian

活动接口

parent eed85aaf
...@@ -9,12 +9,18 @@ Page({ ...@@ -9,12 +9,18 @@ Page({
info: {}, info: {},
activeState: 0, //0 未开始 1进行中 2已结束
stateText: '未开始',
// 接口参数 // 接口参数
id: '', id: '',
}, },
onLoad: function (options) { onLoad: function (options) {
this.queryDetail() // this.queryDetail()
this.setData({
id: options.id
})
this.getActivityDetail()
}, },
/** /**
...@@ -51,8 +57,26 @@ Page({ ...@@ -51,8 +57,26 @@ Page({
}, },
onContact: function () { onContact: function () {
switch(this.data.activeState) {
case 0:
wx.lin.showToast({
title: '活动未开始',
icon: 'error',
})
return
break;
case 1:
break;
case 2:
wx.lin.showToast({
title: '报名已截止',
icon: 'error',
})
return
break;
}
wx.navigateTo({ wx.navigateTo({
url: '/pages/activity-entry/activity-entry' url: '/pages/activity-entry/activity-entry?id='+this.data.id
}) })
}, },
...@@ -71,6 +95,41 @@ Page({ ...@@ -71,6 +95,41 @@ Page({
//主题活动详情 //主题活动详情
getActivityDetail(){ getActivityDetail(){
var that = this var that = this
app.wxRequest({
url: '/api/v1/activity/getDetail',
data: { id: that.data.id },
success: function(res) {
var response = res.data.jsonobject
that.setData({
banner: response.banners,
info: {
title: response.name,
date: response.activeDate + ' ' + response.activeTime,
address: response.address,
quota: response.enrollNum,
describe: response.summary,
// contact: response.contact,
}
})
that.configActiveState(response.activeState*1)
}
})
},
configActiveState(state) {
var text = this.data.stateText
switch(state) {
case 0:text = '未开始'
break;
case 1:text = '立即报名'
break;
case 2:text = '报名已截止'
break;
}
this.setData({
activeState: state,
stateText: text,
})
} }
}) })
\ No newline at end of file
...@@ -42,6 +42,6 @@ ...@@ -42,6 +42,6 @@
</view> </view>
<view class="contact"> <view class="contact">
<l-button size="long" bindtap="onContact">立即报名</l-button> <l-button size="long" bindtap="onContact">{{stateText}}</l-button>
</view> </view>
</view> </view>
\ No newline at end of file
import iMiment from '../../npm/miment.js' import iMiment from '../../npm/miment.js'
const app = getApp()
Page({ Page({
data: { data: {
formType: 1, // formType: 1,
entryComplete: false, // entryComplete: false,
formInto: { formInto: {
name: '', name: '',
phone: '', phone: '',
quantity: 0, quantity: 0,
date: '', // date: '',
}, },
activityImage: './image/entry-1.png',
activityName: '',
activeTime: '',
activityTimes: [{beginTime:'',endTime:''}],// 活动场次
activityIndex: 0,
// 接口参数
id: '',
}, },
onLoad: function (options) { onLoad: function (options) {
this.setData({ this.setData({
formType: Number(options.type) id: options.id
}) })
this.setReset() // this.setReset()
this.getEnrollView()
}, },
setReset: function () { // setReset: function () {
let funcDate = iMiment(new Date().getTime()).format('YYYY-MM-DD') // let funcDate = iMiment(new Date().getTime()).format('YYYY-MM-DD')
let funcFormInto = { // let funcFormInto = {
name: '', // name: '',
phone: '', // phone: '',
quantity: 0, // quantity: 0,
date: funcDate, // date: funcDate,
} // }
this.setData({ // this.setData({
formInto: funcFormInto, // formInto: funcFormInto,
appointmentDate: funcDate, // appointmentDate: funcDate,
}) // })
}, // },
onQuantityCut: function () { onQuantityCut: function () {
let funcFormInto = this.data.formInto let funcFormInto = this.data.formInto
...@@ -48,25 +58,40 @@ Page({ ...@@ -48,25 +58,40 @@ Page({
onQuantityAdd: function () { onQuantityAdd: function () {
let funcFormInto = this.data.formInto let funcFormInto = this.data.formInto
if (funcFormInto.quantity < 5) { let activityTime = this.data.activityTimes[this.data.activityIndex]
funcFormInto.quantity = funcFormInto.quantity + 1 if (funcFormInto.quantity >= activityTime.residue*1) {
} else { wx.lin.showToast({
title: '该场次剩余名额' + activityTime.residue + '人',
icon: 'error',
})
} else if (funcFormInto.quantity >= 5) {
wx.lin.showToast({ wx.lin.showToast({
title: '每个账号最多预约5人', title: '每个账号最多预约5人',
icon: 'error', icon: 'error',
}) })
} else {
funcFormInto.quantity = funcFormInto.quantity + 1
} }
this.setData({ this.setData({
formInto: funcFormInto formInto: funcFormInto
}) })
}, },
onSelectionDate: function (event) { onSelectionDate: function (event) {
let funcFormInto = this.data.formInto console.log(event)
funcFormInto.date = event.detail.value
this.setData({ this.setData({
formInto: funcFormInto activityIndex: event.detail.value*1
})
// 切换报名场次更新重置报名人数
this.setData({
['formInto.quantity']: 0
}) })
// let funcFormInto = this.data.formInto
// funcFormInto.date = event.detail.value
// this.setData({
// formInto: funcFormInto
// })
}, },
onServic: function () { onServic: function () {
...@@ -76,9 +101,7 @@ Page({ ...@@ -76,9 +101,7 @@ Page({
}, },
onSubmit: function () { onSubmit: function () {
this.setData({ this.doActivityEnroll()
entryComplete: true
})
}, },
onEntryComplete: function () { onEntryComplete: function () {
...@@ -89,4 +112,93 @@ Page({ ...@@ -89,4 +112,93 @@ Page({
delta: 1 delta: 1
}) })
}, },
bindNameInput: function (e) {
this.setData({
['formInto.name']: e.detail.value
})
},
bindPhoneInput: function (e) {
this.setData({
['formInto.phone']: e.detail.value
})
},
//活动报名页
getEnrollView(){
var that = this
app.wxRequest({
url: '/api/v1/activity/getEnrollView',
data: { id: that.data.id },
success: function(res) {
var response = res.data.jsonobject
var activityTimes = []
response.activityTimes.forEach(item => {
var obj = item
obj.date = item.beginTime + ' - ' + item.endTime
activityTimes.push(obj)
})
that.setData({
activityImage: response.cover,
activityName: response.name,
activeTime: response.activeDate + ' ' + response.activeTime,
activityTimes: activityTimes,
})
}
})
},
// 活动报名
doActivityEnroll() {
var activityTime = this.data.activityTimes[this.data.activityIndex]
console.log(activityTime)
if (activityTime.residue*1 == 0) {
wx.lin.showToast({
title: '该场次已没剩余名额',
icon: 'error',
})
return
}
let formInto = this.data.formInto
if (formInto.name == ''){
wx.lin.showToast({
title: '请输入名字',
icon: 'error',
})
return
}
if (formInto.phone == ''){
wx.lin.showToast({
title: '请输入手机号',
icon: 'error',
})
return
}
if (formInto.quantity == 0){
wx.lin.showToast({
title: '请设置报名人数',
icon: 'error',
})
return
}
var that = this
app.wxRequest({
url: '/api/v1/activity/doActivityEnroll',
data: {
activityId: that.data.id,
activityTimesId: activityTime.id,
enrollNum: formInto.quantity,
name: formInto.name,
mobile: formInto.phone,
},
success: function(res) {
that.setData({
entryComplete: true
})
}
})
},
}) })
\ No newline at end of file
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
<view class="entry-tip row align-c"> <view class="entry-tip row align-c">
<view class="row align-c"> <view class="row align-c">
<image src="./image/entry-1.png"></image> <image src="{{activityImage}}"></image>
</view> </view>
<view class="col"> <view class="col">
<text class="entry-tip-title">艺术花坊插花交流分享会</text> <text class="entry-tip-title">{{activityName}}</text>
<text class="entry-tip-date">6月30日-7月15日 10:00-12:00</text> <text class="entry-tip-date">{{activeTime}}</text>
</view> </view>
</view> </view>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<text space="ensp">姓 名</text> <text space="ensp">姓 名</text>
</view> </view>
<view class="input-wrap row align-c"> <view class="input-wrap row align-c">
<input class="weui-input" placeholder-class="input-tip" placeholder="请输入名字"></input> <input maxlength="16" class="weui-input" placeholder-class="input-tip" placeholder="请输入名字" bindinput="bindNameInput"></input>
</view> </view>
</view> </view>
<view class="row align-c"> <view class="row align-c">
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<text space="ensp">手 机 号</text> <text space="ensp">手 机 号</text>
</view> </view>
<view class="input-wrap row align-c"> <view class="input-wrap row align-c">
<input class="weui-input" placeholder-class="input-tip" placeholder="请输入手机号"></input> <input maxlength="11" type="number" class="weui-input" placeholder-class="input-tip" placeholder="请输入手机号" bindinput="bindPhoneInput"></input>
</view> </view>
</view> </view>
<view class="row align-c"> <view class="row align-c">
...@@ -64,8 +64,12 @@ ...@@ -64,8 +64,12 @@
<text space="ensp">报名时间</text> <text space="ensp">报名时间</text>
</view> </view>
<view class="input-wrap row con-b align-c"> <view class="input-wrap row con-b align-c">
<picker class="input-picker" mode="date" value="{{date}}" start="{{appointmentDate}}" bindchange="onSelectionDate"> <!-- <picker class="input-picker" mode="date" value="{{date}}" start="{{appointmentDate}}" bindchange="onSelectionDate">
<view class="picker">{{formInto.date}}</view> <view class="picker">{{formInto.date}}</view>
</picker> -->
<picker class="input-picker" mode="selector" range-key="{{'date'}}" range="{{activityTimes}}" bindchange="onSelectionDate">
<!-- item.beginTime + ' - ' + item.endTime -->
<text class="picker">{{activityTimes[activityIndex].beginTime + '\n' + activityTimes[activityIndex].endTime}}</text>
</picker> </picker>
<image class="input-icon" src="../../image/more.png"></image> <image class="input-icon" src="../../image/more.png"></image>
</view> </view>
......
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
.input-picker { .input-picker {
flex-grow: 1; flex-grow: 1;
font-size: 30rpx;
} }
.quota { .quota {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</view> </view>
</view> </view>
</view> </view>
<view> <view style="margin-bottom:10px">
<l-water-flow column-gap="14rpx" generic:l-water-flow-item="strategy-item" bind:linitemtap="onStrategyDetail"></l-water-flow> <l-water-flow column-gap="14rpx" generic:l-water-flow-item="strategy-item" bind:linitemtap="onStrategyDetail"></l-water-flow>
</view> </view>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment