248 lines
8.4 KiB
JavaScript
248 lines
8.4 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const store_modules_user = require("../../store/modules/user.js");
|
|
const api_booking_users_index = require("../../api/booking/users/index.js");
|
|
const api_cms_mpMenu_index = require("../../api/cms/mp-menu/index.js");
|
|
const api_shop_merchant_index = require("../../api/shop/merchant/index.js");
|
|
const api_shop_users_index = require("../../api/shop/users/index.js");
|
|
const utils_common = require("../../utils/common.js");
|
|
const api_passport_login_index = require("../../api/passport/login/index.js");
|
|
const store_modules_tenant = require("../../store/modules/tenant.js");
|
|
const tenantStore = store_modules_tenant.useTenantStore();
|
|
const userStore = store_modules_user.useUserStore();
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
orderNo: void 0,
|
|
statusBarHeight: 104,
|
|
isLogin: false,
|
|
userInfo: {},
|
|
currMerchant: {},
|
|
merchantId: null,
|
|
fields: {},
|
|
logo: "",
|
|
bookingUser: {},
|
|
server: [],
|
|
order: [],
|
|
hideUser: true,
|
|
hideTools: true,
|
|
// 是否拥有场馆管理员权限
|
|
hasMerchantRole: false,
|
|
// 是否拥有场馆职员权限
|
|
hasMerchantClerkRole: false,
|
|
// 是否拥有超级管理员权限
|
|
hasSuperAdminRole: false,
|
|
scanType: "",
|
|
scanResult: ""
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
if (option.orderNo) {
|
|
this.orderNo = option.orderNo;
|
|
}
|
|
this.reload();
|
|
},
|
|
methods: {
|
|
async reload(e) {
|
|
const app = this;
|
|
common_vendor.index.getSystemInfo({
|
|
success(data) {
|
|
if (data) {
|
|
app.statusBarHeight = data.statusBarHeight;
|
|
}
|
|
}
|
|
});
|
|
const tenantInfo = await tenantStore.fetchTenantInfo();
|
|
app.logo = tenantInfo.websiteLogo;
|
|
if (tenantInfo.fields) {
|
|
tenantInfo.fields.map((d) => {
|
|
const key = d.name;
|
|
app.fields[key] = d.value;
|
|
});
|
|
}
|
|
const userInfo = await userStore.fetchUserInfo();
|
|
if (Object.keys(userInfo).length > 0) {
|
|
app.isLogin = true;
|
|
if (app.orderNo) {
|
|
return common_vendor.index.redirectTo({
|
|
url: "/package/admin/order-scan?orderNo=" + app.orderNo
|
|
});
|
|
}
|
|
app.userInfo = userInfo;
|
|
common_vendor.index.setStorageSync("user_id", app.userInfo.userId);
|
|
app.hasMerchantRole = userInfo.roles.find((d) => d.roleCode === "merchant");
|
|
app.hasMerchantClerkRole = userInfo.roles.find((d) => d.roleCode === "merchantClerk");
|
|
app.hasSuperAdminRole = userInfo.roles.find((d) => d.roleCode === "superAdmin");
|
|
api_shop_merchant_index.pageMerchant({ merchantIds: userInfo.merchants, limit: 50 }).then((res) => {
|
|
app.merchantList = res.list.map((d, i) => {
|
|
if (i === 0) {
|
|
app.currMerchant = d;
|
|
app.merchantId = d.merchantId;
|
|
}
|
|
return {
|
|
text: d.merchantName,
|
|
value: d.merchantId
|
|
};
|
|
});
|
|
common_vendor.index.setStorageSync("merchantList", app.merchantList);
|
|
});
|
|
api_booking_users_index.getByPhone({
|
|
phone: userInfo.phone
|
|
}).then((data) => {
|
|
if (data) {
|
|
app.hideUser = false;
|
|
app.userInfo.ouid = data.userId;
|
|
app.userInfo = Object.assign({}, app.userInfo, data);
|
|
}
|
|
});
|
|
} else {
|
|
app.isLogin = false;
|
|
app.userInfo = {};
|
|
}
|
|
api_cms_mpMenu_index.pageMpMenu({ type: 4, limit: 100 }).then((res) => {
|
|
app.order = res.list.filter((d) => d.rows === 0);
|
|
app.server = res.list.filter((d) => d.rows === 0);
|
|
app.hideTools = false;
|
|
}).catch(() => {
|
|
common_vendor.index.showToast({
|
|
title: "请检查您的网络.",
|
|
icon: "none"
|
|
});
|
|
app.hideTools = false;
|
|
});
|
|
common_vendor.index.login({
|
|
success: (res) => {
|
|
api_passport_login_index.getWxOpenId({
|
|
code: res.code
|
|
}).then((response) => {
|
|
if (!app.userInfo.openid) {
|
|
api_shop_users_index.updateUsers({
|
|
userId: app.userInfo.ouid,
|
|
openid: response.openid,
|
|
sessionKey: response.session_key,
|
|
unionid: response.unionid
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
},
|
|
navTo(item) {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
} else {
|
|
if (item.path === "/package/admin/order-scan") {
|
|
common_vendor.index.showModal({
|
|
title: "直接使用微信扫一扫功能完成核销"
|
|
});
|
|
return false;
|
|
} else {
|
|
utils_common.openUrl(item);
|
|
}
|
|
}
|
|
},
|
|
// 弹出登录提示框
|
|
openLogin() {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
},
|
|
back() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
goBack() {
|
|
return common_vendor.index.switchTab({
|
|
url: "/pages/user/user"
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uv_gap2 = common_vendor.resolveComponent("uv-gap");
|
|
const _easycom_ws_admin_card2 = common_vendor.resolveComponent("ws-admin-card");
|
|
const _easycom_uv_skeleton2 = common_vendor.resolveComponent("uv-skeleton");
|
|
const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
|
|
const _easycom_uni_list_item2 = common_vendor.resolveComponent("uni-list-item");
|
|
const _easycom_uni_list2 = common_vendor.resolveComponent("uni-list");
|
|
const _easycom_ws_login2 = common_vendor.resolveComponent("ws-login");
|
|
(_easycom_uv_gap2 + _easycom_ws_admin_card2 + _easycom_uv_skeleton2 + _easycom_uni_card2 + _easycom_uni_list_item2 + _easycom_uni_list2 + _easycom_ws_login2)();
|
|
}
|
|
const _easycom_uv_gap = () => "../../uni_modules/uv-gap/components/uv-gap/uv-gap.js";
|
|
const _easycom_ws_admin_card = () => "../../uni_modules/ws-admin-card/components/ws-admin-card/ws-admin-card.js";
|
|
const _easycom_uv_skeleton = () => "../../uni_modules/uv-skeleton/components/uv-skeleton/uv-skeleton.js";
|
|
const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
|
|
const _easycom_uni_list_item = () => "../../uni_modules/uni-list/components/uni-list-item/uni-list-item.js";
|
|
const _easycom_uni_list = () => "../../uni_modules/uni-list/components/uni-list/uni-list.js";
|
|
const _easycom_ws_login = () => "../../uni_modules/ws-login/components/ws-login/ws-login.js";
|
|
if (!Math) {
|
|
(_easycom_uv_gap + _easycom_ws_admin_card + _easycom_uv_skeleton + _easycom_uni_card + _easycom_uni_list_item + _easycom_uni_list + _easycom_ws_login)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
height: "20"
|
|
}),
|
|
b: common_vendor.o($options.openLogin),
|
|
c: common_vendor.p({
|
|
merchantList: _ctx.merchantList,
|
|
merchantId: $data.merchantId,
|
|
data: $data.userInfo,
|
|
["is-login"]: $data.isLogin
|
|
}),
|
|
d: $data.hideTools
|
|
}, $data.hideTools ? {
|
|
e: common_vendor.p({
|
|
rows: "2",
|
|
loading: $data.hideTools,
|
|
title: false
|
|
}),
|
|
f: common_vendor.p({
|
|
border: false,
|
|
padding: "18px 8px"
|
|
}),
|
|
g: common_vendor.p({
|
|
rows: "9",
|
|
loading: $data.hideTools,
|
|
title: false
|
|
}),
|
|
h: common_vendor.p({
|
|
border: false,
|
|
padding: "18px 8px"
|
|
})
|
|
} : common_vendor.e({
|
|
i: $data.hasMerchantRole || $data.hasMerchantClerkRole
|
|
}, $data.hasMerchantRole || $data.hasMerchantClerkRole ? {
|
|
j: common_vendor.f($data.server, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.title),
|
|
b: item.color ? item.color : "#333333",
|
|
c: common_vendor.o(($event) => $options.navTo(item), index),
|
|
d: "2fabd118-8-" + i0 + ",2fabd118-7",
|
|
e: common_vendor.p({
|
|
thumb: item.icon,
|
|
link: true
|
|
}),
|
|
f: index
|
|
};
|
|
}),
|
|
k: common_vendor.p({
|
|
border: false
|
|
})
|
|
} : {}, {
|
|
l: common_vendor.p({
|
|
border: false,
|
|
padding: 0
|
|
}),
|
|
m: common_vendor.sr("login", "2fabd118-9"),
|
|
n: common_vendor.o($options.reload),
|
|
o: common_vendor.p({
|
|
logo: $data.logo
|
|
}),
|
|
p: common_vendor.o((...args) => $options.goBack && $options.goBack(...args))
|
|
}));
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/admin/index.vue"]]);
|
|
wx.createPage(MiniProgramPage);
|