From 6ad14fcddea92f430afb20ebb9462f5e729baa0c Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 13 Sep 2024 14:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=AD=9B=E9=80=89=E6=9C=AA=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=B4=AD=E4=B9=B0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=AD=9B=E9=80=89=E5=B7=B2=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- js/src/forum/components/pages/MyCartPage.tsx | 2 +- src/Controller/ListCartController.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/dist/forum.js b/js/dist/forum.js index dc7fb72..be451ae 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -(()=>{var t={n:a=>{var e=a&&a.__esModule?()=>a.default:()=>a;return t.d(e,{a:e}),e},d:(a,e)=>{for(var s in e)t.o(e,s)&&!t.o(a,s)&&Object.defineProperty(a,s,{enumerable:!0,get:e[s]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};(()=>{"use strict";t.r(a);const e=flarum.core.compat["forum/app"];var s=t.n(e);const o=flarum.core.compat["common/extend"],r=flarum.core.compat["forum/components/IndexPage"];var i=t.n(r);const n=flarum.core.compat["common/components/LinkButton"];var l=t.n(n);const c=flarum.core.compat["forum/components/UserPage"];var u=t.n(c);function p(t,a){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},p(t,a)}function d(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,p(t,a)}const h=flarum.core.compat["common/helpers/listItems"];var f=t.n(h);const y=flarum.core.compat["common/components/Button"];var v=t.n(y);const b=flarum.core.compat["common/utils/Stream"];var g=t.n(b);const D=flarum.core.compat.Component;var N=t.n(D);const x=flarum.core.compat["common/components/Modal"];var w=t.n(x);const R=flarum.core.compat["common/components/Switch"];var L=t.n(R);const C=flarum.core.compat["common/components/Select"];var P=t.n(C),T=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o0?a.replace("[money]",this.storeData.price):s().translator.trans("mattoid-store.forum.free"),o=a.replace("[money]",this.storeData.discountPrice);return m("div",{id:this.storeData.id,onclick:function(){return t.showDetails(t.storeData)}},m("div",{className:"itemTitle"},this.storeData.title),m("div",{className:"price spacing"},this.storeData.discountPrice>0?m("div",null,m("span",{className:"price"},o)," ",m("span",{className:"discount"},e)):m("span",{className:"price"},e)),m("div",{className:"spacing"},s().translator.trans("mattoid-store.lib.item-stock"),": ",-99==this.storeData.stock?s().translator.trans("mattoid-store.forum.infinite"):this.storeData.stock," | ",s().translator.trans("mattoid-store.lib.item-type-"+this.storeData.type)," ",m("span",{style:"limit"===this.storeData.type?"display:inline-block":"display: none"},"(",this.storeData.outtime,s().translator.trans("mattoid-store.forum.days"),")"),m("span",{style:"limit"===this.storeData.type&&this.storeData.autoDeduction?"display:inline-block":"display: none"}," | ",s().translator.trans("mattoid-store.lib.item-invalid",{day:this.storeData.outtime}))),m("div",{className:"spacing"},m("div",{id:"box"},this.storeData.desc)),m("div",{className:"spacing center"},m("img",{id:"logo-img",className:"icon-size",src:this.storeData.icon,style:this.storeData.icon&&".webm"===this.storeData.icon.slice(-5)?"display: none":""}),m("video",{id:"logo-video",autoplay:!0,loop:!0,muted:!0,playsinline:!0,className:"icon-size",poster:"https://invites.fun/assets/mattoid/store/1726117989_u9m3xRVtpxBiWYMn.png",style:this.storeData.icon&&".webm"===this.storeData.icon.slice(-5)?"":"display: none"},m("source",{src:this.storeData.icon,type:"video/webm"}))))},e.showDetails=function(t){s().session.user&&s().modal.show(T,{storeData:t})},a}(N()),B=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o0?e.replace("[money]",this.cartData.price):s().translator.trans("mattoid-store.forum.free"),r=this.cartData.payAmt>0?e.replace("[money]",this.cartData.payAmt):s().translator.trans("mattoid-store.forum.free");return m("div",{className:"frame"},m("div",{className:"row margin-top-10"},m("div",{className:"col-md-10"},m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-title"),": ")," ",m("span",{className:"color-green"},this.cartData.title),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-pay-amt"),": ")," ",m("span",{className:"color-red"},r),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-price"),": ")," ",m("span",{className:""},o)),m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-status"),": "),m("span",{className:a[this.cartData.status].class},a[this.cartData.status].value),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-type"),": ")," ",m("span",{className:(this.cartData.type,"")},"limit"==this.cartData.type?"限时有效":"永久有效"),"  | ","limit"==this.cartData.type?m("span",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-outtime"),": "),m("span",null,this.cartData.outtime)):""),m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-auto-deduction"),": "),m("span",{className:0==this.cartData.autoDeduction?"color-red":"color-green"},0==this.cartData.autoDeduction?"否":"是"),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-created"),": ")," ",m("span",{className:""},this.cartData.createdAt))),m("div",{className:"col-md-2",style:"height: 71px;line-height: 71px;"},1==this.cartData.enableType?v().component({type:"submit",className:"Button Button--primary margin-left-30",loading:this.loading,onclick:function(a){t.onsubmit(a)}},s().translator.trans(0==this.cartData.enable?"mattoid-store.lib.item-cart-button-use":"mattoid-store.lib.item-cart-button-cancel")):"")))},e.onsubmit=function(t){var a=this;t.preventDefault(),this.loading=!0,s().request({method:"POST",url:s().forum.attribute("apiUrl")+"/store/use/goods",body:this.params}).then((function(){return location.reload()}),(function(t){a.loading=!1}))},a}(N());const O=flarum.core.compat["components/Button"];var S=t.n(O),M=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o{var t={n:a=>{var e=a&&a.__esModule?()=>a.default:()=>a;return t.d(e,{a:e}),e},d:(a,e)=>{for(var s in e)t.o(e,s)&&!t.o(a,s)&&Object.defineProperty(a,s,{enumerable:!0,get:e[s]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};(()=>{"use strict";t.r(a);const e=flarum.core.compat["forum/app"];var s=t.n(e);const o=flarum.core.compat["common/extend"],r=flarum.core.compat["forum/components/IndexPage"];var i=t.n(r);const n=flarum.core.compat["common/components/LinkButton"];var l=t.n(n);const c=flarum.core.compat["forum/components/UserPage"];var u=t.n(c);function p(t,a){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},p(t,a)}function d(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,p(t,a)}const h=flarum.core.compat["common/helpers/listItems"];var f=t.n(h);const y=flarum.core.compat["common/components/Button"];var v=t.n(y);const b=flarum.core.compat["common/utils/Stream"];var g=t.n(b);const D=flarum.core.compat.Component;var N=t.n(D);const x=flarum.core.compat["common/components/Modal"];var w=t.n(x);const R=flarum.core.compat["common/components/Switch"];var L=t.n(R);const C=flarum.core.compat["common/components/Select"];var P=t.n(C),T=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o0?a.replace("[money]",this.storeData.price):s().translator.trans("mattoid-store.forum.free"),o=a.replace("[money]",this.storeData.discountPrice);return m("div",{id:this.storeData.id,onclick:function(){return t.showDetails(t.storeData)}},m("div",{className:"itemTitle"},this.storeData.title),m("div",{className:"price spacing"},this.storeData.discountPrice>0?m("div",null,m("span",{className:"price"},o)," ",m("span",{className:"discount"},e)):m("span",{className:"price"},e)),m("div",{className:"spacing"},s().translator.trans("mattoid-store.lib.item-stock"),": ",-99==this.storeData.stock?s().translator.trans("mattoid-store.forum.infinite"):this.storeData.stock," | ",s().translator.trans("mattoid-store.lib.item-type-"+this.storeData.type)," ",m("span",{style:"limit"===this.storeData.type?"display:inline-block":"display: none"},"(",this.storeData.outtime,s().translator.trans("mattoid-store.forum.days"),")"),m("span",{style:"limit"===this.storeData.type&&this.storeData.autoDeduction?"display:inline-block":"display: none"}," | ",s().translator.trans("mattoid-store.lib.item-invalid",{day:this.storeData.outtime}))),m("div",{className:"spacing"},m("div",{id:"box"},this.storeData.desc)),m("div",{className:"spacing center"},m("img",{id:"logo-img",className:"icon-size",src:this.storeData.icon,style:this.storeData.icon&&".webm"===this.storeData.icon.slice(-5)?"display: none":""}),m("video",{id:"logo-video",autoplay:!0,loop:!0,muted:!0,playsinline:!0,className:"icon-size",poster:"https://invites.fun/assets/mattoid/store/1726117989_u9m3xRVtpxBiWYMn.png",style:this.storeData.icon&&".webm"===this.storeData.icon.slice(-5)?"":"display: none"},m("source",{src:this.storeData.icon,type:"video/webm"}))))},e.showDetails=function(t){s().session.user&&s().modal.show(T,{storeData:t})},a}(N()),B=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o0?e.replace("[money]",this.cartData.price):s().translator.trans("mattoid-store.forum.free"),r=this.cartData.payAmt>0?e.replace("[money]",this.cartData.payAmt):s().translator.trans("mattoid-store.forum.free");return m("div",{className:"frame"},m("div",{className:"row margin-top-10"},m("div",{className:"col-md-10"},m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-title"),": ")," ",m("span",{className:"color-green"},this.cartData.title),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-pay-amt"),": ")," ",m("span",{className:"color-red"},r),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-price"),": ")," ",m("span",{className:""},o)),m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-status"),": "),m("span",{className:a[this.cartData.status].class},a[this.cartData.status].value),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-type"),": ")," ",m("span",{className:(this.cartData.type,"")},"limit"==this.cartData.type?"限时有效":"永久有效"),"  | ","limit"==this.cartData.type?m("span",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-outtime"),": "),m("span",null,this.cartData.outtime)):""),m("div",null,m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-auto-deduction"),": "),m("span",{className:0==this.cartData.autoDeduction?"color-red":"color-green"},0==this.cartData.autoDeduction?"否":"是"),"  | ",m("label",{className:"Cart-Label"},s().translator.trans("mattoid-store.lib.item-cart-created"),": ")," ",m("span",{className:""},this.cartData.createdAt))),m("div",{className:"col-md-2",style:"height: 71px;line-height: 71px;"},1==this.cartData.enableType?v().component({type:"submit",className:"Button Button--primary margin-left-30",loading:this.loading,onclick:function(a){t.onsubmit(a)}},s().translator.trans(0==this.cartData.enable?"mattoid-store.lib.item-cart-button-use":"mattoid-store.lib.item-cart-button-cancel")):"")))},e.onsubmit=function(t){var a=this;t.preventDefault(),this.loading=!0,s().request({method:"POST",url:s().forum.attribute("apiUrl")+"/store/use/goods",body:this.params}).then((function(){return location.reload()}),(function(t){a.loading=!1}))},a}(N());const O=flarum.core.compat["components/Button"];var S=t.n(O),M=function(t){function a(){for(var a,e=arguments.length,s=new Array(e),o=0;o {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LinkButton'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/Stream'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Switch'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Select'];","import Modal, {IInternalModalAttrs} from \"flarum/common/components/Modal\";\nimport type Mithril from \"mithril\";\nimport Stream from \"flarum/common/utils/Stream\";\nimport Button from 'flarum/common/components/Button';\nimport Switch from 'flarum/common/components/Switch';\nimport Select from \"flarum/common/components/Select\";\nimport TextEditor from 'flarum/common/components/TextEditor'\n\ninterface IStoreModalAttrs extends IInternalModalAttrs {\n storeData: object\n}\n\nexport default class StoreBox extends Modal {\n private storeData: object = {}\n private params: object = {}\n private range: boolean = false\n\n static initAttrs(attrs: IStoreModalAttrs) {\n super.initAttrs(attrs);\n }\n\n oninit(vnode: Mithril.Vnode) {\n super.oninit(vnode);\n\n this.storeData = this.attrs.storeData;\n this.params.id = this.attrs.storeData.id;\n }\n\n title() {\n return this.storeData.title;\n }\n\n className(): string {\n return this.storeData.className;\n }\n\n content() {\n return m('.Modal-body', [\n this.getHtml(JSON.parse(this.storeData.popUp)),\n m('.Form-group .center', [\n Button.component({\n type: 'submit',\n className: 'Button Button--primary',\n loading: this.loading,\n // disabled: parseFloat(this.amount || '0') <= 0,\n }, app.translator.trans('mattoid-store.forum.button'))\n ])\n ])\n }\n\n getHtml(popUp) {\n return popUp.map((item) => {\n return this.getInput(item);\n })\n }\n\n getInput(column) {\n let input;\n\n switch (column.prop) {\n case 'input':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n m('input.FormControl', {\n type: column.type || 'text',\n value: this.params[column.value],\n onchange: (event: InputEvent) => {\n this.params[column.value] = (event.target as HTMLInputElement).value;\n },\n min: 0,\n step: 0.1,\n disabled: this.loading,\n })\n ])\n )\n break;\n case 'switch':\n input = (\n m('.Form-group', [\n Switch.component({\n state: this.range,\n onchange: (value: boolean) => {\n this.range = value;\n this.params[column.value] = value\n },\n disabled: this.loading,\n }, app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText))\n ])\n )\n break;\n case 'select':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n Select.component({\n value: this.params[column.value],\n disabled: this.loading,\n options: column.options,\n buttonClassName: \"Button\",\n onchange: (val) => {\n this.params[column.value] = val\n }\n })\n ])\n )\n break;\n case 'textarea':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n m('textarea.FormControl', {\n value: this.params[column.value],\n onchange: (event: InputEvent) => {\n this.params[column.value] = (event.target as HTMLInputElement).value;\n },\n })\n ])\n )\n break\n }\n\n return input;\n }\n\n onsubmit(event: Event) {\n event.preventDefault();\n this.loading = true;\n\n app.request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/store/buy/goods',\n body: this.params\n }).then(\n () => location.reload(),\n (result) => {\n this.loading = false;\n // this.handleErrors(result);\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport Component from \"flarum/Component\";\nimport StoreBox from \"../modal/StoreBox\";\n\nexport default class StoreItem extends Component {\n private storeData: object = {}\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.storeData = this.attrs.item.attributes\n this.storeData.id = this.attrs.item.id\n }\n\n view() {\n const moneyName = app.forum.attribute('antoinefr-money.moneyname') || '[money]';\n const price = this.storeData.price > 0 ? moneyName.replace('[money]', this.storeData.price) : app.translator.trans('mattoid-store.forum.free');\n const discountPrice = moneyName.replace('[money]', this.storeData.discountPrice);\n\n return (\n
this.showDetails(this.storeData)}>\n
\n {this.storeData.title}\n
\n
\n {this.storeData.discountPrice > 0 ?\n (\n
\n {discountPrice} \n {price}\n
\n ) :\n ({price})}\n
\n
\n {app.translator.trans('mattoid-store.lib.item-stock')}: {this.storeData.stock == -99 ? app.translator.trans('mattoid-store.forum.infinite') : this.storeData.stock } | \n {app.translator.trans('mattoid-store.lib.item-type-' + this.storeData.type)} \n ({this.storeData.outtime}{app.translator.trans('mattoid-store.forum.days')})\n  | {app.translator.trans('mattoid-store.lib.item-invalid', {'day' : this.storeData.outtime})}\n
\n
\n
\n {this.storeData.desc}\n
\n
\n
\n \n \n
\n
\n )\n }\n\n showDetails(storeData) {\n if (app.session.user) {\n app.modal.show(StoreBox, {storeData});\n }\n }\n}\n","import IndexPage from \"flarum/forum/components/IndexPage\";\nimport { IPageAttrs } from 'flarum/common/components/Page';\nimport listItems from 'flarum/common/helpers/listItems';\nimport Mithril from 'mithril';\nimport Button from \"flarum/common/components/Button\";\nimport Stream from \"flarum/common/utils/Stream\";\nimport StoreItem from \"../component/StoreItem\";\n\nexport interface IIndexPageAttrs extends IPageAttrs {}\n\nexport default class StorePage extends IndexPage {\n\n private storeList: any = []\n private moreResults: boolean = false\n\n oncreate(vnode: Mithril.VnodeDOM) {\n super.oncreate(vnode);\n\n app.setTitle(app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital'));\n app.setTitleCount(0);\n\n this.status = Stream('1');\n this.type = Stream('-1');\n\n this.loadResults();\n }\n\n view() {\n return (\n
\n
\n
\n \n
\n

