1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <view>
- <block v-if="access_token">
- <web-view :src="url + urlPath + '?queryList=' + queryList + '&token=' + access_token" @message="handleGetMessage"></web-view>
- </block>
- </view>
- </template>
- <script>
- import { User } from "@/config/api.js";
- import { pcUrl } from "@/config/config";
- export default {
- data() {
- return {
- urlPath: "/index",
- queryList: "",
- urlShare: "",
- titleShare: "",
- access_token: "",
- };
- },
- computed: {
- url() {
- return pcUrl;
- },
- },
- methods: {
- // 获取token
- getToken() {
- uni.login({
- success: (result) => {
- User.wechatLog({
- Code: result.code,
- }).then((res) => {
- try {
- let token = res.Data.Authorization;
- this.$db.set("access_token", token);
- this.access_token = token;
- } catch (e) {}
- });
- },
- });
- },
- // 获取web-view 的消息
- handleGetMessage(e) {
- const data = e.detail.data[e.detail.data.length - 1];
- this.urlShare = data.url;
- this.titleShare = data.title;
- },
- // 进入页面 处理数据
- initLoad(optios) {
- let urlType = [
- "index",
- "reportForm",
- "activity",
- "themeActivity",
- "activityDetail",
- "reportDetail",
- "reportSecretDetail",
- "roadEssence",
- "chartPage",
- "specialDetail",
- "specialResearchPage",
- "purchaser",
- "IndustryReport",
- ];
- if (JSON.stringify(optios) !== "{}" && optios.path) {
- let new_url = optios.path.split("/")[2];
- let pathUrl = decodeURIComponent(new_url);
- this.urlPath = urlType.includes(pathUrl) ? "/" + pathUrl : pathUrl == "reportPage" ? "/reportDetail" : "/index";
- this.queryList = optios.query || "";
- }
- },
- },
- onLoad(optios) {
- this.getToken();
- this.initLoad(optios);
- },
- onShareAppMessage() {
- return {
- title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.titleShare,
- path: this.urlShare,
- };
- },
- };
- </script>
- <style></style>
|