zhangshuling 3 rokov pred
rodič
commit
f67e41668f

+ 9 - 6
pages/makePiano/makePiano.js

@@ -151,11 +151,6 @@ Page({
     })
     this.localtionMethod()
   },
-  toQueue:function(){
-    wx.navigateTo({
-      url: '/pages/queue/queue',
-    })
-  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
@@ -168,7 +163,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-
+    this.queryList()
   },
 
   /**
@@ -326,5 +321,13 @@ Page({
         })
       }
     });
+  },
+  toQueueUp(e) {
+    let id = e.currentTarget.dataset.id;
+    let w = this.data.weekList[this.data.curIndex];
+    let sid = this.data.schoolList[this.data.schoolIndex].id
+    wx.navigateTo({
+      url: '/pages/queue/queue?planId=' + id + '&orgId=' +  sid + '&visitDate=' + w.ds
+    })
   }
 })

+ 2 - 5
pages/makePiano/makePiano.wxml

@@ -68,18 +68,15 @@
                 {{ item.time}}
               </view>
               <view class="wait-tip">
-                <text wx:if="{{item.hasVisitNum > item.maxNum}}" bindtap="toQueue">排队中,前面还有10人</text>
+                <text wx:if="{{item.pd_num && item.pd_num > 0}}">排队中,前面还有{{item.pd_num}}人</text>
               </view>
               <view class="class-get-view">
                 <view class="class-stu-num">
                   {{ item.hasVisitNum}}/{{ item.maxNum}}
                 </view>
-                <view class="class-get-btn wait-btn" wx:if="{{item.hasVisitNum == item.maxNum}}" bindtap="doAppointment" data-index="{{index}}" data-cindex="{{cItem}}" data-id="{{item.id}}">
+                <view class="class-get-btn wait-btn" wx:if="{{item.hasVisitNum >= item.maxNum}}" bindtap="toQueueUp" data-index="{{index}}" data-cindex="{{cItem}}" data-id="{{item.id}}">
                  排队
                 </view>
-                <view class="class-get-btn wait-btn" wx:elif="{{item.hasVisitNum > item.maxNum}}" bindtap="doAppointment" data-index="{{index}}" data-cindex="{{cItem}}" data-id="{{item.id}}">
-                 取消排队
-                </view>
                 <view class="class-get-btn" wx:elif="{{item.hasVisitNum < item.maxNum}}" bindtap="doAppointment" data-index="{{index}}" data-cindex="{{cItem}}" data-id="{{item.id}}">
                  预约
                 </view>

+ 34 - 0
pages/piano/piano.js

@@ -136,6 +136,40 @@ Page({
     const dayTime = 3600000;
     return item.attend == 0 && (vdt - tdt) >= dayTime
   },
+  doCancelQueue: function(e) {
+    let id = e.currentTarget.dataset.id
+    let that = this
+    wx.showModal({
+      title: '确认信息',
+      content: '确定要取消本次排队?',
+      showCancel: true,
+      cancelText: "否",
+      confirmText: "是",
+      success: function (res) {
+        if (res.cancel) {
+        } else {
+          wx.showLoading({
+            title: '正在取消',
+            mask: true
+          })
+          const urls = urlDef.urls;
+          util.apiPost(urls.delete_queue, {'ids[]': [id]}).then(rs => {
+            if (rs.message) {
+              wx.showToast({ title: rs.message, icon: 'none' })
+              return
+            }
+            wx.showToast({ title: '取消成功', icon: 'success' })
+            that.setData({
+              list: [],
+              pageNum: 0,
+              loading: '加载中'
+            })
+            that.queryList()
+          })
+        }
+      }
+    })
+  },
   doCancel: function (e) {
     let id = e.currentTarget.dataset.id
     let that = this

+ 2 - 3
pages/piano/piano.wxml

@@ -19,9 +19,8 @@
       <view class="class-status" wx:if="{{item.attend == 1}}">已点名</view>
       <view class="class-status" wx:if="{{item.attend == 2}}">已缺勤</view>
       <view class="class-status" wx:if="{{item.attend == 3}}">已取消</view>
-      <view class="class-status listTip" wx:if="{{item.attend == 4}}">排队中,还有10人</view>
-      <view class="class-btn" bindtap="doCancel" data-id="{{item.id}}" wx:if="{{item.cancelFlag}}">取消预约</view>
-      <view class="class-btn cancelList" data-id="{{item.id}}" wx:if="{{}}">取消排队</view>
+      <view class="class-btn" bindtap="doCancel" data-id="{{item.id}}" wx:if="{{item.cancelFlag && item.type == '1'}}">取消预约</view>
+      <view class="class-btn cancelList" bindtap="doCancelQueue" data-id="{{item.id}}" wx:if="{{item.type == '2'}}">取消排队</view>
       </view>
     </view>
   </view>

+ 55 - 4
pages/queue/queue.js

@@ -1,18 +1,29 @@
 // pages/queue/queue.js
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    planId: undefined,
+    orgId: undefined,
+    waitDate: undefined,
+    list: [
+    ],
+    loading: '上拉加载',
+    flag: 0,
+    pageNum: 0,
+    hasNextPage: true,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    this.setData({ planId: options.planId, orgId: options.orgId, waitDate: options.visitDate })
+    this.queryList()
   },
 
   /**
@@ -54,7 +65,11 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    if (this.data.hasNextPage) {
+      let pn = this.data.pageNum
+      this.setData({ loading: '加载中', 'pageNum': ++pn })
+      this.queryList()
+    }
   },
 
   /**
@@ -62,5 +77,41 @@ Page({
    */
   onShareAppMessage: function () {
 
-  }
+  },
+  doQueueUp: function () {
+    wx.showLoading({
+      title: '处理中',
+      mask: true
+    })
+    const urls = urlDef.urls;
+    let stu = wx.getStorageSync('student');
+    this.setData({studentId: stu.studentId})
+    util.apiPost(urls.queueUp, this.data).then(rs => {
+      wx.hideLoading({});
+      if(rs.message ) {
+        wx.showToast({
+          title: rs.message,
+          icon: 'none'
+        })
+      }else{
+        wx.showToast({
+          title: '排队成功',
+          icon: 'success'
+        })
+      }
+    })
+  },
+  queryList: function () {
+    const urls = urlDef.urls;
+    let params = { 'q.orgId': this.data.orgId, 'q.visitDate': this.data.waitDate, 'q.planId': this.data.planId }
+    params.pageNum = this.data.pageNum
+    util.apiPost(urls.queue_list, params).then(rs => {
+      let list = rs.list
+      this.setData({
+        'hasNextPage': rs.hasNextPage,
+        'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
+        'list': this.data.list.concat(list)
+      })
+    })
+  },
 })

