index.js 5.8 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. hasShare:true,
  16. positionId: 0,
  17. positionCategory: 0, //0:全职 1:兼职 2:入职奖励 3:高薪急聘 4:拼团岗位 5:福利岗位 8:自发布全职 9:自发布兼职
  18. imgServerUrl: imgServerUrl,
  19. clearTimer: false,
  20. myFormat: ['天', ':', ':', ' '],
  21. leftTime: 0,
  22. groupId: '', //拼团id
  23. inviteUser_id: '', //拼团邀请人
  24. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  25. successReward: 0, //拼团成功奖励金
  26. failReward: 0, //拼团失败奖励金
  27. isLogin: false,
  28. },
  29. onLoad: function(options) {
  30. console.log("sdfg", options)
  31. if (options.scene) {
  32. const scene = decodeURIComponent(options.scene)
  33. console.log("dfg", scene)
  34. var arrPara = scene.split("&");
  35. var arrValue = [];
  36. for (var i in arrPara) {
  37. var arr = [];
  38. arr = arrPara[i].split("=");
  39. arrValue[i] = arr[1];
  40. console.log("setStorageSync:", arr[0], "=", arr[1]);
  41. console.log("arrValue", arrValue);
  42. }
  43. this.setData({
  44. hpPositionGroupId: arrValue[0],
  45. positionCategory: arrValue[1],
  46. positionId: arrValue[2],
  47. })
  48. } else {
  49. this.setData({
  50. hpPositionGroupId: options.gd,
  51. positionCategory: options.pc,
  52. positionId: options.pd
  53. })
  54. }
  55. },
  56. onShow: function(options) {
  57. var userId = wx.getStorageSync("user_id");
  58. var userToken = wx.getStorageSync("user_token");
  59. var memberId = wx.getStorageSync("member_id");
  60. var userInfo = wx.getStorageSync("userInfo");
  61. var isLogin = false;
  62. if (userId && memberId) {
  63. isLogin = true;
  64. app.globalData.userId = userId;
  65. app.globalData.userToken = userToken;
  66. app.globalData.memberId = memberId;
  67. if (userInfo) {
  68. app.globalData.userInfo = userInfo;
  69. console.log('有info===', userInfo)
  70. }
  71. }
  72. this.setData({
  73. isLogin: isLogin
  74. })
  75. this.fetchData();
  76. },
  77. onShareAppMessage: function() {
  78. return {
  79. title: '开心工作参团有奖',
  80. path: '/pages/pt-detail/index?gd=' + this.data.hpPositionGroupId + '&pc=' + this.data.positionCategory + '&pd=' + this.data.positionId,
  81. imageUrl: ''
  82. }
  83. },
  84. //获取拼团详情
  85. fetchData() {
  86. let paramsObj = {
  87. positionCategory: this.data.positionCategory,
  88. positionId: this.data.positionId,
  89. groupId: this.data.hpPositionGroupId,
  90. member_id: app.globalData.memberId
  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. if (!self.data.isLogin) {
  138. wx.navigateTo({
  139. url: '/pages/login/login',
  140. })
  141. return;
  142. }
  143. wx.showModal({
  144. title: '提示',
  145. content: '确定要加入该拼工吗?',
  146. success: function(res) {
  147. if (res.confirm) {
  148. let {
  149. formId
  150. } = e.detail
  151. let paramsObj = {
  152. groupId: self.data.hpPositionGroupId,
  153. inviteUser_id: self.data.inviteUser_id,
  154. positionCategory: self.data.positionCategory,
  155. positionId: self.data.positionId,
  156. user_id: app.globalData.userId,
  157. user_token: app.globalData.userToken,
  158. member_id: app.globalData.memberId
  159. }
  160. Object.assign(paramsObj);
  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. })