pcWebViev.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. export default {
  11. data() {
  12. return {
  13. //url:"http://192.168.2.22:3000/cygx_pc/",//开发
  14. url: "https://cygxpctest.hzinsights.com/cygx_pc", //测试
  15. //url: 'https://cygxpc.hzinsights.com/cygx_pc', //生产
  16. urlPath: "/index",
  17. queryList: "",
  18. urlShare: "",
  19. titleShare: "",
  20. access_token: "",
  21. };
  22. },
  23. methods: {
  24. getToken() {
  25. uni.login({
  26. success: (result) => {
  27. User.wechatLog({
  28. Code: result.code,
  29. }).then((res) => {
  30. try {
  31. let token = res.Data.Authorization;
  32. this.$db.set("access_token", token);
  33. this.access_token = token;
  34. } catch (e) {}
  35. });
  36. },
  37. });
  38. },
  39. handleGetMessage(e) {
  40. const data = e.detail.data[e.detail.data.length - 1];
  41. this.urlShare = data.url;
  42. this.titleShare = data.title;
  43. },
  44. initLoad(optios) {
  45. let urlType = [
  46. "index",
  47. "reportForm",
  48. "activity",
  49. "themeActivity",
  50. "activityDetail",
  51. "reportDetail",
  52. "IndustryReport",
  53. "reportSecretDetail",
  54. "roadEssence",
  55. "chartPage",
  56. "specialDetail",
  57. "specialResearchPage",
  58. ];
  59. if (JSON.stringify(optios) !== "{}" && optios.path) {
  60. let pathUrl = optios.path.split("/")[2];
  61. this.urlPath = urlType.includes(pathUrl) ? "/" + pathUrl : "/index";
  62. this.queryList = optios.query || "";
  63. }
  64. },
  65. },
  66. onLoad(optios) {
  67. this.getToken();
  68. this.initLoad(optios);
  69. },
  70. onShareAppMessage() {
  71. return {
  72. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.titleShare,
  73. path: this.urlShare,
  74. };
  75. },
  76. };
  77. </script>
  78. <style></style>