优化
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
var filters = {//截取字符串返回
|
||||
substring:function(str,start,end){
|
||||
if(!str){
|
||||
return
|
||||
}
|
||||
//也可做一些判断 //我不需要所以没做其他处理,直接返回的
|
||||
return str.substring(start,end);
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
substring:filters.substring
|
||||
}
|
||||
@@ -18,6 +18,7 @@ Page({
|
||||
data_list_5: [],
|
||||
conversationList: [],
|
||||
message_inquiry_type: 99999,
|
||||
now_message_inquiry_type: 5,
|
||||
system_notice_unreadnnum: "",
|
||||
service_notice_unreadnnum: "",
|
||||
hasOnShow: false,
|
||||
@@ -25,7 +26,11 @@ Page({
|
||||
show_dialog_from_account: "",
|
||||
show_dialog_order_inquiry_id: "",
|
||||
show_dialog_inquiry_type: "",
|
||||
unreadnnum_inter: 0
|
||||
unreadnnum_inter: 0,
|
||||
current_page: 0,
|
||||
total: 0,
|
||||
per_page: 0,
|
||||
last_page: 0,
|
||||
},
|
||||
onLoad() {
|
||||
console.log("wenzhen onloadddd");
|
||||
@@ -38,8 +43,20 @@ Page({
|
||||
// wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived, this);
|
||||
// });
|
||||
// }
|
||||
|
||||
//监听网络状态变化事件
|
||||
wx.onNetworkStatusChange(function (res) {
|
||||
console.log("onNetworkStatusChange from wenzhen: ")
|
||||
console.log(res.isConnected)
|
||||
console.log(res.networkType)
|
||||
wx.showToast({
|
||||
title: '网络类型'+res.networkType,
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
initInterval(){
|
||||
let _this = this;
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let userID = wx.getStorageSync('user_id_'+usertype);
|
||||
let unreadnnum_inter = setInterval(() => {
|
||||
@@ -49,7 +66,21 @@ Page({
|
||||
system_notice_unreadnnum: system_notice_unreadnnum,
|
||||
service_notice_unreadnnum: service_notice_unreadnnum,
|
||||
})
|
||||
}, 1000);
|
||||
|
||||
if(_this.data.data_list_1.length > 0 || _this.data.data_list_2.length > 0 || _this.data.data_list_3.length > 0 || _this.data.data_list_4.length > 0 || _this.data.data_list_5.length > 0){
|
||||
_this.setData({
|
||||
has_data: true
|
||||
})
|
||||
_this.selectComponent('#tabs').resize();
|
||||
let getCurrentName = _this.selectComponent('#tabs').getCurrentName();
|
||||
let now_message_inquiry_type = _this.data.now_message_inquiry_type;
|
||||
if(getCurrentName != now_message_inquiry_type){
|
||||
_this.setData({
|
||||
now_message_inquiry_type: getCurrentName
|
||||
})
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
this.setData({
|
||||
unreadnnum_inter: unreadnnum_inter
|
||||
})
|
||||
@@ -58,13 +89,18 @@ Page({
|
||||
onShow: function () {
|
||||
console.log("onShow from wenzhen V2")
|
||||
if(this.data.hasOnShow){
|
||||
wx.stopPullDownRefresh()
|
||||
return;
|
||||
}
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
this.getTabBar().setData({
|
||||
active: 1 //数字是当前页面在tabbar的索引,如我的查询页索引是2,因此这边为2,同理首页就为0,审批页面为1
|
||||
})
|
||||
|
||||
this.getTabBar().startInterval()
|
||||
}
|
||||
this.getDoctorInquiryFinishMessage();
|
||||
this.getDoctorMessageNotice();
|
||||
this.getConversationList();
|
||||
if(this.data.unreadnnum_inter == 0){
|
||||
this.initInterval();
|
||||
@@ -74,6 +110,7 @@ Page({
|
||||
hasOnShow: true
|
||||
})
|
||||
|
||||
|
||||
if(wx.$TUIKit){
|
||||
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived, this);
|
||||
}else{
|
||||
@@ -82,10 +119,12 @@ Page({
|
||||
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived, this);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
onHide(){
|
||||
console.log("onHideonHide from wenzhen")
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
this.getTabBar().stopInterval()
|
||||
}
|
||||
clearInterval(this.data.unreadnnum_inter)
|
||||
this.setData({
|
||||
hasOnShow: false,
|
||||
@@ -95,7 +134,13 @@ Page({
|
||||
data_list_4: [],
|
||||
data_list_5: [],
|
||||
message_inquiry_type: 9999,
|
||||
unreadnnum_inter: 0
|
||||
now_message_inquiry_type: 5,
|
||||
unreadnnum_inter: 0,
|
||||
has_data: false,
|
||||
current_page: 0,
|
||||
total: 0,
|
||||
per_page: 0,
|
||||
last_page: 0,
|
||||
})
|
||||
wx.$TUIKit.off(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived);
|
||||
},
|
||||
@@ -103,7 +148,8 @@ Page({
|
||||
console.log("onUnload from wenzhen")
|
||||
this.setData({
|
||||
hasOnShow: false,
|
||||
message_inquiry_type: 9999
|
||||
message_inquiry_type: 9999,
|
||||
now_message_inquiry_type: 5,
|
||||
})
|
||||
},
|
||||
getConversationList(){
|
||||
@@ -124,6 +170,9 @@ Page({
|
||||
});
|
||||
},
|
||||
go(e){
|
||||
this.setData({
|
||||
show: false
|
||||
})
|
||||
let url = e.currentTarget.dataset.url;
|
||||
let name = e.currentTarget.dataset.name;
|
||||
wx.setStorageSync(name, 0);
|
||||
@@ -246,8 +295,8 @@ Page({
|
||||
let conversationList = this.data.conversationList;
|
||||
//获取医生问诊消息用户属性
|
||||
api.getDoctorInquiryMessageAttr({order_inquiry_ids: order_inquiry_id_list.join(",")}).then(response => {
|
||||
let new_conversationList = [];
|
||||
if(response.data.length > 0){
|
||||
let new_conversationList = [];
|
||||
conversationList.forEach(item => {
|
||||
let conversationID = item.conversationID;
|
||||
if(conversationID == "C2Cadministrator") return;//如果是管理员消息直接跳过
|
||||
@@ -278,11 +327,10 @@ Page({
|
||||
item.patient_sex = order.patient_sex;
|
||||
new_conversationList.push(item);
|
||||
})
|
||||
|
||||
this.setData({
|
||||
conversationList: new_conversationList
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
conversationList: new_conversationList
|
||||
})
|
||||
}).then(() => {
|
||||
console.log("开始格式化formatConversationList")
|
||||
this.formatConversationList();
|
||||
@@ -343,6 +391,13 @@ Page({
|
||||
}
|
||||
lastMessage.messageForShow = text;
|
||||
}
|
||||
if(lastMessage.isRevoked){
|
||||
if(lastMessage.fromAccount == app.globalData.config.userID){
|
||||
lastMessage.messageForShow = "你撤回了一条消息";
|
||||
}else{
|
||||
lastMessage.messageForShow = "对方撤回了一条消息";
|
||||
}
|
||||
}
|
||||
txt.Text= lastMessage.messageForShow;
|
||||
session_item.last_message_content = txt;
|
||||
session_item.message_send_time = getTimeAgo(lastMessage.lastTime);
|
||||
@@ -368,9 +423,8 @@ Page({
|
||||
session_list[inquiry_type - 1].push(session_item);
|
||||
})
|
||||
|
||||
if(totalUnreadCount == 0){
|
||||
app.formatUnReadNum(userID+"_wenzhen_info", totalUnreadCount);
|
||||
}
|
||||
wx.setStorageSync(userID+'_wenzhen_info', totalUnreadCount);
|
||||
|
||||
|
||||
this.setData({
|
||||
data_list_1: session_data_list_1,
|
||||
@@ -379,13 +433,8 @@ Page({
|
||||
data_list_4: session_data_list_4,
|
||||
message_inquiry_type: message_inquiry_type
|
||||
})
|
||||
|
||||
if(this.data.data_list_1.length == 0 && this.data.data_list_2.length == 0 && this.data.data_list_3.length == 0 && this.data.data_list_4.length == 0 && this.data.data_list_5.length == 0){
|
||||
this.setData({has_data: false})
|
||||
}else{
|
||||
this.setData({has_data: true})
|
||||
this.selectComponent('#tabs').resize();
|
||||
}
|
||||
wx.stopPullDownRefresh()
|
||||
// this.selectComponent('#tabs').resize();
|
||||
|
||||
},
|
||||
checkOrderInquiryId(list, order_inquiry_id){
|
||||
@@ -431,7 +480,19 @@ Page({
|
||||
}).catch(errors => {
|
||||
console.error(errors);
|
||||
})
|
||||
|
||||
},
|
||||
//获取上方角标
|
||||
getDoctorMessageNotice(e){
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let userID = wx.getStorageSync('user_id_'+usertype);
|
||||
api.getDoctorMessageNotice().then(response => {
|
||||
let service_message_notice = response.data.service_message_notice;
|
||||
let system_message_notice = response.data.system_message_notice;
|
||||
wx.setStorageSync(userID+"_service_notice_unreadnnum", service_message_notice==true?1:"");//3、医生端系统通知
|
||||
wx.setStorageSync(userID+"_system_notice_unreadnnum", system_message_notice);//4、医生端服务通知
|
||||
}).catch(errors => {
|
||||
console.error(errors);
|
||||
})
|
||||
},
|
||||
tabShow(e){
|
||||
let show_dialog_from_account = e.currentTarget.dataset.show_dialog_from_account;
|
||||
@@ -450,5 +511,41 @@ Page({
|
||||
this.setData({
|
||||
show: false
|
||||
})
|
||||
},
|
||||
vanTabsChange(e){
|
||||
console.log(e)
|
||||
this.setData({
|
||||
now_message_inquiry_type: e.detail.name
|
||||
})
|
||||
},
|
||||
onPullDownRefresh(){
|
||||
console.log("用户下拉动作")
|
||||
this.onHide();
|
||||
this.onShow();
|
||||
},
|
||||
onReachBottom() {
|
||||
console.log('===触底了!!===');
|
||||
let now_message_inquiry_type = this.data.now_message_inquiry_type;
|
||||
if(now_message_inquiry_type == 5){
|
||||
if(this.data.current_page < this.data.last_page){//最后一页时停止分页
|
||||
this.getDoctorInquiryFinishMessage()
|
||||
}
|
||||
}
|
||||
},
|
||||
getDoctorInquiryFinishMessage(){
|
||||
let data_list_5 = this.data.data_list_5;
|
||||
let params = {};
|
||||
params.page = this.data.current_page + 1;
|
||||
api.getDoctorInquiryFinishMessage(params).then(response => {
|
||||
console.log(response);
|
||||
this.setData({
|
||||
"data_list_5": data_list_5.concat(response.data.data),
|
||||
current_page: response.data.current_page,
|
||||
total: response.data.total,
|
||||
per_page: response.data.per_page,
|
||||
last_page: response.data.last_page
|
||||
})
|
||||
// this.selectComponent('#tabs').resize();
|
||||
}).catch(errors => {console.error(errors);})
|
||||
}
|
||||
})
|
||||
@@ -11,6 +11,9 @@
|
||||
"van-image": "@vant/weapp/image/index",
|
||||
"van-tab": "@vant/weapp/tab/index",
|
||||
"van-tabs": "@vant/weapp/tabs/index",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog"
|
||||
}
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"van-divider": "@vant/weapp/divider/index"
|
||||
},
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
<!-- 问诊页面 -->
|
||||
<wxs module="dateSubstr" src="./substr.wxs"></wxs>
|
||||
|
||||
<te-nav-bar navbar-data='{{navbarData}}' ></te-nav-bar>
|
||||
<view class="container">
|
||||
<view class="top">
|
||||
@@ -20,7 +22,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty" wx:if="{{ !has_data }}" >
|
||||
<view class="empty" wx:if="{{ has_data==false }}" >
|
||||
<van-image src="https://gdxz-hospital.oss-cn-chengdu.aliyuncs.com/applet/doctor/static/images/yishi/wnzhen_empty.png" fit="heightFix" height="108rpx" aria-label="empty" />
|
||||
<view class="empty_note">未收到任何消息</view>
|
||||
</view>
|
||||
@@ -141,12 +143,14 @@
|
||||
</t-tabs>
|
||||
</view> -->
|
||||
|
||||
<view class="tabs" wx:if="{{ has_data }}" >
|
||||
<van-tabs active="{{ message_inquiry_type }}"
|
||||
<view class="tabs" wx:if="{{ has_data==true }}">
|
||||
<van-tabs
|
||||
color="#3CC7C0"
|
||||
title-active-color="#3CC7C0"
|
||||
border="{{true}}"
|
||||
id="tabs"
|
||||
bind:change="vanTabsChange"
|
||||
wx:if="{{ has_data }}"
|
||||
>
|
||||
<van-tab title="在线问诊" name="1" wx:if="{{data_list_1.length > 0}}">
|
||||
<!-- <wenzhen-data
|
||||
@@ -327,6 +331,25 @@
|
||||
<view class="content_4" wx:if="{{ item.inquiry_status == 3 }}">不接诊24小时后自动取消</view>
|
||||
</view>
|
||||
</van-tab>
|
||||
<van-tab title="问诊结束" name="5" wx:if="{{data_list_5.length > 0}}">
|
||||
<view class="content" wx:for="{{ data_list_5 }}" bindtap="goChat" data-from_account="{{item.from_account}}" data-inquiry_type="{{item.inquiry_type}}" data-order_inquiry_id="{{item.order_inquiry_id}}" data-url="/Pages/yishi/chat/index">
|
||||
<view class="content_1" >
|
||||
<view class="name">
|
||||
<text style="font-size: 34rpx;color: #333;">就诊人:</text>
|
||||
{{item.patient_name}} {{item.patient_sex==1?'男':'女'}}|{{item.patient_age}}<t-badge dot="{{false}}" offset="{{ [-4, 4] }}" content="岁" />
|
||||
</view>
|
||||
<view class="date"> {{dateSubstr.substring(item.complete_time,0,10)}}</view>
|
||||
</view>
|
||||
<view class="content_2">问诊已结束</view>
|
||||
<view class="content_3">
|
||||
<view class="status status_end">{{ item.inquiry_type==1?'专家问诊':item.inquiry_type==2?'快速问诊':item.inquiry_type==3?'公益问诊':item.inquiry_type==4?'问诊购药':'其他' }}</view>
|
||||
</view>
|
||||
<view class="content_4" wx:if="{{ item.inquiry_status == 3 }}">不接诊24小时后自动取消</view>
|
||||
</view>
|
||||
|
||||
<van-empty description="暂无数据" wx:if="{{data_list_5.length == 0}}" />
|
||||
<van-divider contentPosition="center" wx:if="{{data_list_5.length > 0 && current_page == last_page}}">到底了~</van-divider>
|
||||
</van-tab>
|
||||
</van-tabs>
|
||||
</view>
|
||||
<view style="height: 200rpx;"></view>
|
||||
|
||||
@@ -78,6 +78,7 @@ page{
|
||||
color: #666666;
|
||||
height: 50rpx;
|
||||
line-height: 50rpx;
|
||||
display: flex;
|
||||
}
|
||||
.date{
|
||||
font-size: 30rpx;
|
||||
@@ -135,6 +136,4 @@ page{
|
||||
border-top: 1px solid #E9E9E9;
|
||||
color: #3CC7C0;
|
||||
}
|
||||
.t-badge__content-text {
|
||||
line-height: 70rpx !important;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user