Browse Source

pref(appointment): pref appointment relative logic and page ui

wangyuan 2 years ago
parent
commit
012cb744a0
6 changed files with 214 additions and 36 deletions
  1. 62 20
      pages/buy/buy.js
  2. 34 2
      pages/createFile/createFile.js
  3. 1 1
      pages/handleFile/handleFile.js
  4. 25 6
      pages/index/index.js
  5. 50 3
      pages/my/my.js
  6. 42 4
      pages/report/report.js

+ 62 - 20
pages/buy/buy.js

@@ -2,6 +2,7 @@
 import { goodsList } from '../../api/index'
 import { submitOrder } from '../../api/pay'
 import { getAccountNmber } from '../../api/appointment'
+import { documentList } from "../../api/document"
 const app = getApp()
 
 Page({
@@ -25,7 +26,6 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onLoad(options) {
-    console.log(options, 'options');
     this.getGoodsList()
     this.getAccountNmberFn()
     this.setData({
@@ -122,24 +122,8 @@ Page({
         signType: res.data.signType,
         paySign: res.data.paySign,
         success (res) {
-          that.getAccountNmberFn() 
-          wx.showModal({
-            title: '支付成功,立即去预约',
-            confirmText: '去预约',
-            confirmColor: '#333',
-            cancelColor: '#666',
-            success (modalRes) {
-              if (modalRes.confirm) {
-                if (that.data.from == 'appointment') {
-                  wx.navigateBack()
-                } else {
-                  wx.navigateTo({
-                    url: '/pages/appointment/appointment?from=buy'
-                  })
-                }
-              }
-            }
-          })
+          that.getAccountNmberFn()
+          that.paySuccess()
         },
         fail (res) {
           wx.showToast({
@@ -156,5 +140,63 @@ Page({
         showCancel: false
       })
     })
-  }
+  },
+
+  // 支付成功
+  paySuccess () {
+    var that = this
+    wx.showModal({
+      title: '支付成功,立即去预约',
+      confirmText: '去预约',
+      confirmColor: '#333',
+      cancelColor: '#666',
+      success (modalRes) {
+        if (modalRes.confirm) {
+          if (that.data.from == 'appointment') {
+            wx.navigateBack()
+          } else {
+            that.getDocumentList()
+          }
+        }
+      }
+    })
+  },
+  // 获取用户档案信息
+  getDocumentList () {
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
+    documentList({
+      currentPage: 1
+    }).then(res => {
+      wx.hideLoading()
+      const response = res.data.vos || []
+      if (response.length == 0) {
+        wx.showModal({
+          content: '预约用户前需要先添加检测人员信息',
+          cancelColor: '#666',
+          confirmColor: '#333',
+          success (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: '/pages/createFile/createFile?from=buy'
+              })
+            }
+          }
+        })
+      } else {
+        wx.navigateTo({
+          url: '/pages/appointment/appointment?from=buy'
+        })
+      }
+    }).catch(e => {
+      wx.hideLoading()
+      wx.showModal({
+        content: e,
+        confirmColor: '#333',
+        showCancel: false
+      })
+    })
+  },
 })

+ 34 - 2
pages/createFile/createFile.js

@@ -7,6 +7,7 @@ Page({
    * 页面的初始数据
    */
   data: {
+    from: '',
     choseAvatar: false,
     choseAvaSrc: '',
     username: '',
@@ -17,6 +18,12 @@ Page({
     relativeRange: ['本人','父母', '子女', '配偶', '朋友', '祖孙', '兄妹', '其他']  // 关系  关系  1.本人 2.父母 3.子女 4.配偶  5.朋友 6.祖孙、7.兄妹、8.其他
   },
 
+  onLoad (options) {
+    this.setData({
+      from: options.from
+    })
+  },
+
   bindUserNameInput (e) {
     this.setData({
       username: e.detail.value
@@ -27,6 +34,7 @@ Page({
    * 保存
    */
   handleSave() {
+    var that = this
     if (this.data.choseAvaSrc == '') {
       wx.showToast({
         title: '请选择头像',
@@ -55,6 +63,22 @@ Page({
       })
       return
     }
+    wx.showModal({
+      title: '温馨提示',
+      content: '新建健康档案时,请您如实填写信息,如填写不正确将会影响您的健康指标!',
+      confirmColor: '#333',
+      cancelColor: '#666',
+      success (res) {
+        if (res.confirm) {
+          that.submitCreate()
+        }
+      }
+    })
+  },
+
+  // 提交新建人员表单
+  submitCreate () {
+    var that = this
     var data = {
       realName: this.data.username,
       sex: this.data.sexIndex == 0 ? true : false,
@@ -62,7 +86,6 @@ Page({
       relationship: this.data.relateIndex,
       headImg: this.data.choseAvaSrc
     }
-    console.log(data);
     wx.showLoading({
       title: '加载中...',
       mask: true
@@ -73,7 +96,16 @@ Page({
         title: '保存成功',
         icon: 'success'
       })
-      wx.navigateBack()
+      var timer = setTimeout(() => {
+        if (that.data.from == 'buy') {
+          wx.navigateBack({
+            delta: 2
+          })
+        } else {
+          wx.navigateBack()
+        }
+        clearTimeout(timer)
+      }, 1500);
     }).catch(e => {
       wx.hideLoading()
       wx.showModal({

+ 1 - 1
pages/handleFile/handleFile.js

@@ -84,7 +84,7 @@ Page({
     }
     wx.showModal({
       title: '确定要删除档案信息吗?',
-      content: '相对应的体检报告也会相应删除哦!',
+      content: '相对应的体检报告也会删除哦!',
       cancelColor: '#666',
       confirmColor: '#333',
       success (res) {

+ 25 - 6
pages/index/index.js

@@ -87,12 +87,33 @@ Page({
         })
       break;
       case 1:
-        wx.navigateTo({
-          url: '/pages/appointment/appointment?from=index',
-        })
+        this.appointmentAuth()
       break;
     }
   },
+
+  // 预约前判断是否存在一位检测人
+  appointmentAuth () {
+    if (this.data.documentVos.length == 0) {
+      wx.showModal({
+        content: '预约用户前需要先添加检测人员信息',
+        cancelColor: '#666',
+        confirmColor: '#333',
+        success (res) {
+          if (res.confirm) {
+            wx.navigateTo({
+              url: '/pages/createFile/createFile?from=index'
+            })
+          }
+        }
+      })
+    } else {
+      wx.navigateTo({
+        url: '/pages/appointment/appointment?from=index',
+      })
+    }
+  },
+  
   // 点击全部档案
   handleAllFile () {
     wx.navigateTo({
@@ -134,9 +155,7 @@ Page({
         }
       })
     } else {
-      wx.navigateTo({
-        url: '/pages/appointment/appointment?from=index'
-      })
+      this.appointmentAuth()
     }
   },
 

+ 50 - 3
pages/my/my.js

@@ -3,6 +3,7 @@ import itt from '../../utils/util'
 import { ittLogin, bindMobile, bindBaseInfo } from '../../api/my'
 import { getAccountNmber } from '../../api/appointment'
 import { userUploadHeadImg } from '../../api/upload'
+import { documentList } from "../../api/document"
 const app = getApp()
 Page({
 
@@ -61,14 +62,20 @@ Page({
         url: '/pages/report/report?form=my',
         imgUrl: '../../imaes/baogao2@2x.png'
       },
-      {
+      /* {
         id: 5,
         title: '开通区域',
         url: '/pages/openArea/openArea?form=my',
         imgUrl: '../../imaes/quyu@2x.png'
-      },
+      }, */
       {
         id: 6,
+        title: '去充值',
+        url: '/pages/buy/buy?form=my',
+        imgUrl: '../../imaes/quyu@2x.png'
+      },
+      {
+        id: 7,
         title: '设置',
         url: '/pages/set/set?form=my',
         imgUrl: '../../imaes/shezhi@2x.png'
@@ -91,6 +98,44 @@ Page({
     this.userLogin()
   },
 
+  // 获取用户档案信息
+  getDocumentList () {
+    var that = this
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
+    documentList({
+      currentPage: 1
+    }).then(res => {
+      wx.hideLoading()
+      const response = res.data.vos || []
+      if (response.length == 0) {
+        wx.showModal({
+          content: '预约用户前需要先添加检测人员信息',
+          cancelColor: '#666',
+          confirmColor: '#333',
+          success (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: '/pages/createFile/createFile?from=index'
+              })
+            }
+          }
+        })
+      } else {
+        that.authNavTo('/pages/appointment/appointment')
+      }
+    }).catch(e => {
+      wx.hideLoading()
+      wx.showModal({
+        content: e,
+        confirmColor: '#333',
+        showCancel: false
+      })
+    })
+  },
+
   // 获取用户头像和昵称权限 该api将于2022年10月25号之后失效
   getUserinfo () {
     var that = this
@@ -336,8 +381,10 @@ Page({
     var url = e.currentTarget.dataset.url
     this.authNavTo(url)
   },
+
+  // 立即预约
   handleAppoint () {
-    this.authNavTo('/pages/appointment/appointment')
+    this.getDocumentList()
   },
   /**
    * 路由拦截

+ 42 - 4
pages/report/report.js

@@ -1,5 +1,6 @@
 // pages/report/report.js
-import { myReportList, getReport } from '../../api/my'
+import { myReportList } from '../../api/my'
+import { documentList } from "../../api/document";
 const app = getApp()
 Page({
 
@@ -46,9 +47,7 @@ Page({
    * 立即预约
    */
   handleAppoint() {
-    wx.navigateTo({
-      url: '/pages/appointment/appointment',
-    })
+    this.getDocumentList()
   },
 
   /**
@@ -80,5 +79,44 @@ Page({
     wx.navigateTo({
       url: '/pages/reportDetail/reportDetail?reportid=' + reportId
     })
+  },
+   // 获取用户档案信息
+   getDocumentList () {
+    var that = this
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
+    documentList({
+      currentPage: 1
+    }).then(res => {
+      wx.hideLoading()
+      const response = res.data.vos || []
+      if (response.length == 0) {
+        wx.showModal({
+          content: '预约用户前需要先添加检测人员信息',
+          cancelColor: '#666',
+          confirmColor: '#333',
+          success (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: '/pages/createFile/createFile?from=index'
+              })
+            }
+          }
+        })
+      } else {
+        wx.navigateTo({
+          url: '/pages/appointment/appointment',
+        })
+      }
+    }).catch(e => {
+      wx.hideLoading()
+      wx.showModal({
+        content: e,
+        confirmColor: '#333',
+        showCancel: false
+      })
+    })
   }
 })