From d30135a833a81c272d7db3afc5a701c2bffa083a Mon Sep 17 00:00:00 2001 From: jinna Date: Fri, 25 Aug 2023 14:40:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/pages_zhentou/form/form.vue | 288 +++++++++++++++++------------- 1 file changed, 161 insertions(+), 127 deletions(-) diff --git a/pages/pages_zhentou/form/form.vue b/pages/pages_zhentou/form/form.vue index 5bea8ce..4e9657a 100644 --- a/pages/pages_zhentou/form/form.vue +++ b/pages/pages_zhentou/form/form.vue @@ -8,7 +8,7 @@

上一页

-

下一页

+

下一页

@@ -69,7 +69,7 @@ - +

单位:厘米cm

@@ -170,7 +170,7 @@
扫码添加 - + @@ -178,7 +178,7 @@

跳过

-

提交

+

提交

@@ -248,7 +248,8 @@ }, { validateFunction: function(rule, value, data, callback) { - const moblie = /^(0{1}|[1-9]\d{0,3}|.{0})$/; + // const moblie = /^(0{1}|[1-9]\d{0,3}|.{0})$/; + const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/ if (!moblie.test(value)) { callback('请填写正确的身高'); } else { @@ -265,7 +266,7 @@ }, { validateFunction: function(rule, value, data, callback) { - const moblie = /^(0(\.\d{1}){0,1}|[1-8]\d{1,3}(\.\d{1}){0,1}|9\d{1,2}(\.\d{1}){0,1}|999(\.0){0,1}|.{0})$/; + const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/; if (!moblie.test(value)) { callback('请填写正确的体重'); } else { @@ -275,6 +276,30 @@ } ] }, + neckShoulderWidth:{ + rules:[{ + validateFunction: function(rule, value, data, callback) { + const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/; + if (!moblie.test(value)) { + callback('请填写正确的肩颈宽度'); + } else { + return true; + } + } + }] + }, + neckLength:{ + rules:[{ + validateFunction: function(rule, value, data, callback) { + const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/; + if (!moblie.test(value)) { + callback('请填写正确的颈椎长度'); + } else { + return true; + } + } + }] + }, pillowHardness: { rules: [{ required: true, @@ -393,7 +418,8 @@ orderData: [], currentNum: null, pageFrom: '', - formData: [] + formData: [], + alreadyForm:{},//下一页表单已经填写的内容 } }, onShow() {}, @@ -419,7 +445,6 @@ // } // }) const res = uni.getSystemInfoSync(); - console.log(res.screenWidth) that.widthScreen = res.screenWidth if (res.screenWidth < 750) { that.fontsize = 100 * (res.screenWidth / 750) @@ -428,7 +453,6 @@ }; // console.log(this.a) this.getData() - console.log(options) this.orderNo = options.orderNo this.orderNum = options.orderNum this.pageFrom = options.pageFrom @@ -441,30 +465,6 @@ // this.getCurrentArea('北京市') }, methods: { - //长按识别二维码 - previewImage(e) { - console.log(e) - uni.previewImage({ - // 需要预览的图片链接列表。若无需预览,可以注释urls - urls: 'http://47.104.224.41:9000/etriphome/appresource/image/add.png', - // 为当前显示图片的链接/索引值 - current: 'http://47.104.224.41:9000/etriphome/appresource/image/add.png', - // 图片指示器样式 - indicator: 'default', - // 是否可循环预览 - loop: false, - // 长按图片显示操作菜单,如不填默认为保存相册 - longPressActions: { - // itemList: [this.l('发送给朋友'), this.l] - }, - success: res => { - console.log('previewImage res', res); - }, - fail: err => { - console.log('previewImage err', err); - } - }); - }, // 根据订单号获取已填写的订单信息 getOrderInfo(type) { uni.request({ @@ -475,7 +475,6 @@ 'Blade-Auth': 'bearer ' + uni.getStorageSync('token') }, success: (res) => { - console.log(res) if (res.data.code == 200) { this.orderData = res.data.data; if(this.orderData.length == 0){ @@ -483,7 +482,8 @@ phone:JSON.parse(uni.getStorageSync('userInfo')).phone, } }else{ - this.valiFormData = this.orderData[this.orderData.length - 1] + this.valiFormData =JSON.parse(JSON.stringify(this.orderData[this.orderData.length - 1])) + this.valiFormData.id = '' this.valiFormData.neckShoulderWidth = this.valiFormData .neckShoulderWidth == -1 ? '' : this.valiFormData.neckShoulderWidth; this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : @@ -548,12 +548,18 @@ }) }, handlePrev() { - // console.log(this.currentNum - 2) this.currentNum = this.currentNum - 1; + this.alreadyForm = JSON.parse(JSON.stringify(this.valiFormData)) ; this.valiFormData = this.orderData[this.currentNum - 1]; if (!this.valiFormData) { - this.valiFormData = {} + this.valiFormData = {}; + this.$nextTick(() =>{ + this.$refs.valiForm.clearValidate() + }) + // this.valiFormData = this.orderData[this.currentNum - 2]; } else { + this.isDisabled = true; + this.valiFormData = this.orderData[this.currentNum - 1]; this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this .valiFormData.neckShoulderWidth; this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength; @@ -563,7 +569,7 @@ this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData .cervicalVertebra; this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed; - } + }; }, jumpOver() { if (this.pageFrom == 'order') { @@ -577,24 +583,41 @@ } }, handleNext() { - console.log(this.currentNum) - this.currentNum = this.currentNum + 1 - this.valiFormData = this.orderData[this.currentNum - 1]; - if (!this.valiFormData) { - console.log('123') - this.valiFormData = {} - } else { - console.log('456') - this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this - .valiFormData.neckShoulderWidth; - this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength; - this.valiFormData.ageRange = this.valiFormData.ageRange == -1 ? '' : this.valiFormData.ageRange; - this.valiFormData.sleepLength = this.valiFormData.sleepLength == -1 ? '' : this.valiFormData - .sleepLength; - this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData - .cervicalVertebra; - this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed; + if(!this.valiFormData.id){ + uni.showToast({ + title:'请先提交本表单', + icon:'none' + }) + }else{ + this.currentNum = this.currentNum + 1 + this.isDisabled = false; + if(JSON.stringify(this.alreadyForm) == '{}'){ + this.valiFormData = this.valiFormData + }else{ + this.valiFormData = this.alreadyForm + } } + // console.log(this.currentNum) + // this.currentNum = this.currentNum + 1 + // this.valiFormData = this.orderData[this.currentNum - 1]; + // if (!this.valiFormData) { + // console.log('123') + // this.valiFormData = {} + // this.$nextTick(() =>{ + // this.$refs.valiForm.clearValidate() + // }) + // } else { + // console.log('456') + // this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this + // .valiFormData.neckShoulderWidth; + // this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength; + // this.valiFormData.ageRange = this.valiFormData.ageRange == -1 ? '' : this.valiFormData.ageRange; + // this.valiFormData.sleepLength = this.valiFormData.sleepLength == -1 ? '' : this.valiFormData + // .sleepLength; + // this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData + // .cervicalVertebra; + // this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed; + // } }, // 获取表单信息 getInfo() { @@ -606,7 +629,7 @@ 'Blade-Auth': 'bearer ' + uni.getStorageSync('token') }, success: (res) => { - console.log(res) + // console.log(res) if (res.data.code == 200) { this.valiFormData = { username: res.data.data.username == '-1' ? '' : res.data.data.username, @@ -663,7 +686,7 @@ this.multiIndex[0] = index item.citys.map((item1, index1) => { if (item1.city == this.province) { - console.log('111') + // console.log('111') this.locationArr[1].push(item.city); } if (item1.city == this.city) { @@ -681,7 +704,7 @@ this.isShowCode = !this.isShowCode; }, getData() { - console.log(this.allCityData) + // console.log(this.allCityData) this.allCityData.map(item => { this.locationArr[0].push(item.province); }) @@ -689,24 +712,24 @@ this.locationArr[1].push(item.area) }) - console.log(this.locationArr) + // console.log(this.locationArr)/ }, cityChange(e) { - console.log(e) + // console.log(e) this.multiIndex = e.detail.value; - console.log(this.locationArr) + // console.log(this.locationArr) this.province = this.locationArr[0][this.multiIndex[0]] this.city = this.locationArr[1][this.multiIndex[1]] this.district = this.locationArr[2][this.multiIndex[2]] }, columnchange(e) { let value = e.detail.value; - console.log(e.detail) + // console.log(e.detail) if (e.detail.column == 0) { this.locationArr[1] = []; this.locationArr[2] = [] let tmp = this.allCityData.find(item => item.province == this.locationArr[0][value]) - console.log(tmp) + // console.log(tmp) if (tmp.citys.length == 1) { tmp.citys[0].areas.map(item => { this.locationArr[1].push(item.area) @@ -732,7 +755,7 @@ }) } this.multiIndex.splice(2, 1, 0) - console.log(this.multiIndex) + // console.log(this.multiIndex) } // 第三列滑动 if (e.detail.column === 2) { @@ -740,65 +763,69 @@ } }, submit(ref) { - this.$refs[ref].validate().then(res => { - console.log(this.valiFormData); - let params = {}; - params = { - username: this.valiFormData.username, - phone: this.valiFormData.phone, - province: this.province, - city: this.city, - district: this.district, - detail: this.valiFormData.detail, - height: this.valiFormData.height, - weight: this.valiFormData.weight, - sleepingPosture: this.valiFormData.sleepingPosture, - pillowHardness: this.valiFormData.pillowHardness, - pillowMaterial: this.valiFormData.pillowMaterial, - neckShoulderWidth: this.valiFormData.neckShoulderWidth, - neckLength: this.valiFormData.neckLength, - ageRange: this.valiFormData.ageRange, - sleepLength: this.valiFormData.sleepLength, - cervicalVertebra: this.valiFormData.cervicalVertebra, - otherNeed: this.valiFormData.otherNeed, - orderNo: this.orderNo, - id: this.valiFormData.id ? this.valiFormData.id : '' - } - console.log(getApp().globalData.baseUrl) - - uni.request({ - url: getApp().globalData.baseUrl + '/blade-desk/custom-made-info/save', - data: params, - method: 'post', - success: res => { - console.log(res) - if (res.data.code == "200" || data.code === "") { - uni.showToast({ - title: '提交成功', - icon: 'none' - }); - this.valiFormData = {}, - this.multiIndex[0, 0, 0]; - this.city = '' - this.province = ''; - this.district = ''; - this.getOrderInfo('save') - } else if (res.data.code == 401) { - this.doLogin() - } else { - uni.showToast({ - title: '提交失败', - icon: 'none' - }); - } - }, - fail: res => { - reject(res) + if(this.isDisabled){ + return; + }else{ + this.$refs[ref].validate().then(res => { + // console.log(this.valiFormData); + let params = {}; + params = { + username: this.valiFormData.username, + phone: this.valiFormData.phone, + province: this.province, + city: this.city, + district: this.district, + detail: this.valiFormData.detail, + height: this.valiFormData.height, + weight: this.valiFormData.weight, + sleepingPosture: this.valiFormData.sleepingPosture, + pillowHardness: this.valiFormData.pillowHardness, + pillowMaterial: this.valiFormData.pillowMaterial, + neckShoulderWidth: this.valiFormData.neckShoulderWidth, + neckLength: this.valiFormData.neckLength, + ageRange: this.valiFormData.ageRange, + sleepLength: this.valiFormData.sleepLength, + cervicalVertebra: this.valiFormData.cervicalVertebra, + otherNeed: this.valiFormData.otherNeed, + orderNo: this.orderNo, + id: this.valiFormData.id ? this.valiFormData.id : '' } + // console.log(getApp().globalData.baseUrl) + + uni.request({ + url: getApp().globalData.baseUrl + '/blade-desk/custom-made-info/save', + data: params, + method: 'post', + success: res => { + console.log(res) + if (res.data.code == "200" || data.code === "") { + uni.showToast({ + title: '提交成功', + icon: 'none' + }); + this.valiFormData = {}, + this.multiIndex[0, 0, 0]; + this.city = '' + this.province = ''; + this.district = ''; + this.getOrderInfo('save') + } else if (res.data.code == 401) { + this.doLogin() + } else { + uni.showToast({ + title: '提交失败', + icon: 'none' + }); + } + }, + fail: res => { + reject(res) + } + }) + }).catch(err => { + // console.log('err', err); }) - }).catch(err => { - console.log('err', err); - }) + } }, //登录 doLogin(type) { @@ -869,9 +896,9 @@ // this.imgUrl = this.successUrl var _this = this // 第几列滑动 - console.log("第几列滑动 = " + JSON.stringify(e.detail.column)) + // console.log("第几列滑动 = " + JSON.stringify(e.detail.column)) // 第几列滑动选中的下标 - console.log("第几列滑动选中的下标 = " + JSON.stringify(e.detail.value)) + // console.log("第几列滑动选中的下标 = " + JSON.stringify(e.detail.value)) // 第一列滑动 if (e.detail.column === 0) { _this.multiIndex[0] = e.detail.value @@ -973,9 +1000,11 @@ } .turn_box{ - width: 690rpx; + padding:0 30rpx; display: flex; margin: 28rpx 0 36rpx 0; + justify-content: space-between; + width: 630rpx; .turn_item{ width: 200rpx; @@ -988,8 +1017,8 @@ justify-content: center; font-size: 26rpx; color: #D73232; - margin-right: 106rpx; - margin-left: 30rpx; + // margin-right: 106rpx; + // margin-left: 30rpx; &.next{ color: #666666; @@ -1030,7 +1059,7 @@ .rele_content { width: 100%; - height: 100%; + height: 99%; margin: 0 auto; position: relative; // overflow: auto; @@ -1423,6 +1452,11 @@ color: #fff; margin-left: 50rpx; } + + &.dis_btn{ + background: rgba(215, 50, 50, 0.3); + border: 1rpx solid rgba(215, 50, 50, 0.3); + } } } }