Commit 41fad4c1 by 胡悦

修改

1 parent d46ea8e7
var measureList = [ var measureList = Object.freeze([
{ {
name: '新车1.0', name: '新车1.0',
iconName: 'icon1', iconName: 'icon1',
...@@ -131,7 +131,7 @@ var measureList = [ ...@@ -131,7 +131,7 @@ var measureList = [
} }
] ]
} }
] ])
export default { export default {
measureList measureList
......
...@@ -9,7 +9,7 @@ Page({ ...@@ -9,7 +9,7 @@ Page({
*/ */
data: { data: {
measureList: measureData.measureList, measureList: null,
isDisabled: true, isDisabled: true,
checkArray: [], checkArray: [],
formData: { formData: {
...@@ -67,7 +67,7 @@ Page({ ...@@ -67,7 +67,7 @@ Page({
console.log(this.data.checkArray) console.log(this.data.checkArray)
}, },
// 校验 // 必填校验
validForm() { validForm() {
const flag = this.data.formData.storeNumber && this.data.formData.carNumber && this.data.formData.customNumber && this.data.checkArray.length const flag = this.data.formData.storeNumber && this.data.formData.carNumber && this.data.formData.customNumber && this.data.checkArray.length
this.setData({ this.setData({
...@@ -79,13 +79,21 @@ Page({ ...@@ -79,13 +79,21 @@ Page({
// 表单输入 // 表单输入
handleInput(e) { handleInput(e) {
let name = e.currentTarget.dataset.name let name = e.currentTarget.dataset.name
let val = e.detail.value let val = this.validateNumber(e.detail.value)
console.log(val)
const form = `formData.${name}` const form = `formData.${name}`
this.setData({ this.setData({
[form]: val [form]: val
}) })
this.validForm() this.validForm()
}, },
// 输入正整数校验
validateNumber(val) {
console.log(val, val.replace(/\D/g, ''))
return val == 0 ? '' : val.replace(/\D/g, '')
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -104,7 +112,11 @@ Page({ ...@@ -104,7 +112,11 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
console.log(measureData)
this.setData({
measureList: measureData.measureList
})
console.log(this.data.measureList)
}, },
/** /**
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
padding: 0 24rpx 90rpx; padding: 0 24rpx 90rpx;
} }
.header-bg { .header-bg {
position: fixed; position: absolute;
top: 0; top: -224rpx;
left: 0; left: 0;
width: 100%; width: 100%;
z-index: -1; z-index: -1;
......
...@@ -7,7 +7,7 @@ Page({ ...@@ -7,7 +7,7 @@ Page({
*/ */
data: { data: {
visible: false, visible: false,
measureList: measureData.measureList, measureList: null,
formData: { formData: {
storeNumber: 1, storeNumber: 1,
carNumber: 1, carNumber: 1,
...@@ -149,9 +149,7 @@ Page({ ...@@ -149,9 +149,7 @@ Page({
console.log(e.changedTouches[0].clientY); console.log(e.changedTouches[0].clientY);
if (e.changedTouches[0].clientY < 451) { if (e.changedTouches[0].clientY < 451) {
this.setData({ this.setData({
visible: false, visible: false
// isReset: false,
formData: this.data.lastFormData
}); });
} }
}, },
...@@ -160,20 +158,19 @@ Page({ ...@@ -160,20 +158,19 @@ Page({
const {rate, averagePrice} = e.detail.value const {rate, averagePrice} = e.detail.value
const index = this.data.dialogData.index const index = this.data.dialogData.index
console.log(index) console.log(index)
const reg = /^[1-9]\d*$/ // const reg = /^[1-9]\d*$/
// const reg1 = /^(\d{+})(.\d{0,2})?$/ // const reg1 = /^[1-9]{0,1}\d{1}(.\d{0,2})$/
const reg1 = /^[1-9]{0,1}\d{1}(.\d{0,2})$/ if (!rate) {
if (!(reg.test(rate) || reg1.test(rate))) {
wx.showToast({ wx.showToast({
title: '转化率只可输入小数点后两位', title: '请输入转化率',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
return return
} }
if (!reg.test(averagePrice)) { if (!averagePrice) {
wx.showToast({ wx.showToast({
title: '客均单价应为正整数', title: '请输入客均单价',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
...@@ -193,6 +190,29 @@ Page({ ...@@ -193,6 +190,29 @@ Page({
countData countData
}) })
}, },
// 输入框输入
handleInput(e) {
console.log(e)
let value = e.detail.value
const reg = /^[1-9]\d*$/
const reg1 = /^[1-9]{0,1}\d{1}(.\d{0,2})$/
console.log(value <100 && value > 0, (reg.test(value) || reg1.test(value)))
if (value < 0) {
value = null
} else if (value > 100) {
value = value.slice(0,2)
} else if (value > 0 && value < 100) {
const valueArr = value.split('.')
if (valueArr.length == 2) {
const decimal = value.split('.')[1].slice(0,2)
const integer = value.split('.')[0]
value = integer + '.' + decimal
}
}
this.setData({
'dialogData.rate': value
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -226,7 +246,9 @@ Page({ ...@@ -226,7 +246,9 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.setData({
measureList: measureData.measureList
})
}, },
/** /**
......
...@@ -158,14 +158,14 @@ ...@@ -158,14 +158,14 @@
<view class="form-item"> <view class="form-item">
<view class="form-label">转化率</view> <view class="form-label">转化率</view>
<view class="input-box"> <view class="input-box">
<input class="form-input" bindfocus="focus" maxlength="8" name="rate" value="{{dialogData.rate}}" type="number" /> <input class="form-input" bindfocus="focus" bindinput="handleInput" maxlength="8" name="rate" value="{{dialogData.rate}}" type="number" />
<view class="form-unit">%</view> <view class="form-unit">%</view>
</view> </view>
</view> </view>
<view class="form-item"> <view class="form-item">
<view class="form-label">客均单价</view> <view class="form-label">客均单价</view>
<view class="input-box"> <view class="input-box">
<input class="form-input" bindfocus="focus" maxlength="8" name="averagePrice" type="number" value="{{dialogData.averagePrice}}" /> <input class="form-input" bindfocus="focus" maxlength="6" name="averagePrice" type="number" value="{{dialogData.averagePrice}}" />
<view class="form-unit">元</view> <view class="form-unit">元</view>
</view> </view>
</view> </view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!