diff --git a/pages/family/family.js b/pages/family/family.js index f11e2cc..9a6d0d5 100644 --- a/pages/family/family.js +++ b/pages/family/family.js @@ -10,6 +10,7 @@ Page({ */ data: { "sexArr":["男","女"], + "sexShow":false, "sex": "0", "name": "", "link": "", @@ -17,14 +18,25 @@ Page({ "ownerId": "", "userId": "", "ownerTypeCd": "1002", + "idCard":"", "age": "", - "memberId": "" + "memberId": "-1", + "communityId":"", + "remark":'' }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) {}, + onLoad: function(options) { + let _that = this; + context.getOwner(function(_owner){ + _that.setData({ + ownerId: _owner.memberId, + communityId: _owner.communityId + }); + }); + }, /** * 生命周期函数--监听页面初次渲染完成 @@ -60,34 +72,17 @@ Page({ onPullDownRefresh: function() { }, - - - bindSexChange: function(e) { - this.setData({ - sex: e.detail.value - }) + bindInput: function (e) { + console.log('数据监听', e); + let _that = this; + let dataset = e.currentTarget.dataset; + let value = e.detail; + let name = dataset.name; + _that.data[name] = value; + console.log(this.data); }, - bindOwnerId: function(e) { - this.setData({ - ownerId: e.detail.value - }) - }, - bindName: function(e) { - this.setData({ - name: e.detail.value - }) - }, - bindAge: function(e) { - this.setData({ - age: e.detail.value - }) - }, - bindRemark: function(e) { - this.setData({ - remark: e.detail.value - }) - }, - submitRepair: function(e) { + submitOwnerMember: function(e) { + console.log('请求信息',e); let obj = { "sex": this.data.sex, "name": this.data.name, @@ -97,7 +92,9 @@ Page({ "userId": this.data.userId, "ownerTypeCd": this.data.ownerTypeCd, "age": this.data.age, - "memberId": this.data.memberId + "memberId": this.data.memberId, + "communityId":this.data.communityId, + "idCard":this.data.idCard } let msg = ""; if (obj.ownerId == "") { @@ -108,6 +105,8 @@ Page({ msg = "请填写性别"; } else if (obj.age == "") { msg = "请填写年龄"; + } else if(obj.idCard == ""){ + msg = "请填写身份证"; } if (msg != "") { wx.showToast({ @@ -116,28 +115,60 @@ Page({ duration: 2000 }) } else { + wx.showLoading({ + title: '提交中', + }); console.log("提交数据", obj); wx.request({ - url: constant.url.saveOwner, // http://hc.demo.winqi.cn:8012/appApi/ownerRepair.saveOwnerRepair + url: constant.url.saveOwner, header: context.getHeaders(), method: "POST", - data: { - "sex": "1", - "name": "1", - "link": "1", - "remark": "1", - "ownerId": "1", - "userId": "1", - "ownerTypeCd": "1002", - "age": "11", - "memberId": "1" - }, + data: obj, // data:obj, //动态数据 success: function(res) { console.log(res, 99999); + + if (res.statusCode == 200) { + wx.hideLoading(); + wx.navigateBack(); + return; + } + + wx.hideLoading(); + wx.showToast({ + title: res.data, + icon: 'none', + duration: 2000 + }); + }, + fail: function (e) { + wx.hideLoading(); + wx.showToast({ + title: "服务器异常了", + icon: 'none', + duration: 2000 + }) } }); } + }, + + onConfirm: function (e) { + let _sex = e.detail.index; + this.setData({ + sex:_sex, + sexShow: false + }); + }, + chooseSex: function (e) { + this.setData({ + sexShow: true + }); + }, + onCancel: function (e) { + this.setData({ + sexShow: false + }); } }) \ No newline at end of file diff --git a/pages/family/family.json b/pages/family/family.json index 9e26dfe..2fed966 100644 --- a/pages/family/family.json +++ b/pages/family/family.json @@ -1 +1,4 @@ -{} \ No newline at end of file +{ + "enablePullDownRefresh": true, + "navigationBarTitleText": "添加成员" +} \ No newline at end of file diff --git a/pages/family/family.wxml b/pages/family/family.wxml index 9a09579..9be7d62 100644 --- a/pages/family/family.wxml +++ b/pages/family/family.wxml @@ -1,99 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - + 基本信息 + + + + + + + 联系信息 + + + + 发送验证码 + + + + - - - - - + + + - - - {{sexArr[sex]}} - - - - - - - - - - - - - - - - - - - - - - - -