优化家庭成员

This commit is contained in:
wuxw 2020-01-19 16:49:01 +08:00
parent 7d621c4285
commit aacf7447fb
8 changed files with 216 additions and 236 deletions

View File

@ -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
});
}
})

View File

@ -1 +1,4 @@
{}
{
"enablePullDownRefresh": true,
"navigationBarTitleText": "添加成员"
}

View File

@ -1,99 +1,32 @@
<view class="page">
<view class="weui-form">
<view class="">
<view class="weui-cells__group weui-cells__group_form">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">业
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text> 主
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindOwnerId" class="weui-input" type="text" placeholder="请输入业主" value="{{ownerId}}" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">姓
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text> 名
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindName" class="weui-input" type="text" placeholder="请输入姓名" value="{{name}}" />
</view>
</view>
<view class="block__title">基本信息</view>
<van-cell-group>
<van-field value="{{ name }}" required label="名称" data-name="name" bindinput="bindInput" placeholder="请输入成员名称" />
<van-field value="{{ sex == '0'?'男':'女' }}" bindinput="bindInput" label="性别" placeholder="请选择成员性别" required readonly icon="arrow" catchtap="chooseSex"/>
<van-field value="{{ age }}" bindinput="bindInput" data-name="age" label="年龄" placeholder="请输入年龄" required />
<van-field value="{{ idCard }}" bindinput="bindInput" data-name="idCard" type="idcard" label="身份证" placeholder="请输入身份证" required />
</van-cell-group>
<view class="block__title">联系信息</view>
<van-cell-group>
<van-field value="{{ link }}" bindinput="bindInput" data-name="link" type="number" label="手机号" placeholder="请输入手机号" required />
<van-field value="{{ msgCode }}" bindinput="bindInput" data-name="msgCode" center clearable label="验证码" placeholder="请输入短信验证码" required>
<van-button slot="button" type="number" size="small" type="primary" catchtap="sendMsgCode">发送验证码</van-button>
</van-field>
<van-field value="{{ remark }}" bindinput="bindInput" label="备注" type="textarea" placeholder="请输入备注" autosize border="{{ false }}" use-button-slot />
</van-cell-group>
<view class="button_up_blank"></view>
<view class="weui-cell_select weui-cell ">
<view class="weui-cell__hd ">
<label class="weui-label" style="margin-left:64rpx">性
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text> 别</label>
</view>
<view class="weui-cell__bd">
<van-popup show="{{ sexShow }}" position="bottom" custom-style="height: 40%;">
<van-picker
show-toolbar
title="选择性别"
columns="{{ sexArr }}"
bind:cancel="onCancel"
bind:confirm="onConfirm"
/>
</van-popup>
<picker bindchange="bindSexChange" value="{{index}}" range="{{sexArr}}">
<view class="weui-select" style="margin-left:-48rpx">
{{sexArr[sex]}}
</view>
</picker>
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text> 龄
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindAge" class="weui-input" type="text" placeholder="请输入年龄" value="{{age}}" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
备<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text>
<text decode="{{true}}">&nbsp;</text> 注
</label>
</view>
<view class="weui-cell__bd">
<textarea bindblur="bindRemark" class="repair_textarea" value="{{remark}}" rows="3" placeholder="备注" />
</view>
</view>
</view>
</view>
</view>
<view class="">
<button type="primary" catchtap="submitRepair">确认报修</button>
</view>
</view>
<van-button type="primary" size="large" catchtap="submitOwnerMember">提交</van-button>
</view>

View File

