index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. imgServerUrl: imgServerUrl,
  16. clearTimer: false,
  17. myFormat: ['天', ':', ':', ' '],
  18. },
  19. onLoad: function(options) {
  20. this.setData({
  21. hpPositionGroupId: options.hpPositionGroupId,
  22. positionCategory: options.positionCategory,
  23. positionId: options.positionId
  24. })
  25. },
  26. onShow: function(options) {
  27. if (app.globalData.userInfo) {
  28. console.log('有info===', app.globalData)
  29. this.fetchData()
  30. } else if (this.data.canIUse) {
  31. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  32. // 所以此处加入 callback 以防止这种情况
  33. app.userInfoReadyCallback = res => {
  34. console.log('userInfoReadyCallback===', app.globalData)
  35. this.fetchData()
  36. }
  37. } else {
  38. // 在没有 open-type=getUserInfo 版本的兼容处理
  39. wx.getUserInfo({
  40. success: res => {
  41. app.globalData.userInfo = res.userInfo
  42. console.log('兼容处理===', app.globalData)
  43. this.fetchData()
  44. }
  45. })
  46. }
  47. },
  48. onUnload: function() {
  49. this.setData({
  50. clearTimer: true
  51. })
  52. },
  53. onShareAppMessage: function() {
  54. return {
  55. title: '开心工作参团有奖',
  56. path: '/pages/pt-detail/index?hpPositionGroupId=' + this.data.hpPositionGroupId,
  57. imageUrl: ''
  58. }
  59. },
  60. //获取历史记录
  61. fetchData() {
  62. },
  63. // 拼团倒计时结束
  64. myLinsterner(e) {
  65. // this.setData({
  66. // clearTimer: true
  67. // })
  68. // showToast('拼团已结束')
  69. },
  70. // 一键参团
  71. joinGroup(e) {
  72. let {
  73. formId
  74. } = e.detail
  75. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionGroupId=' + this.options.hpPositionGroupId + "&formId=" + formId)
  76. groupApply(this.options.hpPositionGroupId, formId).then(data => {
  77. this.fetchData()
  78. })
  79. },
  80. ptTip() {
  81. wx.navigateTo({
  82. url: '../pt-tip/index',
  83. })
  84. },
  85. //分享图片
  86. toShare() {
  87. wx.navigateTo({
  88. url: '../pt-share/pt-share?hpPositionGroupId=' + this.data.hpPositionGroupId,
  89. })
  90. },
  91. onError(err) {
  92. app.aldstat.sendEvent('报错', {
  93. 'err': err
  94. });
  95. },
  96. })