// miniprogram/price/calcprice.js const app=getApp(); const utils=require("../../utils/http"); let time1=null; Component({ /** * 组件的属性列表 */ properties: { priceflag:{ type: Boolean, value:false }, }, /** * 组件的初始数据 */ data: { imgUrl:app.globalData.imgUrl, arr:[0,0,0,0,0,0,0,0,0,0], pricenum:[5,1,5,6,0], homearr:[ {id:1,name:'1室'}, {id:2,name:'2室'}, {id:3,name:'3室'}, {id:4,name:'4室'}, {id:5,name:'5室'}, {id:6,name:'6室'}, {id:7,name:'7室'}, {id:8,name:'8室'}, {id:9,name:'9室'}, {id:10,name:'10室'}], hidx:2, liveroom:[ {id:1,name:'1厅'}, {id:2,name:'2厅'}, {id:3,name:'3厅'}, {id:4,name:'4厅'}, {id:5,name:'5厅'} ], lidx:1, tolitarr:[ {id:1,name:'1卫'}, {id:2,name:'2卫'}, {id:3,name:'3卫'}, {id:4,name:'4卫'}, {id:5,name:'5卫'} ], tidx:0, area:'', phone:'' }, ready() { clearInterval(time1); var num='0000'; time1=setInterval(res=>{ num=parseInt(Math.random()*60000+40000); num=num+''; num.split(''); this.setData({ pricenum:num }) },1000) }, methods:{ dothis(){}, setareatap(e){ this.setData({ area:e.detail.value }) }, bindPickerChange: function(e) { this.setData({ hidx: e.detail.value }) }, bindliveChange: function(e) { this.setData({ lidx: e.detail.value }) }, bindtolietChange: function(e) { this.setData({ tidx: e.detail.value }) }, isPhoneNum: function (phone) { var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/; if (!myreg.test(phone)) { return false; } return true; }, setphonetap(e){ this.setData({ phone: e.detail.value }) }, closetap(){ this.triggerEvent("run", '') }, subfun(){ const that=this; if(!that.data.area){ wx.showToast({ title: "房屋面积不能为空", icon: 'none', duration: 2000 }) return false; } if(!that.data.phone){ wx.showToast({ title: "手机号不能为空", icon: 'none', duration: 2000 }) return false; } if(!this.isPhoneNum(that.data.phone)){ this.setData({ phone:'' }) wx.showToast({ title: "手机号格式不对!", icon: 'none', duration: 2000 }) return false; } wx.showLoading({ title: '计算中...', }) utils.$post({ url: app.globalData.webUrl + 'client/quote_record/add', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ area:that.data.area, room:that.data.homearr[that.data.hidx].id,//室 hall:that.data.liveroom[that.data.lidx].id,//厅 bathroom:that.data.tolitarr[that.data.tidx].id,//卫 phone:that.data.phone, }, success: function (res) { // wx.hideLoading(); if(res.data.code=='0'){ that.triggerEvent("run", '') wx.showToast({ title: res.data.msg, icon: 'none', duration: 2000 }) } } }) }, } })