From fcc7363e01f88e4d4c4721cb8a7ee6b463f0f50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Sun, 14 Aug 2022 14:53:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=A8=A1=E5=9D=97=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=92=8C=E8=B4=AD=E4=B9=B0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/api/backend/module.ts | 17 +++++++++++ web/src/views/backend/module/index.ts | 42 ++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/web/src/api/backend/module.ts b/web/src/api/backend/module.ts index 7a48e8a4..39eed7b2 100644 --- a/web/src/api/backend/module.ts +++ b/web/src/api/backend/module.ts @@ -4,6 +4,7 @@ import { useBaAccount } from '/@/stores/baAccount' const userUrl = '/api/user/' const captchaUrl = '/api/common/captcha' +const installTemplateUrl = '/admin/ajax/installTemplate' export function modules(params: anyObj = {}) { const siteConfig = useSiteConfig() @@ -93,3 +94,19 @@ export function payOrder(orderId: number, payType: number): ApiPromise { } ) as ApiPromise } + +export function postInstallTemplate(uid: string, orderId: number, extend: anyObj = {}) { + const baAccount = useBaAccount() + return createAxios({ + url: installTemplateUrl, + method: 'post', + params: { + uid: uid, + order_id: orderId, + token: baAccount.token, + }, + data: { + extend: extend, + }, + }) as ApiPromise +} diff --git a/web/src/views/backend/module/index.ts b/web/src/views/backend/module/index.ts index cca61b87..85a53385 100644 --- a/web/src/views/backend/module/index.ts +++ b/web/src/views/backend/module/index.ts @@ -1,5 +1,5 @@ import { reactive } from 'vue' -import { modules, info, createOrder, payOrder } from '/@/api/backend/module' +import { modules, info, createOrder, payOrder, postInstallTemplate } from '/@/api/backend/module' import { useBaAccount } from '/@/stores/baAccount' export const state: { @@ -100,6 +100,46 @@ export const showInfo = (id: number) => { }) } +export const onBuy = () => { + state.buy.showDialog = true + state.buy.showLoading = true + createOrder({ + goods_id: state.goodsInfo.info.id, + }) + .then((res) => { + state.buy.showLoading = false + state.buy.info = res.data.info + }) + .catch((err) => { + state.buy.showDialog = false + state.buy.showLoading = false + loginExpired(err) + }) +} + +export const onInstall = (uid: string, id: number) => { + state.publicButtonLoading = true + postInstallTemplate(uid, id) + .then((res) => { + // 安装成功 + // 是否增加了依赖? + // 是否需要npm build + }) + .catch((err) => { + if (loginExpired(err)) return + if (err.code == -1) { + state.install.showDialog = true + state.install.uid = err.data.uid + state.install.title = err.data.title + state.install.fileConflict = err.data.fileConflict + state.install.dependConflict = err.data.dependConflict + } + }) + .finally(() => { + state.publicButtonLoading = false + }) +} + export const loginExpired = (res: ApiResponse) => { const baAccount = useBaAccount() if (res.code == 301 || res.code == 408) {