partDetail.js 12 KB

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