web.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/web/web.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. url: ''
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad(options) {
  13. wx.showLoading({
  14. title: '页面加载中',
  15. })
  16. if (options.se && options.se != '') {
  17. // 有se就是地图搜索
  18. this.setData({
  19. url: options.url + '?se=' + options.se
  20. })
  21. } else if (options.wxUrl && options.wxUrl != '') {
  22. // 代表是微信文章 需要转义
  23. this.setData({
  24. url: decodeURIComponent(options.wxUrl)
  25. })
  26. } else {
  27. // 微信跳转回将url带入参数去除 特定规则'|'=='?',')'=='='
  28. let data = options.url.replace('|','?')
  29. data = data.replace(')','=')
  30. console.log(data);
  31. this.setData({
  32. url: data
  33. })
  34. }
  35. setTimeout(() => {
  36. wx.hideLoading();
  37. }, 1500);
  38. wx.setNavigationBarTitle({
  39. title: '',
  40. })
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady() {
  46. },
  47. /**
  48. * 生命周期函数--监听页面显示
  49. */
  50. onShow() {
  51. },
  52. /**
  53. * 生命周期函数--监听页面隐藏
  54. */
  55. onHide() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面卸载
  59. */
  60. onUnload() {
  61. },
  62. /**
  63. * 页面相关事件处理函数--监听用户下拉动作
  64. */
  65. onPullDownRefresh() {
  66. },
  67. /**
  68. * 页面上拉触底事件的处理函数
  69. */
  70. onReachBottom() {
  71. },
  72. /**
  73. * 用户点击右上角分享
  74. */
  75. onShareAppMessage(options) {
  76. return {
  77. title: ' '
  78. }
  79. },
  80. getMessage(e){
  81. console.log(e.detail.data[0].from);
  82. if(e.detail.data[0].from!=null){
  83. wx.navigateToMiniProgram({
  84. appId: 'wxfc86707bae655315',
  85. success(res) {
  86. // 打开成功
  87. }
  88. })
  89. }
  90. }
  91. })