新增营销系统、分销系统、会员功能、门店、提现功能

This commit is contained in:
Shaw
2024-02-08 21:01:37 +08:00
parent 68b3f2dcc3
commit 17c043348a
1398 changed files with 81279 additions and 56269 deletions

View File

@ -0,0 +1,102 @@
import api from '../../config/api'
import { funMixin } from '../../config/mixin'
import { ref, onMounted, onBeforeUnmount } from 'vue';
export default function (componentContent, typeId, shopId) {
const { sendReq, beforeGetData, afterGetData, jumpProductDetail, jumpDiscount } = funMixin()
const activityData = ref({})
const productList = ref([])
const count = ref([])
const timer = ref(null)
onMounted(() => {
if (componentContent.value.id) {
getProList()
getActivit()
} else {
productList.value = []
}
})
onBeforeUnmount(() => {
clearInterval(timer.value)
})
function getProList () {
beforeGetData()
const params = {
method: 'POST',
url: api.getActivityProduct,
data: {
isPage: 2,
ids: [componentContent.value.id]
}
}
sendReq(
params,
(res) => {
afterGetData()
productList.value = res.data.list
},
() => {
afterGetData()
}
)
}
function getActivit () {
beforeGetData()
const params = {
method: 'GET',
url: `${api.getActivity}?id=${componentContent.value.id}`,
}
sendReq(
params,
(res) => {
afterGetData()
activityData.value = res.data
getTime()
},
() => {
afterGetData()
}
)
}
function getTime () {
const date = new Date().getTime()
let startTime = activityData.value.startTime
let endTime = activityData.value.endTime
let time = 0
if (activityData.value.state === 0) {
time = startTime - date // 未开始
} else if(activityData.value.state === 1) {
time = endTime - date // 进行中
}
let countDownInterval = setInterval(()=>{
countDown(time)
time -= 1000
if(time <= 0){
clearInterval(countDownInterval)
activityData.value.state ++
}
},1000)
}
function countDown (time) {
const fn = (v) => (v < 10 ? `0${v}` : v)
const t = parseInt(time / 1000)
const text = activityData.value.state === 0 ? '开始' : '结束'
const hour = parseInt(t / 3600)
const min = parseInt((t % 3600) / 60)
const s = t % 60
count.value = [text, fn(hour), fn(min), fn(s)]
}
return {
activityData,
productList,
count,
jumpProductDetail,
jumpDiscount
}
}