Jelajahi Sumber

给所有非tab-bar页面添加返回按钮

yang yi 7 bulan lalu
induk
melakukan
cd9150f101

+ 3 - 1
app.json

@@ -3,7 +3,9 @@
     "pages/index/index",
     "pages/order/order",
     "pages/diagnosis/diagnosis",
-    "pages/profile/profile"
+    "pages/profile/profile",
+    "pages/hospital/hospital",
+    "pages/logs/logs"
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 86 - 0
pages/hospital/hospital.js

@@ -0,0 +1,86 @@
+// 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)
+        }
+      }
+    })
+  }
+})

+ 5 - 0
pages/hospital/hospital.json

@@ -0,0 +1,5 @@
+{
+  "navigationBarTitleText": "医院详情",
+  "navigationStyle": "custom",
+  "enablePullDownRefresh": false
+}

+ 94 - 0
pages/hospital/hospital.wxml

@@ -0,0 +1,94 @@
+<!--hospital.wxml-->
+<view class="container">
+  <!-- 自定义导航栏 -->
+  <view class="custom-navbar">
+    <view class="navbar-content">
+      <view class="back-btn" bindtap="goBack">
+        <text class="back-icon">‹</text>
+      </view>
+      <view class="navbar-title">
+        <text>医院详情</text>
+      </view>
+      <view class="navbar-right"></view>
+    </view>
+  </view>
+
+  <!-- 医院信息 -->
+  <view class="hospital-info">
+    <image class="hospital-image" src="{{hospital.image}}" mode="aspectFill"></image>
+    <view class="hospital-details">
+      <text class="hospital-name">{{hospital.name}}</text>
+      <text class="hospital-address">{{hospital.address}}</text>
+      <view class="hospital-meta">
+        <text class="rating">{{hospital.rating}}分</text>
+        <text class="distance">{{hospital.distance}}</text>
+      </view>
+    </view>
+  </view>
+
+  <!-- 病例单列表 -->
+  <view class="cases-section">
+    <view class="section-title">
+      <text>病例单</text>
+      <text class="case-count">共{{hospital.cases.length}}个</text>
+    </view>
+    <view class="case-list">
+      <view class="case-item" wx:for="{{hospital.cases}}" wx:key="id" bindtap="viewCaseDetail" data-case="{{item}}">
+        <view class="case-header">
+          <text class="case-date">{{item.date}}</text>
+          <text class="case-doctor">{{item.doctor}} - {{item.department}}</text>
+        </view>
+        <view class="case-body">
+          <text class="case-diagnosis">诊断:{{item.diagnosis}}</text>
+          <text class="case-medicines">药品:{{item.medicines.length}}种</text>
+        </view>
+        <view class="case-arrow">
+          <text>></text>
+        </view>
+      </view>
+    </view>
+  </view>
+
+  <!-- 病例单详情模态框 -->
+  <view class="modal" wx:if="{{showCaseModal}}">
+    <view class="modal-content">
+      <view class="modal-header">
+        <text class="modal-title">病例单详情</text>
+        <text class="modal-close" bindtap="closeCaseModal">×</text>
+      </view>
+      <view class="modal-body">
+        <view class="case-detail">
+          <view class="detail-row">
+            <text class="detail-label">就诊日期:</text>
+            <text class="detail-value">{{selectedCase.date}}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">医生:</text>
+            <text class="detail-value">{{selectedCase.doctor}}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">科室:</text>
+            <text class="detail-value">{{selectedCase.department}}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">诊断结果:</text>
+            <text class="detail-value diagnosis">{{selectedCase.diagnosis}}</text>
+          </view>
+          <view class="detail-section">
+            <text class="detail-label">处方药品:</text>
+            <view class="medicine-list">
+              <view class="medicine-item" wx:for="{{selectedCase.medicines}}" wx:key="id">
+                <text class="medicine-name">{{item.name}}</text>
+                <text class="medicine-price">¥{{item.price}}</text>
+              </view>
+            </view>
+          </view>
+        </view>
+      </view>
+      <view class="modal-footer">
+        <button class="btn cancel" bindtap="closeCaseModal">关闭</button>
+        <button class="btn confirm" bindtap="orderFromCase">下单</button>
+      </view>
+    </view>
+  </view>
+</view>

+ 338 - 0
pages/hospital/hospital.wxss

