Commit 3effb392 by TengFengLian

设置活动状态显示

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