diff --git a/src/app.json b/src/app.json index def6ef1..f7108e4 100644 --- a/src/app.json +++ b/src/app.json @@ -1,12 +1,20 @@ { "$schema": "https://dldir1.qq.com/WechatWebDev/editor-extension/wx-json/app.schema.json", "pages": [ + "pages/start/index", "pages/home/index", "pages/login/index", "pages/my/index", "pages/information/index", "pages/informationDetail/index", - "pages/message/index" + "pages/message/index", + "pages/webview/index" + ], + "subPackages": [ + { + "root": "doc", + "pages": ["pages/doc1/index"] + } ], "preloadRule": {}, "window": { diff --git a/src/app.ts b/src/app.ts index df371a8..d2d2a0a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -22,13 +22,13 @@ App({ // pro // appid:wxa4a28b299df7d921 - // url: 'https://m.shizhong.hbsaas.com', - // upFileUrl: 'https://m.shizhong.hbsaas.com/', - // imageUrl: 'https://m.shizhong.hbsaas.com/api/shizhong/', + // url: 'https://m.xd.hbsaas.com', + // upFileUrl: 'https://m.xd.hbsaas.com/', + // imageUrl: 'https://m.xd.hbsaas.com/api/shizhong/', loginState: '', isLogin: 0, - isAnswer: '0', + loginType: 0, scene: null, @@ -42,16 +42,17 @@ App({ wx.login({ success: (res) => { - console.log(res) + console.log(res); wx.ajax({ method: 'GET', url: '?r=xd/user/init-login', data: { code: res.code, }, - }).then((res) => { + }).then((res: any) => { this.globalData.loginState = res.loginState; - this.globalData.isLogin = res.isLogin || 999; + this.globalData.isLogin = res.isLogin; + this.globalData.loginType = res.loginType; }); }, }); @@ -66,40 +67,68 @@ App({ this.globalData.scene = parseScene(options.query.scene); } }, - waitLogin(waitLoginState = false, requireLogin = false, bakcPath = '') { - let time: number; + waitLogin({ type = 0 } = { type: 'any' }) { return new Promise((resolve) => { - time = setInterval(() => { - const { isLogin, loginState } = this.globalData; - if (loginState) { - clearInterval(time); - if (waitLoginState) { - resolve(true); - } else if (isLogin === 0 || !isLogin) { - this.globalData.backPath = bakcPath; - wx.reLaunch({ url: '/pages/login/index' }); - } else if (requireLogin && isLogin === 999) { - this.globalData.backPath = bakcPath; - wx.reLaunch({ url: '/pages/login/index' }); - } else { - resolve(true); + const checkLogin = () => { + if (this.globalData.loginState) { + if (this.checkLoginType(type)) { + resolve(); } + return; } - }, 500); + setTimeout(() => { + checkLogin(); + }, 500); + }; + checkLogin(); }); }, - getUserInfo(self: WechatMiniprogram.Page.Instance, callback?: (res: any) => void) { - wx.ajax({ + checkLoginType(type: 0 | 1 | 2 | 'any') { + const { loginType, isLogin } = this.globalData; + + if (type === 'any') { + return true; + } + + if (isLogin !== 1) { + if (type === 0) { + return true; + } + wx.reLaunch({ + url: '/pages/login/index', + }); + return false; + } + + if (loginType !== type) { + const typePageUrl = { + 2: '/pages/index/index', + }[type as 2]; + wx.reLaunch({ + url: typePageUrl, + }); + return false; + } + + return true; + }, + getUserInfo(type: 0 | 1 | 2): Promise { + const url = { + 2: '?r=xd/doctor/index/get-doctor', + }[type]; + return wx.ajax({ method: 'GET', - url: '?r=shizhong/account/get-info', + url, data: {}, - }).then((res) => { - if (self) { - self.setData({ - userInfo: res, - }); - } - callback?.(res); + }) as Promise; + }, + mpBehavior(data) { + wx.ajax({ + method: 'POST', + url: '?r=xd/doctor/index/operate-action-submit', + data: data, + loading: false, + showMsg: false, }); }, getMenuInfo(self) { diff --git a/src/components/popup/index.wxml b/src/components/popup/index.wxml index 179926a..e0a2b1c 100644 --- a/src/components/popup/index.wxml +++ b/src/components/popup/index.wxml @@ -11,7 +11,7 @@ > @@ -33,14 +33,14 @@ - + - + - + - + diff --git a/src/doc/pages/doc1/index.json b/src/doc/pages/doc1/index.json new file mode 100644 index 0000000..248ee53 --- /dev/null +++ b/src/doc/pages/doc1/index.json @@ -0,0 +1,5 @@ +{ + "navigationStyle": "default", + "navigationBarTitleText": "隐私协议保护政策", + "usingComponents": {} +} diff --git a/src/doc/pages/doc1/index.scss b/src/doc/pages/doc1/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/doc/pages/doc1/index.ts b/src/doc/pages/doc1/index.ts new file mode 100644 index 0000000..067b6bb --- /dev/null +++ b/src/doc/pages/doc1/index.ts @@ -0,0 +1,8 @@ +const _app = getApp(); + +Page({ + data: {}, + onLoad() {}, +}); + +export {} diff --git a/src/doc/pages/doc1/index.wxml b/src/doc/pages/doc1/index.wxml new file mode 100644 index 0000000..a10af0e --- /dev/null +++ b/src/doc/pages/doc1/index.wxml @@ -0,0 +1,2 @@ + +pages/story/index.wxml diff --git a/src/images/checkbox.png b/src/images/checkbox.png new file mode 100644 index 0000000..f69bca5 Binary files /dev/null and b/src/images/checkbox.png differ diff --git a/src/pages/home/index.scss b/src/pages/home/index.scss index ba7d375..8dc5daf 100644 --- a/src/pages/home/index.scss +++ b/src/pages/home/index.scss @@ -43,6 +43,7 @@ page { font-size: 28rpx; color: rgba(173, 172, 178, 1); .tag { + margin-left: 10rpx; display: inline-block; font-size: 24rpx; color: rgba(255, 255, 255, 1); @@ -108,11 +109,15 @@ page { } .ad { margin-top: 32rpx; - .ad-img { - display: block; - width: 100%; + .swiper { height: 224rpx; - box-shadow: 0 4rpx 22rpx 0 rgba(0, 0, 0, 0.03); + .ad-img { + display: block; + width: 100%; + height: 224rpx; + border-radius: 24rpx; + box-shadow: 0 4rpx 22rpx 0 rgba(0, 0, 0, 0.03); + } } } .list { @@ -145,7 +150,7 @@ page { border-radius: 12rpx; } .wrap { - padding: 12rpx 0 0 24rpx; + padding: 12rpx 24rpx 0 24rpx; flex: 1; display: flex; flex-direction: column; @@ -179,6 +184,11 @@ page { display: flex; align-items: center; gap: 12rpx; + background-color: transparent; + padding: 0; + &::after { + border: none; + } .icon { width: 36rpx; height: 36rpx; diff --git a/src/pages/home/index.ts b/src/pages/home/index.ts index 81d6143..672baab 100644 --- a/src/pages/home/index.ts +++ b/src/pages/home/index.ts @@ -1,3 +1,5 @@ +import dayjs from 'dayjs'; + const app = getApp(); Page({ @@ -10,9 +12,112 @@ Page({ popupParams: { close: true, } as any, + + userInfo: {}, + unReadMsgCount: 0, + bannerList: [], + + list: [] as any[], + total: 0, + pagination: { + page: 1, + pages: 1, + count: 1, + }, + }, + onShow() { + app.waitLogin({ type: 2 }).then(() => { + // this.getNotice(); + this.getBanner(); + this.getList(); + app.getUserInfo(2).then((userInfo) => { + this.setData({ + userInfo, + }); + }); + }); + }, + handleWebview() { + const encodeUrl = encodeURIComponent('https://dct.meddb.cn'); + wx.navigateTo({ + url: `/pages/webview/index?url=${encodeUrl}`, + }); + }, + getNotice() { + wx.ajax({ + method: 'GET', + url: '?r=xd/doctor/index/get-unread-msg-count', + data: {}, + }).then((res) => { + this.setData({ + unReadMsgCount: res.unReadMsgCount, + }); + }); + }, + handleNotice() { + wx.navigateTo({ + url: '/pages/message/index', + }); + }, + getBanner() { + wx.ajax({ + method: 'GET', + url: '?r=xd/doctor/index/get-banner', + data: { + count: 0, + }, + }).then((res) => { + this.setData({ + bannerList: res.list, + }); + }); + }, + handleBanner(e) { + const { index } = e.currentTarget.dataset; + const { LinkUrl } = this.data.bannerList[index]; + wx.navigateTo({ + url: LinkUrl, + fail() { + wx.switchTab({ + url: LinkUrl, + }); + }, + }); }, - onLoad() { - // app.waitLogin().then(() => {}); + getList(newPage = 1) { + wx.ajax({ + method: 'GET', + url: '?r=xd/doctor/index/get-latest-material', + data: { + page: newPage, + }, + }).then((res) => { + res.list.forEach((item) => { + item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); + }); + const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; + this.setData({ + total: res.count, + list, + pagination: { + page: res.page, + pages: res.pages, + count: res.count, + }, + }); + }); + }, + onReachBottom() { + const { page, pages } = this.data.pagination; + if (pages > page) { + this.getList(page + 1); + } + }, + handleDetail(e: any) { + const { id } = e.currentTarget.dataset; + wx.navigateTo({ + url: `/pages/informationDetail/index?id=${id}`, + }); }, handlePopupOk() { const { popupType } = this.data; @@ -23,6 +128,18 @@ Page({ popupShow: false, }); }, + onShareAppMessage(e) { + if (e.from === 'button') { + const { Title, CoverImgUrl, Id } = e.target.dataset.params; + app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id }); + return { + title: Title, + path: `/pages/informationDetail/index?id=${Id}`, + imageUrl: CoverImgUrl, + }; + } + return {}; + }, }); export {}; diff --git a/src/pages/home/index.wxml b/src/pages/home/index.wxml index 3b9fbe7..74d5a57 100644 --- a/src/pages/home/index.wxml +++ b/src/pages/home/index.wxml @@ -1,65 +1,74 @@ - + - XX医生 + {{userInfo.welcome}},{{userInfo.Name}} - 北京天坛医院 - 三甲 + {{userInfo.HospitalName}} + {{userInfo.HospitalClassificationName}}{{userInfo.HospitalLevel}} -