+ 6 - 4
pages/queue/queue.wxml

@@ -1,19 +1,21 @@
 <view class="container">
   <view class="list-view">
-    <view class="list-box" wx:for="{{5}}" wx:key="index">
+    <view class="list-box" wx:for="{{list}}" wx:key="index">
       <view class="list-img">
         <image src="/images/head.png"></image>
       </view>
       <view class="list-detail">
         <view class="list-name">
-          约课用户
-          <view class="gender-img" wx:if="{{index < 2}}"><image class="boyImg" src="/images/boy.png"></image></view>
+          {{item.name ? item.name : '排队用户'}}
+          <view class="gender-img" wx:if="{{item.sex == 'c21557dd80024bf09a608e39c3918fbc'}}"><image class="boyImg" src="/images/boy.png"></image></view>
           <view class="gender-img" wx:else><image src="/images/girl.png"></image></view>
         </view>
         <view class="list-time">
-          预约时间: 2021-04-14 12:00
+          预约时间: {{item.createdDate}}
         </view>
       </view>
     </view>
   </view>
+  
+  <view  bindtap="doQueueUp">预约</view>
 </view>

+ 4 - 1
utils/urls.js

@@ -3,7 +3,7 @@
 // const baseUrl = 'https://excl.schoolwisdoms.com';
 const baseUrl = 'https://excellent.schoolwisdoms.com'
 
-// const baseUrl = 'http://192.168.2.103';
+// const baseUrl = 'http://192.168.2.102';
 
 const ssoBase = baseUrl + '/sso';
 const platformBase = baseUrl + '/admin';
@@ -165,4 +165,7 @@ export const urls = {
   do_appointment_check: schoolBase + '/student/checkCard',
   query_appointment_list: crudListBase + '?statement=ExercisePlanMapper.queryReserve',
   cancel_appointment: schoolBase + '/timetable/updateExercisePlanStatus',
+  queueUp: schoolBase + '/exerciseVisit/waitInsert',
+  delete_queue: schoolBase + '/crud/delete/exerciseWait',
+  queue_list: crudListBase + '?statement=ExerciseWaitMapper.waitStudentList',
 };