share.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. var util = require('../../utils/util.js');
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // slider_list: [],
  9. poster: '',
  10. imageSize: {
  11. imageWidth: "100%",
  12. imageHeight: 600
  13. },
  14. is_share_html: true,
  15. member_info: {}
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. if (!util.check_login()) {
  22. this.setData({
  23. needAuth: true
  24. })
  25. } else {
  26. this.getMemberInfo();
  27. this.getData();
  28. }
  29. },
  30. /**
  31. * 授权成功回调
  32. */
  33. authSuccess: function () {
  34. let that = this;
  35. this.setData({
  36. needAuth: false
  37. }, () => {
  38. that.getMemberInfo();
  39. that.getData();
  40. })
  41. },
  42. /**
  43. * 图片信息
  44. */
  45. imageLoad: function (e) {
  46. var imageSize = util.imageUtil(e)
  47. this.setData({
  48. imageSize
  49. })
  50. },
  51. getMemberInfo: function () {
  52. var token = wx.getStorageSync('token');
  53. let that = this;
  54. app.util.request({
  55. 'url': 'entry/wxapp/user',
  56. 'data': {
  57. controller: 'user.get_user_info',
  58. token: token
  59. },
  60. dataType: 'json',
  61. success: function (res) {
  62. if (res.data.code == 0) {
  63. let member_info = res.data.data;
  64. //开启分销
  65. if (res.data.commiss_level > 0) {
  66. //还差多少人升级
  67. let commiss_share_member_update = res.data.commiss_share_member_update * 1;
  68. let share_member_count = res.data.share_member_count * 1;
  69. let need_num_update = res.data.commiss_share_member_update * 1 - res.data.share_member_count * 1;
  70. let commiss_diy_name = res.data.commiss_diy_name || '分销';
  71. wx.setNavigationBarTitle({
  72. title: '会员' + commiss_diy_name,
  73. })
  74. that.setData({
  75. member_info,
  76. commiss_level: res.data.commiss_level,
  77. commiss_sharemember_need: res.data.commiss_sharemember_need,
  78. commiss_share_member_update,
  79. share_member_count,
  80. need_num_update,
  81. commiss_diy_name
  82. });
  83. } else {
  84. wx.showModal({
  85. title: '提示',
  86. content: '未开启分销',
  87. showCancel: false,
  88. success(res) {
  89. if (res.confirm) {
  90. console.log('用户点击确定')
  91. wx.reLaunch({
  92. url: '/lionfish_comshop/pages/user/me',
  93. })
  94. }
  95. }
  96. })
  97. }
  98. } else {
  99. //is_login
  100. that.setData({
  101. is_login: false
  102. })
  103. wx.setStorage({
  104. key: "member_id",
  105. data: null
  106. })
  107. }
  108. }
  109. })
  110. },
  111. /**
  112. * 生命周期函数--监听页面显示
  113. */
  114. onShow: function () {
  115. },
  116. getData: function(){
  117. wx.showLoading();
  118. var token = wx.getStorageSync('token');
  119. let that = this;
  120. app.util.request({
  121. url: 'entry/wxapp/user',
  122. data: {
  123. controller: 'distribution.get_haibao',
  124. token: token
  125. },
  126. dataType: 'json',
  127. success: function (res) {
  128. wx.hideLoading();
  129. if (res.data.code == 0) {
  130. that.setData({ poster: res.data.commiss_qrcode })
  131. } else {
  132. that.setData({
  133. needAuth: true
  134. })
  135. }
  136. }
  137. })
  138. },
  139. toggleShare: function(){
  140. let is_share_html = this.data.is_share_html;
  141. this.setData({ is_share_html: !is_share_html })
  142. },
  143. prevImg: function(e){
  144. let image_path = e.currentTarget.dataset.src;
  145. wx.previewImage({
  146. current: image_path, // 当前显示图片的http链接
  147. urls: [image_path] // 需要预览的图片http链接列表
  148. })
  149. },
  150. /**
  151. * 用户点击右上角分享
  152. */
  153. onShareAppMessage: function () {
  154. var community = wx.getStorageSync('community');
  155. var community_id = community.communityId;
  156. var member_id = wx.getStorageSync('member_id');
  157. console.log(community_id, member_id);
  158. return {
  159. title: '',
  160. path: "lionfish_comshop/pages/index/index?community_id=" + community_id + '&share_id=' + member_id,
  161. imageUrl: '',
  162. success: function () { },
  163. fail: function () { }
  164. };
  165. }
  166. })