cardList.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // pages/cardList/cardList.js
  2. var app = getApp()
  3. var util = require('../../utils/util')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imageUrl: app.globalData.imageUrl,
  10. left: 25,
  11. titleIndex:1,
  12. childTitle:'我的卡包',
  13. loading:'正在加载',
  14. loadingIndex:0,
  15. loading2:"没有更多了",
  16. orgTitle: app.globalData.orgTitle,
  17. schoolName: '',
  18. params: {
  19. openId: '',
  20. classesType: '1'
  21. },
  22. wcList: [],
  23. pianoList:[],
  24. params: {
  25. appId: app.globalData.appId,
  26. openId: wx.getStorageSync('openId'),
  27. page: 0,
  28. size: 10,
  29. typeId: '1002',
  30. status: 'select'
  31. }
  32. },
  33. getPiano:function(e){
  34. var index = e.currentTarget.dataset.index
  35. wx.navigateTo({
  36. url: '/pages/pianoDetailCode/pianoDetail?obj='+ JSON.stringify(this.data.pianoList[index]),
  37. })
  38. },
  39. changeTitle:function(e){
  40. var index = e.currentTarget.dataset.index
  41. this.setData({
  42. titleIndex: index,
  43. left: e.currentTarget.dataset.leftnum
  44. })
  45. },
  46. toWcsp:function(e){
  47. wx.navigateTo({
  48. url: '/pages/wcsp/wcsp?id='
  49. + e.currentTarget.dataset.id
  50. + '&typeId=1002&validDay='+ e.currentTarget.dataset.day
  51. + '&price=' + e.currentTarget.dataset.price
  52. + '&total=' + e.currentTarget.dataset.price
  53. })
  54. },
  55. getMySpecials: function () {
  56. if (this.data.params.openId == '') {
  57. const openId = "params.openId"
  58. this.setData({
  59. [openId]: app.globalData.openId
  60. })
  61. }
  62. util.doPost(
  63. 'getMySpecials', this.data.params,
  64. ).then(res => {
  65. if (res.success == 1) {
  66. this.setData({
  67. wcList: this.data.wcList.concat(res.data.list),
  68. })
  69. if (this.data.params.page < res.data.pages - 1) {
  70. this.setData({
  71. loading: '上拉加载更多',
  72. loadingIndex: 1
  73. })
  74. this.data.params.page++;
  75. } else {
  76. this.setData({
  77. loading: '没有更多了',
  78. loadingIndex: 2
  79. })
  80. }
  81. }
  82. })
  83. },
  84. callPhone:function(){
  85. wx.makePhoneCall({
  86. phoneNumber: wx.getStorageSync('campusInfo').telephone,
  87. })
  88. },
  89. getPianoList:function(){
  90. const params ={
  91. openId: wx.getStorageSync('openId')
  92. // openId : 'osm1O5MjCMIy_-wo4fmV8t0xjILs'
  93. }
  94. util.doPost(
  95. "openExercuseRecordList",params
  96. ).then(res =>{
  97. if(res.success == 1){
  98. this.setData({
  99. pianoList: res.data
  100. })
  101. }
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onLoad: function (options) {
  108. this.getPianoList()
  109. // this.getMySpecials()
  110. this.setData({
  111. schoolName: wx.getStorageSync('campusInfo').name
  112. })
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面隐藏
  126. */
  127. onHide: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh: function () {
  138. },
  139. /**
  140. * 页面上拉触底事件的处理函数
  141. */
  142. onReachBottom: function () {
  143. if(this.data.loadingIndex == 1){
  144. this.setData({
  145. loading:"正在加载"
  146. })
  147. this.getMySpecials()
  148. }
  149. },
  150. /**
  151. * 用户点击右上角分享
  152. */
  153. onShareAppMessage: function () {
  154. }
  155. })