recommend.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var util = require('../../utils/util.js');
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. qrcode: ''
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. if (!util.check_login()) {
  15. wx.switchTab({
  16. url: '/lionfish_comshop/pages/user/me',
  17. })
  18. }
  19. wx.showLoading();
  20. },
  21. getData(){
  22. var token = wx.getStorageSync('token');
  23. var that = this;
  24. app.util.request({
  25. 'url': 'entry/wxapp/user',
  26. 'data': {
  27. controller: 'community.get_community_zhitui_qrcode',
  28. token: token
  29. },
  30. dataType: 'json',
  31. success: function (res) {
  32. wx.hideLoading();
  33. if (res.data.code == 0) {
  34. that.setData({ qrcode: res.data.qrcode })
  35. } else {
  36. wx.switchTab({
  37. url: '/lionfish_comshop/pages/user/me',
  38. })
  39. }
  40. }
  41. })
  42. },
  43. preImg: function (event) {
  44. var goodShareImg = this.data.qrcode;
  45. //图片预览
  46. wx.previewImage({
  47. current: goodShareImg, // 当前显示图片的http链接
  48. urls: [goodShareImg] // 需要预览的图片http链接列表
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow: function () {
  55. this.getData();
  56. }
  57. })