优化
This commit is contained in:
+70
-12
@@ -21,8 +21,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取城市信息
|
||||
@@ -32,8 +31,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取区县信息
|
||||
@@ -43,8 +41,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取医院数据
|
||||
@@ -54,8 +51,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取自定义科室数据
|
||||
@@ -65,8 +61,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取医生专长列表
|
||||
@@ -76,8 +71,7 @@ class API extends HTTP {
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//使用微信手机号登陆
|
||||
@@ -542,6 +536,24 @@ class API extends HTTP {
|
||||
}
|
||||
//获取im签名数据
|
||||
getSignIM(params) {
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let userID = wx.getStorageSync('user_id_'+usertype);
|
||||
let imsign = wx.getStorageSync(userID + '_imsign');
|
||||
console.log("缓存中的imsign:", imsign)
|
||||
|
||||
if(imsign){
|
||||
const date = imsign.date;
|
||||
var minute = 1000 * 60;
|
||||
var hour = minute *60;
|
||||
var day = hour *24;
|
||||
if(new Date().getTime() - date < day){
|
||||
console.log("小于一天从缓存中获取imsign")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({"data": imsign.sign,"from":"cache"})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/sign/im`,
|
||||
method: 'GET',
|
||||
@@ -550,6 +562,7 @@ class API extends HTTP {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//药师基本资料
|
||||
getPharmacistInfo(params) {
|
||||
return this.request({
|
||||
@@ -729,6 +742,51 @@ class API extends HTTP {
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/doctor/inquiry/finish/message`,
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
},
|
||||
showLoading: false
|
||||
})
|
||||
}
|
||||
//获取协议内容
|
||||
getBasicAgreement(params) {
|
||||
let agreement_id = params.agreement_id;
|
||||
params = {}
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/basic/agreement/`+agreement_id,
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取弹窗
|
||||
getPopup(params) {
|
||||
let agreement_id = params.agreement_id;
|
||||
params = {}
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/popup`,
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
//检测是否可以开具处方
|
||||
getDoctorPrescriptionCheck(params) {
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/doctor/prescription/check`,
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取医生职称数据
|
||||
getBasicDoctorTitle(params) {
|
||||
return this.request({
|
||||
url: `${this.baseUrl}/basic/doctor/title`,
|
||||
method: 'GET',
|
||||
data: {
|
||||
...params
|
||||
}
|
||||
|
||||
+43
-12
@@ -73,11 +73,11 @@ const getTimeAgo = stringTime =>{
|
||||
if(time < 0){
|
||||
return '刚刚';
|
||||
}else if(time/month >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
result = (new Date(time2)).Format("yyyy-MM-dd hh:mm:ss");
|
||||
}else if(time/week >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm:ss");
|
||||
}else if(time/day >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm");
|
||||
}else if(time/hour >= 1){
|
||||
result = parseInt(time/hour) + "小时前";
|
||||
}else if(time/minute >= 1){
|
||||
@@ -89,34 +89,64 @@ const getTimeAgo = stringTime =>{
|
||||
}
|
||||
|
||||
const getTimeAgoChat = stringTime =>{
|
||||
console.log("stringTime: ", stringTime)
|
||||
var minute = 1000 * 60;
|
||||
var hour = minute *60;
|
||||
var day = hour *24;
|
||||
var week = day * 7;
|
||||
var month = day * 30;
|
||||
var time1 = new Date().getTime();//当前的时间戳
|
||||
var time2 = stringTime*1000;//指定时间的时间戳
|
||||
var time2 = stringTime;//指定时间的时间戳
|
||||
var time = time1 - time2;
|
||||
var result = null;
|
||||
if(time < 0){
|
||||
return '刚刚';
|
||||
}else if(time/month >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
result = (new Date(time2)).Format("yyyy-MM-dd hh:mm:ss");
|
||||
}else if(time/week >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm:ss");
|
||||
}else if(time/day >= 1){
|
||||
result = formatChatTime(new Date(time2));
|
||||
}else if(time/day == 1){
|
||||
result = new Date(time2).Format("MM-dd hh:mm");
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm");
|
||||
}else if(time/hour >= 1){
|
||||
result = new Date(time2).Format("hh:mm");
|
||||
result = parseInt(time/hour) + "小时前";
|
||||
}else if(time/minute >= 1){
|
||||
result = new Date(time2).Format("hh:mm");
|
||||
result = parseInt(time/minute) + "分钟前";
|
||||
}else {
|
||||
result = "刚刚";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//仿微信时间显示
|
||||
const likeWeChatTimeAgoChat = stringTime =>{
|
||||
console.log("stringTime: ", stringTime)
|
||||
var minute = 1000 * 60;
|
||||
var hour = minute *60;
|
||||
var day = hour *24;
|
||||
var week = day * 7;
|
||||
var month = day * 30;
|
||||
var time1 = new Date().getTime();//当前的时间戳
|
||||
var time2 = stringTime;//指定时间的时间戳
|
||||
var time = time1 - time2;
|
||||
var result = null;
|
||||
if(time < 0){
|
||||
return '刚刚';
|
||||
}else if(time/month >= 1){
|
||||
result = (new Date(time2)).Format("yyyy-MM-dd hh:mm:ss");
|
||||
}else if(time/week >= 1){
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm:ss");
|
||||
}else if(time/day >= 1){
|
||||
result = (new Date(time2)).Format("MM-dd hh:mm");
|
||||
}else if(time/hour >= 1){
|
||||
result = parseInt(time/hour) + "小时前";
|
||||
}else if(time/minute >= 1){
|
||||
result = parseInt(time/minute) + "分钟前";
|
||||
}else {
|
||||
result = "刚刚";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// px 转换为 rpx ,传参类型是数字(Number)
|
||||
const rpxTopx = px => {
|
||||
let deviceWidth = wx.getSystemInfoSync().windowWidth; //获取设备屏幕宽度
|
||||
@@ -130,5 +160,6 @@ module.exports = {
|
||||
formatNumber,
|
||||
getTimeAgo,
|
||||
rpxTopx,
|
||||
getTimeAgoChat
|
||||
getTimeAgoChat,
|
||||
likeWeChatTimeAgoChat
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// 星期格式转换 0-6:周日到周六
|
||||
function weekFormat(e, prefix = "周") {
|
||||
switch (e) {
|
||||
case 0:
|
||||
return prefix + "日"
|
||||
break;
|
||||
case 1:
|
||||
return prefix + "一"
|
||||
break;
|
||||
case 2:
|
||||
return prefix + "二"
|
||||
break;
|
||||
case 3:
|
||||
return prefix + "三"
|
||||
break;
|
||||
case 4:
|
||||
return prefix + "四"
|
||||
break;
|
||||
case 5:
|
||||
return prefix + "五"
|
||||
break;
|
||||
case 6:
|
||||
return prefix + "六"
|
||||
break;
|
||||
default:
|
||||
return ""
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 转换今日的时辰格式
|
||||
function todayTimeFormat(e) {
|
||||
if (e >= 0 && e < 7) {
|
||||
return "凌晨"
|
||||
} else if (e >= 7 && e < 11) {
|
||||
return "上午"
|
||||
} else if (e >= 11 && e < 13) {
|
||||
return "中午"
|
||||
} else if (e >= 13 && e < 18) {
|
||||
return "下午"
|
||||
} else if (e >= 18 && e < 24) {
|
||||
return "晚上"
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// 是否显示周几
|
||||
function isShowWeekDay(sub, weekDay) {
|
||||
const currentWeekDay = new Date().getDay()
|
||||
const dayTime = 1000 * 60 * 60 * 24
|
||||
// 1.当前时间与消息时间相差必须大于2天小于7天
|
||||
// 2.当前时间距离本周一相差必须大于2天且小于当前距离周一的天数
|
||||
// 3.消息时间不可能是0-周日,因为周日没有给后面时间留空间,不会走这里的逻辑,而是走今天的逻辑
|
||||
if (sub >= dayTime * 2 && weekDay !== 0 && sub <= dayTime * currentWeekDay) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 仿微信时间显示格式转换 @time 时间戳毫秒
|
||||
function wechatTimeFormat(time) {
|
||||
const today = new Date().getTime()
|
||||
// 当前时间减去获取到的时间
|
||||
const sub = today - time
|
||||
const day = 1000 * 60 * 60 * 24
|
||||
const timeDate = new Date(time)
|
||||
const currentYear = new Date().getFullYear()
|
||||
const getYear = new Date(time).getFullYear()
|
||||
const HHmm = `${formatTime2("hh", timeDate)}:${formatTime2("mm", timeDate)}`
|
||||
const showWeekDay = isShowWeekDay(sub, timeDate.getDay())
|
||||
const currentDay = new Date().getDate()
|
||||
const getDay = new Date(time).getDate()
|
||||
const subDay = currentDay - getDay
|
||||
if (currentYear > getYear) {
|
||||
return `${formatTime2("yyyy-MM-dd", timeDate)} ${formatTime2("hh:mm", timeDate)}`
|
||||
// 上午下午
|
||||
return `${formatTime2("yyyy年MM月dd日", timeDate)} ${todayTimeFormat(timeDate.getHours())} ${formatTime2("hh:mm", timeDate)}`
|
||||
} else if (showWeekDay) {
|
||||
return `${weekFormat(timeDate.getDay())} ${HHmm}`
|
||||
//} else if (sub > day && sub < day * 2) {
|
||||
} else if (subDay === 1) {
|
||||
return `昨天 ${HHmm}`
|
||||
} else if (sub <= day) {
|
||||
return HHmm
|
||||
} else {
|
||||
return `${formatTime2("MM-dd", timeDate)} ${formatTime2("hh:mm", timeDate)}`
|
||||
// 上午下午
|
||||
return `${formatTime2("MM月dd日", timeDate)} ${todayTimeFormat(timeDate.getHours())} ${formatTime2("hh:mm", timeDate)}`
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime2(fmt, timestamp) {
|
||||
var date = new Date(timestamp) // 兼容safari
|
||||
var o = {
|
||||
'M+': date.getMonth() + 1,
|
||||
'd+': date.getDate(),
|
||||
'h+': date.getHours(),
|
||||
'm+': date.getMinutes(),
|
||||
's+': date.getSeconds(),
|
||||
'q+': Math.floor((date.getMonth() + 3) / 3),
|
||||
'S': date.getMilliseconds()
|
||||
}
|
||||
if (/(y+)/.test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
||||
}
|
||||
for (var k in o) {
|
||||
if (new RegExp('(' + k + ')').test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
||||
}
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
weekFormat,
|
||||
todayTimeFormat,
|
||||
isShowWeekDay,
|
||||
wechatTimeFormat
|
||||
}
|
||||
Reference in New Issue
Block a user