qrcode.js 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. skeleton: true,
  8. qrcode: "/img/qrcode.jpg",
  9. ucode: ''
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onShow: function () {
  15. this.getCode()
  16. },
  17. /**
  18. * 生成二维码
  19. **/
  20. getCode: function () {
  21. let that = this;
  22. var ucode = app.globalData.loginuser.ucode;
  23. app.api().Post('openapi/v1/user/miniprogramcode', {
  24. scene: { ucode: ucode },
  25. page: 'pages/index/index',
  26. name: 'popupshop_' + app.globalData.loginuser.uid
  27. }, function (result) {
  28. that.setData({
  29. qrcode: result.data,
  30. ucode: app.globalData.loginuser.ucode
  31. })
  32. })
  33. },
  34. /**
  35. * 分享按钮
  36. */
  37. onShareAppMessage: function (res) {
  38. let that = this;
  39. var ucode = app.globalData.loginuser.ucode;
  40. return {
  41. desc: app.appname,
  42. path: '/pages/index/index?ucode=' + ucode
  43. }
  44. },
  45. })