partDetail.js 9.0 KB

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