work.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. // pages/my/work/work.js
  2. const App = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. appAssetsUrl2: App.appAssetsUrl2,
  9. id: null,
  10. detail: {},
  11. topicList: [],
  12. meetList: [],
  13. meetQuery: {
  14. page: 1,
  15. limit: 10,
  16. },
  17. meetPage: {
  18. totalCount: null,
  19. currPage: null,
  20. totalPage: null,
  21. },
  22. serveObj: {},
  23. items: [
  24. {
  25. week: "周一",
  26. startTime: "09:00",
  27. endTime: "18:00",
  28. checked: true,
  29. },
  30. {
  31. week: "周二",
  32. startTime: "09:00",
  33. endTime: "18:00",
  34. checked: true,
  35. },
  36. {
  37. week: "周三",
  38. startTime: "09:00",
  39. endTime: "18:00",
  40. checked: true,
  41. },
  42. {
  43. week: "周四",
  44. startTime: "09:00",
  45. endTime: "18:00",
  46. checked: true,
  47. },
  48. {
  49. week: "周五",
  50. startTime: "09:00",
  51. endTime: "18:00",
  52. checked: true,
  53. },
  54. {
  55. week: "周六",
  56. startTime: "09:00",
  57. endTime: "18:00",
  58. checked: true,
  59. },
  60. {
  61. week: "周日",
  62. startTime: "09:00",
  63. endTime: "18:00",
  64. checked: true,
  65. },
  66. ],
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad(options) {
  72. this.setData({
  73. id: options.id,
  74. });
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady() {
  80. this.popup2 = this.selectComponent("#popup2");
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow() {
  86. this.getDetail();
  87. },
  88. getDetail() {
  89. wx.showLoading({
  90. title: "努力加载中...",
  91. });
  92. App._get(
  93. "expert/infoMember/" + this.data.id,
  94. {},
  95. (res) => {
  96. if (res.code === 0) {
  97. this.setData({
  98. detail: res.expert,
  99. items: res.expert.periodBOList || this.data.items,
  100. });
  101. wx.hideLoading();
  102. if (res.expert.id) {
  103. this.getTopic(res.expert.id);
  104. this.getExperience(res.expert.id);
  105. this.getServe(res.expert.id);
  106. }
  107. }
  108. },
  109. (err) => {
  110. wx.showToast({
  111. icon: "error",
  112. title: "服务端异常",
  113. });
  114. },
  115. (complete) => {}
  116. );
  117. },
  118. // 获取话题
  119. getTopic(expertId) {
  120. App._get(
  121. "experttopic/list",
  122. {
  123. expertId: expertId,
  124. },
  125. (res) => {
  126. if (res.code === 0) {
  127. this.setData({
  128. topicList: res.list,
  129. });
  130. }
  131. }
  132. );
  133. },
  134. // 获取心得分享
  135. getExperience(expertId) {
  136. if (this.data.meetPage.totalCount > 0) {
  137. if (this.data.meetPage.currPage == this.data.meetPage.totalPage) {
  138. wx.showToast({
  139. title: "没有更多哦~",
  140. icon: "none",
  141. });
  142. return false;
  143. }
  144. }
  145. wx.showLoading({
  146. title: "努力加载中...",
  147. });
  148. App._get(
  149. "meetevaluation/evaluatePage",
  150. {
  151. ...this.data.meetQuery,
  152. expertId: expertId,
  153. },
  154. (res) => {
  155. if (res.code === 0) {
  156. this.setData({
  157. meetList: res.page.list,
  158. meetPage: {
  159. totalCount: res.page.totalCount,
  160. currPage: res.page.currPage,
  161. totalPage: res.page.totalPage,
  162. },
  163. });
  164. wx.hideLoading();
  165. }
  166. },
  167. (err) => {
  168. wx.showToast({
  169. icon: "error",
  170. title: "服务端异常",
  171. });
  172. },
  173. (complete) => {}
  174. );
  175. },
  176. // 获取服务统计
  177. getServe(expertId) {
  178. App._get(
  179. "expert_workbench/myServiceStatistics",
  180. {
  181. expertId: expertId,
  182. },
  183. (res) => {
  184. if (res.code === 0) {
  185. this.setData({
  186. serveObj: res.data,
  187. });
  188. }
  189. }
  190. );
  191. },
  192. toDetail(e) {
  193. wx.navigateTo({
  194. url: `/workbench/work/topic?id=${e.currentTarget.dataset.id}`
  195. })
  196. },
  197. checkboxChange(e) {
  198. console.log(e);
  199. let list = this.data.items;
  200. for (let i = 0, lenI = list.length; i < lenI; ++i) {
  201. list[i].checked = false;
  202. for (let j = 0, lenJ = e.detail.value.length; j < lenJ; ++j) {
  203. if (i == e.detail.value[j]) {
  204. list[i].checked = true;
  205. break;
  206. }
  207. }
  208. }
  209. this.setData({
  210. items: list,
  211. });
  212. },
  213. bindStartTimeChange(e) {
  214. console.log(e);
  215. let list = this.data.items;
  216. for (let i in list) {
  217. if (i == e.currentTarget.dataset.index) {
  218. list[i].startTime = e.detail.value;
  219. break;
  220. }
  221. }
  222. this.setData({
  223. items: list,
  224. });
  225. },
  226. bindEndTimeChange(e) {
  227. console.log(e);
  228. let list = this.data.items;
  229. for (let i in list) {
  230. if (i == e.currentTarget.dataset.index) {
  231. list[i].endTime = e.detail.value;
  232. break;
  233. }
  234. }
  235. this.setData({
  236. items: list,
  237. });
  238. },
  239. toGambit(e) {
  240. wx.navigateTo({
  241. url: "/workbench/gambit/gambit?id=" + e.currentTarget.dataset.id,
  242. });
  243. },
  244. timeHandle() {
  245. this.popup2.showPopup();
  246. },
  247. _error() {
  248. console.log("返回");
  249. let list = this.data.items;
  250. // for (let value of list) {
  251. // value.startTime = "09:00";
  252. // value.endTime = "18:00";
  253. // value.checked = true;
  254. // }
  255. this.setData({
  256. items: list,
  257. });
  258. this.popup2.hidePopup();
  259. },
  260. _success() {
  261. console.log("查看");
  262. App._put_form(
  263. "expert/updatePeriod",
  264. "",
  265. {
  266. id: this.data.detail.id,
  267. memberId: this.data.id,
  268. periodBOList: this.data.items,
  269. },
  270. (res) => {
  271. if (res.code === 0) {
  272. wx.showToast({
  273. title: "保存成功",
  274. icon: "success",
  275. });
  276. }
  277. }
  278. );
  279. this.popup2.hidePopup();
  280. },
  281. lookMore() {
  282. wx.navigateTo({
  283. url: "/workbench/myService/myService",
  284. });
  285. },
  286. toServerList(e) {
  287. console.log(e, 111);
  288. wx.navigateTo({
  289. url:
  290. "/workbench/myService/myService?status=" +
  291. e.currentTarget.dataset.status,
  292. });
  293. },
  294. /**
  295. * 生命周期函数--监听页面隐藏
  296. */
  297. onHide() {},
  298. /**
  299. * 生命周期函数--监听页面卸载
  300. */
  301. onUnload() {},
  302. /**
  303. * 页面相关事件处理函数--监听用户下拉动作
  304. */
  305. onPullDownRefresh() {},
  306. /**
  307. * 页面上拉触底事件的处理函数
  308. */
  309. onReachBottom() {
  310. this.getExperience(this.data.detail.id);
  311. },
  312. /**
  313. * 用户点击右上角分享
  314. */
  315. onShareAppMessage() {},
  316. });