Commit f2bc27ff by TengFengLian

表单提及限制重复点击,我的活动分页加载

parent f3c5f054
......@@ -22,8 +22,8 @@ Page({
errorPhone: '',
errorSession: '',
errorQuantity: '',
canSubmit: false,
isSubmit: false,
// 接口参数
id: '',
},
......@@ -66,7 +66,6 @@ Page({
this.setData({
formInto: funcFormInto
})
this.inspectForm()
},
onQuantityAdd: function () {
......@@ -101,8 +100,6 @@ Page({
formInto: funcFormInto
})
this.inspectForm()
},
onSelectionDate: function (event) {
......@@ -116,18 +113,21 @@ Page({
})
let activityTime = this.data.activityTimes[this.data.activityIndex]
if (1 == activityTime.enroll*1) {
this.setData({
errorQuantity: '该场次已报名过,请选择其他场次',
})
} else if (0 == activityTime.residue*1) {
this.setData({
errorQuantity: '该场次人数已满,请选择其他场次',
})
} else {
this.setData({
errorQuantity: '',
})
}
this.inspectForm()
},
onServic: function () {
......@@ -155,6 +155,7 @@ Page({
},
bindNameInput: function (e) {
console.log(e.detail.value)
this.setData({
['formInto.name']: e.detail.value
})
......@@ -166,6 +167,42 @@ Page({
})
},
onInputBlur: function (e) {
let type = e.target.dataset.type
let value = e.detail.value
if (type == 'name') {
if (value === '') {
this.setData({
canSubmit: false,
errorName: '请输入姓名'
})
return false
} else {
this.setData({
errorName: ''
})
}
} else if (type == 'phone') {
if (value === '') {
this.setData({
canSubmit: false,
errorPhone: '请输入手机号码'
})
complete = false
} else if (value.length != 11) {
this.setData({
canSubmit: false,
errorPhone: '请输入11位手机号码'
})
complete = false
} else {
this.setData({
errorPhone: ''
})
}
}
},
//活动报名页
getEnrollView(){
var that = this
......@@ -197,27 +234,13 @@ Page({
inspectForm: function () {
let activityTime = this.data.activityTimes[this.data.activityIndex]
if (activityTime.residue*1 == 0) {
this.setData({
isSubmit: false,
errorSession: '',
})
return false
} else {
this.setData({
errorSession: '',
})
}
let complete = true
let formInto = this.data.formInto
if (formInto.name === '') {
this.setData({
isSubmit: false,
errorName: '请输入姓名'
})
return false
complete = false
} else {
this.setData({
errorName: ''
......@@ -226,44 +249,60 @@ Page({
if (formInto.phone === '') {
this.setData({
isSubmit: false,
errorPhone: '请输入手机号码'
})
return false
complete = false
} else if (formInto.phone.length != 11) {
this.setData({
isSubmit: false,
errorPhone: '请输入11位手机号码'
})
return false
complete = false
} else {
this.setData({
errorPhone: ''
})
}
if (formInto.quantity === 0) {
let activityTime = this.data.activityTimes[this.data.activityIndex]
if (1 == activityTime.enroll*1) {
this.setData({
errorQuantity: '该场次已报名过,请选择其他场次',
})
complete = false
} else if (0 == activityTime.residue*1) {
this.setData({
errorQuantity: '该场次人数已满,请选择其他场次',
})
complete = false
} else if (formInto.quantity === 0) {
this.setData({
isSubmit: false,
errorQuantity: '请设置报名人数'
})
return false
complete = false
} else {
this.setData({
errorQuantity: ''
})
}
this.setData({
isSubmit: true
canSubmit: complete
})
return true
return complete
},
// 活动报名
doActivityEnroll() {
if (!this.inspectForm()) {
if (!this.inspectForm() || this.data.isSubmit) {
return
}
this.setData({
isSubmit: true,
})
var activityTime = this.data.activityTimes[this.data.activityIndex]
let formInto = this.data.formInto
wx.lin.showToast({
......@@ -283,11 +322,15 @@ Page({
},
success: function(res) {
that.setData({
entryComplete: true
entryComplete: true,
isSubmit: false,
})
wx.lin.hideToast()
},
fail: function(err) {
that.setData({
isSubmit: false,
})
wx.lin.showToast({
icon: 'error',
title: err.msg,
......
......@@ -34,7 +34,7 @@
<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>
<input maxlength="16" class="weui-input" placeholder-class="input-tip" placeholder="请输入名字" data-type="name" bindblur="onInputBlur" bindinput="bindNameInput"></input>
</view>
</view>
<view class="form-error row align-c">
......@@ -47,7 +47,7 @@
<text space="ensp">手 机 号</text>
</view>
<view class="input-wrap row align-c">
<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="请输入手机号" data-type="phone" bindblur="onInputBlur" bindinput="bindPhoneInput"></input>
</view>
</view>
<view class="form-error row align-c">
......@@ -95,6 +95,6 @@
</view>
<view class="entry-operation">
<button class="{{isSubmit ? 'button' : 'button-disable'}} button row con-c align-c" bindtap="onSubmit">确认报名</button>
<button class="{{canSubmit ? 'button' : 'button-disable'}} button row con-c align-c" bindtap="onSubmit">确认报名</button>
</view>
</view>
\ No newline at end of file
......@@ -17,8 +17,9 @@ Page({
errorPhone: '',
errorQuantity: '',
isSubmit: false,
canSubmit: false,
winQuota: false,
isSubmit: false,
// 预约入园剩余名额
total: 0,
......@@ -119,7 +120,7 @@ Page({
inspectForm: function () {
if (this.data.formName === '') {
this.setData({
isSubmit: false,
canSubmit: false,
errorName: '请输入姓名'
})
return
......@@ -131,13 +132,13 @@ Page({
if (this.data.formPhone === '') {
this.setData({
isSubmit: false,
canSubmit: false,
errorPhone: '请输入手机号码'
})
return
} else if (this.data.formPhone.length != 11) {
this.setData({
isSubmit: false,
canSubmit: false,
errorPhone: '请输入11位手机号码'
})
return
......@@ -149,7 +150,7 @@ Page({
if (this.data.formQuantity === 0) {
this.setData({
isSubmit: false,
canSubmit: false,
errorQuantity: '预约人数不能为 0'
})
return
......@@ -160,7 +161,7 @@ Page({
}
this.setData({
isSubmit: true
canSubmit: true
})
},
......@@ -170,11 +171,15 @@ Page({
app.login({
success: function() {
if (!that.data.isSubmit) {
that.inspectForm()
if (!that.data.canSubmit || that.data.isSubmit) {
// that.inspectForm()
return
}
that.setData({
isSubmit: true
})
wx.lin.showToast({
icon: 'loading',
title: '提交中',
......@@ -191,7 +196,8 @@ Page({
},
success: function(res) {
that.setData({
appointmentComplete: true
appointmentComplete: true,
isSubmit: false
})
wx.lin.hideToast()
},
......@@ -200,6 +206,9 @@ Page({
icon: 'error',
title: err.msg,
})
that.setData({
isSubmit: false
})
}
})
......
......@@ -95,7 +95,7 @@
</view>
<view class="appointment-operation">
<button class="{{isSubmit ? 'button' : 'button-disable'}} row con-c align-c" bindtap="onSubmit">确认预约</button>
<button class="{{canSubmit ? 'button' : 'button-disable'}} row con-c align-c" bindtap="onSubmit">确认预约</button>
<button class="button-plain row con-c align-c" bindtap="onServic">电话咨询</button>
</view>
</view>
......@@ -159,6 +159,6 @@
</view>
<view class="appointment-operation">
<button class="{{isSubmit ? 'button' : 'button-disable'}} row con-c align-c" bindtap="onSubmit">确认预约</button>
<button class="{{canSubmit ? 'button' : 'button-disable'}} row con-c align-c" bindtap="onSubmit">确认预约</button>
</view>
</view>
\ No newline at end of file
......@@ -16,13 +16,18 @@ Page({
height:0,
data:[],
active:0,
pageNo: 1,
pageSize: 10,
loading: false,
moreData: true,
},
chageNav(e){
let index = e.currentTarget.dataset.index
this.setData({
active: index
active: index,
pageNo: 1,
})
this.getMyActivityList(index)
this.getMyActivityList()
},
activityDetail(e){
wx.navigateTo({
......@@ -36,7 +41,7 @@ Page({
this.setData({
height: wx.getSystemInfoSync().windowHeight, //获取屏幕的高度
})
this.getMyActivityList(this.data.active)
this.getMyActivityList()
},
/**
......@@ -89,9 +94,9 @@ Page({
},
// 我的活动
getMyActivityList(index) {
getMyActivityList() {
let state = ''
switch (index) {
switch (Number(this.data.active)) {
case 0: state = ''; break;
case 1: state = 0; break;
case 2: state = 1; break;
......@@ -100,9 +105,12 @@ Page({
var that = this
app.login({
success: function() {
that.setData({
loading: true
})
app.wxRequest({
url: '/api/v1/activity/getMyActivityList',
data: { activeState: state, pageSize: 10, pageNo: 1 },
data: { activeState: state, pageSize: that.data.pageSize, pageNo: that.data.pageNo },
success: function(res) {
let list = res.data.list
let tmpArr = []
......@@ -124,13 +132,33 @@ Page({
}
tmpArr.push(obj)
})
if (that.data.pageNo != 1) {
tmpArr = that.data.data.concat(tmpArr)
}
that.setData({
data: tmpArr,
loading: false,
})
that.setData({
moreData: (that.data.data.length >= res.data.count*1) ? false: true
})
},
fail: function(err) {
that.setData({
data: tmpArr
loading: false
})
}
})
}
})
},
onReachBottom: function() {
if (this.data.loading || !this.data.moreData) {
return
}
this.data.pageNo += 1
this.getMyActivityList()
},
},
})
\ No newline at end of file
......@@ -11,7 +11,7 @@
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="姓名" is-link="{{false}}">
<view slot="right-section">
<input style="text-align:right;" placeholder="请填写姓名" placeholder-class="phone" value="{{nickName}}" data-type="name" bindblur="onInputBlur"/>
<input maxlength="10" style="text-align:right;" placeholder="请填写姓名" placeholder-class="phone" value="{{nickName}}" data-type="name" bindblur="onInputBlur"/>
</view>
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="性别" is-link="{{false}}">
......@@ -32,7 +32,7 @@
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="地址" is-link="{{false}}">
<view slot="right-section">
<input style="text-align:right;" placeholder="请填写地址" placeholder-class="phone" value="{{address}}" data-type="address" bindblur="onInputBlur"/>
<input maxlength="30" style="text-align:right;" placeholder="请填写地址" placeholder-class="phone" value="{{address}}" data-type="address" bindblur="onInputBlur"/>
</view>
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="手机号" is-link="{{false}}">
......
......@@ -240,7 +240,7 @@ Page({
url: '/api/v1/activity/getList',
data: {
listType: type,
pageSize: 20,
pageSize: 10,
pageNo: 1,
tagId: '3c95ab1afb3a4d899ac25242c3d089ea',
},
......
......@@ -155,6 +155,41 @@ Page({
})
},
shopDetail(e) {
let datasetId = e.currentTarget.dataset.id
let id = ''
if (datasetId == '21a0cbbd39604380bc46fba38ac5fb63') {
// 海错图展馆
id = 1
} else if (datasetId == 'b8f04379bf164b7f8bca69be14146a17') {
// 拾光花坊
id = 2
} else if (datasetId == 'd8922a8f759245d4949b62693099edb5') {
// 元养水韵SPA馆
id = 3
} else if (datasetId == 'd0e5ff414f794e15bc33c4e11f5356a8') {
// 原味舒食
id = 4
} else if (datasetId == '81078c007c034d46b7dfe59935d84f7a') {
// 原野MOJITO
id = 5
} else if (datasetId == '29e79743f0f94e5eb726e0ebdfe64248') {
// 星空影院
id = 6
} else if (datasetId == '559d980e9eaf4459883fb3a556d24347') {
// 儿童营地信息
} else if (datasetId == 'c0a2d795a7a54dcd9459dd1b969c1771') {
// 住宿信息
}
if (id != '') {
wx.navigateTo({
url: '/pages/shop-detail/shop-detail?id=' + id
})
}
},
// 攻略详情文中提及
getParksByParkIds(parkIds) {
if (!parkIds) {
......
......@@ -31,7 +31,7 @@
<text>文中提及</text>
</view>
<block wx:for="{{relation}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="relation-item row con-b">
<view class="relation-item row con-b" data-id="{{item.id}}" bindtap="shopDetail">
<image mode="widthFix" src="{{item.cover}}"></image>
<view class="relation-item-info col">
<text>{{item.title}}</text>
......
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