You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
18 KiB

2 weeks ago
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-index-index"],{"0c9f":function(t,e,i){"use strict";var a=i("7ee3"),n=i.n(a);n.a},"2c36":function(t,e,i){"use strict";i("6a54");var a=i("f5bd").default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=a(i("9b1b")),s=a(i("2634")),o=a(i("2fdc"));i("5c47"),i("0506"),i("bf0f"),i("c223"),i("64aa"),i("4626");var r=i("bd31"),c={data:function(){return{isWeixinBrowser:!1,userInfo:null,showEditPopup:!1,editForm:{name:"",payer_type:1,phone:"",id_card:""},statistics:{water_level:{taihu:"-",xujiang:"-"},total_count:0,unpaid_count:0,paid_count:0,billed_count:0}}},onLoad:function(){this.isWeixinBrowser=/MicroMessenger/i.test(navigator.userAgent),this.fetchUserInfo(),this.fetchStatistics()},methods:{fetchStatistics:function(){var t=this;return(0,o.default)((0,s.default)().mark((function e(){var i,a;return(0,s.default)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(i=uni.getStorageSync("token"),i){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,new Promise((function(t,e){uni.request({url:"".concat(r.API.STATISTICS,"?token=").concat(i),method:"get",success:t,fail:e})}));case 5:a=e.sent,a.data&&0===a.data.errcode&&(t.statistics=a.data.data);case 7:case"end":return e.stop()}}),e)})))()},fetchUserInfo:function(){var t=this;return(0,o.default)((0,s.default)().mark((function e(){var i,a,o,c,d,l;return(0,s.default)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(i=uni.getStorageSync("token"),i){e.next=4;break}return t.userInfo=null,e.abrupt("return");case 4:return e.prev=4,e.next=7,new Promise((function(t,e){uni.request({url:"".concat(r.API.GET_USER_INFO,"?token=").concat(i),method:"POST",success:t,fail:e})}));case 7:a=e.sent,a.data&&(d=a.data||{},l=Number(null!==(o=null!==(c=d.payer_type)&&void 0!==c?c:d.payerType)&&void 0!==o?o:1),t.userInfo=(0,n.default)((0,n.default)({},d),{},{payer_type:l}),t.editForm={name:d.name||"",payer_type:l,phone:d.phone||"",id_card:d.id_card||""}),e.next=14;break;case 11:e.prev=11,e.t0=e["catch"](4),t.userInfo=null;case 14:case"end":return e.stop()}}),e,null,[[4,11]])})))()},requireUserInfoComplete:function(){var t,e=this.userInfo||{},i=!!(e.name&&(null!==(t=e.payer_type)&&void 0!==t?t:e.payerType)&&e.phone&&e.id_card);return i},openEditPopup:function(){this.showEditPopup=!0},closeEditPopup:function(){this.showEditPopup=!1},validateForm:function(){if(!this.editForm.name)return uni.showToast({title:"请输入姓名",icon:"none"}),!1;if(![1,2].includes(Number(this.editForm.payer_type)))return uni.showToast({title:"请选择交款人类型",icon:"none"}),!1;if(!/^1\d{10}$/.test(this.editForm.phone))return uni.showToast({title:"请输入正确的手机号",icon:"none"}),!1;return!!/^(?:\d{15}|\d{17}[\dXx])$/.test(this.editForm.id_card)||(uni.showToast({title:"请输入正确的证件号",icon:"none"}),!1)},submitUserInfo:function(){var t=this;return(0,o.default)((0,s.default)().mark((function e(){var i,a;return(0,s.default)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(t.validateForm()){e.next=2;break}return e.abrupt("return");case 2:if(i=uni.getStorageSync("token"),i){e.next=6;break}return uni.showToast({title:"请先登录",icon:"none"}),e.abrupt("return");case 6:return e.prev=6,uni.showLoading({title:"提交中..."}),e.next=10,new Promise((function(e,a){uni.request({url:"".concat(r.API.UPDATE_USER_INFO,"?token=").concat(i),method:"POST",data:{name:t.editForm.name,payer_type:Number(t.editForm.payer_type),phone:t.editForm.phone,id_card:t.editForm.id_card},success:e,fail:a})}));case 10:if(a=e.sent,uni.hideLoading(),!a.data||0!==a.data.errcode){e.next=19;break}return uni.showToast({title:"更新成功",icon:"success"}),t.closeEditPopup(),e.next=17,t.fetchUserInfo();case 17:e.next=20;break;case 19:uni.showToast({title:a.data&&a.data.errmsg||"更新失败",icon:"none"});case 20:e.next=26;break;case 22:e.prev=22,e.t0=e["catch"](6),uni.hideLoading(),uni.showToast({title:"更新失败",icon:"none"});case 26:case"end":return e.stop()}}),e,null,[[6,22]])})))()},goReservation:function()