myTimejob.js 5.5 KB

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