index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // pages/detail/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. navHeight: '',
  9. //swiper
  10. background: ['bg1', 'bg2', 'bg3'],
  11. vertical: false,
  12. autoplay: false,
  13. interval: 2000,
  14. duration: 500,
  15. current:0,
  16. //下啦
  17. isScroll: false,
  18. //地图
  19. markers: [{
  20. latitude: 0,
  21. longitude: 0,
  22. }],
  23. BASEIMGURL: app.globalData.BASEIMGURL, //图片域名
  24. currentActivity: {}, //详情
  25. userInfo: {}
  26. },
  27. add() {
  28. //参加活动
  29. console.log('add');
  30. },
  31. async getPhoneNumber(e) {
  32. const that = this;
  33. if (e.detail.errMsg == "getPhoneNumber:ok") {
  34. let res = await app.globalData.api.bindphone({
  35. "openid": app.globalData.userInfo.openid,
  36. "encryptedData": e.detail.encryptedData,
  37. "iv": e.detail.iv,
  38. "invitor": app.globalData.shareOpenId
  39. })
  40. app.globalData.userInfo.phone = res.data.phone;
  41. that.setData({
  42. userInfo: {
  43. ...this.data.userInfo,
  44. 'phone': res.data.phone
  45. }
  46. });
  47. //参加活动
  48. that.add();
  49. // wx.showToast({
  50. // title: '参加成功!',
  51. // icon: 'none'
  52. // })
  53. } else {
  54. wx.showToast({
  55. title: '请授权您的手机号!',
  56. icon: 'none'
  57. })
  58. }
  59. },
  60. change(e){
  61. this.setData({
  62. current: e.detail.current
  63. })
  64. },
  65. scroll(e){
  66. if(e.detail.scrollTop > 1 && this.data.isScroll == false){
  67. this.setData({
  68. isScroll: true
  69. })
  70. }else if(e.detail.scrollTop < 1 && this.data.isScroll == true){
  71. this.setData({
  72. isScroll: false
  73. })
  74. }
  75. },
  76. scrollView(){
  77. this.setData({
  78. isScroll: !this.data.isScroll
  79. })
  80. },
  81. /**
  82. * 生命周期函数--监听页面加载
  83. */
  84. onLoad: function (options) {
  85. this.setData({
  86. userInfo: app.globalData.userInfo,
  87. navHeight: app.globalData.navHeight,
  88. currentActivity: app.globalData.currentActivity,
  89. markers: [{
  90. latitude: app.globalData.currentActivity.lat || 0,
  91. longitude: app.globalData.currentActivity.lng || 0
  92. }]
  93. })
  94. },
  95. /**
  96. * 生命周期函数--监听页面初次渲染完成
  97. */
  98. onReady: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面显示
  102. */
  103. onShow: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面卸载
  112. */
  113. onUnload: function () {
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh: function () {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function () {
  124. },
  125. /**
  126. * 用户点击右上角分享
  127. */
  128. onShareAppMessage() {
  129. const openid = wx.getStorageSync('openid')
  130. let param = openid && typeof openid === 'string' ? `pages/index/index?openid=${ openid }` : `pages/index/index`
  131. return {
  132. title: 'Coffee Talk',
  133. desc: '快来参加活动吧~',
  134. // imageUrl: 'https://cirraybucket.oss-cn-shanghai.aliyuncs.com/nowwa-h5/aboutUs/share.jpg',
  135. path: param
  136. }
  137. },
  138. })