@@ -0,0 +1,338 @@
+.container {
+  width: 100%;
+  align-items: stretch;
+  padding: 0;
+  box-sizing: border-box;
+  background-color: #f5f5f5;
+}
+
+.custom-navbar {
+  background: white;
+  padding: 20rpx 30rpx;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+  position: sticky;
+  top: 0;
+  z-index: 100;
+}
+
+.navbar-content {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  height: 88rpx;
+}
+
+.back-btn {
+  width: 60rpx;
+  height: 60rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.back-icon {
+  font-size: 48rpx;
+  color: #333;
+  font-weight: bold;
+}
+
+.navbar-title {
+  flex: 1;
+  text-align: center;
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+}
+
+.navbar-right {
+  width: 60rpx;
+}
+
+.hospital-info {
+  background: white;
+  margin: 20rpx;
+  border-radius: 20rpx;
+  overflow: hidden;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+}
+
+.hospital-image {
+  width: 100%;
+  height: 300rpx;
+}
+
+.hospital-details {
+  padding: 30rpx;
+}
+
+.hospital-name {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 15rpx;
+}
+
+.hospital-address {
+  font-size: 26rpx;
+  color: #666;
+  margin-bottom: 20rpx;
+  display: block;
+}
+
+.hospital-meta {
+  display: flex;
+  gap: 30rpx;
+}
+
+.rating {
+  font-size: 26rpx;
+  color: #FF6B35;
+  font-weight: bold;
+}
+
+.distance {
+  font-size: 26rpx;
+  color: #007AFF;
+}
+
+.cases-section {
+  background: white;
+  margin: 20rpx;
+  border-radius: 20rpx;
+  padding: 30rpx;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+}
+
+.section-title {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 25rpx;
+  padding-bottom: 15rpx;
+  border-bottom: 1rpx solid #f0f0f0;
+}
+
+.section-title text:first-child {
+  font-size: 28rpx;
+  font-weight: bold;
+  color: #333;
+  padding-left: 10rpx;
+  border-left: 6rpx solid #007AFF;
+}
+
+.case-count {
+  font-size: 24rpx;
+  color: #999;
+}
+
+.case-list {
+  display: flex;
+  flex-direction: column;
+}
+
+.case-item {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 25rpx;
+  background: #f8f8f8;
+  border-radius: 15rpx;
+  margin-bottom: 15rpx;
+  transition: all 0.3s;
+}
+
+.case-item:active {
+  background: #f0f0f0;
+  transform: scale(0.98);
+}
+
+.case-header {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  margin-bottom: 10rpx;
+}
+
+.case-date {
+  font-size: 22rpx;
+  color: #999;
+  margin-bottom: 8rpx;
+}
+
+.case-doctor {
+  font-size: 26rpx;
+  color: #333;
+  font-weight: bold;
+}
+
+.case-body {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+
+.case-diagnosis {
+  font-size: 24rpx;
+  color: #FF6B35;
+  margin-bottom: 8rpx;
+}
+
+.case-medicines {
+  font-size: 24rpx;
+  color: #666;
+}
+
+.case-arrow {
+  font-size: 32rpx;
+  color: #ccc;
+  margin-left: 15rpx;
+}
+
+.modal {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.5);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 1000;
+}
+
+.modal-content {
+  background: white;
+  border-radius: 20rpx;
+  width: 90%;
+  max-height: 80%;
+  overflow: hidden;
+  display: flex;
+  flex-direction: column;
+}
+
+.modal-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 30rpx;
+  border-bottom: 1rpx solid #f0f0f0;
+}
+
+.modal-title {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+}
+
+.modal-close {
+  font-size: 48rpx;
+  color: #999;
+  line-height: 1;
+  padding: 0 10rpx;
+}
+
+.modal-body {
+  flex: 1;
+  overflow-y: auto;
+  padding: 30rpx;
+}
+
+.case-detail {
+  display: flex;
+  flex-direction: column;
+}
+
+.detail-row {
+  display: flex;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+
+.detail-label {
+  font-size: 26rpx;
+  color: #666;
+  min-width: 150rpx;
+}
+
+.detail-value {
+  font-size: 26rpx;
+  color: #333;
+  flex: 1;
+}
+
+.detail-value.diagnosis {
+  color: #FF6B35;
+  font-weight: bold;
+}
+
+.detail-section {
+  margin-top: 30rpx;
+  padding-top: 20rpx;
+  border-top: 1rpx solid #f0f0f0;
+}
+
+.detail-section .detail-label {
+  display: block;
+  margin-bottom: 15rpx;
+  font-size: 28rpx;
+  font-weight: bold;
+  color: #333;
+}
+
+.modal-content .medicine-list {
+  display: flex;
+  flex-direction: column;
+  background: #f8f8f8;
+  border-radius: 15rpx;
+  padding: 20rpx;
+}
+
+.modal-content .medicine-item {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 15rpx 0;
+  border-bottom: 1rpx solid #f0f0f0;
+}
+
+.modal-content .medicine-item:last-child {
+  border-bottom: none;
+}
+
+.modal-content .medicine-name {
+  font-size: 26rpx;
+  color: #333;
+}
+
+.modal-content .medicine-price {
+  font-size: 26rpx;
+  color: #FF6B35;
+  font-weight: bold;
+}
+
+.modal-footer {
+  display: flex;
+  gap: 20rpx;
+  padding: 20rpx 30rpx 30rpx;
+  border-top: 1rpx solid #f0f0f0;
+}
+
+.modal-footer .btn {
+  flex: 1;
+  border-radius: 50rpx;
+  padding: 25rpx 0;
+  font-size: 28rpx;
+  font-weight: bold;
+  border: none;
+}
+
+.modal-footer .cancel {
+  background: #f0f0f0;
+  color: #666;
+}
+
+.modal-footer .confirm {
+  background: #007AFF;
+  color: white;
+}

+ 7 - 0
pages/logs/logs.js

@@ -14,5 +14,12 @@ Page({
         }
       })
     })
