myTimejob.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. // res.data.list.map(v => {
  103. // v.work.tags = [{ tag: '11' }, { tag: '11' }, { tag: '11' }]
  104. // })
  105. if (res.data.list.length > 0 && that.data.listData.length > 0 && res.data.list[0].id == that.data.listData[0].id) {
  106. return;
  107. }
  108. let listData = that.data.listData;
  109. listData.push(...res.data.list);
  110. that.setData({
  111. listData,
  112. currPage: res.data.currPage,
  113. totalPage: res.data.totalPage,
  114. noMore: res.data.totalPage == res.data.currPage
  115. })
  116. }
  117. })
  118. },
  119. calltech (e) {
  120. if (e.currentTarget.dataset.tel == null || e.currentTarget.dataset.tel == "") {
  121. wx.showModal({
  122. title: '温馨提示',
  123. content: "暂无联系老师",
  124. showCancel: false
  125. })
  126. } else {
  127. wx.showModal({
  128. title: '温馨提示',
  129. content: '是否联系该兼职的老师?',
  130. success (res) {
  131. if (res.confirm) {
  132. wx.makePhoneCall({
  133. phoneNumber: e.currentTarget.dataset.tel
  134. })
  135. } else if (res.cancel) {
  136. console.log('用户点击取消')
  137. }
  138. }
  139. })
  140. }
  141. },
  142. cancel (e) {
  143. let _this = this
  144. wx.showModal({
  145. title: '温馨提示',
  146. content: `十分钟内可取消兼职;超过十分钟取消兼职账号将冻结${_this.data.workFreezeTime}小时,是否取消?`,
  147. success (res) {
  148. if (res.confirm) {
  149. if (e.currentTarget.dataset) {
  150. let parm = {
  151. sid: util.getUserId(),
  152. wid: e.currentTarget.dataset.id
  153. }
  154. app._post_form('work/cancel', 'application/json',
  155. JSON.stringify(parm),
  156. function (res) {
  157. if (res.code === 0) {
  158. wx.showModal({
  159. title: '温馨提示',
  160. content: "取消成功",
  161. showCancel: false
  162. })
  163. _this.loadList(true);
  164. }
  165. }
  166. )
  167. }
  168. } else if (res.cancel) { }
  169. }
  170. })
  171. },
  172. /**
  173. * 生命周期函数--监听页面初次渲染完成
  174. */
  175. onReady: function () {
  176. },
  177. comment (e) {
  178. if (e.currentTarget.dataset.isappraise) {
  179. wx.showToast({
  180. title: '您已经评价过了~',
  181. icon: 'none'
  182. })
  183. return;
  184. }
  185. wx.navigateTo({
  186. url: '/partTimeJobEvaluate/index?workId=' + e.currentTarget.dataset.id
  187. })
  188. },
  189. /**
  190. * 生命周期函数--监听页面显示
  191. */
  192. onShow: function () {
  193. },
  194. /**
  195. * 生命周期函数--监听页面隐藏
  196. */
  197. onHide: function () {
  198. },
  199. /**
  200. * 生命周期函数--监听页面卸载
  201. */
  202. onUnload: function () {
  203. },
  204. /**
  205. * 页面相关事件处理函数--监听用户下拉动作
  206. */
  207. onPullDownRefresh: function () {
  208. },
  209. /**
  210. * 页面上拉触底事件的处理函数
  211. */
  212. onReachBottom: function () {
  213. this.loadList();
  214. },
  215. /**
  216. * 用户点击右上角分享
  217. */
  218. onShareAppMessage: function () {
  219. },
  220. getFreezesHour () {
  221. let that = this;
  222. app._post_form('wgfillinfo/apiSelectwgfillinfo', '', this.data.params,
  223. function (res) {
  224. if (res.code == 0) {
  225. that.setData({
  226. workFreezeTime: res.wgFillInfo.freezeTime
  227. })
  228. }
  229. })
  230. }
  231. })