|
@ -1,7 +1,7 @@ |
|
|
import {useEffect, useState} from "react"; |
|
|
import {useEffect, useState} from "react"; |
|
|
import {Image} from '@nutui/nutui-react-taro' |
|
|
import {Image} from '@nutui/nutui-react-taro' |
|
|
import {Share} from '@nutui/icons-react-taro' |
|
|
import {Share} from '@nutui/icons-react-taro' |
|
|
import Taro from '@tarojs/taro' |
|
|
|
|
|
|
|
|
import Taro, {useShareAppMessage, useShareTimeline} from "@tarojs/taro"; |
|
|
import {ShopGoods} from "@/api/shop/shopGoods/model"; |
|
|
import {ShopGoods} from "@/api/shop/shopGoods/model"; |
|
|
import {pageShopGoods} from "@/api/shop/shopGoods"; |
|
|
import {pageShopGoods} from "@/api/shop/shopGoods"; |
|
|
import './BestSellers.scss' |
|
|
import './BestSellers.scss' |
|
@ -9,6 +9,7 @@ import './BestSellers.scss' |
|
|
|
|
|
|
|
|
const BestSellers = () => { |
|
|
const BestSellers = () => { |
|
|
const [list, setList] = useState<ShopGoods[]>([]) |
|
|
const [list, setList] = useState<ShopGoods[]>([]) |
|
|
|
|
|
const [goods, setGoods] = useState<ShopGoods>() |
|
|
|
|
|
|
|
|
const reload = () => { |
|
|
const reload = () => { |
|
|
pageShopGoods({}).then(res => { |
|
|
pageShopGoods({}).then(res => { |
|
@ -20,6 +21,40 @@ const BestSellers = () => { |
|
|
reload() |
|
|
reload() |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
// 分享给好友
|
|
|
|
|
|
useShareAppMessage(() => { |
|
|
|
|
|
return { |
|
|
|
|
|
title: goods?.name || '精选商品', |
|
|
|
|
|
path: `/shop/goodsDetail/index?id=${goods?.goodsId}`, |
|
|
|
|
|
imageUrl: goods?.image, // 分享图片
|
|
|
|
|
|
success: function (res: any) { |
|
|
|
|
|
console.log('分享成功', res); |
|
|
|
|
|
Taro.showToast({ |
|
|
|
|
|
title: '分享成功', |
|
|
|
|
|
icon: 'success', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function (res: any) { |
|
|
|
|
|
console.log('分享失败', res); |
|
|
|
|
|
Taro.showToast({ |
|
|
|
|
|
title: '分享失败', |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000 |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 分享到朋友圈
|
|
|
|
|
|
useShareTimeline(() => { |
|
|
|
|
|
return { |
|
|
|
|
|
title: `${goods?.name || '精选商品'} - 云上商店`, |
|
|
|
|
|
path: `/shop/goodsDetail/index?id=${goods?.goodsId}`, |
|
|
|
|
|
imageUrl: goods?.image |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<div className={'py-3'}> |
|
|
<div className={'py-3'}> |
|
@ -43,9 +78,18 @@ const BestSellers = () => { |
|
|
<span className={'font-bold text-2xl'}>{item.price}</span> |
|
|
<span className={'font-bold text-2xl'}>{item.price}</span> |
|
|
</div> |
|
|
</div> |
|
|
<div className={'buy-btn'}> |
|
|
<div className={'buy-btn'}> |
|
|
<div className={'cart-icon'}> |
|
|
|
|
|
<Share size={20} className={'mx-4 mt-2'} |
|
|
|
|
|
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/> |
|
|
|
|
|
|
|
|
<div className={'cart-icon flex items-center'}> |
|
|
|
|
|
<button |
|
|
|
|
|
className={'flex flex-col justify-center items-center text-gray-500 px-3 gap-1 text-nowrap whitespace-nowrap'} |
|
|
|
|
|
open-type="share" |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
setGoods(item) |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<Share className={'text-white'} size={20}/> |
|
|
|
|
|
</button> |
|
|
|
|
|
{/*<Share size={20} className={'mx-4 mt-2'}*/} |
|
|
|
|
|
{/* onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>*/} |
|
|
</div> |
|
|
</div> |
|
|
<div className={'text-white pl-4 pr-5'} |
|
|
<div className={'text-white pl-4 pr-5'} |
|
|
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买 |
|
|
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买 |
|
|