partDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. var app = getApp();
  2. var util = require("../../../../utils/util.js");
  3. let wxparse = require("../../../../wxParse/wxParse.js");
  4. let pageid = "";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. bottomLeft: app.bottomLeft,
  11. appAssetsUrl: app.appAssetsUrl,
  12. appAssetsUrl2: app.appAssetsUrl2,
  13. maskShow: false,
  14. options: {},
  15. isyn: false,
  16. vipid: util.getUserId(),
  17. detail: {
  18. tags: [],
  19. appraiseManageVoList: [],
  20. collect: false,
  21. },
  22. workContent: "",
  23. attention: "",
  24. member: {},
  25. time: 5,
  26. timer: null,
  27. isDjs: false,
  28. isShowPop: true,
  29. peopleList: [],
  30. people6: [],
  31. isMore: true,
  32. dotLeft: 0,
  33. vipMsg: "",
  34. isWx: false,
  35. isDev: true, //审核
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad: function (options) {
  41. pageid = options.id;
  42. let _this = this;
  43. let user = util.getUser();
  44. this.setData({
  45. options: {
  46. ...options,
  47. type: 1, //类型(1兼职 2活动)
  48. stuId: user ? user.id : "",
  49. },
  50. });
  51. _this.loadData();
  52. _this.addRead();
  53. _this.ready();
  54. _this.env();
  55. },
  56. collect: function () {
  57. let that = this;
  58. if (util.getUserId()) {
  59. app._post_form(
  60. "favorite/addOrCancelFavorite",
  61. "application/json", {
  62. sid: that.data.options.id,
  63. vipid: that.data.options.stuId,
  64. type: 1, //1:兼职 2:活动
  65. },
  66. function (res) {
  67. if (res.code == 0) {
  68. that.setData({
  69. detail: {
  70. ...that.data.detail,
  71. collect: !that.data.detail.collect,
  72. },
  73. });
  74. wx.showToast({
  75. title: that.data.detail.collect ? "收藏成功" : "取消收藏",
  76. icon: "success",
  77. duration: 2000,
  78. });
  79. }
  80. }
  81. );
  82. } else {
  83. wx.showToast({
  84. title: "没有登录,操作失败",
  85. icon: "fail",
  86. duration: 2000,
  87. });
  88. }
  89. },
  90. loadData: function () {
  91. let _this = this;
  92. wx.showLoading({
  93. title: "努力加载中...",
  94. });
  95. app._post_form("work/one", "", _this.data.options, function (res) {
  96. if (res.code === 0) {
  97. _this.setData({
  98. detail: res.data,
  99. });
  100. _this.getUser(res.data.id);
  101. if (res.data.isAppletsRelease == 1) {
  102. // 小程序发布
  103. _this.setData({
  104. isWx: true,
  105. });
  106. } else {
  107. // 后台发布
  108. _this.setData({
  109. isWx: false,
  110. });
  111. wxparse.wxParse(
  112. "workContent",
  113. "html",
  114. res.data.workContent,
  115. _this,
  116. 0
  117. );
  118. wxparse.wxParse("attention", "html", res.data.attention, _this, 0);
  119. }
  120. }
  121. });
  122. },
  123. // 获取参与人员
  124. getUser(id) {
  125. app._get(
  126. `work/participants`, {
  127. workId: id,
  128. },
  129. (res) => {
  130. if (res.code === 0) {
  131. this.setData({
  132. people6: res.list.slice(0, 6),
  133. peopleList: res.list,
  134. });
  135. }
  136. }
  137. );
  138. },
  139. /**
  140. * 生命周期函数--监听页面初次渲染完成
  141. */
  142. onReady: function () {
  143. //获得popup组件
  144. this.popup = this.selectComponent("#popup");
  145. this.popup2 = this.selectComponent("#popup2");
  146. this.popup0 = this.selectComponent("#popup0");
  147. this.popup3 = this.selectComponent("#popup3");
  148. this.popup4 = this.selectComponent("#popup4");
  149. },
  150. addRead() {
  151. app._post_form("read/num", "", {
  152. id: this.data.options.id,
  153. type: 1,
  154. });
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow: function () {
  160. this.PushVipInfo();
  161. let user = util.getUser();
  162. this.setData({
  163. options: {
  164. ...this.data.options,
  165. stuId: user ? user.id : "",
  166. },
  167. });
  168. },
  169. /**
  170. * 生命周期函数--监听页面隐藏
  171. */
  172. onHide: function () {},
  173. /**
  174. * 页面相关事件处理函数--监听用户下拉动作
  175. */
  176. onPullDownRefresh: function () {},
  177. /**
  178. * 页面上拉触底事件的处理函数
  179. */
  180. onReachBottom: function () {},
  181. showShareMenu: function () {
  182. wx.showShareMenu();
  183. },
  184. hideShareMenu() {
  185. wx.hideShareMenu();
  186. },
  187. //查询会员信息
  188. PushVipInfo() {
  189. let _this = this;
  190. let id = util.getUserId();
  191. if (id) {
  192. app._post_form(
  193. "member/apiSelectMeberInfo",
  194. "application/json", {
  195. id
  196. },
  197. function (res) {
  198. if (res.code === 0) {
  199. _this.setData({
  200. member: res.member,
  201. });
  202. }
  203. }
  204. );
  205. }
  206. },
  207. /**
  208. * 用户点击右上角分享
  209. */
  210. onShareAppMessage() {
  211. this.addScore();
  212. return {
  213. title: "兼职详情",
  214. path: `/pages/home/index/partDetail/partDetail?id=${pageid}`,
  215. desc: "欢迎大家踊跃报名",
  216. };
  217. },
  218. //统计积分(每日小程序分享)
  219. addScore: function () {
  220. if (!util.getUserId()) {
  221. return;
  222. }
  223. let _this = this;
  224. wx.showLoading({
  225. title: "努力加载中...",
  226. });
  227. app._post_form(
  228. "scoreStu/share",
  229. "", {
  230. stuId: util.getUserId(),
  231. },
  232. function (res) {
  233. if (res.code === 0) {}
  234. }
  235. );
  236. },
  237. // 预览图片
  238. previewImage(e) {
  239. wx.previewImage({
  240. urls: e.currentTarget.dataset.images,
  241. current: e.currentTarget.dataset.images[e.currentTarget.dataset.index],
  242. });
  243. },
  244. // 判断是否开发huanjing
  245. env() {
  246. let that = this;
  247. app._post_form(
  248. "wgfillinfo/apiSelectwgfillinfo",
  249. "application/json",
  250. null,
  251. function (res) {
  252. if (res.code === 0) {
  253. that.setData({
  254. isDev: res.wgFillInfo.isDev,
  255. });
  256. }
  257. }
  258. );
  259. },
  260. submit() {
  261. let that = this;
  262. //报名满了
  263. if (this.data.detail.statusName != "预定中") {
  264. return;
  265. }
  266. if (util.UserLoginStatus()) {
  267. if (
  268. (this.data.detail.isNeedVip && this.data.member.memberState > 0) ||
  269. !this.data.detail.isNeedVip
  270. ) {
  271. // wx.showModal({
  272. // title: '提示',
  273. // content: '您确定要报名该兼职吗',
  274. // success (res) {
  275. // if (res.confirm) {
  276. // that.signUp();
  277. // }
  278. // }
  279. // })
  280. that.popup4.showPopup();
  281. that.setData({
  282. maskShow: true,
  283. });
  284. } else {
  285. if (that.data.isDev) {
  286. wx.showToast({
  287. title: "暂未开始报名,请关注进度!",
  288. icon: "none",
  289. duration: 2000,
  290. });
  291. return;
  292. }
  293. wx.showToast({
  294. title: "您还不是会员,报名请联系平台客服处理",
  295. icon: "none",
  296. duration: 2000,
  297. });
  298. // this.popup.showPopup();
  299. // this.setData({
  300. // maskShow: true,
  301. // });
  302. }
  303. }
  304. },
  305. showMore() {
  306. this.setData({
  307. isMore: !this.data.isMore,
  308. });
  309. },
  310. // 查看二维码
  311. seeCode() {
  312. if (!this.data.detail.workStuYN) {
  313. wx.showToast({
  314. title: "请报名后查看",
  315. icon: "error",
  316. duration: 2000,
  317. });
  318. return;
  319. }
  320. this.popup0.showPopup();
  321. this.setData({
  322. maskShow: true,
  323. });
  324. // let that = this
  325. // this.popup3.showPopup();
  326. // this.setData({
  327. // maskShow: true,
  328. // isDjs: true,
  329. // timer: setInterval(that.countDown, 1000)
  330. // })
  331. },
  332. //倒计时
  333. countDown() {
  334. var that = this;
  335. if (that.data.time <= 0) {
  336. this.setData({
  337. isDjs: false,
  338. time: 5,
  339. });
  340. clearInterval(that.data.timer);
  341. } else {
  342. --that.data.time;
  343. this.setData({
  344. isDjs: true,
  345. time: that.data.time,
  346. });
  347. }
  348. },
  349. // 我已知晓
  350. know() {
  351. this.popup3.hidePopup();
  352. this.loadData();
  353. if (this.data.isShowPop) {
  354. this.setData({
  355. isShowPop: false,
  356. isDjs: false,
  357. maskShow: false,
  358. });
  359. this.signUp();
  360. }
  361. // if (!this.data.isDjs) {}
  362. },
  363. // 查看地图
  364. goLocal() {
  365. let that = this;
  366. let [latitude, longitude] = [
  367. this.data.detail.coordinate.split(",")[0],
  368. this.data.detail.coordinate.split(",")[1],
  369. ];
  370. console.log(Number(latitude), Number(longitude));
  371. wx.openLocation({
  372. latitude: Number(longitude),
  373. longitude: Number(latitude),
  374. name: that.data.detail.title,
  375. address: that.data.detail.address,
  376. success: function () {
  377. console.log("success");
  378. },
  379. });
  380. },
  381. signUp() {
  382. let that = this;
  383. wx.showLoading({
  384. title: "提交中...",
  385. });
  386. app._post_form(
  387. "work/register",
  388. "", {
  389. wid: that.data.options.id,
  390. sid: that.data.options.stuId,
  391. },
  392. function (res) {
  393. if (res.code === 0) {
  394. wx.hideToast();
  395. wx.showToast({
  396. title: "报名成功",
  397. icon: "none",
  398. });
  399. if (that.data.isShowPop) {
  400. that.popup3.hidePopup();
  401. that.setData({
  402. isShowPop: false,
  403. isDjs: true,
  404. maskShow: true,
  405. timer: setInterval(that.countDown, 1000),
  406. })
  407. } else {
  408. that.setData({
  409. isShowPop: false,
  410. isDjs: false,
  411. maskShow: false,
  412. });
  413. }
  414. that.loadData();
  415. setTimeout(() => {
  416. that.popup0.showPopup();
  417. that.setData({
  418. maskShow: true,
  419. });
  420. // wx.redirectTo({
  421. // url: '/pages/my/myTimejob/myTimejob',
  422. // })
  423. }, 1000);
  424. } else if (res.code == 502) {
  425. setTimeout(() => {
  426. that.loadData()
  427. }, 500);
  428. } else if (res.msg == "请完善学籍认证后进行报名操作") {
  429. wx.hideToast();
  430. that.popup2.showPopup();
  431. }
  432. }
  433. );
  434. },
  435. // 会员必读
  436. ready() {
  437. let _this = this;
  438. app._post_form(
  439. "wgfillinfo/apiSelectwgfillinfo",
  440. "application/json",
  441. null,
  442. function (res) {
  443. if (res.code === 0) {
  444. // _this.setData({
  445. // vipMsg: res.wgFillInfo.vipMessage
  446. // })
  447. wxparse.wxParse(
  448. "vipMsg",
  449. "html",
  450. res.wgFillInfo.vipMessage,
  451. _this,
  452. 0
  453. );
  454. }
  455. }
  456. );
  457. },
  458. //取消事件
  459. _error(e) {
  460. this[e.currentTarget.dataset.name].hidePopup();
  461. this.setData({
  462. maskShow: false,
  463. isDjs: false,
  464. time: 5,
  465. });
  466. clearInterval(this.data.timer);
  467. },
  468. //确认事件
  469. _success(e) {
  470. let that = this;
  471. if (e.currentTarget.dataset.name == "popup0") {} else if (e.currentTarget.dataset.name == "popup4") {
  472. if (that.data.detail.isNeedVip && that.data.member.memberState > 0) {
  473. that.popup3.showPopup();
  474. that.setData({
  475. maskShow: true,
  476. isDjs: true,
  477. timer: setInterval(that.countDown, 1000),
  478. });
  479. console.log("会员");
  480. } else {
  481. // that.popup3.hidePopup();
  482. // that.setData({
  483. // isDjs: false,
  484. // maskShow: false,
  485. // time: 5
  486. // })
  487. that.signUp();
  488. console.log("非会员");
  489. }
  490. } else if (e.currentTarget.dataset.name == "popup2") {
  491. wx.navigateTo({
  492. url: "/pages/my/myStudy/myStudy",
  493. });
  494. } else {
  495. wx.navigateTo({
  496. url: e.currentTarget.dataset.name == "popup" ?
  497. "/pages/myMember/myMember" : "/pages/my/myData/myData",
  498. });
  499. }
  500. this.setData({
  501. maskShow: false,
  502. });
  503. this[e.currentTarget.dataset.name].hidePopup();
  504. },
  505. seeBigCode(e) {
  506. let arr = [this.data.detail.qrCodePicture];
  507. wx.previewImage({
  508. urls: arr, // 需要预览的图片http链接列表
  509. });
  510. },
  511. onUnload: function () {
  512. clearInterval(this.data.timer);
  513. },
  514. });