index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. isLogin: false,
  27. },
  28. onLoad: function(options) {
  29. console.log("sdfg", options)
  30. if (options.scene) {
  31. const scene = decodeURIComponent(options.scene)
  32. console.log("dfg", scene)
  33. var arrPara = scene.split("&");
  34. var arrValue = [];
  35. for (var i in arrPara) {
  36. var arr = [];
  37. arr = arrPara[i].split("=");
  38. arrValue[i] = arr[1];
  39. console.log("setStorageSync:", arr[0], "=", arr[1]);
  40. console.log("arrValue", arrValue);
  41. }
  42. this.setData({
  43. hpPositionGroupId: arrValue[0],
  44. positionCategory: arrValue[1],
  45. positionId: arrValue[2],
  46. })
  47. } else {
  48. this.setData({
  49. hpPositionGroupId: options.gd,
  50. positionCategory: options.pc,
  51. positionId: options.pd
  52. })
  53. }
  54. },
  55. onShow: function(options) {
  56. var userId = wx.getStorageSync("user_id");
  57. var userToken = wx.getStorageSync("user_token");
  58. var memberId = wx.getStorageSync("member_id");
  59. var userInfo = wx.getStorageSync("userInfo");
  60. var isLogin = false;
  61. if (userId && memberId) {
  62. isLogin = true;
  63. app.globalData.userId = userId;
  64. app.globalData.userToken = userToken;
  65. app.globalData.memberId = memberId;
  66. if (userInfo) {
  67. app.globalData.userInfo = userInfo;
  68. console.log('有info===', userInfo)
  69. }
  70. }
  71. this.setData({
  72. isLogin: isLogin
  73. })
  74. this.fetchData();
  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. member_id: app.globalData.memberId
  90. }
  91. Object.assign(paramsObj);
  92. getGroupDetail(paramsObj).then(data => {
  93. console.log("groupDetail", data)
  94. var leftTime = data.data.position.groupEndTime
  95. try {
  96. wx.setStorageSync("groupDetail", data.data);
  97. } catch (e) {
  98. }
  99. var femaleReward = data.data.position.femaleReward;
  100. var maleReward = data.data.position.maleReward;
  101. var fiveGroupCashback = data.data.position.fiveGroupCashback;
  102. var threeGroupCashback = data.data.position.threeGroupCashback;
  103. var hasReward = data.data.position.hasReward;
  104. var successReward;
  105. var failReward;
  106. if (hasReward == 1) {
  107. if (maleReward >= femaleReward) {
  108. successReward = maleReward;
  109. failReward = femaleReward;
  110. } else {
  111. successReward = femaleReward;
  112. failReward = maleReward;
  113. }
  114. } else {
  115. successReward = 0;
  116. failReward = 0;
  117. }
  118. this.setData({
  119. postitionDetail: data.data,
  120. leftTime: leftTime,
  121. failReward: failReward,
  122. successReward: successReward
  123. })
  124. })
  125. },
  126. // 拼团倒计时结束
  127. myLinsterner(e) {
  128. // this.setData({
  129. // clearTimer: true
  130. // })
  131. // showToast('拼团已结束')
  132. },
  133. // 一键参团
  134. joinGroup(e) {
  135. var self = this;
  136. if (!self.data.isLogin) {
  137. wx.navigateTo({
  138. url: '/pages/login/login',
  139. })
  140. return;
  141. }
  142. wx.showModal({
  143. title: '提示',
  144. content: '确定要加入该拼工吗?',
  145. success: function(res) {
  146. if (res.confirm) {
  147. let {
  148. formId
  149. } = e.detail
  150. let paramsObj = {
  151. groupId: self.data.hpPositionGroupId,
  152. inviteUser_id: self.data.inviteUser_id,
  153. positionCategory: self.data.positionCategory,
  154. positionId: self.data.positionId,
  155. user_id: app.globalData.userId,
  156. user_token: app.globalData.userToken,
  157. member_id: app.globalData.memberId
  158. }
  159. Object.assign(paramsObj);
  160. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionGroupId=' + self.data.hpPositionGroupId + "&formId=" + formId)
  161. groupApply(paramsObj).then(data => {
  162. console.log("df");
  163. self.onShow()
  164. })
  165. } else if (res.cancel) {
  166. }
  167. }
  168. })
  169. },
  170. ptTip() {
  171. wx.navigateTo({
  172. url: '../pt-tip/index',
  173. })
  174. },
  175. //分享图片
  176. makeMyPt() {
  177. if (!this.data.isLogin) {
  178. wx.navigateTo({
  179. url: '/pages/login/login',
  180. })
  181. return;
  182. }
  183. wx.navigateTo({
  184. url: '../pt-share/pt-share?hpPositionGroupId=' + this.data.hpPositionGroupId + '&positionCategory=' + this.data.positionCategory + '&positionId=' + this.data.positionId,
  185. })
  186. },
  187. //拨打手机号
  188. phoneCall() {
  189. if (this.data.postitionDetail.position.contactPhone) {
  190. wx.makePhoneCall({
  191. phoneNumber: this.data.postitionDetail.position.contactPhone,
  192. success: function(data) {
  193. console.log(data)
  194. },
  195. fail: function(data) {
  196. console.log(data)
  197. }
  198. })
  199. } else {
  200. showToast('暂无手机号')
  201. }
  202. },
  203. onError(err) {
  204. app.aldstat.sendEvent('报错', {
  205. 'err': err
  206. });
  207. },
  208. })