{app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital')}

\n
\n {\n this.storeList.map((item) => {\n if (!item.attributes.hide || app.session.user.attribute('can'+item.attributes.code.slice(0, 1).toUpperCase()+item.attributes.code.slice(1)+'View')) {\n return (\n
\n {StoreItem.component({ item })}\n
\n );\n }\n })\n }\n
\n\n {!this.loading && this.storeList.length === 0 && (\n
\n
\n {app.translator.trans('mattoid-store.lib.list-empty')}\n
\n
\n )}\n\n {!this.loading && this.hasMoreResults() && (\n
\n \n
\n )}\n\n
\n
\n
\n
\n )\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.storeList.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.storeList, results.payload.data);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n loadResults(offset = 0) {\n const filters = {\n type: this.type(),\n status: this.status()\n };\n\n return app.store\n .find(\"/store/list\", {\n filter:filters,\n page: {\n offset,\n },\n })\n .catch(() => {})\n .then(this.parseResults.bind(this));\n }\n\n}\n","import app from 'flarum/forum/app';\nimport Component from \"flarum/Component\";\nimport Button from \"flarum/common/components/Button\";\n\nexport default class StoreItem extends Component {\n\n private cartData: any = {};\n private params: any = {};\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.cartData = this.attrs.item.attributes;\n this.params.id = this.attrs.item.id;\n }\n\n view() {\n const statusStr = {\n 0: {\n class: '',\n value: '未支付'\n },\n 1: {\n class: 'color-green',\n value: '已支付'\n },\n 2: {\n class: 'color-red',\n value: '已失效'\n },\n 9: {\n class: 'color-coral',\n value: '超时失效'\n }\n }\n const moneyName = app.forum.attribute('antoinefr-money.moneyname') || '[money]';\n const price = this.cartData.price > 0 ? moneyName.replace('[money]', this.cartData.price) : app.translator.trans('mattoid-store.forum.free');\n const payAmt = this.cartData.payAmt > 0 ? moneyName.replace('[money]', this.cartData.payAmt) : app.translator.trans('mattoid-store.forum.free');\n return (\n
\n
\n
\n
\n {this.cartData.title}  | \n {payAmt}  | \n {price}\n
\n
\n \n {statusStr[this.cartData.status].value}  | \n {this.cartData.type == 'limit' ? \"限时有效\" : \"永久有效\"}  | \n {\n this.cartData.type == 'limit' ?\n (\n \n {this.cartData.outtime}\n ) : \"\"\n }\n
\n
\n {app.translator.trans('mattoid-store.lib.item-cart-auto-deduction')}: \n {this.cartData.autoDeduction == 0 ? \"否\" : \"是\"}  | \n {this.cartData.createdAt}\n
\n
\n
\n {\n this.cartData.enableType == 1 ?\n Button.component({\n type: 'submit',\n className: 'Button Button--primary margin-left-30',\n loading: this.loading,\n onclick: (e) => {\n this.onsubmit(e)\n }\n }, app.translator.trans(this.cartData.enable == 0 ? 'mattoid-store.lib.item-cart-button-use' : 'mattoid-store.lib.item-cart-button-cancel'))\n : \"\"\n }\n
\n
\n
\n )\n }\n\n onsubmit(event: Event) {\n event.preventDefault();\n this.loading = true;\n\n app.request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/store/use/goods',\n body: this.params\n }).then(\n () => location.reload(),\n (result) => {\n this.loading = false;\n // this.handleErrors(result);\n });\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","import app from 'flarum/forum/app';\n\nimport UserPage from 'flarum/forum/components/UserPage';\nimport CartItem from \"../component/CartItem\";\nimport Button from 'flarum/components/Button';\nimport Select from \"flarum/common/components/Select\";\nimport Stream from \"flarum/common/utils/Stream\";\n\nexport default class MyCartPage extends UserPage {\n\n private type: number = Stream(\"\");\n private status: number = Stream(\"-1\");\n private autoDeduction: number = Stream(\"-1\");\n private cartList: any = []\n private moreResults: boolean = false\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loadUser(m.route.param('username'));\n\n this.loadResults();\n }\n\n content() {\n return (\n
\n

{app.translator.trans('mattoid-store.forum.cart')}

\n
\n
\n {\n this.status(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n {\n this.type(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n {\n this.autoDeduction(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n
\n {\n this.cartList.map((item) => {\n return (\n
\n {CartItem.component({item})}\n
\n );\n })\n }\n\n {!this.loading && this.cartList.length === 0 && (\n
\n
\n {app.translator.trans('mattoid-store.lib.list-empty')}\n
\n
\n )}\n\n {!this.loading && this.hasMoreResults() && (\n
\n \n
\n )}\n
\n
\n );\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.cartList.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.cartList, results.payload.data);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n loadResults(offset = 0) {\n const filters = {\n 'type': this.type(),\n 'status': this.status(),\n 'autoDeduction': this.autoDeduction()\n };\n return app.store\n .find(\"/store/cart/list\", {\n filter: filters,\n page: {\n offset,\n },\n })\n .catch(() => {\n })\n .then(this.parseResults.bind(this));\n }\n}\n","import app from 'flarum/forum/app';\nimport {extend} from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport StorePage from \"./components/pages/StorePage\";\nimport MyCartPage from \"./components/pages/MyCartPage\";\n\napp.initializers.add('mattoid/store', () => {\n app.routes.store = {\n path: '/store',\n component: StorePage,\n };\n app.routes.myCartPage = {\n path: '/u/:username/cart',\n component: MyCartPage,\n };\n\n extend(UserPage.prototype, 'navItems', function(items) {\n if (!app.session || !app.session.user || !app.session.user.attribute('canStoreView')) {\n return false;\n }\n\n items.add('myCartPage', LinkButton.component({\n href: app.route('myCartPage', {\n username: this.user.slug(),\n }),\n icon: 'fas fa-shopping-cart',\n }, app.translator.trans('mattoid-store.forum.cart')));\n });\n\n extend(IndexPage.prototype, 'navItems', function (items) {\n if (!app.session || !app.session.user || !app.session.user.attribute('canStoreView')) {\n return false;\n }\n\n items.add('store', LinkButton.component({\n href: app.route('store'),\n icon: 'fas fa-store',\n }, app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital')));\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","StoreBox","_Modal","_this","_len","arguments","length","args","Array","_key","apply","concat","storeData","params","range","initAttrs","attrs","_proto","oninit","vnode","this","id","title","className","content","m","getHtml","JSON","parse","popUp","Button","type","loading","app","translator","trans","_this2","map","item","getInput","column","input","_this3","label","helpText","onchange","event","target","min","step","disabled","Switch","state","Select","options","buttonClassName","val","onsubmit","_this4","preventDefault","request","method","url","forum","attribute","body","then","location","reload","result","Modal","StoreItem","_Component","attributes","view","moneyName","price","replace","discountPrice","onclick","showDetails","stock","style","outtime","autoDeduction","desc","src","icon","slice","autoplay","loop","muted","playsinline","poster","user","show","Component","StorePage","_IndexPage","storeList","moreResults","oncreate","setTitle","setTitleCount","status","Stream","loadResults","listItems","sidebarItems","toArray","class","hide","session","code","toUpperCase","component","hasMoreResults","loadMore","parseResults","results","payload","links","next","push","data","redraw","offset","filters","store","find","filter","page","IndexPage","cartData","statusStr","payAmt","createdAt","enableType","e","enable","MyCartPage","_UserPage","cartList","loadUser","route","param","CartItem","UserPage","add","path","myCartPage","extend","items","LinkButton","href","username","slug"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,iBCAlD,EAA+BF,OAAOC,KAA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KW,OACb,OAAUX,KAAKoF,SACf,cAAiBpF,KAAKgE,iBAExB,OAAOnD,IAAAA,MACJgG,KAAK,mBAAoB,CACxBC,OAAQH,EACRI,KAAM,CACJL,OAAAA,KAEF,OACK,WACP,IACC5D,KAAK9C,KAAKkG,aAAa5H,KAAK0B,MACjC,EAACwH,CAAA,CA5I4B,CAASO,KCAxClH,IAAAA,aAAiBmH,IAAI,iBAAiB,WACpCnH,IAAAA,OAAW+F,MAAQ,CACjBqB,KAAM,SACNlC,UAAWlB,GAEbhE,IAAAA,OAAWqH,WAAa,CACtBD,KAAM,oBACNlC,UAAWyB,IAGbW,EAAAA,EAAAA,QAAOJ,IAAAA,UAAoB,YAAY,SAASK,GAC9C,IAAKvH,IAAAA,UAAgBA,IAAAA,QAAY6D,OAAS7D,IAAAA,QAAY6D,KAAK9B,UAAU,gBACnE,OAAO,EAGTwF,EAAMJ,IAAI,aAAcK,IAAAA,UAAqB,CAC3CC,KAAMzH,IAAAA,MAAU,aAAc,CAC5B0H,SAAUvI,KAAK0E,KAAK8D,SAEtBrE,KAAM,wBACLtD,IAAAA,WAAeE,MAAM,6BAC1B,KAEAoH,EAAAA,EAAAA,QAAOnB,IAAAA,UAAqB,YAAY,SAAUoB,GAChD,IAAKvH,IAAAA,UAAgBA,IAAAA,QAAY6D,OAAS7D,IAAAA,QAAY6D,KAAK9B,UAAU,gBACnE,OAAO,EAGTwF,EAAMJ,IAAI,QAASK,IAAAA,UAAqB,CACtCC,KAAMzH,IAAAA,MAAU,SAChBsD,KAAM,gBACLtD,IAAAA,MAAU+B,UAAU,cAAgB/B,IAAAA,WAAeE,MAAM,8BAC9D,GACF,G","sources":["webpack://@mattoid/store/webpack/bootstrap","webpack://@mattoid/store/webpack/runtime/compat get default export","webpack://@mattoid/store/webpack/runtime/define property getters","webpack://@mattoid/store/webpack/runtime/hasOwnProperty shorthand","webpack://@mattoid/store/webpack/runtime/make namespace object","webpack://@mattoid/store/external root \"flarum.core.compat['forum/app']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/extend']\"","webpack://@mattoid/store/external root \"flarum.core.compat['forum/components/IndexPage']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/components/LinkButton']\"","webpack://@mattoid/store/external root \"flarum.core.compat['forum/components/UserPage']\"","webpack://@mattoid/store/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@mattoid/store/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@mattoid/store/external root \"flarum.core.compat['common/helpers/listItems']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/components/Button']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/utils/Stream']\"","webpack://@mattoid/store/external root \"flarum.core.compat['Component']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/components/Modal']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/components/Switch']\"","webpack://@mattoid/store/external root \"flarum.core.compat['common/components/Select']\"","webpack://@mattoid/store/./src/forum/components/modal/StoreBox.tsx","webpack://@mattoid/store/./src/forum/components/component/StoreItem.tsx","webpack://@mattoid/store/./src/forum/components/pages/StorePage.tsx","webpack://@mattoid/store/./src/forum/components/component/CartItem.tsx","webpack://@mattoid/store/external root \"flarum.core.compat['components/Button']\"","webpack://@mattoid/store/./src/forum/components/pages/MyCartPage.tsx","webpack://@mattoid/store/./src/forum/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LinkButton'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/Stream'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Switch'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Select'];","import Modal, {IInternalModalAttrs} from \"flarum/common/components/Modal\";\nimport type Mithril from \"mithril\";\nimport Stream from \"flarum/common/utils/Stream\";\nimport Button from 'flarum/common/components/Button';\nimport Switch from 'flarum/common/components/Switch';\nimport Select from \"flarum/common/components/Select\";\nimport TextEditor from 'flarum/common/components/TextEditor'\n\ninterface IStoreModalAttrs extends IInternalModalAttrs {\n storeData: object\n}\n\nexport default class StoreBox extends Modal {\n private storeData: object = {}\n private params: object = {}\n private range: boolean = false\n\n static initAttrs(attrs: IStoreModalAttrs) {\n super.initAttrs(attrs);\n }\n\n oninit(vnode: Mithril.Vnode) {\n super.oninit(vnode);\n\n this.storeData = this.attrs.storeData;\n this.params.id = this.attrs.storeData.id;\n }\n\n title() {\n return this.storeData.title;\n }\n\n className(): string {\n return this.storeData.className;\n }\n\n content() {\n return m('.Modal-body', [\n this.getHtml(JSON.parse(this.storeData.popUp)),\n m('.Form-group .center', [\n Button.component({\n type: 'submit',\n className: 'Button Button--primary',\n loading: this.loading,\n // disabled: parseFloat(this.amount || '0') <= 0,\n }, app.translator.trans('mattoid-store.forum.button'))\n ])\n ])\n }\n\n getHtml(popUp) {\n return popUp.map((item) => {\n return this.getInput(item);\n })\n }\n\n getInput(column) {\n let input;\n\n switch (column.prop) {\n case 'input':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n m('input.FormControl', {\n type: column.type || 'text',\n value: this.params[column.value],\n onchange: (event: InputEvent) => {\n this.params[column.value] = (event.target as HTMLInputElement).value;\n },\n min: 0,\n step: 0.1,\n disabled: this.loading,\n })\n ])\n )\n break;\n case 'switch':\n input = (\n m('.Form-group', [\n Switch.component({\n state: this.range,\n onchange: (value: boolean) => {\n this.range = value;\n this.params[column.value] = value\n },\n disabled: this.loading,\n }, app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText))\n ])\n )\n break;\n case 'select':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n Select.component({\n value: this.params[column.value],\n disabled: this.loading,\n options: column.options,\n buttonClassName: \"Button\",\n onchange: (val) => {\n this.params[column.value] = val\n }\n })\n ])\n )\n break;\n case 'textarea':\n input = (\n m('.Form-group', [\n m('label', app.translator.trans(column.label)),\n m('.helpText', app.translator.trans(column.helpText)),\n m('textarea.FormControl', {\n value: this.params[column.value],\n onchange: (event: InputEvent) => {\n this.params[column.value] = (event.target as HTMLInputElement).value;\n },\n })\n ])\n )\n break\n }\n\n return input;\n }\n\n onsubmit(event: Event) {\n event.preventDefault();\n this.loading = true;\n\n app.request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/store/buy/goods',\n body: this.params\n }).then(\n () => location.reload(),\n (result) => {\n this.loading = false;\n // this.handleErrors(result);\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport Component from \"flarum/Component\";\nimport StoreBox from \"../modal/StoreBox\";\n\nexport default class StoreItem extends Component {\n private storeData: object = {}\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.storeData = this.attrs.item.attributes\n this.storeData.id = this.attrs.item.id\n }\n\n view() {\n const moneyName = app.forum.attribute('antoinefr-money.moneyname') || '[money]';\n const price = this.storeData.price > 0 ? moneyName.replace('[money]', this.storeData.price) : app.translator.trans('mattoid-store.forum.free');\n const discountPrice = moneyName.replace('[money]', this.storeData.discountPrice);\n\n return (\n
this.showDetails(this.storeData)}>\n
\n {this.storeData.title}\n
\n
\n {this.storeData.discountPrice > 0 ?\n (\n
\n {discountPrice} \n {price}\n
\n ) :\n ({price})}\n
\n
\n {app.translator.trans('mattoid-store.lib.item-stock')}: {this.storeData.stock == -99 ? app.translator.trans('mattoid-store.forum.infinite') : this.storeData.stock } | \n {app.translator.trans('mattoid-store.lib.item-type-' + this.storeData.type)} \n ({this.storeData.outtime}{app.translator.trans('mattoid-store.forum.days')})\n  | {app.translator.trans('mattoid-store.lib.item-invalid', {'day' : this.storeData.outtime})}\n
\n
\n
\n {this.storeData.desc}\n
\n
\n
\n \n \n
\n
\n )\n }\n\n showDetails(storeData) {\n if (app.session.user) {\n app.modal.show(StoreBox, {storeData});\n }\n }\n}\n","import IndexPage from \"flarum/forum/components/IndexPage\";\nimport { IPageAttrs } from 'flarum/common/components/Page';\nimport listItems from 'flarum/common/helpers/listItems';\nimport Mithril from 'mithril';\nimport Button from \"flarum/common/components/Button\";\nimport Stream from \"flarum/common/utils/Stream\";\nimport StoreItem from \"../component/StoreItem\";\n\nexport interface IIndexPageAttrs extends IPageAttrs {}\n\nexport default class StorePage extends IndexPage {\n\n private storeList: any = []\n private moreResults: boolean = false\n\n oncreate(vnode: Mithril.VnodeDOM) {\n super.oncreate(vnode);\n\n app.setTitle(app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital'));\n app.setTitleCount(0);\n\n this.status = Stream('1');\n this.type = Stream('-1');\n\n this.loadResults();\n }\n\n view() {\n return (\n
\n
\n
\n \n
\n

{app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital')}

\n
\n {\n this.storeList.map((item) => {\n if (!item.attributes.hide || app.session.user.attribute('can'+item.attributes.code.slice(0, 1).toUpperCase()+item.attributes.code.slice(1)+'View')) {\n return (\n
\n {StoreItem.component({ item })}\n
\n );\n }\n })\n }\n
\n\n {!this.loading && this.storeList.length === 0 && (\n
\n
\n {app.translator.trans('mattoid-store.lib.list-empty')}\n
\n
\n )}\n\n {!this.loading && this.hasMoreResults() && (\n
\n \n
\n )}\n\n
\n
\n
\n
\n )\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.storeList.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.storeList, results.payload.data);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n loadResults(offset = 0) {\n const filters = {\n type: this.type(),\n status: this.status()\n };\n\n return app.store\n .find(\"/store/list\", {\n filter:filters,\n page: {\n offset,\n },\n })\n .catch(() => {})\n .then(this.parseResults.bind(this));\n }\n\n}\n","import app from 'flarum/forum/app';\nimport Component from \"flarum/Component\";\nimport Button from \"flarum/common/components/Button\";\n\nexport default class StoreItem extends Component {\n\n private cartData: any = {};\n private params: any = {};\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.cartData = this.attrs.item.attributes;\n this.params.id = this.attrs.item.id;\n }\n\n view() {\n const statusStr = {\n 0: {\n class: '',\n value: '未支付'\n },\n 1: {\n class: 'color-green',\n value: '已支付'\n },\n 2: {\n class: 'color-red',\n value: '已失效'\n },\n 9: {\n class: 'color-coral',\n value: '超时失效'\n }\n }\n const moneyName = app.forum.attribute('antoinefr-money.moneyname') || '[money]';\n const price = this.cartData.price > 0 ? moneyName.replace('[money]', this.cartData.price) : app.translator.trans('mattoid-store.forum.free');\n const payAmt = this.cartData.payAmt > 0 ? moneyName.replace('[money]', this.cartData.payAmt) : app.translator.trans('mattoid-store.forum.free');\n return (\n
\n
\n
\n
\n {this.cartData.title}  | \n {payAmt}  | \n {price}\n
\n
\n \n {statusStr[this.cartData.status].value}  | \n {this.cartData.type == 'limit' ? \"限时有效\" : \"永久有效\"}  | \n {\n this.cartData.type == 'limit' ?\n (\n \n {this.cartData.outtime}\n ) : \"\"\n }\n
\n
\n {app.translator.trans('mattoid-store.lib.item-cart-auto-deduction')}: \n {this.cartData.autoDeduction == 0 ? \"否\" : \"是\"}  | \n {this.cartData.createdAt}\n
\n
\n
\n {\n this.cartData.enableType == 1 ?\n Button.component({\n type: 'submit',\n className: 'Button Button--primary margin-left-30',\n loading: this.loading,\n onclick: (e) => {\n this.onsubmit(e)\n }\n }, app.translator.trans(this.cartData.enable == 0 ? 'mattoid-store.lib.item-cart-button-use' : 'mattoid-store.lib.item-cart-button-cancel'))\n : \"\"\n }\n
\n
\n
\n )\n }\n\n onsubmit(event: Event) {\n event.preventDefault();\n this.loading = true;\n\n app.request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/store/use/goods',\n body: this.params\n }).then(\n () => location.reload(),\n (result) => {\n this.loading = false;\n // this.handleErrors(result);\n });\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","import app from 'flarum/forum/app';\n\nimport UserPage from 'flarum/forum/components/UserPage';\nimport CartItem from \"../component/CartItem\";\nimport Button from 'flarum/components/Button';\nimport Select from \"flarum/common/components/Select\";\nimport Stream from \"flarum/common/utils/Stream\";\n\nexport default class MyCartPage extends UserPage {\n\n private type: number = Stream(\"\");\n private status: number = Stream(\"1\");\n private autoDeduction: number = Stream(\"-1\");\n private cartList: any = []\n private moreResults: boolean = false\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loadUser(m.route.param('username'));\n\n this.loadResults();\n }\n\n content() {\n return (\n
\n

{app.translator.trans('mattoid-store.forum.cart')}

\n
\n
\n {\n this.status(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n {\n this.type(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n {\n this.autoDeduction(e)\n this.cartList = []\n this.loadResults()\n }}\n />\n
\n
\n
\n {\n this.cartList.map((item) => {\n return (\n
\n {CartItem.component({item})}\n
\n );\n })\n }\n\n {!this.loading && this.cartList.length === 0 && (\n
\n
\n {app.translator.trans('mattoid-store.lib.list-empty')}\n
\n
\n )}\n\n {!this.loading && this.hasMoreResults() && (\n
\n \n
\n )}\n
\n
\n );\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.cartList.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.cartList, results.payload.data);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n loadResults(offset = 0) {\n const filters = {\n 'type': this.type(),\n 'status': this.status(),\n 'autoDeduction': this.autoDeduction()\n };\n return app.store\n .find(\"/store/cart/list\", {\n filter: filters,\n page: {\n offset,\n },\n })\n .catch(() => {\n })\n .then(this.parseResults.bind(this));\n }\n}\n","import app from 'flarum/forum/app';\nimport {extend} from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport StorePage from \"./components/pages/StorePage\";\nimport MyCartPage from \"./components/pages/MyCartPage\";\n\napp.initializers.add('mattoid/store', () => {\n app.routes.store = {\n path: '/store',\n component: StorePage,\n };\n app.routes.myCartPage = {\n path: '/u/:username/cart',\n component: MyCartPage,\n };\n\n extend(UserPage.prototype, 'navItems', function(items) {\n if (!app.session || !app.session.user || !app.session.user.attribute('canStoreView')) {\n return false;\n }\n\n items.add('myCartPage', LinkButton.component({\n href: app.route('myCartPage', {\n username: this.user.slug(),\n }),\n icon: 'fas fa-shopping-cart',\n }, app.translator.trans('mattoid-store.forum.cart')));\n });\n\n extend(IndexPage.prototype, 'navItems', function (items) {\n if (!app.session || !app.session.user || !app.session.user.attribute('canStoreView')) {\n return false;\n }\n\n items.add('store', LinkButton.component({\n href: app.route('store'),\n icon: 'fas fa-store',\n }, app.forum.attribute(\"storeName\") || app.translator.trans('mattoid-store.forum.tital')));\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","StoreBox","_Modal","_this","_len","arguments","length","args","Array","_key","apply","concat","storeData","params","range","initAttrs","attrs","_proto","oninit","vnode","this","id","title","className","content","m","getHtml","JSON","parse","popUp","Button","type","loading","app","translator","trans","_this2","map","item","getInput","column","input","_this3","label","helpText","onchange","event","target","min","step","disabled","Switch","state","Select","options","buttonClassName","val","onsubmit","_this4","preventDefault","request","method","url","forum","attribute","body","then","location","reload","result","Modal","StoreItem","_Component","attributes","view","moneyName","price","replace","discountPrice","onclick","showDetails","stock","style","outtime","autoDeduction","desc","src","icon","slice","autoplay","loop","muted","playsinline","poster","user","show","Component","StorePage","_IndexPage","storeList","moreResults","oncreate","setTitle","setTitleCount","status","Stream","loadResults","listItems","sidebarItems","toArray","class","hide","session","code","toUpperCase","component","hasMoreResults","loadMore","parseResults","results","payload","links","next","push","data","redraw","offset","filters","store","find","filter","page","IndexPage","cartData","statusStr","payAmt","createdAt","enableType","e","enable","MyCartPage","_UserPage","cartList","loadUser","route","param","CartItem","UserPage","add","path","myCartPage","extend","items","LinkButton","href","username","slug"],"sourceRoot":""} \ No newline at end of file diff --git a/js/src/forum/components/pages/MyCartPage.tsx b/js/src/forum/components/pages/MyCartPage.tsx index b712b74..537869f 100644 --- a/js/src/forum/components/pages/MyCartPage.tsx +++ b/js/src/forum/components/pages/MyCartPage.tsx @@ -9,7 +9,7 @@ import Stream from "flarum/common/utils/Stream"; export default class MyCartPage extends UserPage { private type: number = Stream(""); - private status: number = Stream("-1"); + private status: number = Stream("1"); private autoDeduction: number = Stream("-1"); private cartList: any = [] private moreResults: boolean = false diff --git a/src/Controller/ListCartController.php b/src/Controller/ListCartController.php index 6e52964..9cd0765 100644 --- a/src/Controller/ListCartController.php +++ b/src/Controller/ListCartController.php @@ -47,7 +47,7 @@ protected function data(ServerRequestInterface $request, Document $document) { if ($type) { $filter['type'] = $type; } - if ($status && $status != '-1') { + if ($status !== '' && $status !== null && $status != '-1') { $filter['status'] = $status; } if ($autoDeduction && $autoDeduction != '-1') {