信达小程序
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.
 
 
 

610 lines
16 KiB

import dayjs from 'dayjs';
const app = getApp<IAppOption>();
const licia = require('miniprogram-licia');
Page({
data: {
today: dayjs().format('YYYY年MM月DD日 dddd'),
configList: [],
infoList: [],
storyList: [],
zdUserInfo: {} as any,
anyWhere: false,
regGuide: true,
adlList: [],
adlNum: '',
adlNewRecord: {} as any,
liveList: [],
liveStatus: app.globalData.liveStatus,
liveDownList: [],
detail: {},
referralFromShow: false,
publicCard: false,
// toastShow: true,
// toastType: "doubleStandards",
// toastType: "vipScan",
// toastType: "healthCare",
// toastType: "aldAlert",
// toastType:"dedicatedDoctor",
// toastType: 'referral-toast',
// toastType: 'public-toast',
toastShow: false,
toastType: '',
toastParams: {} as any,
sliderTop: 0,
unreadCount: 0,
options: {} as any,
},
onLoad(options) {
const systemInfo = wx.getSystemInfoSync();
app.zdGetTheme().then((res) => {
this.setData({
theme: res,
});
});
this.setData({
sliderTop: systemInfo.screenHeight - 160,
options,
});
},
onShow() {
app.waitLogin({ type: [0, 1] }).then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTHOME' });
this.setData({
anyWhere: app.globalData.anyWhere,
});
if (this.data.options.es === '201501') {
app.globalData.IsAliQiWei = 1;
app.zdMpBehavior({ PageName: 'JUMP_PATIENT_HOME_INDEX' });
this.setData({
options: {},
});
}
app.getZdUserInfo(this, true, (zdUserInfo) => {
this.setData({
zdUserInfo,
publicCard: zdUserInfo.isShowFollowGuide == 1,
});
this.getPopup();
this.getConfig(zdUserInfo);
this.getSystemConfig();
if (zdUserInfo.ExclusiveDoctorId > 0) {
this.getUnreadCount();
}
if (zdUserInfo.UserType == 4) {
this.getLastRecord();
}
});
});
},
getUnreadCount() {
wx.ajax({
method: 'GET',
url: '?r=zd/message-interact/get-unread-count',
data: {},
}).then((res) => {
this.setData({
unreadCount: res,
});
});
},
getSystemConfig() {
wx.ajax({
method: 'GET',
url: '?r=zd/common/get-config',
data: {},
}).then((res) => {
this.setData({
systemConfig: res,
});
});
},
getLastRecord() {
wx.ajax({
method: 'GET',
url: '?r=zd/medication/last-record',
}).then((res) => {
this.setData({
detail: {
weekName: dayjs(res.InjectionDate).format('ddd'),
days: dayjs().diff(res.InjectionDate, 'day'),
...res,
},
});
});
},
getConfig(zdUserInfo: any) {
let UserType = zdUserInfo.UserType;
if (UserType <= 2) {
UserType = 1;
}
wx.ajax({
method: 'GET',
url: `?r=zd/mini-conf/get-config`,
data: { userType: UserType },
}).then((res) => {
res = res.map((item: any) => {
if (item.code == 'spread1' || item.code == 'spread2' || item.code == 'serviceConf') {
item.subList = item.subList.filter((subItem) => {
return subItem.showStatus == 1;
});
}
// if (item.name === 'BANNER-MINIDOVTOR') {
// item.subList = item.subList
// .filter((subItem: any) => {
// return subItem.linkUrl !== 'MINIDOCTOR' || zdUserInfo.EntryThreePeriod === 1
// })
// .filter((subItem: any) => {
// return subItem.linkUrl !== 'MINIDOCTOR-1.0' || zdUserInfo.EntryTwoPeriod === 1
// })
// }
return item;
});
this.setData({
configList: res,
});
res.forEach((item) => {
if (item.code == 'article') {
this.getInfoList(item.configId);
}
if (item.code == 'story') {
this.getStoryList(item.configId);
}
if (item.code == 'adl') {
this.getAdl();
}
if (item.code == 'activity2') {
this.getActivity(item.configId, item.showNum, 'liveList');
}
if (item.code == 'activity1') {
this.getActivity(item.configId, item.showNum, 'liveDownList');
}
});
});
},
async getPopup() {
const data5 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 5,
},
});
if (data5.showAlert) {
this.setData({
toastShow: data5.showAlert,
toastType: 'doubleStandards',
toastParams: data5,
});
return;
}
const data4 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 4,
},
});
if (data4.showAlert) {
this.setData({
toastShow: data4.showAlert,
toastType: 'vipScan',
toastParams: {},
});
return;
}
const data1 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: { Type: 1 },
});
if (!Array.isArray(data1)) {
this.setData({
toastShow: true,
toastType: 'healthCare',
toastParams: data1,
});
return;
}
const data2 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 2,
},
});
if (data2.showAlert && this.data.zdUserInfo.UserType == 4) {
this.setData({
toastShow: data2.showAlert,
toastType: 'aldAlert',
toastParams: {
id: data2.articleId,
},
});
}
const data3 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 6,
},
});
if (data3.showAlert) {
this.setData({
toastShow: data3.showAlert,
toastType: 'dedicatedDoctor',
toastParams: {},
});
}
const data6 = await wx.ajax({
method: 'GET',
url: '?r=zd/re-visit/get-popup-show-status',
});
if (data6.showStatus === 1) {
this.setData({
toastShow: true,
toastType: 'referral-toast',
toastParams: {},
});
}
},
setPopupInfo() {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/update-click-status',
data: {
Type: 1,
Id: this.data.toastParams.Id,
},
}).then((_res) => {});
},
setBannerClick() {
wx.ajax({
method: 'POST',
url: '?r=zd/nrdl/add-banner-click-record',
data: {},
});
},
getInfoList(configId: string) {
wx.ajax({
method: 'GET',
url: '?r=zd/pic-text/index-list',
data: {
count: 0,
ConfigId: configId,
},
}).then((res) => {
this.setData({
infoList: licia.chunk(res.list, 3),
});
});
},
getStoryList(configId: string) {
wx.ajax({
method: 'GET',
url: '?r=zd/story/index-list',
data: {
count: 0,
ConfigId: configId,
},
}).then((res) => {
this.setData({
storyList: res.list,
});
});
},
getAdl() {
wx.ajax({
method: 'GET',
url: '?r=zd/adl/index',
data: {},
}).then((res) => {
const newRecord = res.newRecord;
this.setData({
adlList: res.list,
adlNum: res.count,
adlNewRecord: {
days: dayjs().diff(newRecord.CreateTime, 'day'),
...newRecord,
newCreateTime: dayjs(newRecord.CreateTime).format('YYYY-MM-DD'),
},
});
});
},
getActivity(ConfigId: string, count: number, key: string) {
wx.ajax({
method: 'GET',
url: '?r=zd/activity/index-list',
data: { ConfigId, count },
}).then((res) => {
this.setData({
[key]: res.list.map((item) => {
item.EndTimeValue = dayjs(item.EndTime).valueOf();
item.BeginTimeValue = dayjs(item.BeginTime).valueOf();
item.SignUpDeadlineValue = dayjs(item.SignUpDeadline).valueOf();
item.BeginDate = dayjs(item.BeginTime).format('YYYY-MM-DD');
item.EndDate = dayjs(item.EndTime).format('YYYY-MM-DD');
item.isDay = item.BeginDate == item.EndDate;
item.BeginHm = dayjs(item.BeginTime).format('HH:mm');
item.EndHm = dayjs(item.EndTime).format('HH:mm');
item.BeginTime = dayjs(item.BeginTime).format('YYYY-MM-DD HH:mm');
item.EndTime = dayjs(item.EndTime).format('YYYY-MM-DD HH:mm');
return item;
}),
});
});
},
routerTo(e) {
let { url, active, code } = e.currentTarget.dataset;
if (!url) return;
if (code === 'adl') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEADLMODULE' });
}
if (code === 'drugs') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEMEDICATIONMODULE' });
}
if (code === 'story' && url === '/patient/pages/story/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMESTORIESVIEWALL' });
}
if (code === 'story' && url.includes('/patient/pages/publishStoryDetail/index')) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMESTORYCLICK' });
}
if (code === 'activity2' && url === '/patient/pages/live/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEONLINEACTIVITIESVIEWALL' });
}
if (code === 'activity2' && url === '/patient/pages/live/index?index=0') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEONLINEACTIVITIESMONTHLYPOSTER' });
}
if (code === 'activity2' && url.includes('/patient/pages/liveDetail/index')) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEONLINEACTIVITIESCARD' });
}
if (code === 'activity1' && url === '/patient/pages/live/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEOFFLINEACTIVITIESVIEWALL' });
}
if (code === 'activity1' && url.includes('/patient/pages/liveDetail/index')) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEOFFLINEACTIVITIESCARD' });
}
if (code === 'article' && url === '/patient/pages/repository/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMERECOMMENDEDREADINGVIEWALL' });
}
if (code === 'article' && url.includes('/patient/pages/repositoryDetail/index')) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMERECOMMENDEDREADINGARTICLE' });
}
if (code === 'serviceConf') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMESERVICE' });
}
if (url === '/patient/pages/interactivePatient/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTHOMEDOCTORCARD' });
}
if (url === 'NRDL') {
this.setBannerClick();
this.handleNRDL();
return;
}
if (url.includes('loginState')) {
url = url + encodeURIComponent(app.globalData.loginState);
app.zdPermissionVerification(2, 11, `/patient/pages/repository/index`).then(() => {
wx.navigateTo({
url,
});
});
return;
}
wx.navigateTo({
url,
fail() {
app.globalData.active = active;
wx.switchTab({
url,
});
},
});
},
handleReg() {
app.zdPermissionVerification(3, 0, '');
},
handleMiniDoctor(e) {
const { link } = e.currentTarget.dataset;
let period = '';
if (link === 'MINIDOCTOR-1.0') {
period = '2';
}
wx.navigateTo({
url: `/patient/pages/webview/index?period=${period}`,
});
},
handleQuestion() {
app.zdPermissionVerification(2, 11, `/patient/pages/repository/index`).then(() => {
const webviewUrl = encodeURIComponent(
`${app.globalData.url}/zdcare/#/info?loginState=${app.globalData.loginState}`,
);
wx.navigateTo({
url: `/patient/pages/webview/index?url=${webviewUrl}`,
});
});
},
handleSlider() {
wx.ajax({
method: 'POST',
url: '?r=zd/nrdl/add-slide-click-record',
data: {},
});
this.handleNRDL();
},
handleNRDL() {
app.zdPermissionVerification(3, 12, `/patient/pages/index/index`).then(() => {
wx.navigateTo({
url: `/patient/pages/nrdl/index`,
});
// if (this.data.zdUserInfo.has7DayAdl === 1) {
// wx.navigateTo({
// url: `/patient/pages/nrdl/index`,
// });
// } else {
// this.setData({
// toastShow: true,
// toastType: "ndrlAldAlert",
// });
// }
});
},
routerVipTo() {
const { MedicineAuditSwitch, UseDrugsAuditStatus, isFollow } = this.data.zdUserInfo;
if (MedicineAuditSwitch === '0') {
wx.navigateTo({
url: '/patient/pages/vipLogin/index',
});
} else if (MedicineAuditSwitch === '1') {
const pendPath = {
0: '/patient/pages/vipPending/index',
1: '/patient/pages/vipStartPending/index',
}[isFollow];
const url = {
1: pendPath,
2: '/patient/pages/vipReject/index',
}[UseDrugsAuditStatus];
wx.navigateTo({
url: url || '/patient/pages/vipCert/index',
});
} else {
wx.showToast({
icon: 'none',
title: '工程师正在努力建设中,敬请期待!',
});
}
},
handleToastOk() {
const { toastType } = this.data;
if (toastType === 'vipScan') {
this.routerVipTo();
this.handleToastCancel();
} else if (toastType === 'aldAlert') {
wx.navigateTo({
url: '/patient/pages/adl/index',
});
this.handleToastCancel();
} else if (toastType === 'healthCare') {
this.setPopupInfo();
this.handleNRDL();
this.handleToastCancel();
} else if (toastType === 'ndrlAldAlert') {
wx.navigateTo({
url: '/patient/pages/adl/index?nrdl=1',
});
this.handleToastCancel();
} else if (toastType === 'doubleStandards') {
wx.navigateTo({
url: '/patient/pages/adl/index',
});
this.handleToastCancel();
} else if (toastType === 'dedicatedDoctor') {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/close-popup',
data: {
Type: 6,
},
}).then((_res) => {
wx.navigateTo({
url: '/patient/pages/interactivePatient/index',
});
});
this.handleToastCancel(null, false);
} else if (toastType === 'referral-toast') {
this.setData({
referralFromShow: true,
});
wx.ajax({
method: 'POST',
url: '?r=zd/re-visit/update-popup-show-status',
data: {},
});
this.handleToastCancel(null, false);
}
},
handleToastCancel(_e = null, sure = true) {
const { toastType } = this.data;
if (toastType === 'doubleStandards' && sure) {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/close-popup',
data: {
Type: 5,
},
});
} else if (toastType === 'dedicatedDoctor' && sure) {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/close-popup',
data: {
Type: 6,
},
});
} else if (toastType === 'referral-toast') {
wx.ajax({
method: 'POST',
url: '?r=zd/re-visit/update-popup-show-status',
data: {},
});
}
this.setData({
toastShow: false,
toastType: '',
toastParams: '',
});
},
handlePublic() {
this.setData({
toastShow: true,
toastType: 'public-toast',
toastParams: {},
});
this.handlePublicClose();
},
handlePublicClose() {
this.setData({
publicCard: false,
});
wx.ajax({
method: 'POST',
url: '?r=zd/account/add-user-subscribe-guide-record',
data: {},
});
},
handleMp(e: any) {
const { code } = e.currentTarget.dataset;
const PageName = {
spread1: 'BTN_PATIENTHOMEBANNER1',
spread2: 'BTN_PATIENTHOMEBANNER2',
}[code];
app.zdMpBehavior({ PageName });
},
handleRegClose() {
this.setData({
regGuide: false,
});
},
});