Explorar el Código

fix: appointment

wangyuan hace 2 años
padre
commit
7a4dac2ef4
Se han modificado 7 ficheros con 127 adiciones y 31 borrados
  1. 1 0
      app.js
  2. 45 5
      pages/buy/buy.js
  3. 1 1
      pages/buy/buy.wxml
  4. 3 0
      pages/buy/buy.wxss
  5. 1 1
      pages/index/index.js
  6. 41 1
      pages/my/my.js
  7. 35 23
      pages/report/report.js

+ 1 - 0
app.js

@@ -15,6 +15,7 @@ App({
   },
   globalData: {
     useNumber: '', // 用户可使用的次数
+    hasAppointment: false, // 是否有待处理预约的数据
     accessToken: '',
     isNeedPhone: false, // 是否有号码权限
     isNeedHeadImg: false, // 是否有头像权限

+ 45 - 5
pages/buy/buy.js

@@ -1,8 +1,9 @@
 // pages/buy/buy.js
 import { goodsList } from '../../api/index'
 import { submitOrder } from '../../api/pay'
-import { getAccountNmber } from '../../api/appointment'
+import { getAccountNmber, appointmentList } from '../../api/appointment'
 import { documentList } from "../../api/document"
+
 const app = getApp()
 
 Page({
@@ -22,12 +23,16 @@ Page({
     from: '' // 从哪个页面进入的页面
   },
 
+  onShow () {
+    this.getGoodsList()
+    this.getAccountNmberFn()
+  },
+
   /**
    * 生命周期函数--监听页面显示
    */
   onLoad(options) {
-    this.getGoodsList()
-    this.getAccountNmberFn()
+    
     this.setData({
       from: options.from,
       appusername: app.globalData.userInfo.userName.length > 8 ? app.globalData.userInfo.userName.substring(0,4) : app.globalData.userInfo.userName,
@@ -60,7 +65,6 @@ Page({
         recommendIndx = index
         return item.isRecommend == true
       })
-      console.log(recommendItem,recommendIndx,'recommendItem');
       if (recommendItem) {
         this.setData({
           activeIndex: recommendIndx,
@@ -156,12 +160,48 @@ Page({
           if (that.data.from == 'appointment') {
             wx.navigateBack()
           } else {
-            that.getDocumentList()
+            that.hasAppointmentFn()
           }
         }
       }
     })
   },
+  // 获取用户预约信息
+  hasAppointmentFn (flag = true) {
+    var that = this
+    wx.showNavigationBarLoading()
+    appointmentList({
+      status: 1,
+      currentPage: 1
+    }).then(res => {
+      wx.hideNavigationBarLoading()
+      if (res.data.vos.length !== 0) {
+        app.globalData.hasAppointment = true
+        that.navigateAppointment()
+      } else {
+        app.globalData.hasAppointment = false
+        that.getDocumentList()
+      }
+    }).catch(e => {
+      wx.hideNavigationBarLoading()
+    })
+  },
+  navigateAppointment () {
+    wx.showModal({
+      content: '您预约的健康筛查还未体验,请先体验',
+      cancelColor: '#666',
+      cancelText: '取消',
+      confirmText: '我的预约',
+      confirmColor: '#333',
+      success (res) {
+        if (res.confirm) {
+          wx.navigateTo({
+            url: '/pages/myAppointment/myAppointment'
+          })
+        }
+      }
+    })
+  },
   // 获取用户档案信息
   getDocumentList () {
     wx.showLoading({

+ 1 - 1
pages/buy/buy.wxml

@@ -26,7 +26,7 @@
         </view>
       </view> -->
       <block wx:for="{{goodsList}}" wx:key="index">
-        <view class="pay-item four-time {{index == activeIndex ? 'pay-item-active' : ''}}" data-index="{{index}}" data-goodsinfo="{{item}}" bindtap="handlePayType">
+        <view class="pay-item four-time {{index == activeIndex ? 'pay-item-active' : ''}}" data-index="{{index}} {{goodsList.length == 1 ? 'pay-item-nomargin' : ''}}" data-goodsinfo="{{item}}" bindtap="handlePayType">
           <view class="p-title-flex">
             <view class="light-text ittflex" wx:if="{{item.isRecommend}}">荐</view>
             <text class="sub-title">{{item.goodsName}}</text>

+ 3 - 0
pages/buy/buy.wxss

@@ -81,6 +81,9 @@
 .pay-item-active {
   border: 2rpx solid #45A6B5;
 }
+.pay-item-nomargin {
+  margin-left: 0;
+}
 .p-title {
   margin-top: 40rpx;
   font-size: 30rpx;

+ 1 - 1
pages/index/index.js

@@ -298,12 +298,12 @@ Page({
       status: 1,
       currentPage: 1
     }).then(res => {
-      console.log(res, 'appointmentList');
       if (res.data.vos.length !== 0) {
         that.setData({
           showTopBar: true,
           topBarObj: res.data.vos[0]
         })
+        app.globalData.hasAppointment = true
       } else {
         that.setData({
           showTopBar: false,

+ 41 - 1
pages/my/my.js

@@ -1,6 +1,7 @@
 // pages/my/my.js
 import { getAccountNmber } from '../../api/appointment'
 import { documentList } from "../../api/document"
+import { appointmentList } from '../../api/appointment'
 const app = getApp()
 Page({
 
@@ -73,6 +74,7 @@ Page({
   onShow () {
     if (!this.data.isFirstGetCount) {
       this.getAccountNmberFn()
+      this.appointmentListFn()
     }
   },
 
@@ -89,6 +91,7 @@ Page({
       appUserName: userName
     })
     this.getAccountNmberFn()
+    this.appointmentListFn()
   },
 
   // 获取用户档案信息
@@ -129,6 +132,24 @@ Page({
     })
   },
 
+  // 获取用户预约信息
+  appointmentListFn () {
+    wx.showNavigationBarLoading()
+    appointmentList({
+      status: 1,
+      currentPage: 1
+    }).then(res => {
+      wx.hideNavigationBarLoading()
+      if (res.data.vos.length !== 0) {
+        app.globalData.hasAppointment = true
+      } else {
+        app.globalData.hasAppointment = false
+      }
+    }).catch(e => {
+      wx.hideNavigationBarLoading()
+    })
+  },
+
   // 获取用户剩余检测机会
   getAccountNmberFn () {
     var that = this
@@ -140,6 +161,8 @@ Page({
         isFirstGetCount: false
       })
       app.globalData.useNumber = res.data
+    }).catch(e => {
+      wx.hideNavigationBarLoading()
     })
   },
 
@@ -156,7 +179,24 @@ Page({
 
   // 立即预约
   handleAppoint () {
-    this.getDocumentList()
+    if (app.globalData.hasAppointment) {
+      wx.showModal({
+        content: '您预约的健康筛查还未体验,请先体验',
+        cancelColor: '#666',
+        cancelText: '取消',
+        confirmText: '我的预约',
+        confirmColor: '#333',
+        success (res) {
+          if (res.confirm) {
+            wx.navigateTo({
+              url: '/pages/myAppointment/myAppointment',
+            })
+          }
+        }
+      })
+    } else {
+      this.getDocumentList()
+    }
   },
   /**
    * 路由拦截

+ 35 - 23
pages/report/report.js

@@ -1,6 +1,7 @@
 // pages/report/report.js
 import { myReportList } from '../../api/my'
-import { documentList } from "../../api/document";
+import { documentList } from "../../api/document"
+import { appointmentList } from '../../api/appointment'
 const app = getApp()
 Page({
 
@@ -16,8 +17,23 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
+    console.log(app.globalData.hasAppointment);
     app.globalData.selectedInex = 1
     this.getMyReportList()
+    this.appointmentListFn()
+  },
+
+  appointmentListFn () {
+    appointmentList({
+      status: 1,
+      currentPage: 1
+    }).then(res => {
+      if (res.data.vos.length !== 0) {
+        app.globalData.hasAppointment = true
+      } else {
+        app.globalData.hasAppointment = false
+      }
+    })
   },
 
   // 我的报告
@@ -67,31 +83,27 @@ Page({
         }
       })
     } else {
-      this.getDocumentList()
+      if (app.globalData.hasAppointment) {
+        wx.showModal({
+          content: '您预约的健康筛查还未体验,请先体验',
+          cancelColor: '#666',
+          cancelText: '取消',
+          confirmText: '我的预约',
+          confirmColor: '#333',
+          success (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: '/pages/myAppointment/myAppointment',
+              })
+            }
+          }
+        })
+      } else {
+        this.getDocumentList()
+      }
     }
   },
 
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
   /**
    * 点击报告进入详情
    */