+  },
+
+  // 返回上一页
+  goBack() {
+    wx.navigateBack({
+      delta: 1
+    })
   }
 })

+ 1 - 0
pages/logs/logs.json

@@ -1,4 +1,5 @@
 {
+  "navigationStyle": "custom",
   "usingComponents": {
   }
 }

+ 21 - 5
pages/logs/logs.wxml

@@ -1,6 +1,22 @@
 <!--logs.wxml-->
-<scroll-view class="scrollarea" scroll-y type="list">
-  <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
-    <view class="log-item">{{index + 1}}. {{log.date}}</view>
-  </block>
-</scroll-view>
+<view class="container">
+  <!-- 自定义导航栏 -->
+  <view class="custom-navbar">
+    <view class="navbar-content">
+      <view class="back-btn" bindtap="goBack">
+        <text class="back-icon">‹</text>
+      </view>
+      <view class="navbar-title">
+        <text>日志记录</text>
+      </view>
+      <view class="navbar-right"></view>
+    </view>
+  </view>
+
+  <!-- 内容区域 -->
+  <scroll-view class="scrollarea" scroll-y type="list">
+    <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
+      <view class="log-item">{{index + 1}}. {{log.date}}</view>
+    </block>
+  </scroll-view>
+</view>

+ 59 - 1
pages/logs/logs.wxss

@@ -3,14 +3,72 @@ page {
   display: flex;
   flex-direction: column;
 }
+
+.container {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  background-color: #f5f5f5;
+}
+
+/* 自定义导航栏样式 */
+.custom-navbar {
+  background: #ffffff;
+  padding-top: env(safe-area-inset-top);
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
+  z-index: 1000;
+}
+
+.navbar-content {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  height: 88rpx;
+  padding: 0 20rpx;
+}
+
+.back-btn {
+  width: 60rpx;
+  height: 60rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.back-icon {
+  font-size: 48rpx;
+  color: #333;
+  font-weight: bold;
+}
+
+.navbar-title {
+  flex: 1;
+  text-align: center;
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+}
+
+.navbar-right {
+  width: 60rpx;
+}
+
 .scrollarea {
   flex: 1;
   overflow-y: hidden;
+  padding: 20rpx;
 }
+
 .log-item {
-  margin-top: 20rpx;
+  background: white;
+  padding: 30rpx;
+  border-radius: 10rpx;
+  margin-bottom: 20rpx;
   text-align: center;
+  font-size: 28rpx;
+  color: #333;
 }
+
 .log-item:last-child {
   padding-bottom: env(safe-area-inset-bottom);
 }