pcWebViev.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. getToken() {
  28. uni.login({
  29. success: (result) => {
  30. User.wechatLog({
  31. Code: result.code,
  32. }).then((res) => {
  33. try {
  34. let token = res.Data.Authorization;
  35. this.$db.set("access_token", token);
  36. this.access_token = token;
  37. } catch (e) {}
  38. });
  39. },
  40. });
  41. },
  42. handleGetMessage(e) {
  43. const data = e.detail.data[e.detail.data.length - 1];
  44. this.urlShare = data.url;
  45. this.titleShare = data.title;
  46. },
  47. initLoad(optios) {
  48. let urlType = [
  49. "index",
  50. "reportForm",
  51. "activity",
  52. "themeActivity",
  53. "activityDetail",
  54. "reportDetail",
  55. "reportSecretDetail",
  56. "roadEssence",
  57. "chartPage",
  58. "specialDetail",
  59. "specialResearchPage",
  60. 'purchaser'
  61. ];
  62. if (JSON.stringify(optios) !== "{}" && optios.path) {
  63. let pathUrl = optios.path.split("/")[2];
  64. this.urlPath = urlType.includes(pathUrl) ? "/" + pathUrl : pathUrl == "reportPage" ? "/reportDetail" : "/index";
  65. this.queryList = optios.query || "";
  66. }
  67. },
  68. },
  69. onLoad(optios) {
  70. this.getToken();
  71. this.initLoad(optios);
  72. },
  73. onShareAppMessage() {
  74. return {
  75. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.titleShare,
  76. path: this.urlShare,
  77. };
  78. },
  79. };
  80. </script>
  81. <style></style>