import { getDyLiveList, getDyProductList, getJdProductList, getPddProductList, getSuProductList, getTaobaoProductList, getVipProductList, searchProductList } from "~/apis/product"; import type { DyProductModel, IProductDetail, JdProductModel, SuNingProductModel, TaobaoProductDetailModel, TaobaoProductThirdPartyWaresModel, VipProductModel } from "~/apis/model/product.model"; import {getDcProductList} from "~/apis/dacang"; import type {DcProductModel} from "~/apis/model/dacang.model"; import {encodeBase64} from "~/utils/http/helper"; import {PLATFORM_NAME} from "~/apis/model/common.model"; import {CDN_URL} from "~/config/app"; interface TabItem { id: PLATFORM_NAME, text: string, iconPath: string, selectedIconPath: string } const tabList = >[{ id: PLATFORM_NAME.JD, text: '京东', iconPath: CDN_URL + '/static/assets/jingdong_x.png', selectedIconPath: CDN_URL + '/static/assets/jingdong_d.png', }, { id: PLATFORM_NAME.TB, text: '淘宝', iconPath: CDN_URL + '/static/assets/taobaoyanglao_x.png', selectedIconPath: CDN_URL + '/static/assets/taobaoyanglao_d.png', }, { id: PLATFORM_NAME.PDD, text: '拼多多', iconPath: CDN_URL + '/static/assets/pinduoduo_x.png', selectedIconPath: CDN_URL + '/static/assets/pinduoduo_d.png', }, { id: PLATFORM_NAME.DC, text: '大仓', iconPath: CDN_URL + '/static/assets/dacang_x_220914.png', selectedIconPath: CDN_URL + '/static/assets/dacang_d_220914.png', }, { id: PLATFORM_NAME.DY, text: '抖音', iconPath: CDN_URL + '/static/assets/douyin_x_230313.png', selectedIconPath: CDN_URL + '/static/assets/douyin_d_230313.png', }, { id: PLATFORM_NAME.VIP, text: '唯品会', iconPath: CDN_URL + '/static/assets/weipinhui_x.png', selectedIconPath: CDN_URL + '/static/assets/weipinhui_d.png', }, { id: PLATFORM_NAME.SU, text: '苏宁', iconPath: CDN_URL + '/static/assets/suningyigou_x.png', selectedIconPath: CDN_URL + '/static/assets/suningyigou_d.png', }] const state = reactive({ currentTab: PLATFORM_NAME.JD }) onLoad((options) => { const platform = options.platform if (platform) { state.currentTab = platform loadProductList(state.currentTab) } }) const list = ref>() const dyLiveList = ref>() export function loadProductList(platform: PLATFORM_NAME) { switch (platform) { case PLATFORM_NAME.JD: { getJdProductList({ page: 1, limit: 10 }).then(res => { list.value = res // res[0]. // console.log(res) }) break; } case PLATFORM_NAME.DC: { getDcProductList({ page: 1, limit: 10, classify: '', keyword: '' }).then(res => { list.value = res }) break; } case PLATFORM_NAME.DY: { getDyLiveList({ page: 1, limit: 4, // keyword: '' }).then(res => { // console.log(res) // console.log(res.authorPic) }) getDyLiveList({page: 1,limit: 4}) .then(res => { // console.log(res) if (res) { dyLiveList.value = res } }) getDyProductList({ page: 1, limit: 10, }).then(res => { list.value = res }) break; } case PLATFORM_NAME.PDD: { getPddProductList({ page: 1, limit: 10 }).then(res => { list.value = res }) break; } case PLATFORM_NAME.SU: { getSuProductList({ page: 1, limit: 10 }).then(res => { list.value = res console.log(res) }) break; } case PLATFORM_NAME.TB: { getTaobaoProductList({ pageNum: '1', pageSize: '10' }).then(res => { list.value = res.thirdPartyWaresList }) break; } case PLATFORM_NAME.VIP: { getVipProductList({ page: 1, limit: 10 }).then(res => { list.value = res }) break; } default: { // getJdProductList({ // page: 1, // limit: 10 // }).then(res => { // list.value = res // }) } } } export function handleCategoryItemClick(item: TabItem) { state.currentTab = item.id loadProductList(item.id) } export function handleProductItemClick( item: JdProductModel & DcProductModel & DyProductModel & SuNingProductModel & TaobaoProductThirdPartyWaresModel & VipProductModel ) { console.log(item) function navigateToDetail(params) { let otherDetailUrl = `/pages/store/product/other` return uni.navigateTo({ url: `${otherDetailUrl}?params=${params}` }) } // 大仓 if (state.currentTab === PLATFORM_NAME.DC && item.type === '5') { uni.navigateTo({ url: `/pages/store/product/detail?id=${item.product_id}` }) } // 京东 if (item.type === 6) { // productParams.id = item.skuId const productParams: Partial = { platform: item.type, id: item.skuId, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.lowestCouponPrice, price: item.price, coupon: { amount: item.coupon_money[0].discount, startTime: item.coupon_money[0].getStartTime, endTime: item.coupon_money[0].getEndTime }, spreadUrl: item.coupon_link } return navigateToDetail(encodeBase64(productParams)) } // 淘宝 if (item.type === 5) { const productParams: Partial = { platform: item.type, id: item.id, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.price, // 原价 price: item.market_price, coupon: { amount: item.coupon_money // amount: item.coupon_money[0].discount, // startTime: item.coupon_money[0].getStartTime, // endTime: item.coupon_money[0].getEndTime }, spreadUrl: item.coupon_share_url } return navigateToDetail(encodeBase64(productParams)) // uni.navigateTo({ // url: `/pages/store/product/other?platform=${item.type}&id=${item.id}` // }) } // 拼多多 if (item.type === 1) { const productParams: Partial = { platform: item.type, id: item.id, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.price, // 原价 price: item.market_price, coupon: { amount: item.coupon_money // amount: item.coupon_money[0].discount, // startTime: item.coupon_money[0].getStartTime, // endTime: item.coupon_money[0].getEndTime }, // spreadUrl: item.coupon_share_url } return navigateToDetail(encodeBase64(productParams)) // uni.navigateTo({ // url: `/pages/store/product/other?platform=${item.type}&id=${item.id}&allowance=${item.commission}` // }) } // 唯品会 if (item.type === 2) { const productParams: Partial = { platform: item.type, id: item.id, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.price, // 原价 price: item.market_price, // coupon: { // amount: item.coupon_money // }, } return navigateToDetail(encodeBase64(productParams)) } // 苏宁 if (item.type === 3) { const productParams: Partial = { platform: item.type, id: item.id, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.price, // 原价 price: item.market_price, // coupon: { // amount: item.coupon_money // }, } return navigateToDetail(encodeBase64(productParams)) // } // 抖音 9 if (item.type === 9) { console.log(item) const productParams: Partial = { platform: item.type, id: item.id, title: item.name, featured: [item.thumb], allowance: item.commission, salePrice: item.price, // 原价 price: item.market_price, // coupon: { // amount: item.coupon_money // }, } return navigateToDetail(encodeBase64(productParams)) } } export function handleLiveRecommendTitleClick() { uni.navigateTo({ url: `/pages/store/product/dy-live` }) }