更新
This commit is contained in:
+165
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const common_vendor = require("./common/vendor.js");
|
||||
if (!Math) {
|
||||
"./tongji/pages/weekly.js";
|
||||
"./pages/user/user.js";
|
||||
"./pages/user/userinfo.js";
|
||||
"./pages/Card/Card.js";
|
||||
"./pages/Card/edit_card.js";
|
||||
"./pages/Card/contact.js";
|
||||
"./tongji/pages/index.js";
|
||||
"./tongji/pages/more.js";
|
||||
"./tongji/endless-game/index.js";
|
||||
"./training/pages/grip-ring.js";
|
||||
"./training/pages/pilates-ring.js";
|
||||
"./training/pages/foot-pedal.js";
|
||||
"./training/pages/dumbbell.js";
|
||||
"./training/pages/metronome.js";
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "App",
|
||||
setup(__props) {
|
||||
const { proxy } = common_vendor.getCurrentInstance();
|
||||
common_vendor.onLaunch(() => {
|
||||
try {
|
||||
common_vendor.index.setInnerAudioOption({
|
||||
obeyMuteSwitch: false,
|
||||
mixWithOther: true
|
||||
});
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at App.vue:16", "setInnerAudioOption failed:", e);
|
||||
}
|
||||
common_vendor.index.login({
|
||||
provider: "weixin",
|
||||
success: function(loginRes) {
|
||||
if (common_vendor.index.getStorageSync("token")) {
|
||||
userinfo(loginRes.code);
|
||||
} else {
|
||||
wxcode(loginRes.code);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
const wxcode = async (code) => {
|
||||
try {
|
||||
const res = await proxy.apiUrl(
|
||||
{
|
||||
url: "/api/login/mnpLogin",
|
||||
method: "POST",
|
||||
data: {
|
||||
code
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
if (res && res.data && res.data.token) {
|
||||
common_vendor.index.setStorageSync("token", res.data.token);
|
||||
common_vendor.index.setStorageSync("userData", res.data);
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
};
|
||||
const userinfo = async (code) => {
|
||||
try {
|
||||
const res = await proxy.apiUrl(
|
||||
{
|
||||
url: "/api/user/info",
|
||||
method: "POST"
|
||||
},
|
||||
false
|
||||
);
|
||||
if (res.code == -1) {
|
||||
wxcode(code);
|
||||
return;
|
||||
}
|
||||
if (res && res.data) {
|
||||
common_vendor.index.setStorageSync("userData", res.data);
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
};
|
||||
return () => {
|
||||
};
|
||||
}
|
||||
};
|
||||
var baseUrl = "https://admin.zhenyangtang.com.cn/";
|
||||
function joinApiUrl(base, path) {
|
||||
const b = String(base || "").replace(/\/+$/, "");
|
||||
const p = String(path || "").replace(/^\/+/, "");
|
||||
return p ? `${b}/${p}` : b;
|
||||
}
|
||||
function apiUrl(promise, Loading = true) {
|
||||
const token = common_vendor.index.getStorageSync("token");
|
||||
const header = {
|
||||
token,
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
...promise.header || {}
|
||||
};
|
||||
const data = promise.data || {};
|
||||
const url = joinApiUrl(baseUrl, promise.url || "");
|
||||
return new Promise((resolve, reject) => {
|
||||
if (Loading) {
|
||||
common_vendor.index.showLoading({ title: "加载中...", mask: true });
|
||||
}
|
||||
common_vendor.index.request({
|
||||
url,
|
||||
data,
|
||||
timeout: promise.timeout != null ? promise.timeout : 15e3,
|
||||
method: promise.method || "POST",
|
||||
header,
|
||||
sslVerify: false,
|
||||
success: (res) => {
|
||||
const data2 = res.data;
|
||||
if (data2.code === -1) {
|
||||
common_vendor.index.removeStorageSync("token");
|
||||
}
|
||||
resolve(data2);
|
||||
},
|
||||
fail: (e) => {
|
||||
reject(e);
|
||||
},
|
||||
complete: (e) => {
|
||||
if (Loading) {
|
||||
common_vendor.index.hideLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function parsePageParams(options) {
|
||||
const params = {};
|
||||
if (!options)
|
||||
return params;
|
||||
if (options.scene) {
|
||||
try {
|
||||
const decodedScene = decodeURIComponent(options.scene);
|
||||
decodedScene.split("&").forEach((item) => {
|
||||
const [key, value] = item.split("=");
|
||||
if (key && value) {
|
||||
params[key] = value;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at main.js:126", "解析scene参数失败:", error);
|
||||
}
|
||||
}
|
||||
Object.keys(options).forEach((key) => {
|
||||
if (key !== "scene" && options[key]) {
|
||||
params[key] = options[key];
|
||||
}
|
||||
});
|
||||
return params;
|
||||
}
|
||||
function createApp() {
|
||||
const app = common_vendor.createSSRApp(_sfc_main);
|
||||
app.config.globalProperties.$url = baseUrl;
|
||||
app.config.globalProperties.apiUrl = apiUrl;
|
||||
app.config.globalProperties.$parsePageParams = parsePageParams;
|
||||
return {
|
||||
app
|
||||
};
|
||||
}
|
||||
createApp().app.mount("#app");
|
||||
exports.createApp = createApp;
|
||||
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map
|
||||
Reference in New Issue
Block a user