index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import {
  2. getGroupDetail,
  3. groupApply
  4. } from '../../services/index.js'
  5. import {
  6. imgServerUrl
  7. } from '../../config/config.js'
  8. import {
  9. showToast
  10. } from '../../utils/tips.js'
  11. const WxParse = require('../../plugins/wxParse/wxParse.js');
  12. var app = getApp()
  13. Page({
  14. data: {
  15. positionId: 0,
  16. positionCategory: 0, //0:全职 1:兼职 2:入职奖励 3:高薪急聘 4:拼团岗位 5:福利岗位 8:自发布全职 9:自发布兼职
  17. imgServerUrl: imgServerUrl,
  18. clearTimer: false,
  19. myFormat: ['天', ':', ':', ' '],
  20. leftTime: 0,
  21. groupId: '', //拼团id
  22. inviteUser_id: '', //拼团邀请人
  23. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  24. },
  25. onLoad: function(options) {
  26. console.log("sdfg", options)
  27. if (options.scene) {
  28. const scene = decodeURIComponent(options.scene)
  29. console.log("dfg", scene)
  30. var arrPara = scene.split("&");
  31. var arrValue = [];
  32. for (var i in arrPara) {
  33. var arr = [];
  34. arr = arrPara[i].split("=");
  35. arrValue[i] = arr[1];
  36. console.log("setStorageSync:", arr[0], "=", arr[1]);
  37. console.log("arrValue", arrValue);
  38. }
  39. this.setData({
  40. hpPositionGroupId: arrValue[0],
  41. positionCategory: arrValue[1],
  42. positionId: arrValue[2],
  43. })
  44. } else {
  45. this.setData({
  46. hpPositionGroupId: options.gd,
  47. positionCategory: options.pc,
  48. positionId: options.pd
  49. })
  50. }
  51. },
  52. onShow: function(options) {
  53. if (app.globalData.userInfo) {
  54. console.log('有info===', app.globalData)
  55. this.fetchData()
  56. } else if (this.data.canIUse) {
  57. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  58. // 所以此处加入 callback 以防止这种情况
  59. app.userInfoReadyCallback = res => {
  60. console.log('userInfoReadyCallback===', app.globalData)
  61. this.fetchData()
  62. }
  63. } else {
  64. // 在没有 open-type=getUserInfo 版本的兼容处理
  65. wx.getUserInfo({
  66. success: res => {
  67. app.globalData.userInfo = res.userInfo
  68. console.log('兼容处理===', app.globalData)
  69. this.fetchData()
  70. }
  71. })
  72. }
  73. },
  74. onShareAppMessage: function() {
  75. return {
  76. title: '开心工作参团有奖',
  77. path: '/pages/pt-detail/index?gd=' + this.data.hpPositionGroupId + '&pc=' + this.data.positionCategory + '&pd=' + this.data.positionId,
  78. imageUrl: ''
  79. }
  80. },
  81. //获取拼团详情
  82. fetchData() {
  83. let paramsObj = {
  84. positionCategory: this.data.positionCategory,
  85. positionId: this.data.positionId,
  86. groupId: this.data.hpPositionGroupId,
  87. user_id: app.globalData.userId,
  88. user_token: app.globalData.userToken
  89. }
  90. Object.assign(paramsObj);
  91. getGroupDetail(paramsObj).then(data => {
  92. console.log("groupDetail", data)
  93. var leftTime = data.data.position.groupEndTime
  94. try {
  95. wx.setStorageSync("groupDetail", data.data);
  96. } catch (e) {
  97. }
  98. this.setData({
  99. postitionDetail: data.data,
  100. leftTime: leftTime
  101. })
  102. })
  103. },
  104. // 拼团倒计时结束
  105. myLinsterner(e) {
  106. // this.setData({
  107. // clearTimer: true
  108. // })
  109. // showToast('拼团已结束')
  110. },
  111. // 一键参团
  112. joinGroup(e) {
  113. var self = this;
  114. wx.showModal({
  115. title: '提示',
  116. content: '确定要加入该拼工吗?',
  117. success: function(res) {
  118. if (res.confirm) {
  119. let {
  120. formId
  121. } = e.detail
  122. let paramsObj = {
  123. groupId: self.data.hpPositionGroupId,
  124. inviteUser_id: self.data.inviteUser_id,
  125. positionCategory: self.data.positionCategory,
  126. positionId: self.data.positionId,
  127. user_id: app.globalData.userId,
  128. user_token: app.globalData.userToken
  129. }
  130. Object.assign(paramsObj);
  131. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionGroupId=' + self.data.hpPositionGroupId + "&formId=" + formId)
  132. groupApply(paramsObj).then(data => {
  133. console.log("df");
  134. self.onShow()
  135. })
  136. } else if (res.cancel) {
  137. }
  138. }
  139. })
  140. },
  141. ptTip() {
  142. wx.navigateTo({
  143. url: '../pt-tip/index',
  144. })
  145. },
  146. //分享图片
  147. makeMyPt() {
  148. wx.navigateTo({
  149. url: '../pt-share/pt-share?hpPositionGroupId=' + this.data.hpPositionGroupId + '&positionCategory=' + this.data.positionCategory + '&positionId=' + this.data.positionId,
  150. })
  151. },
  152. //拨打手机号
  153. phoneCall() {
  154. if (this.data.postitionDetail.position.contactPhone) {
  155. wx.makePhoneCall({
  156. phoneNumber: this.data.postitionDetail.position.contactPhone,
  157. success: function(data) {
  158. console.log(data)
  159. },
  160. fail: function(data) {
  161. console.log(data)
  162. }
  163. })
  164. } else {
  165. showToast('暂无手机号')
  166. }
  167. },
  168. onError(err) {
  169. app.aldstat.sendEvent('报错', {
  170. 'err': err
  171. });
  172. },
  173. })