diff --git a/components/pop.vue b/components/pop.vue index 661dd89..29052b4 100644 --- a/components/pop.vue +++ b/components/pop.vue @@ -35,6 +35,10 @@ export default { content: { type: String, default: "" + }, + index: { + type: Number, + default: 0 } }, data() { @@ -43,15 +47,15 @@ export default { } }, methods: { - open() { + open() { this.show_pop = true; }, - close() { + close() { this.show_pop = false; }, - Confirm(e) { - this.$emit("confirm", e); - this.close(); + Confirm(e) { + this.close(); + this.$emit("confirm", e, this.index); }, Cancel(e) { this.$emit("cancel", e); diff --git a/main.js b/main.js index 0f9f2be..ece9aca 100644 --- a/main.js +++ b/main.js @@ -175,7 +175,7 @@ if(Vue.prototype.provider == Vue.prototype.provider_weixin) { const CODE_SUCCESS = 2000; const CODE_ERROR = 40001; -const CODE_LOGIN_EXIPRE = 4000; +const CODE_LOGIN_EXIPRE = 401; Vue.prototype.user_preview = 1; Vue.prototype.edit_preview = 2; @@ -224,7 +224,7 @@ function req(url, data={}, method = 'POST', header={}) { try{ var rdata = res.data; if(rdata.code != CODE_SUCCESS) { - if((rdata.msg.indexOf('Signature verification failed')>-1 || rdata.msg.indexOf('身份认证信息未提供'))>-1 && rdata.code==CODE_LOGIN_EXIPRE && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != getWxH5LoginConfigUri && data.repeat != 1){ + if((rdata.code==CODE_LOGIN_EXIPRE || rdata.msg.indexOf('Signature verification failed')>-1 || rdata.msg.indexOf('身份认证信息未提供')>-1) && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != getWxH5LoginConfigUri && data.repeat != 1){ removeLogin(); var logindatac = new Object(); @@ -243,9 +243,9 @@ function req(url, data={}, method = 'POST', header={}) { uni.showModal({ title: '提示', showCancel: false, - content: rdata.msg ? rdata.msg : '网络错误,请重试|'+res.statusCode, + content: rdata.msg ? rdata.msg+'|'+rdata.code : '网络错误,请重试|'+res.statusCode, success: function (rs) { - if (rs.confirm && rdata.code==CODE_LOGIN_EXIPRE && (rdata.msg.indexOf('Signature verification failed')>-1 || rdata.msg.indexOf('身份认证信息未提供')>-1)) { + if (rs.confirm && (rdata.code==CODE_LOGIN_EXIPRE || rdata.msg.indexOf('Signature verification failed')>-1 || rdata.msg.indexOf('身份认证信息未提供')>-1)) { removeLogin(); const pages = getCurrentPages(); const currentPage = pages[pages.length - 1]; diff --git a/manifest.json b/manifest.json index ef58cd6..45c83f4 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wxba76fd01dab5e1d8", "setting" : { "urlCheck" : false }, diff --git a/pages/index/index.vue b/pages/index/index.vue index 3ca43db..75f53d7 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -144,7 +144,7 @@ }); }, login() { - this.$http.req('client/user/login/', {code:this.code}, 'POST').then(data=>{ + this.$http.req('client/user/login', {code:this.code}, 'POST').then(data=>{ if(data == -1) return uni.setStorageSync('token', data.token) var rebackPagePath = uni.getStorageSync('rebackPagePath') diff --git a/pages/visitors/visitors.vue b/pages/visitors/visitors.vue index c76b000..8a887b6 100644 --- a/pages/visitors/visitors.vue +++ b/pages/visitors/visitors.vue @@ -22,24 +22,23 @@ 请确保预约就诊前在门诊先挂号 - + - {{item.name}} + {{item.real_name}} 身份证尾号:{{item.id_no}} - - 广安门中医医院西单门诊部10周未看病 - 剩余2 - 10 - - - - 顺天德中医医院停诊 - 剩余20 - 10 + + + {{item2.hospital_name}} {{item2.hospital_dept}} + 停诊 + {{item2.expire_day}}未看病 + + + 剩余{{item2.times}} + {{-item2.times}} @@ -49,6 +48,7 @@ ref="popcom" :content="popContent" :title="popTitle" + :index="popIndex" :showCancel='popShowCancel' @confirm="popConfirm" @cancel="popCancel" @@ -71,17 +71,26 @@ visitUsers:false, selectCount:0, hospitalId:false, - activeVisitors:[] + activeVisitors:[], + popMsgs:[], + popIndex:0 } }, components:{ pop }, onLoad(option) { - if(option.type) this.type = option.type + if(option.type) { + this.type = option.type + }else{ + var type = uni.getStorageSync('visitor_type') + if(type) this.type = type + } + uni.setStorageSync('visitor_type', this.type) + this.getVisitors() this.hospitalId = uni.getStorageSync('hospital_id') - if(!this.hospitalId) { + if(!this.hospitalId && this.type == 1) { this.$pop.modelShow('请先选择要预约的医院', '/pages/index/index') return } @@ -103,22 +112,103 @@ param.limit = 10000 this.$http.req('client/user/visit_user/', param, 'GET').then(data=>{ if(data == -1) return + var server_time = data.server_time this.visitUsers = data.data + this.popMsgs = [] for (var i = 0; i < this.visitUsers.length; i++) { this.visitUsers[i].select = false + // this.visitUsers[i].hospital_info = [ + // { + // "times": -1, + // "hospital_name": "测试医院", + // "hospital_dept": "呼吸科", + // "hospital_state": true, + // "is_expire":true, + // "last_visit_time": "2021-01-12 13:16:26" + // }, + + // { + // "times": 10, + // "hospital_name": "测试医院", + // "hospital_dept": "呼吸科", + // "hospital_state": true, + // "is_expire":true, + // "last_visit_time": "2021-01-12 13:16:26" + // } + // ] + + try{ + var dateService = new Date(server_time.replaceAll('-', "/")); + var timestampService = Math.floor(dateService)/1000; + var hospitalInfo = this.visitUsers[i].hospital_info + for (var j = 0; j < hospitalInfo.length; j++) { + var datestr = new Date(hospitalInfo[j].last_visit_time.replaceAll('-', "/")); + var timestamp = Math.floor(datestr)/1000; + var visitTimeDayTotal = Math.floor((timestampService-timestamp)/3600/24) + if(visitTimeDayTotal>0 && visitTimeDayTotal < 7) hospitalInfo[j].expire_day = visitTimeDayTotal+'天' + if(visitTimeDayTotal>=7) hospitalInfo[j].expire_day = Math.floor(visitTimeDayTotal/7)+'周' + if(visitTimeDayTotal>=365) hospitalInfo[j].expire_day = Math.floor(visitTimeDayTotal/365)+'年' + if(!hospitalInfo[j].expire_day) { + var visitTimeMinute = Math.floor((timestampService-timestamp)/60) + if(visitTimeMinute <= 0) hospitalInfo[j].expire_day = (timestampService-timestamp)+'秒' + if(visitTimeMinute >= 1 && visitTimeMinute<60) hospitalInfo[j].expire_day = Math.floor((timestampService-timestamp)/60)+'分' + if(visitTimeMinute>=60) hospitalInfo[j].expire_day = Math.floor((visitTimeMinute)/60)+'小时' + } + + if(!hospitalInfo[j].hospital_state) continue + + var popobj = new Object() + popobj.popShowCancel = false + if(hospitalInfo[j].is_expire){ + popobj.popContent = this.visitUsers[i].real_name+'已'+hospitalInfo[j].expire_day+'没有来'+hospitalInfo[j].hospital_name+hospitalInfo[j].hospital_dept+'针灸。如还需要,请尽快安排' + popobj.popTitle = "提醒" + } + + if(hospitalInfo[j].times < 0){ + popobj.popContent = this.visitUsers[i].real_name+'在'+hospitalInfo[j].hospital_name+hospitalInfo[j].hospital_dept+'须补挂号啦,请挂号缴费后告知医生' + popobj.popTitle = "挂号提醒" + } + this.popMsgs.push(popobj) + } + }catch(et){ + } + } + + if(this.popMsgs.length > 0 && !uni.getStorageSync('has_noticed')){ + this.popIndex = 0 + var popinfo = this.popMsgs[this.popIndex] + this.popContent = popinfo.popContent + this.popTitle = popinfo.popTitle + this.popIndex = popinfo.popIndex + this.popShowCancel = popinfo.popShowCancel + this.showPopCom() } }); }, showPopCom() { this.$refs.popcom.open() }, - popConfirm(e){ + closePopCom() { + this.$refs.popcom.close() + }, + popConfirm(e, index){ + if(this.popMsgs.length > 0 && index<(this.popMsgs.length-1)){ + this.popIndex = index+1 + var popinfo = this.popMsgs[this.popIndex] + this.popContent = popinfo.popContent + this.popTitle = popinfo.popTitle + this.popShowCancel = popinfo.popShowCancel + this.showPopCom() + }else{ + uni.setStorageSync('has_noticed', 1) + this.closePopCom() + } }, popCancel(e){ }, addVisitor(){ uni.navigateTo({ - url:"/pages/modify_visitor/modify_visitor" + url:"/pages/modify_visitor/modify_visitor?type="+this.type }) }, toPrebook(){ @@ -126,7 +216,7 @@ this.$pop.modelShow('请选择就诊人') return } - + this.activeVisitors = [] for (var i = 0; i < this.visitUsers.length; i++) { if(this.visitUsers[i].select) this.activeVisitors.push(this.visitUsers[i])