web.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. let siteId = options.wxUrl;
  23. let id = options.metadataId;
  24. // 代表是微信文章 需要转义
  25. let url = "https://www.cqna.gov.cn/personalCenter/answerSheet/answerSheet.html?siteId="+siteId+"&metadataId="+id;
  26. this.setData({
  27. url: url
  28. })
  29. } else if(options.gzUrl && options.wxUrl != ''){
  30. this.setData({
  31. url: options.gzUrl
  32. })
  33. }
  34. else {
  35. // 微信跳转回将url带入参数去除 特定规则'|'=='?',')'=='='
  36. let data = options.url.replace('|','?')
  37. data = data.replace(')','=')
  38. // console.log(data);
  39. this.setData({
  40. url: data
  41. })
  42. }
  43. setTimeout(() => {
  44. wx.hideLoading();
  45. }, 1500);
  46. wx.setNavigationBarTitle({
  47. title: '',
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady() {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow() {
  59. },
  60. /**
  61. * 生命周期函数--监听页面隐藏
  62. */
  63. onHide() {
  64. },
  65. /**
  66. * 生命周期函数--监听页面卸载
  67. */
  68. onUnload() {
  69. },
  70. /**
  71. * 页面相关事件处理函数--监听用户下拉动作
  72. */
  73. onPullDownRefresh() {
  74. },
  75. /**
  76. * 页面上拉触底事件的处理函数
  77. */
  78. onReachBottom() {
  79. },
  80. /**
  81. * 用户点击右上角分享
  82. */
  83. onShareAppMessage(options) {
  84. return {
  85. title: ' '
  86. }
  87. },
  88. getMessage(e){
  89. // console.log(e.detail.data[0].from);
  90. if(e.detail.data[0].from!=null){
  91. wx.navigateToMiniProgram({
  92. appId: 'wxfc86707bae655315',
  93. success(res) {
  94. // 打开成功
  95. }
  96. })
  97. }
  98. }
  99. })