Przeglądaj źródła

订单信息添加送货地址

yang yi 7 miesięcy temu
rodzic
commit
27573f3aeb

BIN
images/hospital.jpg


BIN
images/hospital.png


+ 4 - 0
pages/order-detail/order-detail.wxml

@@ -50,6 +50,10 @@ module.exports = {
         <text class="info-label">下单时间:</text>
         <text class="info-value">{{order.date}}</text>
       </view>
+      <view class="info-row" wx:if="{{order.deliveryAddress}}">
+        <text class="info-label">送货地址:</text>
+        <text class="info-value address">{{order.deliveryAddress}}</text>
+      </view>
       <view class="info-row">
         <text class="info-label">订单状态:</text>
         <text class="info-value status {{utils.getStatusClass(order.status)}}">{{utils.getStatusText(order.status)}}</text>

+ 6 - 0
pages/order-detail/order-detail.wxss

@@ -94,6 +94,12 @@
   flex: 1;
 }
 
+.info-value.address {
+  color: #666;
+  font-size: 24rpx;
+  line-height: 1.6;
+}
+
 .info-value.status {
   color: #007AFF;
   font-weight: bold;

+ 122 - 42
pages/order/order.js

@@ -17,10 +17,13 @@ Page({
     ],
     showCaseModal: false,
     showMedicineModal: false,
+    showPriceConfirmModal: false,
     selectedHospital: null,
     selectedCase: null,
     selectedMedicines: [],
-    totalPrice: 0
+    selectedPriceItem: null,
+    totalPrice: 0,
+    deliveryAddress: ''
   },
 
   onLoad() {
@@ -104,7 +107,8 @@ Page({
       showMedicineModal: false,
       selectedCase: null,
       selectedMedicines: [],
-      totalPrice: 0
+      totalPrice: 0,
+      deliveryAddress: ''
     })
   },
 
@@ -146,6 +150,34 @@ Page({
     })
   },
 
