新增营销系统、分销系统、会员功能、门店、提现功能
This commit is contained in:
78
components/canvasShow/basics/product/mixin.js
Normal file
78
components/canvasShow/basics/product/mixin.js
Normal file
@ -0,0 +1,78 @@
|
||||
import api from '../../config/api'
|
||||
import { funMixin } from '../../config/mixin'
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
export default function (componentContent) {
|
||||
const { sendReq, beforeGetData, afterGetData, jumpProductDetail, jumpProList } = funMixin()
|
||||
|
||||
const productData = ref([])
|
||||
onMounted(() => {
|
||||
getData(true)
|
||||
})
|
||||
|
||||
function getData (isFirst) {
|
||||
if (componentContent.value.productData.sourceType === '1') {
|
||||
if (
|
||||
componentContent.value.productData.productIdList?.length > 0
|
||||
) {
|
||||
beforeGetData()
|
||||
sendReq(
|
||||
{
|
||||
url: `${api.getProducts}?page=1&isPage=2&ids=${componentContent.value.productData.productIdList}`,
|
||||
method: 'GET',
|
||||
},
|
||||
(proRes) => {
|
||||
afterGetData()
|
||||
productData.value = proRes.data.list
|
||||
if (isFirst) {
|
||||
componentContent.value.productData.imgTextData = productData.value
|
||||
}
|
||||
},
|
||||
() => {
|
||||
afterGetData()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
productData.value = []
|
||||
}
|
||||
} else if (componentContent.value.productData.sourceType === '2') {
|
||||
if (componentContent.value.productData?.categoryId) {
|
||||
beforeGetData()
|
||||
sendReq(
|
||||
{
|
||||
url: `${api.getProducts}?page=1&isPage=2&cateId=${componentContent.value.productData.categoryId}`,
|
||||
method: 'GET',
|
||||
},
|
||||
(proRes) => {
|
||||
afterGetData()
|
||||
productData.value = proRes.data.list
|
||||
if (isFirst) {
|
||||
componentContent.value.productData.imgTextData = productData.value
|
||||
}
|
||||
// _.swiper.update()
|
||||
},
|
||||
() => {
|
||||
afterGetData()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
productData.value = {
|
||||
products: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取进度条数字
|
||||
function getPercentageNum(item){
|
||||
const total = item.campaignTotal || item.total
|
||||
const stock = item.campaignStock || item.stock
|
||||
return (total-stock)/total
|
||||
}
|
||||
return {
|
||||
productData,
|
||||
jumpProductDetail,
|
||||
jumpProList,
|
||||
getPercentageNum
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user