Commit e44907b9 by TengFengLian

活动接口

parent eed85aaf
......@@ -9,12 +9,18 @@ Page({
info: {},
activeState: 0, //0 未开始 1进行中 2已结束
stateText: '未开始',
// 接口参数
id: '',
},
onLoad: function (options) {
this.queryDetail()
// this.queryDetail()
this.setData({
id: options.id
})
this.getActivityDetail()
},
/**
......@@ -51,8 +57,26 @@ Page({
},
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({
url: '/pages/activity-entry/activity-entry'
url: '/pages/activity-entry/activity-entry?id='+this.data.id
})
},
......@@ -71,6 +95,41 @@ Page({
//主题活动详情
getActivityDetail(){
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 @@
</view>
<view class="contact">
<l-button size="long" bindtap="onContact">立即报名</l-button>
<l-button size="long" bindtap="onContact">{{stateText}}</l-button>
</view>
</view>
\ No newline at end of file
import iMiment from '../../npm/miment.js'
const app = getApp()
Page({
data: {
formType: 1,
entryComplete: false,
// formType: 1,
// entryComplete: false,
formInto: {
name: '',
phone: '',
quantity: 0,
date: '',
// date: '',
},
activityImage: './image/entry-1.png',
activityName: '',
activeTime: '',
activityTimes: [{beginTime:'',endTime:''}],// 活动场次
activityIndex: 0,
// 接口参数
id: '',
},
onLoad: function (options) {
this.setData({
formType: Number(options.type)
id: options.id
})
this.setReset()
// this.setReset()
this.getEnrollView()
},
setReset: function () {
let funcDate = iMiment(new Date().getTime()).format('YYYY-MM-DD')
let funcFormInto = {
name: '',
phone: '',
quantity: 0,
date: funcDate,
}
// setReset: function () {
// let funcDate = iMiment(new Date().getTime()).format('YYYY-MM-DD')
// let funcFormInto = {
// name: '',
// phone: '',
// quantity: 0,
// date: funcDate,
// }
this.setData({
formInto: funcFormInto,
appointmentDate: funcDate,
})
},
// this.setData({
// formInto: funcFormInto,
// appointmentDate: funcDate,
// })
// },
onQuantityCut: function () {
let funcFormInto = this.data.formInto
......@@ -48,25 +58,40 @@ Page({
onQuantityAdd: function () {
let funcFormInto = this.data.formInto
if (funcFormInto.quantity < 5) {
funcFormInto.quantity = funcFormInto.quantity + 1
} else {
let activityTime = this.data.activityTimes[this.data.activityIndex]
if (funcFormInto.quantity >= activityTime.residue*1) {
wx.lin.showToast({
title: '该场次剩余名额' + activityTime.residue + '人',
icon: 'error',
})
} else if (funcFormInto.quantity >= 5) {
wx.lin.showToast({
title: '每个账号最多预约5人',
icon: 'error',
})
} else {
funcFormInto.quantity = funcFormInto.quantity + 1
}
this.setData({
formInto: funcFormInto
})
},
onSelectionDate: function (event) {
let funcFormInto = this.data.formInto
funcFormInto.date = event.detail.value
console.log(event)
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 () {
......@@ -76,9 +101,7 @@ Page({
},
onSubmit: function () {
this.setData({
entryComplete: true
})
this.doActivityEnroll()
},
onEntryComplete: function () {
......@@ -89,4 +112,93 @@ Page({
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 @@
<view class="entry-tip row align-c">
<view class="row align-c">
<image src="./image/entry-1.png"></image>
<image src="{{activityImage}}"></image>
</view>
<view class="col">
<text class="entry-tip-title">艺术花坊插花交流分享会</text>
<text class="entry-tip-date">6月30日-7月15日 10:00-12:00</text>
<text class="entry-tip-title">{{activityName}}</text>
<text class="entry-tip-date">{{activeTime}}</text>
</view>
</view>
......@@ -34,7 +34,7 @@
<text space="ensp">姓 名</text>
</view>
<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 class="row align-c">
......@@ -42,7 +42,7 @@
<text space="ensp">手 机 号</text>
</view>
<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 class="row align-c">
......@@ -64,8 +64,12 @@
<text space="ensp">报名时间</text>
</view>
<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>
</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>
<image class="input-icon" src="../../image/more.png"></image>
</view>
......
......@@ -125,6 +125,7 @@
.input-picker {
flex-grow: 1;
font-size: 30rpx;
}
.quota {
......
......@@ -87,7 +87,7 @@
</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>
</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