myPlay.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // pages/my/myTimejob/myTimejob.js
  2. let app = getApp();
  3. let util = require('../../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. appAssetsUrl: app.appAssetsUrl,
  10. appAssetsUrl2: app.appAssetsUrl2,
  11. typeList: [{
  12. name: '已报名',
  13. value: '01'
  14. }, {
  15. name: '历史活动',
  16. value: '02'
  17. }],
  18. typeListIndex: 0,
  19. nodata: util.nodata(),
  20. params: {
  21. page: 1,
  22. limit: 10,
  23. sid: '',
  24. type: ''
  25. },
  26. total:{
  27. currPage: 0,
  28. totalPage: 0
  29. },
  30. noMore:false,
  31. listData:[],
  32. workFreezeTime: 0
  33. },
  34. switchType(e) {
  35. if (e) {
  36. let typeListIndex = e.currentTarget.dataset.index;
  37. this.setData({
  38. typeListIndex
  39. })
  40. this.loadList(true);
  41. }
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function(options) {
  47. if (util.getUserId()) {
  48. this.data.params.sid = util.getUserId()
  49. } else {
  50. return;
  51. }
  52. this.loadList(true);
  53. this.getFreezesHour();
  54. },
  55. seeDetails(e) {
  56. if (e.currentTarget.dataset) {
  57. wx.navigateTo({
  58. url: '/pages/home/index/activityDetail/activityDetail?id=' + e.currentTarget.dataset.id
  59. })
  60. }
  61. },
  62. loadList(isRefresh) {
  63. let that = this;
  64. if (!isRefresh && this.data.noMore) {
  65. wx.showToast({
  66. title: '没有更多了~',
  67. icon: 'none'
  68. })
  69. return false;
  70. }
  71. this.setData({
  72. listData: isRefresh ? [] : this.data.listData,
  73. noMore: isRefresh ? false : this.data.noMore,
  74. params: {
  75. ...this.data.params,
  76. page: isRefresh?1:this.data.params.page+1,
  77. type: `0${this.data.typeListIndex+1}`,
  78. }
  79. })
  80. wx.showLoading({
  81. title: '努力加载中...',
  82. })
  83. app._post_form('act/mylist', '', this.data.params,
  84. function(res) {
  85. if (res.code == 0) {
  86. if(res.data.list.length>0 && that.data.listData.length>0 && res.data.list[0].id == that.data.listData[0].id){
  87. return ;
  88. }
  89. let listData = that.data.listData;
  90. listData.push(...res.data.list);
  91. that.setData({
  92. listData,
  93. currPage: res.data.currPage,
  94. totalPage: res.data.totalPage,
  95. noMore: res.data.totalPage == res.data.currPage
  96. })
  97. }
  98. },
  99. function(res) {
  100. wx.hideLoading()
  101. })
  102. },
  103. calltech(e) {
  104. if (e.currentTarget.dataset.tel == null || e.currentTarget.dataset.tel == "") {
  105. wx.showModal({
  106. title: '温馨提示',
  107. content: "暂无联系老师",
  108. showCancel: false
  109. })
  110. } else {
  111. wx.showModal({
  112. title: '温馨提示',
  113. content: '是否联系该兼职的老师?',
  114. success(res) {
  115. if (res.confirm) {
  116. wx.makePhoneCall({
  117. phoneNumber: e.currentTarget.dataset.tel
  118. })
  119. } else if (res.cancel) {
  120. console.log('用户点击取消')
  121. }
  122. }
  123. })
  124. }
  125. },
  126. cancel(e) {
  127. let _this = this
  128. wx.showModal({
  129. title: '温馨提示',
  130. content: `十分钟内可取消活动;超过十分钟取消活动账号将冻结${_this.data.workFreezeTime}小时,是否取消?`,
  131. success(res) {
  132. if (res.confirm) {
  133. if (e.currentTarget.dataset) {
  134. let parm = {
  135. sid: util.getUserId(),
  136. aid: e.currentTarget.dataset.id
  137. }
  138. app._post_form('act/cancel', 'application/json',
  139. JSON.stringify(parm),
  140. function(res) {
  141. if (res.code === 0) {
  142. wx.showModal({
  143. title: '温馨提示',
  144. content: "取消成功",
  145. showCancel: false
  146. })
  147. _this.loadList(true);
  148. }
  149. }
  150. )
  151. }
  152. } else if (res.cancel) {}
  153. }
  154. })
  155. },
  156. /**
  157. * 生命周期函数--监听页面初次渲染完成
  158. */
  159. onReady: function() {
  160. },
  161. comment(e) {
  162. if (e.currentTarget.dataset) {
  163. wx.navigateTo({
  164. url: '/pages/my/myTimejob/mycomment?clientId=' + e.currentTarget.dataset.cid + '&wid=' +
  165. e.currentTarget.dataset.wid,
  166. })
  167. }
  168. },
  169. /**
  170. * 生命周期函数--监听页面显示
  171. */
  172. onShow: function() {
  173. },
  174. /**
  175. * 生命周期函数--监听页面隐藏
  176. */
  177. onHide: function() {
  178. },
  179. /**
  180. * 生命周期函数--监听页面卸载
  181. */
  182. onUnload: function() {
  183. },
  184. /**
  185. * 页面相关事件处理函数--监听用户下拉动作
  186. */
  187. onPullDownRefresh: function() {
  188. },
  189. /**
  190. * 页面上拉触底事件的处理函数
  191. */
  192. onReachBottom: function() {
  193. this.loadList();
  194. },
  195. /**
  196. * 用户点击右上角分享
  197. */
  198. onShareAppMessage: function() {
  199. },
  200. getFreezesHour(){
  201. let that = this;
  202. app._post_form('wgfillinfo/apiSelectwgfillinfo', '', this.data.params,
  203. function(res) {
  204. if (res.code == 0) {
  205. that.setData({
  206. workFreezeTime: res.wgFillInfo.freezeTime
  207. })
  208. }
  209. })
  210. }
  211. })