户籍信息录入

This commit is contained in:
itgaojian 2023-12-06 15:50:43 +08:00
parent 0ac48d15f3
commit 78ba1fc1ae
10 changed files with 1665 additions and 114 deletions

View File

@ -10,7 +10,8 @@
"pages/mine/mine",
"pages/censusinput/censusinput",
"pages/chooseArea/chooseArea",
"pages/censusDetail/censusDetail"
"pages/censusDetail/censusDetail",
"pages/censusEdit/censusEdit"
],
"window": {
"backgroundTextStyle": "light",

View File

@ -48,6 +48,7 @@ Page({
bean: data
});
}, (code, error) => {
console.log(error);
wx.hideLoading();
wx.showToast({
title: '加载失败',
@ -57,7 +58,15 @@ Page({
},
//编辑
doEdit() {
var _self = this;
wx.navigateTo({
url: '/pages/censusEdit/censusEdit?id=' + _self.data.id,
events: {
doNeedRefresh: (data) => {
_self.getDetailData();
}
}
})
},
//删除
doDel() {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
{
"usingComponents": {
"t-picker": "/miniprogram_npm/tdesign-miniprogram/picker/picker",
"t-picker-item": "/miniprogram_npm/tdesign-miniprogram/picker-item/picker-item",
"t-date-time-picker": "/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker"
},
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "户籍信息编辑"
}

View File

@ -0,0 +1,341 @@
<scroll-view scroll-y style="height:{{scrollHeight}}px;padding-bottom: 35px;">
<view class="page-container">
<!-- 基础信息 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>基础信息</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title must">姓名</view>
<input class="form-content" placeholder="请输入姓名" bindinput="inputName" value="{{name}}" />
</view>
<view class="form-item" bind:tap="onShowCardType">
<view class="form-title must">证件类型</view>
<view class="form-content select">{{cardType==null?'请选择证件类型':cardType.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">证件号码</view>
<input class="form-content" placeholder="请输入证件号码" bindinput="inputCardNum" value="{{cardNum}}" />
</view>
<view class="form-item">
<view class="form-title must">出生日期</view>
<view class="form-content select" bind:tap="onShowBirthDay">{{birthDay==''?'请选择出生日期':birthDay}}</view>
</view>
<view class="form-item">
<view class="form-title must">性别</view>
<view class="form-content select" bind:tap="onShowGender">{{gender==null?'请选择性别':gender.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">民族</view>
<view class="form-content select" bind:tap="onShowNation">{{nation==null?'请选择民族':nation.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">文化程度</view>
<view class="form-content select" bind:tap="onShowEdu">{{edu==null?'请选择文化程度':edu.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">与户主关系</view>
<view class="form-content select" bind:tap="onShowRelation">{{relation==null?'请选择与户主关系':relation.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">联系电话</view>
<input class="form-content" placeholder="请输入联系电话" bindinput="inputPhoneNum" type="number" value="{{phoneNum}}" />
</view>
</view>
<!-- 宗教、学历、工作信息 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>宗教、学历、工作等信息</view>
</view>
<view class="box-container">
<view class="form-item ver">
<view class="form-title ">就读院校及专业</view>
<textarea class="form-textarea" placeholder="请输入就读院校及专业" placeholder-style="font-size:14px;" bindinput="inputAcademy" value="{{academy}}" />
</view>
<view class="form-item">
<view class="form-title must">所属党派</view>
<view class="form-content select" bind:tap="onShowPolitical">{{political==null? '请选择所属党派':political.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">宗教信仰</view>
<view class="form-content select" bind:tap="onShowReligion">{{religion== null? '请选择宗教信仰':religion.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">婚姻状况</view>
<view class="form-content select" bind:tap="onShowMarry">{{marry== null?'请选择婚姻状况':marry.label}}</view>
</view>
<view class="form-item">
<view class="form-title">婚变日期</view>
<view class="form-content select" bind:tap="onShowMarryChangeDate">{{marryChangeDate== "" ? '请选择婚变日期':marryChangeDate}}</view>
</view>
<view class="form-item">
<view class="form-title">初婚日期</view>
<view class="form-content select" bind:tap="onShowMarryDate">{{marryDate=="" ? '请选择与初婚日期':marryDate}}</view>
</view>
<view class="form-item">
<view class="form-title must">社会保险情况</view>
<view class="form-content select" bind:tap="onShowInsure">{{insure==null ? '请选择社会保险情况':insure.label}}</view>
</view>
<view class="form-item">
<view class="form-title must">健康状况</view>
<view class="form-content select" bind:tap="onShowHealth">{{health==null ? '请选择健康状况':health.label}}</view>
</view>
<view class="form-item ver">
<view class="form-title">就业状况</view>
<radio-group bindchange="onSelJobStatus">
<radio checked="{{jobStatus=='已就业'}}" value="已就业">已就业</radio>
<radio checked="{{jobStatus=='未就业'}}" value="未就业">未就业</radio>
<radio checked="{{jobStatus=='灵活就业'}}" value="灵活就业">灵活就业</radio>
<radio checked="{{jobStatus=='退休'}}" value="退休">退休</radio>
</radio-group>
</view>
<view class="form-item">
<view class="form-title">工作单位</view>
<input class="form-content" placeholder="请输入工作单位" bindinput="inputWorkPlace" value="{{workPlace}}" />
</view>
<view class="form-item">
<view class="form-title">工作职务</view>
<input class="form-content" placeholder="请输入工作职务" bindinput="inputJobTitle" value="{{jobTitle}}" />
</view>
<view class="form-item">
<view class="form-title">专业技术职称</view>
<input class="form-content" placeholder="请输入专业技术职称" bindinput="inputTechnical" value="{{technical}}" />
</view>
<view class="form-item">
<view class="form-title">专长</view>
<input class="form-content" placeholder="请输入专长" bindinput="inputSpeciality" value="{{speciality}}" />
</view>
</view>
<!-- 家庭信息 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>家庭信息</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">父亲姓名</view>
<input class="form-content" placeholder="请输入父亲姓名" bindinput="inputFather" value="{{fatherName}}" />
</view>
<view class="form-item">
<view class="form-title">父亲证件</view>
<input class="form-content" placeholder="请输入父亲证件号码" bindinput="inputFatherCardNum" value="{{fatherCardNum}}" />
</view>
<view class="form-item">
<view class="form-title">父亲电话</view>
<input class="form-content" placeholder="请输入父亲联系电话" bindinput="inputFatherPhone" value="{{fatherPhone}}" />
</view>
<view class="form-item">
<view class="form-title">母亲姓名</view>
<input class="form-content" placeholder="请输入母亲姓名" bindinput="inputMather" value="{{matherName}}" />
</view>
<view class="form-item">
<view class="form-title">母亲证件</view>
<input class="form-content" placeholder="请输入母亲证件号码" bindinput="inputMatherCardNum" value="{{matherCardNum}}" />
</view>
<view class="form-item">
<view class="form-title">母亲电话</view>
<input class="form-content" placeholder="请输入母亲联系电话" bindinput="inputMatherPhone" value="{{matherPhone}}" />
</view>
<view class="form-item">
<view class="form-title must">户籍地址</view>
<view class="form-content select" bind:tap="onShowCensus">{{censusAddress==null?'请选择户籍地址':censusAddress.name}}</view>
</view>
<view class="form-item">
<view class="form-title">户籍详细地址</view>
<input class="form-content" placeholder="请输入户籍详细地址" bindinput="inputCensusDetail" value="{{censusDetail}}" />
</view>
<view class="form-item">
<view class="form-title">籍贯地址</view>
<input class="form-content" placeholder="请输入籍贯地址" bindinput="inputNative" value="{{nativeAddress}}" />
</view>
<view class="form-item">
<view class="form-title">流动日期</view>
<view class="form-content select" bind:tap="onShowFlowDate">{{flowDate=="" ? '请选择流动日期':flowDate}}</view>
</view>
<view class="form-item">
<view class="form-title">流动原因</view>
<view class="form-content select" bind:tap="onShowFlowReason">{{flowReason== null ? '请选择流动原因':flowReason.label}}</view>
</view>
<view class="form-item">
<view class="form-title">其他原因</view>
<input class="form-content" placeholder="请输入其他原因" bindinput="inputFlowOtherReason" value="{{flowOtherReason}}" />
</view>
</view>
<!-- 老年人 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>老年人</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">是否为老年人</view>
<switch checked="{{isOld=='是'}}" class="form-content" bindchange="onSelIsOld"></switch>
</view>
<view class="form-item">
<view class="form-title">老人类别</view>
<view class="form-content select" bind:tap="onShowOldType">{{oldType==null?'请选择老人类别':oldType.label}}</view>
</view>
<view class="form-item">
<view class="form-title">离退休前单位</view>
<input class="form-content" placeholder="请输入离退休前单位" bindinput="inputRetireWorkUnit" value="{{retireWorkUnit}}" />
</view>
<view class="form-item">
<view class="form-title">生活照料情况</view>
<view class="form-content select" bind:tap="onShowLiveTakeCare">{{liveTakeCare==null?'请选择生活照料情况':liveTakeCare.label}}</view>
</view>
<view class="form-item">
<view class="form-title">健康情况</view>
<view class="form-content select" bind:tap="onShowOldHealthStatus">{{oldHealthStatus==null?'请选择健康情况':oldHealthStatus.label}}</view>
</view>
<view class="form-item">
<view class="form-title">生活自理能力</view>
<view class="form-content select" bind:tap="onShowOldSelfCare">{{oldSelfCare==null?'请选择生活自理能力':oldSelfCare.label}}</view>
</view>
<view class="form-item">
<view class="form-title">居住状况</view>
<view class="form-content select" bind:tap="onShowOldLiveStatus">{{oldLiveStatus==null?'请选择居住状况':oldLiveStatus.label}}</view>
</view>
</view>
<!-- 残疾人 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>残疾人</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">是否为残疾人</view>
<switch class="form-content" checked="{{isDeformity=='是'}}" bindchange="onSelIsDeformity"></switch>
</view>
<view class="form-item">
<view class="form-title">残疾类别</view>
<view class="form-content select" bind:tap="onShowDeformityType">{{deformityType==null?'请选择残疾类别':deformityType.label}}</view>
</view>
<view class="form-item">
<view class="form-title">残疾等级</view>
<view class="form-content select" bind:tap="onShowDeformityLevel">{{deformityLevel==null?'请选择残疾等级':deformityLevel.label}}</view>
</view>
<view class="form-item">
<view class="form-title">残疾证号</view>
<input class="form-content" placeholder="请输入残疾证号" bindinput="inputDeformityCardNum" value="{{deformityCardNum}}" />
</view>
<view class="form-item">
<view class="form-title">残疾车牌号</view>
<input class="form-content" placeholder="请输入残疾车牌号" bindinput="inputDeformityCarNum" value="{{deformityCarNum}}"/>
</view>
<view class="form-item">
<view class="form-title">居住地址</view>
<view class="form-content select" bind:tap="onShowDeformityLiveAddress">{{deformityLiveAddress==null?'请选择居住地址':deformityLiveAddress.name}}</view>
</view>
<view class="form-item">
<view class="form-title">收入情况</view>
<view class="form-content select" bind:tap="onShowDeformityEarning">{{deformityEarning== null? '请选择收入情况':deformityEarning.label}}</view>
</view>
<view class="form-item">
<view class="form-title">住房来源</view>
<view class="form-content select" bind:tap="onShowDeformityHouseSource">{{deformityHouseSource==null?'请选择住房来源':deformityHouseSource.label}}</view>
</view>
<view class="form-item">
<view class="form-title">办证时间</view>
<view class="form-content select" bind:tap="onShowCerDate">{{cerDate==""?'请选择办证时间':cerDate}}</view>
</view>
<view class="form-item">
<view class="form-title">监护人或配偶姓名</view>
<input class="form-content" placeholder="请输入监护人或配偶姓名" bindinput="inputGuarder" value="{{deformityGuarder}}" />
</view>
<view class="form-item">
<view class="form-title">监护人电话</view>
<input class="form-content" placeholder="请输入监护人联系电话" bindinput="inputGuarderPhone" value="{{deformityGuarderPhone}}" />
</view>
<view class="form-item">
<view class="form-title">监护人关系</view>
<view class="form-content select" bind:tap="onShowGuarderRelation">{{deformityGuarderRelation==null?'请选择监护人关系':deformityGuarderRelation.label}}</view>
</view>
</view>
<!-- 服役/退役 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>服役/退役</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">是否为服役/退役</view>
<switch class="form-content" checked="{{isSoldier=='是'}}" bindchange="onSelIsSoldier"></switch>
</view>
<view class="form-item">
<view class="form-title">批准退出现役日期</view>
<view class="form-content select" bind:tap="onShowSoldierRetireDate">{{soldierRetireDate==""?'请选择批准退出现役日期':soldierRetireDate}}</view>
</view>
<view class="form-item">
<view class="form-title">退出现役时职级</view>
<view class="form-content select" bind:tap="onShowSoldierRetireLevel">{{soldierRetireLevel==null?'请选择批准退出现役时职级':soldierRetireLevel.label}}</view>
</view>
</view>
<!-- 社会救助 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>社会救助</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">是否为社会救助</view>
<switch class="form-content" checked="{{isSocial=='是'}}" bindchange="onSelIsSocial"></switch>
</view>
<view class="form-item">
<view class="form-title">低保户</view>
<switch class="form-content" checked="{{isLow=='是'}}" bindchange="onShowIsLow"></switch>
</view>
<view class="form-item">
<view class="form-title">医疗救助</view>
<switch class="form-content" checked="{{isMedical=='是'}}" bindchange="onSelIsMedical"></switch>
</view>
<view class="form-item">
<view class="form-title">困难职工</view>
<switch class="form-content" checked="{{isHard=='是'}}" bindchange="onSelIsHard"></switch>
</view>
<view class="form-item">
<view class="form-title">老龄补贴</view>
<switch class="form-content" checked="{{isSubsidy=='是'}}" bindchange="onSelIsSubsidy"></switch>
</view>
</view>
<!-- 党员信息 -->
<view class="form-head">
<view class="form-head-line"></view>
<view>党员</view>
</view>
<view class="box-container">
<view class="form-item">
<view class="form-title">是否为党员</view>
<switch class="form-content" checked="{{isPartyMember=='是'}}" bindchange="onSelIsPartyMember"></switch>
</view>
<view class="form-item">
<view class="form-title">党组织名称</view>
<input class="form-content" placeholder="请输入党组织名称" bindinput="inputPartyName" value="{{partyName}}" />
</view>
<view class="form-item">
<view class="form-title">入党时间</view>
<view class="form-content select" bind:tap="onShowIntoPartyDate">{{intoPartyDate==""?'请选择入党时间':intoPartyDate}}</view>
</view>
<view class="form-item ver">
<view class="form-title">其他说明</view>
<textarea class="form-textarea" placeholder="请输入其他说明" placeholder-style="font-size:14px;" bindinput="inputPartyMemberDesc" value="{{partyMemberDesc}}" />
</view>
</view>
<!-- 字典选择 -->
<t-picker visible="{{showPicker}}" value="{{dicList}}" keys="{{keys}}" title="请选择" cancelBtn="取消" confirmBtn="确认" data-type="{{currentDicType}}" bindchange="onDicPickerChange" bindpick="onCardTypePick" bindcancel="onDicPickerCancel">
<t-picker-item options="{{dicList}}" />
</t-picker>
<!-- 日期选择 -->
<t-date-time-picker title="选择日期" visible="{{showDate}}" mode="date" defaultValue="{{date}}" format="YYYY-MM-DD" data-type="{{dateType}}" bindchange="onConfirmDate" bindpick="onDateChange" bindcancel="hideDatePicker" />
</view>
</scroll-view>
<view class="btn-submit" bind:tap="doConfirm">保存</view>

View File

@ -0,0 +1,121 @@
/* pages/censusinput/censusinput.wxss */
page {
background-color: #efefef;
}
.page-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-top: 5px;
border-radius: 10px;
flex-basis: 100%;
padding: 10px;
}
.box-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
border-radius: 10px;
background-color: white;
flex-basis: 100%;
padding-left: 10px;
padding-right: 10px;
margin-top: 10px;
width: 94%;
margin-bottom: 10px;
}
.form-item {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 5px;
width: fit-content;
width: 97%;
}
.ver {
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}
.form-textarea {
background-color: #EFEFEF;
width: 95%;
margin-top: 5px;
padding: 5px;
font-size: 14px;
height: 100px;
border-radius: 5px;
}
.form-title {
font-size: 14px;
flex: .4;
}
.must::after {
content: "*";
color: red;
}
.select::after {
content: "\25BC";
color: #6d6d6d;
font-size: 12px;
padding-left: 5px;
}
.form-content {
font-size: 14px;
flex: .6;
text-align: right;
padding: 5px;
}
.form-head {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
font-size: 15px;
color: black;
font-weight: bold;
}
.form-head-line {
height: 15px;
width: 6px;
background-color: #4985f8;
margin-right: 5px;
}
radio {
transform: scale(0.7);
font-size: 18px;
}
.btn-submit {
width: 100%;
position: fixed;
bottom: 0;
height: 48px;
background-color: #4985f8;
display: flex;
justify-content: center;
align-items: center;
align-self: center;
color: #FFFFFF;
z-index: 23;
}
.btn-submit:active {
transform: scale(0.9);
}

View File

@ -830,7 +830,8 @@ Page({
}, function (code, data) {
wx.hideLoading()
wx.showToast({
title: '保存失败',
title: data.msg ? data.msg : '保存失败',
icon: 'error'
})
});
}

View File

@ -6,5 +6,6 @@
},
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
"navigationBarTextStyle": "black",
"navigationBarTitleText": "户籍信息录入"
}

View File

@ -114,4 +114,7 @@ radio {
align-self: center;
color: #FFFFFF;
z-index: 23;
}
.btn-submit:active {
transform: scale(0.9);
}

View File

@ -1,8 +1,8 @@
var methods = {
POST_METHOD: 'POST',
DELETE_METHOD: 'DELETE',
PUT_METHOD: 'PUT',
GET_METHOD: 'GET'
POST_METHOD: 'POST',
DELETE_METHOD: 'DELETE',
PUT_METHOD: 'PUT',
GET_METHOD: 'GET'
};
/**
@ -15,7 +15,7 @@ var methods = {
* @param completeCallback
*/
function postJson(url, dataObj, args, successCallback, errorCallback, completeCallback) {
doAjax(url, methods.POST_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
doAjax(url, methods.POST_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@ -28,7 +28,7 @@ function postJson(url, dataObj, args, successCallback, errorCallback, completeCa
* @param completeCallback
*/
function deleteForm(url, dataObj, args, successCallback, errorCallback, completeCallback) {
doAjax(url, methods.DELETE_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
doAjax(url, methods.DELETE_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@ -41,7 +41,7 @@ function deleteForm(url, dataObj, args, successCallback, errorCallback, complete
* @param completeCallback
*/
function putJson(url, dataObj, args, successCallback, errorCallback, completeCallback) {
doAjax(url, methods.PUT_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
doAjax(url, methods.PUT_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@ -54,7 +54,7 @@ function putJson(url, dataObj, args, successCallback, errorCallback, completeCal
* @param completeCallback
*/
function getForm(url, dataObj, args, successCallback, errorCallback, completeCallback) {
doAjax(url, methods.GET_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
doAjax(url, methods.GET_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@ -68,34 +68,40 @@ function getForm(url, dataObj, args, successCallback, errorCallback, completeCal
* @param completeCallback
*/
function doAjax(url, method, dataObj, args, successCallback, errorCallback, completeCallback) {
var headers = {};
if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
headers = args.headers;
}
wx.request({
url: url,
method: method,
data: dataObj,
header: headers,
dataType: 'json',
success: function (response) {
if (response.statusCode == 200) {
successCallback(response.statusCode, response.data, args);
} else {
if (errorCallback && typeof (errorCallback) == 'function') {
errorCallback(response.statusCode, response.data);
}
}
},
fail: function (response) {
console.log(response);
},
complete: function () {
if (completeCallback && typeof (completeCallback) == 'function') {
completeCallback();
}
}
})
var headers = {};
if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
headers = args.headers;
}
wx.request({
url: url,
method: method,
data: dataObj,
header: headers,
dataType: 'json',
success: function (response) {
if (response.statusCode == 200) {
successCallback(response.statusCode, response.data, args);
} else {
console.log(response)
if (errorCallback && typeof errorCallback == 'function') {
console.log('走走');
errorCallback(response.statusCode, response.data);
}
}
},
fail: function (response) {
console.log(response);
if (errorCallback) {
console.log(response);
errorCallback(response.statusCode, response.data);
}
},
complete: function () {
if (completeCallback && typeof (completeCallback) == 'function') {
completeCallback();
}
}
})
}
/**
@ -104,18 +110,18 @@ function doAjax(url, method, dataObj, args, successCallback, errorCallback, comp
* @returns {boolean}
*/
function pathArgsHasSameValue(pathArgArray) {
var tempArgIndex = 0;
var tempArgs = pathArgArray[tempArgIndex];
for (var i = (tempArgIndex + 1), item; item = pathArgArray[i]; i++) {
if (tempArgs == item) {
throw new Error('参数' + item + '有重复值!!!');
}
if (i == pathArgArray.length - 1) {
tempArgs = pathArgArray[++tempArgIndex];
i = tempArgIndex;
continue;
}
}
var tempArgIndex = 0;
var tempArgs = pathArgArray[tempArgIndex];
for (var i = (tempArgIndex + 1), item; item = pathArgArray[i]; i++) {
if (tempArgs == item) {
throw new Error('参数' + item + '有重复值!!!');
}
if (i == pathArgArray.length - 1) {
tempArgs = pathArgArray[++tempArgIndex];
i = tempArgIndex;
continue;
}
}
}
/**
@ -123,22 +129,22 @@ function pathArgsHasSameValue(pathArgArray) {
* @param url
*/
function getParamsArg(url) {
var params = url.split('?')[1];
var paramsObj = {};
if (typeof (params) == 'undefined' || params == null) {
return paramsObj;
}
var paramsKVs = params.split('&');
for (var i = 0, item = null; item = paramsKVs[i++];) {
var kvs = item.split('=');
if (kvs.length == 1) {
paramsObj[kvs[0]] = null;
}
if (kvs.length == 2) {
paramsObj[kvs[0]] = decodeURI(kvs[1]);
}
}
return paramsObj;
var params = url.split('?')[1];
var paramsObj = {};
if (typeof (params) == 'undefined' || params == null) {
return paramsObj;
}
var paramsKVs = params.split('&');
for (var i = 0, item = null; item = paramsKVs[i++];) {
var kvs = item.split('=');
if (kvs.length == 1) {
paramsObj[kvs[0]] = null;
}
if (kvs.length == 2) {
paramsObj[kvs[0]] = decodeURI(kvs[1]);
}
}
return paramsObj;
}
/**
@ -148,22 +154,22 @@ function getParamsArg(url) {
* @returns {*}
*/
function buildPath(basePath, pathArgs) {
var path = basePath;
if (!basePath || !(typeof (basePath) == 'string')) {
throw new Error('basePath必须为字符串!!!');
}
if (!pathArgs || !Array.isArray(pathArgs)) {
throw new Error('pathArgs必须为数组!!!');
}
var pathArgArray = basePath.match(/\{\w+\}/g);
if (!pathArgArray) {
return path;
}
pathArgsHasSameValue(pathArgArray);
for (var i = 0, item; item = pathArgArray[i]; i++) {
path = path.replace(item, pathArgs[i]);
}
return path;
var path = basePath;
if (!basePath || !(typeof (basePath) == 'string')) {
throw new Error('basePath必须为字符串!!!');
}
if (!pathArgs || !Array.isArray(pathArgs)) {
throw new Error('pathArgs必须为数组!!!');
}
var pathArgArray = basePath.match(/\{\w+\}/g);
if (!pathArgArray) {
return path;
}
pathArgsHasSameValue(pathArgArray);
for (var i = 0, item; item = pathArgArray[i]; i++) {
path = path.replace(item, pathArgs[i]);
}
return path;
}
/**
@ -177,33 +183,33 @@ function buildPath(basePath, pathArgs) {
* @param completeCallback
*/
function postFile(url, path, name, args, successCallback, errorCallback, completeCallback) {
var headers = {};
if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
headers = args.headers;
}
wx.uploadFile({
filePath: path,
name: name,
url: url,
header: headers,
success: function (response) {
if (response.statusCode == 200) {
successCallback(response.statusCode, response.data, args);
} else {
if (errorCallback && typeof (errorCallback) == 'function') {
errorCallback(response.statusCode, response.data);
}
}
},
fail: function (response) {
console.log(response);
},
complete: function () {
if (completeCallback && typeof (completeCallback) == 'function') {
completeCallback();
}
}
})
var headers = {};
if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
headers = args.headers;
}
wx.uploadFile({
filePath: path,
name: name,
url: url,
header: headers,
success: function (response) {
if (response.statusCode == 200) {
successCallback(response.statusCode, response.data, args);
} else {
if (errorCallback && typeof (errorCallback) == 'function') {
errorCallback(response.statusCode, response.data);
}
}
},
fail: function (response) {
console.log(response);
},
complete: function () {
if (completeCallback && typeof (completeCallback) == 'function') {
completeCallback();
}
}
})
};
/**
@ -212,9 +218,9 @@ function postFile(url, path, name, args, successCallback, errorCallback, complet
* @returns {string}
*/
function escape(html) {
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
}
module.exports.post = postJson;