first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
@@ -0,0 +1,193 @@
|
||||
<script>
|
||||
import "~/assets/styles/PromoCodeField.qFEkB6Hm.css";
|
||||
import { toDisplayString } from "vue";
|
||||
import { normalizeClass } from "vue";
|
||||
import { mergeModels } from "vue";
|
||||
import { useModel } from "vue";
|
||||
import { watch } from "vue";
|
||||
import { createBlock } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { createCommentVNode } from "vue";
|
||||
import { isRef } from "vue";
|
||||
import { createElementBlock } from "vue";
|
||||
import { createElementVNode } from "vue";
|
||||
import { unref } from "vue";
|
||||
import { defineComponent } from "vue";
|
||||
import { createVNode } from "vue";
|
||||
import { openBlock } from "vue";
|
||||
import { withKeys } from "vue";
|
||||
import button from "primevue/button";
|
||||
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
||||
import inputtext from "primevue/inputtext";
|
||||
var y = [`open`],
|
||||
b = {
|
||||
class: `promo-body`,
|
||||
},
|
||||
x = Object.assign(
|
||||
_plugin_vue_export_helper_t(
|
||||
defineComponent({
|
||||
__name: `PromoCodeField`,
|
||||
props: mergeModels(
|
||||
{
|
||||
discount: {},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
{
|
||||
modelValue: {
|
||||
default: ``,
|
||||
},
|
||||
modelModifiers: {},
|
||||
},
|
||||
),
|
||||
emits: mergeModels([`recalc`], [`update:modelValue`]),
|
||||
setup(n, { emit: f }) {
|
||||
let _ = useModel(n, `modelValue`),
|
||||
x = n,
|
||||
S = f,
|
||||
C = ref(``),
|
||||
w = ref(!1),
|
||||
T = ref(`idle`);
|
||||
function E() {
|
||||
if (x.disabled || x.loading) return;
|
||||
let e = C.value.trim();
|
||||
e &&
|
||||
((w.value = !0), (T.value = `idle`), (_.value = e), S(`recalc`));
|
||||
}
|
||||
function D() {
|
||||
x.disabled ||
|
||||
x.loading ||
|
||||
((C.value = ``),
|
||||
(_.value = ``),
|
||||
(T.value = `idle`),
|
||||
(w.value = !1),
|
||||
S(`recalc`));
|
||||
}
|
||||
return (
|
||||
watch(
|
||||
() => x.loading,
|
||||
(e, t) => {
|
||||
t &&
|
||||
!e &&
|
||||
w.value &&
|
||||
((w.value = !1),
|
||||
(T.value = (x.discount ?? 0) > 0 ? `ok` : `fail`));
|
||||
},
|
||||
),
|
||||
watch(_, (e) => {
|
||||
!e && !w.value && ((C.value = ``), (T.value = `idle`));
|
||||
}),
|
||||
(r, i) => {
|
||||
let o = inputtext,
|
||||
f = button;
|
||||
return (
|
||||
openBlock(),
|
||||
createElementBlock(
|
||||
`details`,
|
||||
{
|
||||
class: `promo`,
|
||||
open: !!_.value,
|
||||
},
|
||||
[
|
||||
(i[1] ||= createElementVNode(
|
||||
`summary`,
|
||||
null,
|
||||
`我有优惠码,立即使用`,
|
||||
-1,
|
||||
)),
|
||||
createElementVNode(`div`, b, [
|
||||
createVNode(
|
||||
o,
|
||||
{
|
||||
modelValue: unref(C),
|
||||
"onUpdate:modelValue": (i[0] ||= (e) =>
|
||||
isRef(C) ? (C.value = e) : null),
|
||||
"aria-label": `优惠码`,
|
||||
placeholder: `选填,输入后点「使用」`,
|
||||
disabled: n.disabled,
|
||||
class: `promo-input`,
|
||||
onKeyup: withKeys(E, [`enter`]),
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`modelValue`, `disabled`],
|
||||
),
|
||||
createVNode(
|
||||
f,
|
||||
{
|
||||
label: `使用`,
|
||||
size: `small`,
|
||||
severity: `secondary`,
|
||||
outlined: ``,
|
||||
disabled: n.disabled || !unref(C).trim(),
|
||||
loading: unref(w),
|
||||
onClick: E,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`disabled`, `loading`],
|
||||
),
|
||||
_.value
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
f,
|
||||
{
|
||||
key: 0,
|
||||
label: `取消`,
|
||||
size: `small`,
|
||||
severity: `secondary`,
|
||||
text: ``,
|
||||
disabled: n.disabled,
|
||||
onClick: D,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`disabled`],
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
]),
|
||||
unref(T) === `idle`
|
||||
? createCommentVNode(``, !0)
|
||||
: (openBlock(),
|
||||
createElementBlock(
|
||||
`p`,
|
||||
{
|
||||
key: 0,
|
||||
class: normalizeClass([
|
||||
`promo-tip`,
|
||||
{
|
||||
ok: unref(T) === `ok`,
|
||||
fail: unref(T) === `fail`,
|
||||
},
|
||||
]),
|
||||
role: `status`,
|
||||
},
|
||||
toDisplayString(
|
||||
unref(T) === `ok`
|
||||
? `优惠码已生效,已优惠 ¥${(n.discount ?? 0).toFixed(2)}`
|
||||
: `该优惠码不可用`,
|
||||
),
|
||||
3,
|
||||
)),
|
||||
],
|
||||
8,
|
||||
y,
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
}),
|
||||
[[`__scopeId`, `data-v-a17e621a`]],
|
||||
),
|
||||
{
|
||||
__name: `PromoCodeField`,
|
||||
},
|
||||
);
|
||||
export {};
|
||||
export default x;
|
||||
</script>
|
||||
Reference in new issue
Block a user