scene.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // pages/scene/scene.js
  2. const api = require('../../config/api.js');
  3. import config from '../../config'
  4. var getUserInfo = require('../../utils/getUserInfo').default;
  5. Page({
  6. onLoad() {
  7. this.setData({ url: '' })
  8. },
  9. getUserInfo,
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onShow: async function () {
  14. // let { data: { brand } } = await util.request(api.BrandDetail, options)
  15. let options = this.options
  16. let brand = {
  17. sceneNum: options.scene,
  18. // sceneNum: 't-sfytakg',
  19. id: options.id,
  20. shareUserId: options.shareUserId
  21. }
  22. let userInfo = this.getUserInfo()
  23. let query = {
  24. m: brand.sceneNum,
  25. id: brand.id,
  26. fireId: options.id,
  27. shareUserId: brand.shareUserId,
  28. token: wx.getStorageSync('token'),
  29. detailApi: api.fireDetail,
  30. userId: userInfo.id,
  31. attachListApi: api.getAttachList,
  32. }
  33. let url = config.viewHost + '?' + Object.keys(query).map(key => `${key}=${query[key]}`).join('&')
  34. wx.setNavigationBarTitle({ title: brand.name })
  35. if (userInfo.id) {
  36. this.setData({ url })
  37. }
  38. getApp().orderBuyCbs((order) => {
  39. setTimeout(() => {
  40. this.addOrderNew = true
  41. this.setData({
  42. url: url + '#' + JSON.stringify(order)
  43. })
  44. }, 300)
  45. })
  46. },
  47. /**
  48. * 用户点击右上角分享
  49. */
  50. onShareAppMessage: function (res) {
  51. let userInfo = this.getUserInfo()
  52. let title = '【好友推荐】场景还原,实现线上选座'
  53. if (this.addOrderNew) {
  54. title = '【好友分享】特设薄宴,静待贵客'
  55. }
  56. return {
  57. title,
  58. imageUrl: '/static/images/share.png',
  59. path: `pages/scene/scene?id=${this.options.id}&scene=${this.options.scene}&shareUserId=${userInfo.id}`
  60. }
  61. },
  62. })