mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-23 21:36:38 +08:00
优化 加入小区
This commit is contained in:
parent
d8089d2b35
commit
aaf2087a98
2
app.js
2
app.js
@ -41,7 +41,7 @@ App({
|
||||
success: function (res, data){
|
||||
console.log(data);
|
||||
wx.setStorageSync('location', data.pois[0].title);
|
||||
wx.setStorageSync('currentLocation', data.reverseGeocoderResult.address_component);
|
||||
wx.setStorageSync('currentLocation', data.reverseGeocoderSimplify);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
2
app.json
2
app.json
@ -42,7 +42,7 @@
|
||||
]
|
||||
},
|
||||
"networkTimeout": {
|
||||
"request": 3000
|
||||
"request": 10000
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
|
||||
@ -18,7 +18,7 @@ const appInfo = {
|
||||
};
|
||||
|
||||
const urlInfo = {
|
||||
areaUrl: baseUrl +"appApi/app.listAreas"
|
||||
areaUrl: baseUrl +"appApi/area.listAreas"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,8 +10,18 @@ Page({
|
||||
data: {
|
||||
province:'',
|
||||
city:'',
|
||||
multiArray: [],
|
||||
multiIndex: [0, 0, 0],
|
||||
provinces:[],
|
||||
citys:[]
|
||||
areas:[],
|
||||
currentArea:{},
|
||||
|
||||
communityName:'',
|
||||
ownerName:'',
|
||||
idCard:'',
|
||||
tel:'',
|
||||
validateCode:''
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@ -19,10 +29,10 @@ Page({
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
//查询省级地区
|
||||
let pros = this._loadArea('101','0');
|
||||
this.setData({
|
||||
provinces: pros.areas,
|
||||
})
|
||||
let pros = this._loadArea('','');
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@ -40,10 +50,13 @@ Page({
|
||||
this.setData({
|
||||
province: curLocation.province,
|
||||
city: curLocation.city,
|
||||
communityName:'',
|
||||
idCard:'',
|
||||
tel:'',
|
||||
validateCode:'',
|
||||
|
||||
communityName: '',
|
||||
ownerName: '',
|
||||
idCard: '',
|
||||
tel: '',
|
||||
validateCode: ''
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
@ -80,8 +93,17 @@ Page({
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
|
||||
bindRegionChange: function (e) {
|
||||
console.log('picker发送选择改变,携带值为', e.detail.value)
|
||||
// this.setData({
|
||||
// region: e.detail.value
|
||||
// })
|
||||
|
||||
},
|
||||
_loadArea:function(_level,_parentAreaCode){
|
||||
let that = this;
|
||||
wx.request({
|
||||
url: urlInfo.areaUrl,
|
||||
header: util.getHeaders(),
|
||||
@ -89,26 +111,125 @@ Page({
|
||||
areaLevel: _level, // 临时登录凭证
|
||||
parentAreaCode: _parentAreaCode
|
||||
},
|
||||
|
||||
success: function (res) {
|
||||
console.log('login success');
|
||||
res = res.data;
|
||||
var province = [], city = [], area = [];
|
||||
var _currentArea = [];
|
||||
province = res.areas.filter(item => {
|
||||
return item.parentAreaCode == 0;
|
||||
})
|
||||
city = res.areas.filter(item => {
|
||||
return item.parentAreaCode == province[0].areaCode;
|
||||
})
|
||||
area = res.areas.filter(item => {
|
||||
return item.parentAreaCode == city[0].areaCode;
|
||||
})
|
||||
var provinceList = province.map(item => {
|
||||
return item.areaName;
|
||||
})
|
||||
var cityList = city.map(item => {
|
||||
return item.areaName;
|
||||
})
|
||||
var quyuList = area.map(item => {
|
||||
return item.areaName;
|
||||
});
|
||||
let curLocation = wx.getStorageSync("currentLocation");
|
||||
_currentArea = res.areas.filter(item => {
|
||||
return item.areaCode == curLocation.adcode;
|
||||
})
|
||||
that.setData({
|
||||
multiArray: [provinceList, cityList, quyuList],
|
||||
areas: res.areas,
|
||||
currentArea: _currentArea[0],
|
||||
province
|
||||
});
|
||||
|
||||
|
||||
if (res.result == 0) {
|
||||
that.globalData.userInfo = res.userInfo;
|
||||
wx.setStorageSync('userInfo', JSON.stringify(res.userInfo));
|
||||
wx.setStorageSync('loginFlag', res.sessionKey);
|
||||
callback();
|
||||
} else {
|
||||
that.showInfo(res.errmsg);
|
||||
}
|
||||
},
|
||||
|
||||
fail: function (error) {
|
||||
// 调用服务端登录接口失败
|
||||
that.showInfo('调用接口失败');
|
||||
wx.showToast({
|
||||
title: '调用接口失败',
|
||||
});
|
||||
console.log(error);
|
||||
}
|
||||
})
|
||||
},
|
||||
bindMultiPickerChange: function (e) {
|
||||
console.log('picker发送选择改变,携带值为', e.detail.value)
|
||||
this.setData({
|
||||
multiIndex: e.detail.value
|
||||
})
|
||||
},
|
||||
bindMultiPickerColumnChange: function (e) {
|
||||
console.log('修改的列为', e.detail.column, ',值为', e.detail.value,this.data);
|
||||
var data = {
|
||||
multiArray: this.data.multiArray,
|
||||
multiIndex: this.data.multiIndex
|
||||
};
|
||||
data.multiIndex[e.detail.column] = e.detail.value;
|
||||
const provinceName = data.multiArray[0][data.multiIndex[0]];
|
||||
let provinceId = "";
|
||||
let province = this.data.province;
|
||||
let quyuList = [], cityList = [], provinceList = [], city = [], area = [];
|
||||
try {
|
||||
province.forEach(item => {
|
||||
if (item.areaName === provinceName) {
|
||||
provinceId = item.areaCode;
|
||||
throw (new Error('find item'))
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
}
|
||||
city = this.data.areas.filter(item => {
|
||||
return item.parentAreaCode == provinceId;
|
||||
})
|
||||
if (e.detail.column == 0) {
|
||||
data.multiIndex = [e.detail.value, 0, 0];
|
||||
try {
|
||||
area = this.data.areas.filter(item => {
|
||||
return item.parentAreaCode == city[data.multiIndex[1]].areaCode;
|
||||
})
|
||||
} catch (err) { }
|
||||
} else if (e.detail.column == 1) {
|
||||
data.multiIndex[2] = 0;
|
||||
area = this.data.areas.filter(item => {
|
||||
return item.parentAreaCode == city[e.detail.value].areaCode;
|
||||
})
|
||||
} else {
|
||||
const cityName = data.multiArray[1][data.multiIndex[1]];
|
||||
let cityId = '';
|
||||
try {
|
||||
this.data.areas.forEach(item => {
|
||||
if (item.areaName === cityName) {
|
||||
cityId = item.areaCode;
|
||||
throw (new Error('find item'));
|
||||
}
|
||||
})
|
||||
} catch (err) { }
|
||||
area = this.data.areas.filter(item => {
|
||||
return item.parentAreaCode == cityId;
|
||||
//return item.parentAreaCode == city[e.detail.value].areaCode;
|
||||
|
||||
})
|
||||
}
|
||||
provinceList = province.map(item => {
|
||||
return item.areaName
|
||||
})
|
||||
cityList = city.map(item => {
|
||||
return item.areaName;
|
||||
})
|
||||
quyuList = area.map(item => {
|
||||
return item.areaName;
|
||||
});
|
||||
data.currentArea = area[data.multiIndex[2]];
|
||||
data.multiArray = [provinceList, cityList, quyuList],
|
||||
this.setData(data);
|
||||
},
|
||||
enterCommunity:function(e){
|
||||
this.data.areaCode = this.data.currentArea.areaCode;
|
||||
console.log("提交数据",this.data);
|
||||
}
|
||||
})
|
||||
@ -2,48 +2,62 @@
|
||||
<view class="weui-form">
|
||||
<view class="">
|
||||
<view class="weui-cells__group weui-cells__group_form">
|
||||
<view class="weui-cells">
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">省份</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="text" value="{{province}}" placeholder="请输入省份名称"/>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<view class="weui-cell_select weui-cell " >
|
||||
<view class="weui-cell__hd ">
|
||||
<label class="weui-label" style="margin-left:64rpx">市、区</label>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">市/州</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="text" value="{{city}}" placeholder="请输入州市"/>
|
||||
<picker mode="multiSelector"
|
||||
bindchange="bindMultiPickerChange"
|
||||
bindcolumnchange="bindMultiPickerColumnChange"
|
||||
value="{{multiIndex}}"
|
||||
range="{{multiArray}}" >
|
||||
<view class="weui-select " style="margin-left:-48rpx">
|
||||
{{currentArea.parentAreaName}}{{currentArea.areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">小区名称</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="text" placeholder="请输入名称"/>
|
||||
<input class="weui-input" type="text" placeholder="请输入名称" value="{{communityName}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<label class="weui-label">
|
||||
姓<text decode="{{true}}"> </text>名
|
||||
</label>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="text" placeholder="请输入姓名" value="{{ownerName}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">身份证</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="number" placeholder="请输入身份证"/>
|
||||
<input class="weui-input" type="number" placeholder="请输入身份证" value="{{idCard}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">手机号</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="number" placeholder="请输入登记手机号"/>
|
||||
<input class="weui-input" type="number" placeholder="请输入登记手机号" value="{{tel}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd"><label class="weui-label">验证码</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" type="number" placeholder="请输入验证码"/>
|
||||
<input class="weui-input" type="number" placeholder="请输入验证码" value="{{validateCode}}"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-form__control-area ">
|
||||
<button type="primary">确定</button>
|
||||
<button type="primary" catchtap="enterCommunity">申请加入</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
Loading…
Reference in New Issue
Block a user