web-view.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function prop(e, a, t) {
  2. return a in e ? Object.defineProperty(e, a, {
  3. value: t,
  4. enumerable: !0,
  5. configurable: !0,
  6. writable: !0
  7. }) : e[a] = t, e;
  8. }
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. url: "",
  15. shareMessage: {
  16. title: "",
  17. path: "",
  18. imageUrl: ""
  19. }
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. // let url = decodeURIComponent(options.url) + "?" + Math.random();
  26. let url = decodeURIComponent(options.url);
  27. options.url && this.setData(prop({
  28. url: url
  29. }, "shareMessage.path", "/lionfish_comshop/pages/web-view?url=" + url));
  30. console.log("webviewUrl", this.data.url);
  31. },
  32. getPostMessage: function (e) {
  33. var a = e.detail;
  34. console.log("收到的信息", a);
  35. var shareMessage = Object.assign({}, this.data.shareMessage, a.data[0]);
  36. this.setData({
  37. shareMessage: shareMessage
  38. }), wx.showShareMenu({
  39. withShareTicket: !0,
  40. success: function () {
  41. console.log("成功");
  42. },
  43. fail: function () {
  44. console.log("失败");
  45. }
  46. }), wx.updateShareMenu();
  47. },
  48. onPageLoad: function (e) {
  49. e.detail;
  50. },
  51. onPageError: function (e) {
  52. e.detail;
  53. },
  54. /**
  55. * 用户点击右上角分享
  56. */
  57. onShareAppMessage: function () {
  58. return console.log(this.data.shareMessage), Object.assign({}, this.data.shareMessage, {
  59. success: function () {
  60. console.log("share succeed");
  61. },
  62. error: function () {
  63. console.log("share failed");
  64. }
  65. });
  66. }
  67. })