const util = require('../../../utils/util.js'); Component({ properties: { theam:{ type: String, value:'redContent', observer: function (newVal) { this.setData({ theam: newVal }); } }, prizeId:{ type: String, observer: function (newVal) { this.setData({ id: newVal }); } }, show:{ type: Boolean, observer: function (val){ this.setData({ show: val }); if (val) {this.getFormData()} } }, }, data: { id:'', show:false, height:'60%', theam:'redContent', provincial:'', address:'', info:{ region: ['浙江省', '杭州市', '上城区'] } }, methods: { bindRegionChange(e) { let value = e.detail.value, provincial = this.data.provincial; if (value){ provincial=value.join('/') } this.setData({ 'info.region':provincial }); }, save(e){ let data = e.detail.value,that=this; if (util.isEmpty(data.contactName)) { util.showTips('姓名不能为空'); return false; } if (util.isEmpty(data.contactPhone)) { util.showTips('手机号不能为空'); return false; } if (util.isPhone(data.contactPhone)) { util.showTips('请正确填写手机号');; return false; } if (util.isEmpty(data.provincial)) { util.showTips('省市区不能为空'); return false; } if (util.isEmpty(data.address)) { util.showTips('详细地址不能为空'); return false; } let arr =[]; arr.push(data.provincial) arr.push(data.address) data.mailAddress = arr.join(' '); data.id = this.data.id; util.ajax({ func: "v2/market/wheel/record/change/mailAddress", method:'post', data: data }, function (res) { if (res.code==0) { util.showTips(res.reason) setTimeout(() => { that.closePopup() }, 500); } else {util.showTips(res.reason)} }) }, // 获取表单数据 getFormData(){ let that = this; util.ajax({ func: "v2/market/wheel/record/mailAddress", data: {id:this.data.id} }, function (res) { if (res.code==0) { let data = res.data; let region = data.mailAddress.split(' ')[0] data.region = region.split('/'); data.address = data.mailAddress.split(' ')[1] that.setData({info:data}) } else {util.showTips(res.reason)} }) }, // 关闭弹窗 closeTip(e){ this.close(e.detail) }, // 确定 closePopup(){ this.close(false) }, close(data){ this.triggerEvent("close", { status:data, type:'address' }); } } })