Ui修改
This commit is contained in:
+83
-157
@@ -6,9 +6,7 @@
|
||||
class="mobile"
|
||||
:os="os"
|
||||
@getApkInfo="handleGetApkInfo"
|
||||
@recordClick="recordClick"
|
||||
:ip="ip"
|
||||
:configs="configs"
|
||||
:switchData="switchData"
|
||||
:version="version"
|
||||
style="height:100%"
|
||||
@@ -22,7 +20,6 @@
|
||||
class="pc"
|
||||
:qr-img="QRImg"
|
||||
:os="os"
|
||||
:configs="configs"
|
||||
@getApkInfo="handleGetApkInfo"
|
||||
></pc>
|
||||
</template>
|
||||
@@ -32,9 +29,7 @@
|
||||
class="mobile"
|
||||
:os="os"
|
||||
@getApkInfo="handleGetApkInfo"
|
||||
@recordClick="recordClick"
|
||||
:ip="ip"
|
||||
:configs="configs"
|
||||
:switchData="switchData"
|
||||
style="height:100%"
|
||||
ref="mobileRef"
|
||||
@@ -47,7 +42,6 @@
|
||||
class="pc"
|
||||
:qr-img="QRImg"
|
||||
:os="os"
|
||||
:configs="configs"
|
||||
@getApkInfo="handleGetApkInfo"
|
||||
></pc2>
|
||||
</template>
|
||||
@@ -74,8 +68,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import getApkInfo from "@/api/getApkInfo";
|
||||
import getButtonlist from "@/api/getTemplate";
|
||||
import { getButtonList, bottonclick, downloadH5 } from "@/api/btn";
|
||||
import userAgent from "@/utils/userAgent";
|
||||
import QRCode from "qrcode";
|
||||
import axios from "@/utils/request.js";
|
||||
@@ -85,8 +78,7 @@ import pc from "./components/pc";
|
||||
import pc2 from "./components/pc2";
|
||||
import tips from "./components/tips";
|
||||
import selectLinePopup from "./components/selectLinePopup";
|
||||
import { getTraceId, landingPageView } from "@/utils/eventTracker";
|
||||
const APPID = 214;
|
||||
import { getTraceId } from "@/utils/traceId";
|
||||
export default {
|
||||
components: {
|
||||
mobile1,
|
||||
@@ -98,29 +90,15 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
type: "",
|
||||
QRImg: "",
|
||||
os: "",
|
||||
param: "",
|
||||
cutInfo: {}, //替换url参数对象内<key> dc内容;
|
||||
ip: "",
|
||||
switchData: {},
|
||||
page_pc_url: "",
|
||||
iosDownUrl: "",
|
||||
androidDownUrl: "",
|
||||
shopIosDownUrl: "", // 商店包链接
|
||||
storeAndroidDownUrl: "",
|
||||
channelApkAndDownUrl: "",
|
||||
// iosJumpSetUpUrl: "", // 执行完下载链接后需要执行的跳转
|
||||
loading: true,
|
||||
currUrl: window.location.href,
|
||||
apiUrls: JSON.parse(process.env.VUE_APP_BASE_HOSTS), // api数组
|
||||
showOverlay: false, // 显示选线弹窗
|
||||
configs: [],
|
||||
// tgUrl: "",
|
||||
// potatoUrl: "",
|
||||
// swUrl: "",
|
||||
// qdUrl: "",
|
||||
version: "A",
|
||||
trace_id: getTraceId()
|
||||
};
|
||||
@@ -132,67 +110,47 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// const queryVersion = (this.$route.query.version || "").toUpperCase();
|
||||
// this.version =
|
||||
// queryVersion === "A" || queryVersion === "B"
|
||||
// ? queryVersion
|
||||
// : Math.random() < 0.5
|
||||
// ? "A"
|
||||
// : "B";
|
||||
this.version = "A";
|
||||
this.getPcUrl();
|
||||
this.os = userAgent();
|
||||
this.functionParam();
|
||||
this.getButtonlist();
|
||||
landingPageView(this);
|
||||
this.init();
|
||||
const referrer = document.referrer;
|
||||
// console.log(referrer, "-----------referrer");
|
||||
if (referrer) {
|
||||
sessionStorage.setItem("referrer", referrer);
|
||||
}
|
||||
if (this.$route.query.dc) {
|
||||
sessionStorage.setItem("dc", this.$route.query.dc);
|
||||
}
|
||||
// this.getIp();
|
||||
},
|
||||
mounted() {
|
||||
this.getQRImg();
|
||||
},
|
||||
methods: {
|
||||
isDcMatch(value) {
|
||||
const reg = /^(?:ky(?:(?:0[1-9]|[1-9][0-9]|100))|TLGG(?:(?:0[1-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-6]))|erra(?:(?:0[1-9]|10))|cctl(?:(?:0[1-9]|10))|mijieer[1-5][a-d])$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
getPcUrl() {
|
||||
this.page_pc_url = window.location.href;
|
||||
},
|
||||
//1.判断进来的url地址 替换到需要手动设置的参数 如cd
|
||||
functionParam() {
|
||||
this.param =
|
||||
JSON.stringify(this.$route.query) === "{}"
|
||||
? "{}"
|
||||
: JSON.stringify(this.$route.query);
|
||||
async init() {
|
||||
await this.getIp();
|
||||
await this.getButtonlist();
|
||||
},
|
||||
//2.获取按钮状态信息
|
||||
// 去掉空值后序列化渠道参数
|
||||
filterChannel() {
|
||||
const result = {};
|
||||
Object.entries(this.$route.query).forEach(([key, value]) => {
|
||||
if (value) result[key] = value;
|
||||
});
|
||||
return JSON.stringify(result);
|
||||
},
|
||||
//1.获取按钮开关(iosDown / iosStore / iosTF / iosH5 / androidButton)
|
||||
async getButtonlist() {
|
||||
try {
|
||||
let param_btn_list = {
|
||||
appId: APPID,
|
||||
channel: this.param,
|
||||
domain: window.location.protocol + "//" + window.location.host,
|
||||
version: this.version
|
||||
};
|
||||
const res = await getButtonlist(param_btn_list);
|
||||
const res = await getButtonList({
|
||||
ip: this.ip,
|
||||
channel: JSON.stringify(this.$route.query)
|
||||
});
|
||||
this.loading = false;
|
||||
if (res.data.code === 200) {
|
||||
this.switchData = res.data.data;
|
||||
this.configs = res.data.data.configs || [];
|
||||
this.androidDownUrl = res.data.data.androidDownUrl;
|
||||
this.storeAndroidDownUrl = res.data.data.storeAndroidDownUrl;
|
||||
this.channelApkAndDownUrl = res.data.data.channelApkAndDownUrl;
|
||||
this.iosDownUrl = res.data.data.iosDownUrl;
|
||||
this.shopIosDownUrl = res.data.data.shopIosDownUrl;
|
||||
// this.iosJumpSetUpUrl = res.data.data.iosJumpSetUpUrl;
|
||||
this.switchData = res.data.data || {};
|
||||
}
|
||||
} catch (err) {
|
||||
this.loading = false;
|
||||
@@ -200,105 +158,73 @@ export default {
|
||||
console.log(err);
|
||||
}
|
||||
},
|
||||
//3. 获取外网IP地址
|
||||
getIp() {
|
||||
axios.get("https://api.ipify.org/?format=json").then(res => {
|
||||
this.ip = res.data.ip;
|
||||
});
|
||||
//2. 获取外网IP地址
|
||||
async getIp() {
|
||||
try {
|
||||
const res = await fetch("https://api.ipify.org?format=json");
|
||||
const data = await res.json();
|
||||
this.ip = data.ip || "";
|
||||
} catch (err) {
|
||||
console.log("获取外部IP失败" + err);
|
||||
}
|
||||
},
|
||||
//4. 点击下载按钮获取apk信息并下载
|
||||
jumpToLink(link) {
|
||||
// 微信内加时间戳,避免命中缓存
|
||||
window.location.href = this.os.isWx ? link + "?time=" + Date.now() : link;
|
||||
},
|
||||
// bottonclick 返回的下载地址数组
|
||||
async fetchLinks(terminal, extra = {}) {
|
||||
const res = await bottonclick({
|
||||
ip: this.ip,
|
||||
channel: this.filterChannel(),
|
||||
domain: window.location.host || "",
|
||||
type: "iosH5",
|
||||
terminal,
|
||||
...extra
|
||||
});
|
||||
const link = res && res.data && res.data.data && res.data.data.link;
|
||||
return Array.isArray(link) ? link.filter(Boolean) : [];
|
||||
},
|
||||
// iOS 轻量版:直接调 h5/config 下载描述文件
|
||||
async downloadMobileConfig() {
|
||||
const paramData = {};
|
||||
if (this.$route.query.dc) paramData.dc = String(this.$route.query.dc);
|
||||
if (this.$route.query.pc) paramData.pc = String(this.$route.query.pc);
|
||||
const content = await downloadH5(paramData);
|
||||
const file = new File([content], "descriptionFile.mobileconfig", {
|
||||
type: "application/x-apple-aspen-config"
|
||||
});
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = objectUrl;
|
||||
link.download = "descriptionFile.mobileconfig";
|
||||
link.click();
|
||||
setTimeout(() => URL.revokeObjectURL(objectUrl), 10000);
|
||||
},
|
||||
//3. 点击下载按钮获取下载地址并下载
|
||||
async handleGetApkInfo(type) {
|
||||
await this.doCopy();
|
||||
let terminal;
|
||||
let packageType;
|
||||
if (type === "ios") {
|
||||
terminal = "ios";
|
||||
packageType = 1;
|
||||
} else if (type == "shopIos") {
|
||||
terminal = "ios";
|
||||
packageType = 2;
|
||||
} else if (type == "androidSpare") {
|
||||
terminal = "androidSpare";
|
||||
} else {
|
||||
terminal = "android";
|
||||
try {
|
||||
if (type === "ios") {
|
||||
await this.downloadMobileConfig();
|
||||
} else if (type === "shopIos") {
|
||||
if (!this.switchData.iosStore) return;
|
||||
const links = await this.fetchLinks("ios", {
|
||||
type: "iosStore",
|
||||
packageType: 2
|
||||
});
|
||||
if (links.length) this.jumpToLink(links[0]);
|
||||
} else {
|
||||
const links = await this.fetchLinks("android");
|
||||
const target = (type === "androidSpare" && links[1]) || links[0];
|
||||
if (target) this.jumpToLink(target);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("下载失败" + err);
|
||||
}
|
||||
if (terminal === "android" || terminal === "androidSpare") {
|
||||
let dc = this.$route.query.dc;
|
||||
if (this.storeAndroidDownUrl && this.isDcMatch(dc)) {
|
||||
let url = this.storeAndroidDownUrl || this.channelApkAndDownUrl;
|
||||
window.location.href = url;
|
||||
} else if (terminal === "androidSpare") {
|
||||
window.location.href = this.androidDownUrl;
|
||||
} else {
|
||||
let jumpUrl = this.channelApkAndDownUrl || this.androidDownUrl;
|
||||
window.location.href = jumpUrl;
|
||||
}
|
||||
} else {
|
||||
let dc = this.$route.query.dc;
|
||||
let ch = this.$route.query.ch;
|
||||
let pc = this.$route.query.pc;
|
||||
let linkUrl = "";
|
||||
if (dc) {
|
||||
linkUrl = `${this.iosDownUrl}?dc=${dc}&tid=${this.trace_id}`;
|
||||
} else if (ch) {
|
||||
linkUrl = `${this.iosDownUrl}?ch=${ch}&tid=${this.trace_id}`;
|
||||
} else if (pc) {
|
||||
linkUrl = `${this.iosDownUrl}?pc=${pc}&tid=${this.trace_id}`;
|
||||
} else {
|
||||
linkUrl = `${this.iosDownUrl}?tid=${this.trace_id}`;
|
||||
}
|
||||
if (type == "shopIos" && this.shopIosDownUrl) {
|
||||
window.open(this.shopIosDownUrl);
|
||||
} else {
|
||||
window.location.href = linkUrl;
|
||||
}
|
||||
// if (this.iosJumpSetUpUrl) {
|
||||
// setTimeout(() => {
|
||||
// window.location.href = this.iosJumpSetUpUrl;
|
||||
// }, 1500);
|
||||
// }
|
||||
}
|
||||
// getApkInfo(param);
|
||||
},
|
||||
recordClick(type) {
|
||||
let terminal;
|
||||
let packageType;
|
||||
if (type === "ios") {
|
||||
terminal = "ios";
|
||||
packageType = 1;
|
||||
} else if (type == "shopIos") {
|
||||
terminal = "ios";
|
||||
packageType = 2;
|
||||
} else {
|
||||
terminal = "android";
|
||||
}
|
||||
const param = {
|
||||
appId: APPID,
|
||||
ip: this.ip ? this.ip : "", //获取ip地址
|
||||
channel: JSON.stringify({
|
||||
...JSON.parse(this.param),
|
||||
...this.cutInfo
|
||||
}),
|
||||
domain: window.location.protocol + "//" + window.location.host,
|
||||
terminal,
|
||||
packageType,
|
||||
version: this.version
|
||||
};
|
||||
getApkInfo(param);
|
||||
},
|
||||
//5.生成二维码
|
||||
//4.生成二维码
|
||||
getQRImg() {
|
||||
// const referrer = sessionStorage.getItem("referrer");
|
||||
// const dc = sessionStorage.getItem("dc");
|
||||
// if (referrer && dc) {
|
||||
// this.currUrl = referrer + "user.html?dc=" + dc;
|
||||
// } else {
|
||||
// if (referrer) {
|
||||
// this.currUrl = referrer + "user.html";
|
||||
// } else {
|
||||
// this.currUrl = window.location.href;
|
||||
// }
|
||||
// }
|
||||
QRCode.toDataURL(this.currUrl, {
|
||||
width: 170,
|
||||
margin: 1,
|
||||
@@ -317,13 +243,13 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 6.剪贴板
|
||||
// 5.剪贴板
|
||||
doCopy() {
|
||||
let req = JSON.stringify({
|
||||
...this.$route.query,
|
||||
tid: this.trace_id
|
||||
});
|
||||
this.$copyText(req).then(
|
||||
return this.$copyText(req).then(
|
||||
() => {
|
||||
console.log("复制成功");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user