@ -1,17 +1,11 @@
.user-container {
padding: 25rpx 10rpx;
background-color: #F0F0F0;
/*border: 1px solid black;*/
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69,90,100,.6);
padding: 40rpx 30rpx 20rpx;
}
.form{
background-color: #fff;
margin: 10rpx 7rpx;
}
.repair_textarea{
width: 100%;
height: 150rpx;
}
.repair_image{
width: 150rpx;
height: 150rpx;
.button_up_blank{
height: 40rpx;
}

View File

@ -4,43 +4,58 @@ const constant = context.constant;
Page({
data: {
tableData: [],
owners: [],
page: 1,
totalPage: 0,
loading: false
loading: false,
communityId:'',
ownerId:''
},
onLoad: function() {
let that = this;
context.getOwner(function(_owner) {
console.log(_owner.communityId,99999999);
},
onShow: function () {
let that = this;
context.getOwner(function (_owner) {
console.log(_owner.communityId, 99999999);
that.setData({
communityId: _owner.communityId,
ownerId: _owner.memberId
})
that.getTable(1);
})
},
onShow: function () {
let that = this;
});
},
getTable: function (page, override) {
let that = this;
this.setData({
loading: true
})
return this.request({
"ownerId": that.data.communityId,
"communityId": that.data.ownerId
// "page": page,
// "row": 10
}).then(res => {
that.setData({
tableData: override ? res.data.ownerRepairs : this.data.tableData.concat(res.data.ownerRepairs),
totalPage: res.data.records,
page: page,
loading: false
})
});
let _paramIn = {
"communityId": that.data.communityId,
"ownerId": that.data.ownerId
};
context.request({
url: constant.url.queryOwnerMembers,
header: context.getHeaders(),
method: "GET",
data: _paramIn,
success: function (res) {
if (res.statusCode == 200) {
let _owners = res.data.owners;
that.setData({
owners : _owners,
loading: false
})
}
},
fail:function(e){
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
})
},
goAdd: function (e) {
@ -69,21 +84,5 @@ Page({
if (!this.data.loading && this.data.page < this.data.totalPage) {
this.getTable(this.data.page + 1)
}
},
//封装请求
request: function (data) {
return new Promise((resolve, reject) => {
wx.request({
url: constant.url.queryOwnerMembers,
header: context.getHeaders(),
method: "POST",
data: data,
success: function (res) {
if (res.statusCode == 200) {
resolve(res);
}
}
})
})
},
}
})

View File

@ -1,3 +1,4 @@
{
"enablePullDownRefresh": true
"enablePullDownRefresh": true,
"navigationBarTitleText": "家庭成员"
}

View File

@ -1,22 +1,35 @@
<view class="user-container">
<view class="add_button">
<button size="mini" type="primary" catchtap="goAdd" data-item="{{item}}">+ 添加</button>
</view>
<view wx:for="{{tableData}}" wx:for-index="idx" wx:for-item="item" class="notice" data-item="{{item}}" bindtap="gotoDetail">
<view class="title">
<view>{{item.repairName}}</view>
<view>{{item.appointmentTime}}</view>
</view>
<view class="main">
<view>
<view class="text"> 性别: {{item.repairTypeName}}</view>
<view class="text"> 年龄: {{item.stateName}}</view>
<view class="text"> 电话: {{item.tel}}</view>
<view class="block__title">成员信息</view>
<view class="ppfl_c" wx:for="{{owners}}" wx:for-index="idx" wx:for-item="item" >
<van-panel title="{{item.name}}" desc="" status="{{item.link}}" >
<view class="ppfl_context">
<van-row >
<van-col span="8">成员编号:</van-col>
<van-col span="16">{{item.memberId}}</van-col>
</van-row>
<van-row class="ppfl_context_row">
<van-col span="8">身份证号:</van-col>
<van-col span="16">{{item.idCard}}</van-col>
</van-row>
<van-row class="ppfl_context_row">
<van-col span="8">成员年龄:</van-col>
<van-col span="16">{{item.age}}岁</van-col>
</van-row>
<van-row class="ppfl_context_row">
<van-col span="8">成员性别:</van-col>
<van-col span="16">{{item.sex == 0? '男': '女'}}</van-col>
</van-row>
</view>
<view>
<button class="button" size="mini" type="default" catchtap="gotoDetail" data-item="{{item}}">修改</button>
<button class="button" size="mini" type="default" catchtap="gotoDetail" data-item="{{item}}">删除</button>
</view>
</view>
</van-panel>
</view>
<view class="block__bottom"></view>
<van-submit-bar
button-type="primary"
button-text="添加成员"
bind:submit="goAdd"
>
<view slot="tip">
</view>
</van-submit-bar>
</view>

View File

@ -1,34 +1,40 @@
.user-container {
padding: 25rpx 10rpx;
background-color: #F0F0F0;
.ppfl_footer{
text-align: right;
}
.ppfl_footer .ppfl_footer_his{
margin-right: 20rpx;
}
/*border: 1px solid black;*/
.ppfl_c{
padding: 0rpx 20rpx 20rpx 20rpx;
}
.add_button{
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69,90,100,.6);
padding: 40rpx 30rpx 20rpx;
}
.notice {
margin: 10rpx 7rpx;
padding: 25rpx;
background-color: #ffffff;
border-radius: 7rpx;
/* display: flex;
justify-content: space-between;
align-items: flex-end; */
.ppfl_context{
padding: 20rpx 40rpx 40rpx 40rpx;
font-size: 28rpx;
color: #8a8a8a;
}
.title {
border-bottom: 1rpx solid #dedede;
font-weight: 700;
font-size: 34rpx;
color: #5f5e5e;
display: flex;
justify-content: space-between;
.ppfl_context .ppfl_context_row{
margin-top: 30rpx;
}
.text{
padding: 4rpx 0;
font-size: 30rpx;
.button_up_blank{
height: 40rpx;
}
.main{
display: flex;
justify-content: space-between;
align-items: flex-end;
.block__bottom{
height: 160rpx;
}
.van-submit-bar__tip{
background-color: #e8e8e8;
}