myTimejob.js 5.3 KB

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