index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. successReward: 0, //拼团成功奖励金
  25. failReward: 0, //拼团失败奖励金
  26. },
  27. onLoad: function(options) {
  28. console.log("sdfg", options)
  29. if (options.scene) {
  30. const scene = decodeURIComponent(options.scene)
  31. console.log("dfg", scene)
  32. var arrPara = scene.split("&");
  33. var arrValue = [];
  34. for (var i in arrPara) {
  35. var arr = [];
  36. arr = arrPara[i].split("=");
  37. arrValue[i] = arr[1];
  38. console.log("setStorageSync:", arr[0], "=", arr[1]);
  39. console.log("arrValue", arrValue);
  40. }
  41. this.setData({
  42. hpPositionGroupId: arrValue[0],
  43. positionCategory: arrValue[1],
  44. positionId: arrValue[2],
  45. })
  46. } else {
  47. this.setData({
  48. hpPositionGroupId: options.gd,
  49. positionCategory: options.pc,
  50. positionId: options.pd
  51. })
  52. }
  53. },
  54. onShow: function(options) {
  55. if (app.globalData.userInfo) {
  56. console.log('有info===', app.globalData)
  57. this.fetchData()
  58. } else if (this.data.canIUse) {
  59. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  60. // 所以此处加入 callback 以防止这种情况
  61. app.userInfoReadyCallback = res => {
  62. console.log('userInfoReadyCallback===', app.globalData)
  63. this.fetchData()
  64. }
  65. } else {
  66. // 在没有 open-type=getUserInfo 版本的兼容处理
  67. wx.getUserInfo({
  68. success: res => {
  69. app.globalData.userInfo = res.userInfo
  70. console.log('兼容处理===', app.globalData)
  71. this.fetchData()
  72. }
  73. })
  74. }
  75. },
  76. onShareAppMessage: function() {
  77. return {
  78. title: '开心工作参团有奖',
  79. path: '/pages/pt-detail/index?gd=' + this.data.hpPositionGroupId + '&pc=' + this.data.positionCategory + '&pd=' + this.data.positionId,
  80. imageUrl: ''
  81. }
  82. },
  83. //获取拼团详情
  84. fetchData() {
  85. let paramsObj = {
  86. positionCategory: this.data.positionCategory,
  87. positionId: this.data.positionId,
  88. groupId: this.data.hpPositionGroupId,
  89. user_id: app.globalData.userId,
  90. user_token: app.globalData.userToken
  91. }
  92. Object.assign(paramsObj);
  93. getGroupDetail(paramsObj).then(data => {
  94. console.log("groupDetail", data)
  95. var leftTime = data.data.position.groupEndTime
  96. try {
  97. wx.setStorageSync("groupDetail", data.data);
  98. } catch (e) {
  99. }
  100. var femaleReward = data.data.position.femaleReward;
  101. var maleReward = data.data.position.maleReward;
  102. var fiveGroupCashback = data.data.position.fiveGroupCashback;
  103. var threeGroupCashback = data.data.position.threeGroupCashback;
  104. var hasReward = data.data.position.hasReward;
  105. var successReward;
  106. var failReward;
  107. if (hasReward == 1) {
  108. if (maleReward >= femaleReward) {
  109. successReward = maleReward;
  110. failReward = femaleReward;
  111. } else {
  112. successReward = femaleReward;
  113. failReward = maleReward;
  114. }
  115. } else {
  116. successReward = 0;
  117. failReward = 0;
  118. }
  119. this.setData({
  120. postitionDetail: data.data,
  121. leftTime: leftTime,
  122. failReward: failReward,
  123. successReward: successReward
  124. })
  125. })
  126. },
  127. // 拼团倒计时结束
  128. myLinsterner(e) {
  129. // this.setData({
  130. // clearTimer: true
  131. // })
  132. // showToast('拼团已结束')
  133. },
  134. // 一键参团
  135. joinGroup(e) {
  136. var self = this;
  137. wx.showModal({
  138. title: '提示',
  139. content: '确定要加入该拼工吗?',
  140. success: function(res) {
  141. if (res.confirm) {
  142. let {
  143. formId
  144. } = e.detail
  145. let paramsObj = {
  146. groupId: self.data.hpPositionGroupId,
  147. inviteUser_id: self.data.inviteUser_id,
  148. positionCategory: self.data.positionCategory,
  149. positionId: self.data.positionId,
  150. user_id: app.globalData.userId,
  151. user_token: app.globalData.userToken
  152. }
  153. Object.assign(paramsObj);
  154. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionGroupId=' + self.data.hpPositionGroupId + "&formId=" + formId)
  155. groupApply(paramsObj).then(data => {
  156. console.log("df");
  157. self.onShow()
  158. })
  159. } else if (res.cancel) {
  160. }
  161. }
  162. })
  163. },
  164. ptTip() {
  165. wx.navigateTo({
  166. url: '../pt-tip/index',
  167. })
  168. },
  169. //分享图片
  170. makeMyPt() {
  171. wx.navigateTo({
  172. url: '../pt-share/pt-share?hpPositionGroupId=' + this.data.hpPositionGroupId + '&positionCategory=' + this.data.positionCategory + '&positionId=' + this.data.positionId,
  173. })
  174. },
  175. //拨打手机号
  176. phoneCall() {
  177. if (this.data.postitionDetail.position.contactPhone) {
  178. wx.makePhoneCall({
  179. phoneNumber: this.data.postitionDetail.position.contactPhone,
  180. success: function(data) {
  181. console.log(data)
  182. },
  183. fail: function(data) {
  184. console.log(data)
  185. }
  186. })
  187. } else {
  188. showToast('暂无手机号')
  189. }
  190. },
  191. onError(err) {
  192. app.aldstat.sendEvent('报错', {
  193. 'err': err
  194. });
  195. },
  196. })