pcWebViev.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: "",
  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 = ["index", "reportForm", "activity", "themeActivity", "activityDetail", "reportDetail", "IndustryReport", "reportSecretDetail", "roadEssence"];
  46. if (JSON.stringify(optios) !== "{}" && optios.path) {
  47. let pathUrl = optios.path.split("/")[2];
  48. this.urlPath = urlType.includes(pathUrl) ? '/' + pathUrl : "/index";
  49. this.queryList = optios.query || "";
  50. }
  51. },
  52. },
  53. onLoad(optios) {
  54. this.getToken();
  55. this.initLoad(optios);
  56. },
  57. onShareAppMessage(op) {
  58. return {
  59. title: this.titleShare,
  60. path: this.urlShare,
  61. };
  62. },
  63. };
  64. </script>
  65. <style></style>