// template/formId.js var app = getApp() Component({ /** * 组件的属性列表 */ properties: { value:Object, property:Object, isrestofWorld:Boolean,//是否为世界各地租房筛选 school:Object,//附近学校列表 }, /** * 组件的初始数据 */ data: { show:false, info:{ // rent_min:'', // rent_max:'', gender:{ title: 'gender', value: "0", name: '', show: false, list: { 0: "不限", 1: "女", 2: "男", } }, leaseterm:{ title: 'leaseterm', value: "0", name: '', show: false, list: { 0: "不限", 1: "一年以上", 2: "低于一年", } }, publish:{ title: 'publish', value: 'twomonth', name: '发布时间', show: false, // 0 不限 triduum 三天 hebdomad 一周 onemonth 一个月内 trimester 三个月 list: { '0': '不限', 'triduum': "三天", "hebdomad": "一周", 'onemonth': '一个月内', 'twomonth': '二个月内', 'trimester': '三个月内' }, showTips: 'publish' }, // school: { // title: 'school', // value: '0', // name: '发布时间', // show: false, // // 0 不限 triduum 三天 hebdomad 一周 onemonth 一个月内 trimester 三个月 // list: [], // showTips: 'school' // }, } }, observers: { "value": function (e) { for(let i in e){ this.data.info[i].value = e[i] } this.setData({ info:this.data.info }) }, 'school':function(e){ let schoolList = [] for (let i in e) { schoolList.push({ name:e[i], value:i }) } this.data.info.school.list = schoolList; this.setData({ info: this.data.info }) } }, lifetimes: { attached: function () { this.attachedIn() }, }, attached: function () { this.attachedIn() }, /** * 组件的方法列表 */ methods: { catchmove() { }, attachedIn() { }, showMoreCondition(e){ this.setData({ show:e.currentTarget.dataset.show==1 ? true:false, }) }, input(e){ let letter = e.currentTarget.dataset.letter; this.data.info[letter].value = e.detail.value; this.setData({ info: this.data.info }) }, selectItem(e){ let box = e.currentTarget.dataset.box; let value = e.currentTarget.dataset.value; this.data.info[box].value = value; this.setData({ info:this.data.info }) if (box == 'area') { if(value==0){ return false } // console.log(this.data.info.area) let name = this.data.info.area.list[value] var myEventDetail = { value:value, name:name } // detail对象,提供给事件监听函数 var myEventOption = {} // 触发事件的选项 this.triggerEvent('selectArea', myEventDetail, myEventOption) return false; } }, submit(){ if(this.data.info.rent_max *1 >0){ // 如果有输入最大金额 if(this.data.info.rent_max*1 < this.data.info.rent_min*1){ wx.showModal({ title: '提示', content: '租金区间最大金额不能小于最小金额~', }) return false } } let myEventDetail = {}; let myEventOption = {}; for(let i in this.data.info){ if(i =='rent_min' || i =='rent_max'){ myEventDetail[i] = this.data.info[i] }else{ myEventDetail[i] = this.data.info[i].value } } this.setData({ show:false }) this.triggerEvent('selectSubmit', myEventDetail, myEventOption) } }, })