pcWebViev.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view>
  3. <block v-if="access_token">
  4. <web-view :src="url + urlPath + '?queryList=' + queryList + '&token=' + access_token" @message="handleGetMessage"></web-view>
  5. </block>
  6. </view>
  7. </template>
  8. <script>
  9. import { User } from "@/config/api.js";
  10. import { pcUrl } from "@/config/config";
  11. export default {
  12. data() {
  13. return {
  14. urlPath: "/index",
  15. queryList: "",
  16. urlShare: "",
  17. titleShare: "",
  18. access_token: "",
  19. };
  20. },
  21. computed: {
  22. url() {
  23. return pcUrl;
  24. },
  25. },
  26. methods: {
  27. // 获取token
  28. getToken() {
  29. uni.login({
  30. success: (result) => {
  31. User.wechatLog({
  32. Code: result.code,
  33. }).then((res) => {
  34. try {
  35. let token = res.Data.Authorization;
  36. this.$db.set("access_token", token);
  37. this.access_token = token;
  38. } catch (e) {}
  39. });
  40. },
  41. });
  42. },
  43. // 获取web-view 的消息
  44. handleGetMessage(e) {
  45. const data = e.detail.data[e.detail.data.length - 1];
  46. this.urlShare = data.url;
  47. this.titleShare = data.title;
  48. },
  49. // 进入页面 处理数据
  50. initLoad(optios) {
  51. let urlType = [
  52. "index",
  53. "reportForm",
  54. "activity",
  55. "themeActivity",
  56. "activityDetail",
  57. "reportDetail",
  58. "reportSecretDetail",
  59. "roadEssence",
  60. "chartPage",
  61. "specialDetail",
  62. "specialResearchPage",
  63. "purchaser",
  64. "IndustryReport",
  65. ];
  66. if (JSON.stringify(optios) !== "{}" && optios.path) {
  67. let new_url = optios.path.split("/")[2];
  68. let pathUrl = decodeURIComponent(new_url);
  69. this.urlPath = urlType.includes(pathUrl) ? "/" + pathUrl : pathUrl == "reportPage" ? "/reportDetail" : "/index";
  70. this.queryList = optios.query || "";
  71. }
  72. },
  73. },
  74. onLoad(optios) {
  75. this.getToken();
  76. this.initLoad(optios);
  77. },
  78. onShareAppMessage() {
  79. return {
  80. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.titleShare,
  81. path: this.urlShare,
  82. };
  83. },
  84. };
  85. </script>
  86. <style></style>