myTimejob.js 5.2 KB

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