| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // hospital.js
- const mockData = require('../../utils/mockData.js')
- Page({
- data: {
- hospital: null,
- showCaseModal: false,
- selectedCase: null
- },
- onLoad(options) {
- const hospitalId = parseInt(options.id)
- const hospital = mockData.hospitals.find(h => h.id === hospitalId)
-
- if (hospital) {
- this.setData({
- hospital: hospital
- })
- } else {
- wx.showToast({
- title: '医院信息不存在',
- icon: 'none'
- })
- setTimeout(() => {
- wx.navigateBack()
- }, 1500)
- }
- },
- // 返回上一页
- goBack() {
- wx.navigateBack({
- delta: 1
- })
- },
- // 查看病历单详情
- viewCaseDetail(e) {
- const selectedCase = e.currentTarget.dataset.case
- this.setData({
- selectedCase: selectedCase,
- showCaseModal: true
- })
- },
- // 关闭病历单模态框
- closeCaseModal() {
- this.setData({
- showCaseModal: false,
- selectedCase: null
- })
- },
- // 从病历单下单
- orderFromCase() {
- const hospitalName = this.data.hospital.name
- const caseInfo = this.data.selectedCase
-
- wx.showModal({
- title: '确认下单',
- content: `确认在${hospitalName}购买病历单中的药品吗?`,
- success: (res) => {
- if (res.confirm) {
- this.closeCaseModal()
-
- // 跳转到下单页面
- wx.switchTab({
- url: '/pages/order/order'
- })
-
- // 延迟设置搜索关键词
- setTimeout(() => {
- const pages = getCurrentPages()
- const orderPage = pages.find(page => page.route === 'pages/order/order')
- if (orderPage) {
- orderPage.setData({
- currentTab: 0,
- hospitalKeyword: hospitalName
- })
- }
- }, 500)
- }
- }
- })
- }
- })
|