+  // 地址输入处理
+  onAddressInput(e) {
+    this.setData({
+      deliveryAddress: e.detail.value
+    })
+  },
+
+  // 使用默认地址
+  useDefaultAddress() {
+    const app = getApp()
+    const userInfo = app.globalData.userInfo || mockData.userInfo
+    
+    if (userInfo && userInfo.defaultAddress) {
+      this.setData({
+        deliveryAddress: userInfo.defaultAddress
+      })
+      wx.showToast({
+        title: '已使用默认地址',
+        icon: 'success'
+      })
+    } else {
+      wx.showToast({
+        title: '暂无默认地址',
+        icon: 'none'
+      })
+    }
+  },
+
   // 确认下单
   confirmOrder() {
     const selectedMedicines = this.data.selectedCase.medicines
@@ -164,6 +196,15 @@ Page({
       return
     }
 
+    // 验证送货地址
+    if (!this.data.deliveryAddress || this.data.deliveryAddress.trim() === '') {
+      wx.showToast({
+        title: '请输入送货地址',
+        icon: 'none'
+      })
+      return
+    }
+
     // 根据医院生成地图轨迹数据
     const hospitalLocation = this.getHospitalLocation(this.data.selectedHospital.name)
     const mapTracking = this.generateMapTracking(hospitalLocation)
@@ -176,6 +217,7 @@ Page({
       totalPrice: this.data.totalPrice,
       status: '配送中',
       date: new Date().toISOString().split('T')[0],
+      deliveryAddress: this.data.deliveryAddress,
       droneTracking: {
         status: '配送中',
         steps: ['订单确认', '药品准备', '无人机起飞', '配送中', '待送达']
@@ -190,7 +232,7 @@ Page({
     // 模拟下单成功
     wx.showModal({
       title: '下单成功',
-      content: `订单总价:¥${this.data.totalPrice}\n药品将尽快通过无人机配送`,
+      content: `订单总价:¥${this.data.totalPrice}\n送货地址:${this.data.deliveryAddress}\n药品将尽快通过无人机配送`,
       showCancel: false,
       success: () => {
         this.closeMedicineModal()
@@ -279,47 +321,85 @@ Page({
     const priceInfo = e.currentTarget.dataset.price
     const medicineName = this.data.medicineKeyword
     
+    // 显示确认模态框
+    this.setData({
+      showPriceConfirmModal: true,
+      selectedPriceItem: {
+        medicine: medicineName,
+        hospital: priceInfo.hospital,
+        price: priceInfo.price
+      },
+      deliveryAddress: ''
+    })
+  },
+
+  // 关闭比价确认模态框
+  closePriceConfirmModal() {
+    this.setData({
+      showPriceConfirmModal: false,
+      selectedPriceItem: null,
+      deliveryAddress: ''
+    })
+  },
+
+  // 确认比价下单
+  confirmPriceOrder() {
+    // 验证送货地址
+    if (!this.data.deliveryAddress || this.data.deliveryAddress.trim() === '') {
+      wx.showToast({
+        title: '请输入送货地址',
+        icon: 'none'
+      })
+      return
+    }
+
+    const selectedPriceItem = this.data.selectedPriceItem
+    
+    // 根据医院生成地图轨迹数据
+    const hospitalLocation = this.getHospitalLocation(selectedPriceItem.hospital)
+    const mapTracking = this.generateMapTracking(hospitalLocation)
+
+    // 创建订单数据
+    const order = {
+      id: Date.now(),
+      hospital: selectedPriceItem.hospital,
+      medicines: [selectedPriceItem.medicine],
+      totalPrice: selectedPriceItem.price,
+      status: '配送中',
+      date: new Date().toISOString().split('T')[0],
+      deliveryAddress: this.data.deliveryAddress,
+      droneTracking: {
+        status: '配送中',
+        steps: ['订单确认', '药品准备', '无人机起飞', '配送中', '待送达']
+      },
+      mapTracking: mapTracking
+    }
+
+    // 保存订单到全局变量和本地存储
+    const app = getApp()
+    app.addOrder(order)
+
+    // 保存地址用于显示
+    const savedAddress = this.data.deliveryAddress
+
+    // 关闭模态框
+    this.setData({
+      showPriceConfirmModal: false,
+      selectedPriceItem: null,
+      deliveryAddress: ''
+    })
+
     wx.showModal({
-      title: '确认下单',
-      content: `确认在${priceInfo.hospital}购买${medicineName},价格:¥${priceInfo.price}`,
-      success: (res) => {
-        if (res.confirm) {
-          // 根据医院生成地图轨迹数据
-          const hospitalLocation = this.getHospitalLocation(priceInfo.hospital)
-          const mapTracking = this.generateMapTracking(hospitalLocation)
-
-          // 创建订单数据
-          const order = {
-            id: Date.now(),
-            hospital: priceInfo.hospital,
-            medicines: [medicineName],
-            totalPrice: priceInfo.price,
-            status: '配送中',
-            date: new Date().toISOString().split('T')[0],
-            droneTracking: {
-              status: '配送中',
-              steps: ['订单确认', '药品准备', '无人机起飞', '配送中', '待送达']
-            },
-            mapTracking: mapTracking
-          }
-
-          // 保存订单到全局变量和本地存储
-          const app = getApp()
-          app.addOrder(order)
-
-          wx.showToast({
-            title: '下单成功',
-            icon: 'success',
-            success: () => {
-              // 跳转到我的页面查看订单
-              setTimeout(() => {
-                wx.switchTab({
-                  url: '/pages/profile/profile'
-                })
-              }, 500)
-            }
+      title: '下单成功',
+      content: `订单总价:¥${selectedPriceItem.price}\n送货地址:${savedAddress}\n药品将尽快通过无人机配送`,
+      showCancel: false,
+      success: () => {
+        // 跳转到我的页面查看订单
+        setTimeout(() => {
+          wx.switchTab({
+            url: '/pages/profile/profile'
           })
-        }
+        }, 500)
       }
     })
   }

+ 70 - 0
pages/order/order.wxml

@@ -126,6 +126,26 @@
           </view>
         </view>
       </view>
+      
+      <!-- 送货地址 -->
+      <view class="address-section">
+        <view class="address-title">
+          <text>送货地址</text>
+        </view>
+        <view class="address-input-wrapper">
+          <input 
+            class="address-input" 
+            placeholder="请输入送货地址" 
+            value="{{deliveryAddress}}" 
+            bindinput="onAddressInput"
+            maxlength="100"
+          />
+          <view class="address-actions">
+            <text class="address-btn" bindtap="useDefaultAddress">使用默认地址</text>
+          </view>
+        </view>
+      </view>
+      
       <view class="modal-footer">
         <view class="total-price">
           <text>总计:¥{{totalPrice}}</text>
@@ -137,4 +157,54 @@
       </view>
     </view>
   </view>
+
+  <!-- 药品比价下单确认模态框 -->
+  <view class="modal" wx:if="{{showPriceConfirmModal}}">
+    <view class="modal-content">
+      <view class="modal-header">
+        <text class="modal-title">确认下单</text>
+        <text class="modal-close" bindtap="closePriceConfirmModal">×</text>
+      </view>
+      <view class="price-confirm-info">
+        <view class="confirm-item">
+          <text class="confirm-label">药品:</text>
+          <text class="confirm-value">{{selectedPriceItem.medicine}}</text>
+        </view>
+        <view class="confirm-item">
+          <text class="confirm-label">医院:</text>
+          <text class="confirm-value">{{selectedPriceItem.hospital}}</text>
+        </view>
+        <view class="confirm-item">
+          <text class="confirm-label">价格:</text>
+          <text class="confirm-value price">¥{{selectedPriceItem.price}}</text>
+        </view>
+      </view>
+      
+      <!-- 送货地址 -->
+      <view class="address-section">
+        <view class="address-title">
+          <text>送货地址</text>
+        </view>
+        <view class="address-input-wrapper">
+          <input 
+            class="address-input" 
+            placeholder="请输入送货地址" 
+            value="{{deliveryAddress}}" 
+            bindinput="onAddressInput"
+            maxlength="100"
+          />
+          <view class="address-actions">
+            <text class="address-btn" bindtap="useDefaultAddress">使用默认地址</text>
+          </view>
+        </view>
+      </view>
+      
+      <view class="modal-footer">
+        <view class="action-buttons">
+          <button class="btn cancel" bindtap="closePriceConfirmModal">取消</button>
+          <button class="btn confirm" bindtap="confirmPriceOrder">确认下单</button>
+        </view>
+      </view>
+    </view>
+  </view>
 </view>

+ 91 - 0
pages/order/order.wxss

@@ -434,6 +434,60 @@
   text-align: center;
 }
 
+/* 送货地址样式 */
+.address-section {
+  padding: 20rpx 30rpx;
+  background: white;
+  border-top: 1rpx solid #f0f0f0;
+}
+
+.address-title {
+  font-size: 28rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 20rpx;
+  padding-left: 10rpx;
+  border-left: 6rpx solid #007AFF;
+}
+
+.address-input-wrapper {
+  display: flex;
+  flex-direction: column;
+  gap: 15rpx;
+}
+
+.address-input {
+  width: 100%;
+  padding: 20rpx;
+  background: #f8f8f8;
+  border-radius: 10rpx;
+  font-size: 28rpx;
+  color: #333;
+  border: 1rpx solid #e8e8e8;
+}
+
+.address-input:focus {
+  border-color: #007AFF;
+  background: white;
+}
+
+.address-actions {
+  display: flex;
+  justify-content: flex-end;
+}
+
+.address-btn {
+  font-size: 26rpx;
+  color: #007AFF;
+  padding: 10rpx 20rpx;
+  border-radius: 20rpx;
+  background: #e6f7ff;
+}
+
+.address-btn:active {
+  background: #bae7ff;
+}
+
 .modal-footer {
   padding: 20rpx 30rpx;
   border-top: 1rpx solid #f0f0f0;
@@ -471,3 +525,40 @@
   background: #007AFF;
   color: white;
 }
+
+/* 比价确认信息样式 */
+.price-confirm-info {
+  padding: 20rpx 30rpx;
+  background: #f8f8f8;
+  border-radius: 10rpx;
+  margin: 20rpx 30rpx;
+}
+
+.confirm-item {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 15rpx 0;
+  border-bottom: 1rpx solid #e8e8e8;
+}
+
+.confirm-item:last-child {
+  border-bottom: none;
+}
+
+.confirm-label {
+  font-size: 26rpx;
+  color: #666;
+  font-weight: 500;
+}
+
+.confirm-value {
+  font-size: 26rpx;
+  color: #333;
+  font-weight: bold;
+}
+
+.confirm-value.price {
+  color: #FF6B35;
+  font-size: 30rpx;
+}

+ 5 - 1
pages/profile/profile.js

@@ -222,7 +222,11 @@ Page({
       content += `   药品:${order.medicines.join('、')}\n`
       content += `   价格:¥${order.totalPrice}\n`
       content += `   状态:${order.status}\n`
-      content += `   日期:${order.date}\n\n`
+      content += `   日期:${order.date}\n`
+      if (order.deliveryAddress) {
+        content += `   地址:${order.deliveryAddress}\n`
+      }
+      content += `\n`
     })
 
     wx.showModal({

+ 1 - 1
project.config.json

@@ -36,6 +36,6 @@
     "tabIndent": "auto",
     "tabSize": 2
   },
-  "appid": "wx34960fa35fdc6e5f",
+  "appid": "wxe2c6aa83d83015b0",
   "simulatorPluginLibVersion": {}
 }

+ 7 - 4
utils/mockData.js

@@ -7,7 +7,7 @@ const mockData = {
       address: "北京市东城区帅府园1号",
       distance: "3.5km",
       rating: 4.8,
-      image: "/images/hospital.png",
+      image: "/images/hospital.jpg",
       cases: [
         {
           id: 1,
@@ -39,7 +39,7 @@ const mockData = {
       address: "上海市黄浦区瑞金二路197号",
       distance: "5.2km",
       rating: 4.7,
-      image: "/images/hospital.png",
+      image: "/images/hospital.jpg",
       cases: [
         {
           id: 3,
@@ -60,7 +60,7 @@ const mockData = {
       address: "广州市越秀区中山二路58号",
       distance: "7.8km",
       rating: 4.6,
-      image: "/images/hospital.png",
+      image: "/images/hospital.jpg",
       cases: [
         {
           id: 4,
@@ -125,7 +125,8 @@ const mockData = {
     avatar: "/images/default-avatar.png",
     fingerprintRegistered: false,
     faceRegistered: false,
-    medicalRecordsShared: false
+    medicalRecordsShared: false,
+    defaultAddress: "北京市朝阳区建国路88号"
   },
 
   // 病历记录数据
@@ -201,6 +202,7 @@ const mockData = {
       totalPrice: 43.5,
       status: "completed",
       date: "2024-03-01",
+      deliveryAddress: "北京市朝阳区建国路88号",
       droneTracking: {
         status: "已送达",
         steps: ["订单确认", "药品准备", "无人机起飞", "配送中", "已送达"]
@@ -249,6 +251,7 @@ const mockData = {
       totalPrice: 45.0,
       status: "delivering",
       date: "2024-03-05",
+      deliveryAddress: "上海市浦东新区世纪大道100号",
       droneTracking: {
         status: "配送中",
         steps: ["订单确认", "药品准备", "无人机起飞", "配送中", "待送达"]