452 lines
20 KiB
Vue
452 lines
20 KiB
Vue
<script>
|
|
/** 会员等级说明弹窗:按打开动作读取 /client_level,显示升级条件与各等级商品折扣。 */
|
|
import "~/assets/styles/ClientLevelDialog.DcYabp-W.css";
|
|
import { toDisplayString } from "vue";
|
|
import { renderList } from "vue";
|
|
import { mergeModels } from "vue";
|
|
import { useModel } from "vue";
|
|
import { watch } from "vue";
|
|
import { createBlock } from "vue";
|
|
import { ref } from "vue";
|
|
import { withCtx } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { computed } from "vue";
|
|
import { createElementBlock } from "vue";
|
|
import { Fragment } from "vue";
|
|
import { createElementVNode } from "vue";
|
|
import { createTextVNode } from "vue";
|
|
import { unref } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { createVNode } from "vue";
|
|
import { openBlock } from "vue";
|
|
import { normalizeStyle } from "vue";
|
|
import { useApi } from "~/lib/auth.js";
|
|
import dialog from "primevue/dialog";
|
|
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
|
import { n as product_name_n } from "~/lib/product-name.js";
|
|
import { r as dict_r } from "~/lib/dict.js";
|
|
import datatable from "primevue/datatable";
|
|
import column from "primevue/column";
|
|
var E = {
|
|
key: 0,
|
|
class: `lvl-state`,
|
|
},
|
|
D = {
|
|
key: 1,
|
|
class: `lvl-state`,
|
|
},
|
|
O = {
|
|
class: `lvl-grid`,
|
|
},
|
|
k = {
|
|
class: `lvl-item`,
|
|
},
|
|
A = {
|
|
class: `lvl-item`,
|
|
},
|
|
j = {
|
|
class: `lvl-value`,
|
|
},
|
|
M = {
|
|
class: `lvl-item`,
|
|
},
|
|
N = {
|
|
class: `lvl-value`,
|
|
},
|
|
P = {
|
|
class: `lvl-item`,
|
|
},
|
|
F = {
|
|
class: `lvl-value`,
|
|
},
|
|
I = {
|
|
class: `lvl-grid`,
|
|
},
|
|
L = {
|
|
class: `lvl-item`,
|
|
},
|
|
R = {
|
|
key: 4,
|
|
class: `lvl-state`,
|
|
},
|
|
z = Object.assign(
|
|
_plugin_vue_export_helper_t(
|
|
defineComponent({
|
|
__name: `ClientLevelDialog`,
|
|
props: mergeModels(
|
|
{
|
|
accountLevel: {},
|
|
},
|
|
{
|
|
modelValue: {
|
|
type: Boolean,
|
|
default: !1,
|
|
},
|
|
modelModifiers: {},
|
|
},
|
|
),
|
|
emits: [`update:modelValue`],
|
|
setup(n) {
|
|
let h = useModel(n, `modelValue`),
|
|
x = useApi(),
|
|
z = ref(null),
|
|
B = ref(!1),
|
|
V = ref(``),
|
|
H = computed(() => z.value?.levels ?? []),
|
|
U = computed(() => {
|
|
// 将每个等级的 discount_list 转置为“商品行 × 等级列”,便于并排比较。
|
|
let e = {};
|
|
for (let t of H.value)
|
|
for (let n of t.discount_list ?? []) {
|
|
if (!n.product_name) continue;
|
|
let r = e[n.product_name] ?? (e[n.product_name] = {});
|
|
r[`level_${t.id}`] = n.discount_percent;
|
|
}
|
|
return Object.entries(e).map(([e, t]) => ({
|
|
product_name: e,
|
|
...t,
|
|
}));
|
|
});
|
|
function W(e, t) {
|
|
let n = e[`level_${t}`];
|
|
return n == null || n === `` ? `--` : `${n}%`;
|
|
}
|
|
function G(e) {
|
|
return `¥${Number(e ?? 0).toFixed(2)}`;
|
|
}
|
|
async function K() {
|
|
((B.value = !0), (V.value = ``));
|
|
try {
|
|
z.value = await x.get(`/client_level`);
|
|
} catch (e) {
|
|
V.value = e instanceof Error ? e.message : `等级信息加载失败`;
|
|
} finally {
|
|
B.value = !1;
|
|
}
|
|
}
|
|
return (
|
|
watch(h, (e) => {
|
|
e && K();
|
|
}),
|
|
(r, i) => {
|
|
let o = column,
|
|
l = datatable,
|
|
y = dialog;
|
|
return (
|
|
openBlock(),
|
|
createBlock(
|
|
y,
|
|
{
|
|
visible: h.value,
|
|
"onUpdate:visible": (i[0] ||= (e) => (h.value = e)),
|
|
header: `等级策略`,
|
|
modal: ``,
|
|
style: {
|
|
width: `min(720px, calc(100vw - 28px))`,
|
|
},
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
unref(B)
|
|
? (openBlock(), createElementBlock(`div`, E, `加载中…`))
|
|
: unref(V)
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
D,
|
|
toDisplayString(unref(V)),
|
|
1,
|
|
))
|
|
: unref(z) && unref(z).level_id > 0
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
{
|
|
key: 2,
|
|
},
|
|
[
|
|
createElementVNode(`div`, O, [
|
|
createElementVNode(`div`, k, [
|
|
(i[1] ||= createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-label`,
|
|
},
|
|
`我的等级`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-value`,
|
|
style: normalizeStyle({
|
|
color:
|
|
unref(z).background_color ||
|
|
void 0,
|
|
}),
|
|
},
|
|
toDisplayString(
|
|
unref(z).level_name || `普通会员`,
|
|
),
|
|
5,
|
|
),
|
|
]),
|
|
createElementVNode(`div`, A, [
|
|
(i[2] ||= createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-label`,
|
|
},
|
|
`等级有效期`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`span`,
|
|
j,
|
|
toDisplayString(
|
|
unref(z).cycle_end_time
|
|
? (`formatTime` in r
|
|
? r.formatTime
|
|
: unref(dict_r))(
|
|
unref(z).cycle_end_time,
|
|
)
|
|
: `长期有效`,
|
|
),
|
|
1,
|
|
),
|
|
]),
|
|
createElementVNode(`div`, M, [
|
|
(i[3] ||= createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-label`,
|
|
},
|
|
`当前周期消费`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`span`,
|
|
N,
|
|
toDisplayString(
|
|
G(unref(z).cycle_consume_amount),
|
|
),
|
|
1,
|
|
),
|
|
]),
|
|
createElementVNode(`div`, P, [
|
|
(i[4] ||= createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-label`,
|
|
},
|
|
`距下一等级`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`span`,
|
|
F,
|
|
toDisplayString(
|
|
unref(z).next_level_name
|
|
? `${unref(z).next_level_name} 还需 ${G(unref(z).next_level_need_amount)}`
|
|
: `已是最高等级`,
|
|
),
|
|
1,
|
|
),
|
|
]),
|
|
]),
|
|
(i[6] ||= createElementVNode(
|
|
`p`,
|
|
{
|
|
class: `lvl-desc`,
|
|
},
|
|
`等级折扣由系统在结算时自动应用;部分优惠码不可与等级折扣叠加,以下单页的实际价格为准。`,
|
|
-1,
|
|
)),
|
|
unref(U).length
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
{
|
|
key: 0,
|
|
},
|
|
[
|
|
(i[5] ||= createElementVNode(
|
|
`h4`,
|
|
{
|
|
class: `lvl-section`,
|
|
},
|
|
`等级折扣`,
|
|
-1,
|
|
)),
|
|
createVNode(
|
|
l,
|
|
{
|
|
value: unref(U),
|
|
size: `small`,
|
|
scrollable: ``,
|
|
scrollHeight: `400px`,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createVNode(
|
|
o,
|
|
{
|
|
field: `product_name`,
|
|
header: `商品`,
|
|
frozen: ``,
|
|
style: {
|
|
"min-width": `150px`,
|
|
},
|
|
},
|
|
{
|
|
body: withCtx(
|
|
({ data: t }) => [
|
|
createTextVNode(
|
|
toDisplayString(
|
|
unref(
|
|
product_name_n,
|
|
)(t.product_name),
|
|
),
|
|
1,
|
|
),
|
|
],
|
|
),
|
|
_: 1,
|
|
},
|
|
),
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
unref(H),
|
|
(t) => (
|
|
openBlock(),
|
|
createBlock(
|
|
o,
|
|
{
|
|
key: t.id,
|
|
style: {
|
|
"min-width": `100px`,
|
|
},
|
|
},
|
|
{
|
|
header: withCtx(
|
|
() => [
|
|
createElementVNode(
|
|
`span`,
|
|
{
|
|
style:
|
|
normalizeStyle(
|
|
{
|
|
color:
|
|
t.background_color ||
|
|
void 0,
|
|
},
|
|
),
|
|
},
|
|
toDisplayString(
|
|
t.name,
|
|
),
|
|
5,
|
|
),
|
|
],
|
|
),
|
|
body: withCtx(
|
|
({ data: n }) => [
|
|
createTextVNode(
|
|
toDisplayString(
|
|
W(n, t.id),
|
|
),
|
|
1,
|
|
),
|
|
],
|
|
),
|
|
_: 2,
|
|
},
|
|
1024,
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
]),
|
|
_: 1,
|
|
},
|
|
8,
|
|
[`value`],
|
|
),
|
|
],
|
|
64,
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
],
|
|
64,
|
|
))
|
|
: n.accountLevel
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
{
|
|
key: 3,
|
|
},
|
|
[
|
|
createElementVNode(`div`, I, [
|
|
createElementVNode(`div`, L, [
|
|
(i[7] ||= createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-label`,
|
|
},
|
|
`我的等级`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`span`,
|
|
{
|
|
class: `lvl-value`,
|
|
style: normalizeStyle({
|
|
color:
|
|
n.accountLevel
|
|
.background_color || void 0,
|
|
}),
|
|
},
|
|
toDisplayString(n.accountLevel.name),
|
|
5,
|
|
),
|
|
]),
|
|
]),
|
|
(i[8] ||= createElementVNode(
|
|
`p`,
|
|
{
|
|
class: `lvl-desc`,
|
|
},
|
|
`该等级没有公开的升级策略(下一等级与折扣范围由平台设置);下单时折扣会自动应用到价格。`,
|
|
-1,
|
|
)),
|
|
],
|
|
64,
|
|
))
|
|
: (openBlock(),
|
|
createElementBlock(`div`, R, `暂无等级信息`)),
|
|
]),
|
|
_: 1,
|
|
},
|
|
8,
|
|
[`visible`],
|
|
)
|
|
);
|
|
}
|
|
);
|
|
},
|
|
}),
|
|
[[`__scopeId`, `data-v-7c5ffb84`]],
|
|
),
|
|
{
|
|
__name: `ClientLevelDialog`,
|
|
},
|
|
);
|
|
export {};
|
|
export default z;
|
|
</script>
|