| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- 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 = <Array<TabItem>>[{
- 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<Array<
- JdProductModel
- | DcProductModel
- | DyProductModel
- | SuNingProductModel
- | TaobaoProductThirdPartyWaresModel
- | VipProductModel
- | any
- >>()
- const dyLiveList = ref<Array<DyProductModel>>()
- 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<IProductDetail> = {
- 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<IProductDetail> = {
- 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<IProductDetail> = {
- 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<IProductDetail> = {
- 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<IProductDetail> = {
- 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<IProductDetail> = {
- 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`
- })
- }
|