myPlay.js 5.5 KB

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