You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
3.2 KiB
133 lines
3.2 KiB
import { post } from "../../app";
|
|
const baseUrl = "https://huiju.mapais.com/livatwuxi/";
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
url: "",
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
async onLoad({ q = "", e = "", s = "", fe, plate = "" }) {
|
|
if (q) {
|
|
q = decodeURIComponent(q);
|
|
const kvs = q
|
|
.split("?")
|
|
.pop()
|
|
.split("&")
|
|
.map((kv) => kv.split("="));
|
|
s = kvs.find(([k]) => k === "s")[1];
|
|
e = kvs.find(([k]) => k === "e")[1];
|
|
}
|
|
const app = getApp();
|
|
if (!app.globalData.openid) {
|
|
const openid = await new Promise((resolve) => app.onOpenid(resolve));
|
|
const agreed = await this.getAgreement();
|
|
if (!agreed)
|
|
return wx.redirectTo({
|
|
url: `/pages/agreement/index?q=${q}&e=${e}&s=${s}&plate=${plate}`,
|
|
});
|
|
this.setData({
|
|
url: `${baseUrl}?t=${new Date().getTime()}#/?openid=${openid}${
|
|
e ? "&e=" + e : ""
|
|
}${e && s ? "&s=" + s : ""}${plate ? "&plate=" + plate : ""}${
|
|
fe ? "&fe=true" : ""
|
|
}`,
|
|
});
|
|
} else {
|
|
const openid = app.globalData.openid;
|
|
const agreed = await this.getAgreement();
|
|
if (!agreed)
|
|
return wx.redirectTo({
|
|
url: `/pages/agreement/index?q=${q}&e=${e}&s=${s}&plate=${plate}`,
|
|
});
|
|
this.setData({
|
|
url: `${baseUrl}?t=${new Date().getTime()}#/?openid=${openid}${
|
|
e ? "&e=" + e : ""
|
|
}${e && s ? "&s=" + s : ""}${plate ? "&plate=" + plate : ""}${
|
|
fe ? "&fe=true" : ""
|
|
}`,
|
|
});
|
|
}
|
|
},
|
|
async getAgreement() {
|
|
const app = getApp();
|
|
if (app.globalData.agreed) return true;
|
|
const openid = app.globalData.openid;
|
|
|
|
try {
|
|
const { data } = await post("/api/Privacy/Query", { openid });
|
|
app.globalData.agreed = data;
|
|
} catch (error) {
|
|
console.warn(error);
|
|
}
|
|
return app.globalData.agreed;
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage({ webViewUrl: q }) {
|
|
let e;
|
|
let name;
|
|
if (q) {
|
|
q = decodeURIComponent(q);
|
|
const kvs = q
|
|
.split("?")
|
|
.pop()
|
|
.split("&")
|
|
.map((kv) => kv.split("="));
|
|
console.log(kvs);
|
|
if (kvs.find(([k]) => k === "e")) {
|
|
e = kvs.find(([k]) => k === "e")[1];
|
|
}
|
|
if (kvs.find(([k]) => k === "name")) {
|
|
name = kvs.find(([k]) => k === "name")[1];
|
|
}
|
|
}
|
|
|
|
return name
|
|
? {
|
|
title: name,
|
|
path: `/pages/h5map/index?e=${e}`,
|
|
imageUrl: "/pages/h5map/share.png",
|
|
}
|
|
: {
|
|
title: "无锡荟聚实景导航",
|
|
path: "/pages/h5map/index",
|
|
imageUrl: "/pages/h5map/share.png",
|
|
};
|
|
},
|
|
});
|
|
|