mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-22 23:28:43 +00:00
feat:模块市场安装和购买请求函数
This commit is contained in:
parent
55e12c8203
commit
fcc7363e01
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user