71 lines
2.6 KiB
JavaScript
71 lines
2.6 KiB
JavaScript
"use strict";
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const utils_commUtils = require("../../../utils/commUtils.js");
|
|
const utils_http = require("../../../utils/http.js");
|
|
require("../../../store/index.js");
|
|
const store_user = require("../../../store/user.js");
|
|
if (!Array) {
|
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
|
_component_layout_default_uni();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
const webviewSrc = common_vendor.ref("");
|
|
const shopUserData = common_vendor.ref({});
|
|
const userStore = store_user.useUserStore();
|
|
const shopUserInfo = () => __async(this, null, function* () {
|
|
if (userStore.userInfo.shopLoginUser) {
|
|
shopUserData.value = userStore.userInfo.shopLoginUser;
|
|
webviewSrc.value = `http://localhost:3000/?token=${shopUserData.value.accessToken}&refresh-token=${shopUserData.value.refreshToken}`;
|
|
return;
|
|
}
|
|
try {
|
|
const shopUser = yield utils_http.httpPost("/shopLogin");
|
|
if (shopUser && shopUser.code === 200) {
|
|
webviewSrc.value = `http://localhost:3000/?token=${shopUserData.value.accessToken}&refresh-token=${shopUserData.value.refreshToken}`;
|
|
shopUserData.value = shopUser.data;
|
|
userStore.setUserInfo({ shopLoginUser: shopUserData.value });
|
|
onWebViewLoad();
|
|
} else {
|
|
utils_commUtils.toast(shopUser.message || "获取商城用户信息失败, 无法跳转到商城, 请联系管理员!");
|
|
}
|
|
} catch (e) {
|
|
utils_commUtils.toast(e.data.message || "发生错误,请稍后重试!");
|
|
}
|
|
});
|
|
common_vendor.onLoad(() => __async(this, null, function* () {
|
|
yield shopUserInfo();
|
|
}));
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: webviewSrc.value
|
|
}, webviewSrc.value ? {
|
|
b: webviewSrc.value
|
|
} : {});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2d065b42"]]);
|
|
wx.createPage(MiniProgramPage);
|