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