Commit 3effb392 by TengFengLian

设置活动状态显示

parent 5811e75b
...@@ -10,6 +10,7 @@ Page({ ...@@ -10,6 +10,7 @@ Page({
info: {}, info: {},
activeState: 0, //0 未开始 1进行中 2已结束 activeState: 0, //0 未开始 1进行中 2已结束
isSubmit: false,
stateText: '未开始', stateText: '未开始',
// 接口参数 // 接口参数
id: '', id: '',
...@@ -129,6 +130,7 @@ Page({ ...@@ -129,6 +130,7 @@ Page({
this.setData({ this.setData({
activeState: state, activeState: state,
stateText: text, stateText: text,
isSubmit: state == 1 ? true : false,
}) })
} }
......
...@@ -43,6 +43,6 @@ ...@@ -43,6 +43,6 @@
</view> </view>
<view class="contact"> <view class="contact">
<l-button size="long" bindtap="onContact">{{stateText}}</l-button> <button class="{{isSubmit ? 'button' : 'button-disable'}} row con-c align-c" size="long" bindtap="onContact">{{stateText}}</button>
</view> </view>
</view> </view>
\ No newline at end of file
...@@ -119,3 +119,28 @@ ...@@ -119,3 +119,28 @@
border-top: 1rpx #E2E7EF solid; border-top: 1rpx #E2E7EF solid;
background: #ffffff; background: #ffffff;
} }
.contact .button {
width: 670rpx;
height: 96rpx;
margin-bottom: 40rpx;
background: #86C5E1;
border-radius: 2px;
font-size: 30rpx;
font-weight: 500;
color: #ffffff;
line-height: 42rpx;
}
.contact .button-disable {
width: 670rpx;
height: 96rpx;
margin-bottom: 40rpx;
background: #C8E1EC;
border: 1px solid #C8E1EC;
border-radius: 2px;
font-size: 30rpx;
font-weight: 500;
color: #ffffff;
line-height: 42rpx;
}
\ No newline at end of file
...@@ -17,6 +17,13 @@ Page({ ...@@ -17,6 +17,13 @@ Page({
activeTime: '', activeTime: '',
activityTimes: [{beginTime:'',endTime:''}],// 活动场次 activityTimes: [{beginTime:'',endTime:''}],// 活动场次
activityIndex: 0, activityIndex: 0,
errorName: '',
errorPhone: '',
errorSession: '',
errorQuantity: '',
isSubmit: false,
// 接口参数 // 接口参数
id: '', id: '',
}, },
...@@ -54,28 +61,34 @@ Page({ ...@@ -54,28 +61,34 @@ Page({
this.setData({ this.setData({
formInto: funcFormInto formInto: funcFormInto
}) })
this.inspectForm()
}, },
onQuantityAdd: function () { onQuantityAdd: function () {
let funcFormInto = this.data.formInto let funcFormInto = this.data.formInto
let activityTime = this.data.activityTimes[this.data.activityIndex] let activityTime = this.data.activityTimes[this.data.activityIndex]
if (funcFormInto.quantity >= activityTime.residue*1) { if (funcFormInto.quantity >= activityTime.residue*1) {
wx.lin.showToast({ this.setData({
title: '该场次剩余名额' + activityTime.residue + '人', errorQuantity: '该场次剩余名额' + activityTime.residue + '人',
icon: 'error',
}) })
} else if (funcFormInto.quantity >= 5) { } else if (funcFormInto.quantity >= 5) {
wx.lin.showToast({ this.setData({
title: '每个账号最多预约5人', errorQuantity: '每个账号最多预约5人',
icon: 'error',
}) })
} else { } else {
funcFormInto.quantity = funcFormInto.quantity + 1 funcFormInto.quantity = funcFormInto.quantity + 1
this.setData({
errorQuantity: ''
})
} }
this.setData({ this.setData({
formInto: funcFormInto formInto: funcFormInto
}) })
this.inspectForm()
}, },
onSelectionDate: function (event) { onSelectionDate: function (event) {
...@@ -87,11 +100,7 @@ Page({ ...@@ -87,11 +100,7 @@ Page({
this.setData({ this.setData({
['formInto.quantity']: 0 ['formInto.quantity']: 0
}) })
// let funcFormInto = this.data.formInto
// funcFormInto.date = event.detail.value
// this.setData({
// formInto: funcFormInto
// })
}, },
onServic: function () { onServic: function () {
...@@ -149,40 +158,108 @@ Page({ ...@@ -149,40 +158,108 @@ Page({
}) })
}, },
// 活动报名 inspectForm: function () {
doActivityEnroll() {
var activityTime = this.data.activityTimes[this.data.activityIndex] let activityTime = this.data.activityTimes[this.data.activityIndex]
console.log(activityTime)
if (activityTime.residue*1 == 0) { if (activityTime.residue*1 == 0) {
wx.lin.showToast({ this.setData({
title: '该场次已没剩余名额', isSubmit: false,
icon: 'error', errorSession: '该场次已没剩余名额',
}) })
return return false
} }
let formInto = this.data.formInto let formInto = this.data.formInto
if (formInto.name == ''){ if (formInto.name === '') {
wx.lin.showToast({ this.setData({
title: '请输入名字', isSubmit: false,
icon: 'error', errorName: '请输入姓名'
})
return false
} else {
this.setData({
errorName: ''
}) })
return
} }
if (formInto.phone == ''){
wx.lin.showToast({ if (formInto.phone === '') {
title: '请输入手机号', this.setData({
icon: 'error', isSubmit: false,
errorPhone: '请输入手机号码'
})
return false
} else if (formInto.phone.length != 11) {
this.setData({
isSubmit: false,
errorPhone: '请输入11位手机号码'
})
return false
} else {
this.setData({
errorPhone: ''
}) })
return
} }
if (formInto.quantity == 0){
wx.lin.showToast({ if (formInto.quantity === 0) {
title: '请设置报名人数', this.setData({
icon: 'error', isSubmit: false,
errorQuantity: '请设置报名人数'
}) })
return false
}
this.setData({
isSubmit: true
})
return true
},
// 活动报名
doActivityEnroll() {
if (!this.inspectForm()) {
return return
} }
// 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
// }
wx.lin.showToast({
icon: 'loading',
title: '提交中',
show: true,
})
var that = this var that = this
app.wxRequest({ app.wxRequest({
url: '/api/v1/activity/doActivityEnroll', url: '/api/v1/activity/doActivityEnroll',
...@@ -197,6 +274,14 @@ Page({ ...@@ -197,6 +274,14 @@ Page({
that.setData({ that.setData({
entryComplete: true entryComplete: true
}) })
wx.lin.hideToast()
},
fail: function(err) {
wx.lin.hideToast()
wx.lin.showToast({
icon: 'error',
title: err.msg,
})
} }
}) })
}, },
......
...@@ -30,13 +30,18 @@ ...@@ -30,13 +30,18 @@
<view class="form"> <view class="form">
<view class="row align-c"> <view class="row align-c">
<view class="input-label row align-c"> <view class="input-label row con-b align-c">
<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 maxlength="16" class="weui-input" placeholder-class="input-tip" placeholder="请输入名字" bindinput="bindNameInput"></input> <input maxlength="16" class="weui-input" placeholder-class="input-tip" placeholder="请输入名字" bindinput="bindNameInput"></input>
</view> </view>
</view> </view>
<view class="form-error row align-c">
<text hidden="{{errorName ? false : true}}">{{errorName}}</text>
</view>
<view class="row align-c"> <view class="row align-c">
<view class="input-label row align-c"> <view class="input-label row align-c">
<text space="ensp">手 机 号</text> <text space="ensp">手 机 号</text>
...@@ -45,6 +50,11 @@ ...@@ -45,6 +50,11 @@
<input maxlength="11" type="number" class="weui-input" placeholder-class="input-tip" placeholder="请输入手机号" bindinput="bindPhoneInput"></input> <input maxlength="11" type="number" class="weui-input" placeholder-class="input-tip" placeholder="请输入手机号" bindinput="bindPhoneInput"></input>
</view> </view>
</view> </view>
<view class="form-error row align-c">
<text hidden="{{errorPhone ? false : true}}">{{errorPhone}}</text>
</view>
<view class="row align-c"> <view class="row align-c">
<view class="input-label row align-c"> <view class="input-label row align-c">
<text space="ensp">报名时间</text> <text space="ensp">报名时间</text>
...@@ -60,6 +70,10 @@ ...@@ -60,6 +70,10 @@
<image class="input-icon" src="../../image/more.png"></image> <image class="input-icon" src="../../image/more.png"></image>
</view> </view>
</view> </view>
<view class="form-error row align-c">
<text hidden="{{errorSession ? false : true}}">{{errorSession}}</text>
</view>
<view class="row align-c"> <view class="row align-c">
<view class="input-label row align-c"> <view class="input-label row align-c">
<text space="ensp">报名人数</text> <text space="ensp">报名人数</text>
...@@ -74,9 +88,13 @@ ...@@ -74,9 +88,13 @@
</l-button> </l-button>
</view> </view>
</view> </view>
<view class="form-error row align-c">
<text hidden="{{errorQuantity ? false : true}}">{{errorQuantity}}</text>
</view>
</view> </view>
<view class="entry-operation"> <view class="entry-operation">
<button class="button row con-c align-c" bindtap="onSubmit">确认报名</button> <button class="{{isSubmit ? 'button' : 'button-disable'}} button row con-c align-c" bindtap="onSubmit">确认报名</button>
</view> </view>
</view> </view>
\ No newline at end of file
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
.input-wrap { .input-wrap {
width: 510rpx; width: 510rpx;
height: 80rpx; height: 80rpx;
margin: 36rpx 0; margin: 20rpx 0;
padding: 0 24rpx; padding: 0 24rpx;
border: 1px #DBDFE5 solid; border: 1px #DBDFE5 solid;
border-radius: 2px; border-radius: 2px;
...@@ -128,6 +128,17 @@ ...@@ -128,6 +128,17 @@
font-size: 30rpx; font-size: 30rpx;
} }
.form-error {
width: 510rpx;
height: 32rpx;
margin-bottom: 8rpx;
margin-left: 160rpx;
font-size: 22rpx;
font-weight: 400;
color: #D92B3A;
line-height: 32rpx;
}
.quota { .quota {
position: relative; position: relative;
top: -20rpx; top: -20rpx;
...@@ -163,3 +174,17 @@ ...@@ -163,3 +174,17 @@
color: #ffffff; color: #ffffff;
line-height: 42rpx; line-height: 42rpx;
} }
.entry-operation .button-disable {
width: 670rpx;
height: 96rpx;
margin-bottom: 40rpx;
background: #C8E1EC;
border: 1px solid #C8E1EC;
border-radius: 2px;
font-size: 30rpx;
font-weight: 500;
color: #ffffff;
line-height: 42rpx;
}
\ No newline at end of file
...@@ -101,7 +101,7 @@ Page({ ...@@ -101,7 +101,7 @@ Page({
tmpArr.push(tmpItem) tmpArr.push(tmpItem)
}) })
// 活动开始时间倒序 // 活动开始时间倒序排序
tmpArr.sort(function(a,b) { tmpArr.sort(function(a,b) {
return new Date(b.beginDate.replace(/月/g,"\/").replace(/日/g,"\/")) - new Date(a.beginDate.replace(/月/g,"\/").replace(/日/g,"\/")) return new Date(b.beginDate.replace(/月/g,"\/").replace(/日/g,"\/")) - new Date(a.beginDate.replace(/月/g,"\/").replace(/日/g,"\/"))
}) })
......
...@@ -119,11 +119,11 @@ ...@@ -119,11 +119,11 @@
<text>名</text> <text>名</text>
</view> </view>
<view class="input-wrap row align-c"> <view class="input-wrap row align-c">
<input class="text" placeholder-class="input-tip" placeholder="请输入名字" data-type="name" bindblur="onInputBlur"></input> <input maxlength="16" class="text" placeholder-class="input-tip" placeholder="请输入名字" data-type="name" bindblur="onInputBlur"></input>
</view> </view>
</view> </view>
<view class="form-error row align-c"> <view class="form-error row align-c">
<text maxlength="16" hidden="{{errorName ? false : true}}">{{errorName}}</text> <text hidden="{{errorName ? false : true}}">{{errorName}}</text>
</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