diff --git a/src/app.scss b/src/app.scss index ae872ba..272310c 100644 --- a/src/app.scss +++ b/src/app.scss @@ -87,6 +87,10 @@ button[open-type="chooseAvatar"] { justify-content: center; height: 80px; } + .cart-buy-only{ + border-radius: 20px; + flex: 1; + } } image { diff --git a/src/shop/goodsDetail/index.tsx b/src/shop/goodsDetail/index.tsx index 4c4fa19..c62b9a4 100644 --- a/src/shop/goodsDetail/index.tsx +++ b/src/shop/goodsDetail/index.tsx @@ -36,6 +36,7 @@ const GoodsDetail = () => { }) // 水票套票模板:存在时该商品不允许加入购物车(购物车无法支付此类商品) const [ticketTemplate, setTicketTemplate] = useState(null) + const [ticketTemplateChecked, setTicketTemplateChecked] = useState(false) // const [selectedSku, setSelectedSku] = useState(null); const [loading, setLoading] = useState(false); const router = Taro.getCurrentInstance().router; @@ -70,16 +71,20 @@ const GoodsDetail = () => { // 水票套票商品:不允许加入购物车(购物车无法支付) // 优先使用已加载的 ticketTemplate;若尚未加载则补一次查询 let tpl = ticketTemplate + let checked = ticketTemplateChecked if (!tpl && goods?.goodsId) { try { tpl = await getGltTicketTemplateByGoodsId(Number(goods.goodsId)) setTicketTemplate(tpl) + setTicketTemplateChecked(true) + checked = true } catch (_e) { tpl = null + setTicketTemplateChecked(true) + checked = true } } - if (tpl) { - Taro.showToast({title: '该商品为水票套票商品,请点击“立即购买”下单', icon: 'none'}) + if (!checked || tpl) { return } @@ -126,16 +131,20 @@ const GoodsDetail = () => { if (action === 'cart') { // 水票套票商品:不允许加入购物车(购物车无法支付) let tpl = ticketTemplate + let checked = ticketTemplateChecked if (!tpl && goods?.goodsId) { try { tpl = await getGltTicketTemplateByGoodsId(Number(goods.goodsId)) setTicketTemplate(tpl) + setTicketTemplateChecked(true) + checked = true } catch (_e) { tpl = null + setTicketTemplateChecked(true) + checked = true } } - if (tpl) { - Taro.showToast({title: '该商品为水票套票商品,请点击“立即购买”下单', icon: 'none'}) + if (!checked || tpl) { return } @@ -190,6 +199,7 @@ const GoodsDetail = () => { setLoading(true); // 切换商品时先重置套票模板,避免复用上一个商品状态 setTicketTemplate(null) + setTicketTemplateChecked(false) // 加载商品详情 getShopGoods(Number(goodsId)) @@ -218,10 +228,12 @@ const GoodsDetail = () => { .then((tpl) => { if (!alive) return setTicketTemplate(tpl) + setTicketTemplateChecked(true) }) .catch((_e) => { if (!alive) return setTicketTemplate(null) + setTicketTemplateChecked(true) }) // 加载商品规格 @@ -284,6 +296,8 @@ const GoodsDetail = () => { return 加载中...; } + const showAddToCart = ticketTemplateChecked && !ticketTemplate + return ( { - handleAddToCart()}>加入购物车 - - handleAddToCart()}>加入购物车 + + )} + handleBuyNow()}>立即购买 diff --git a/src/user/ticket/index.tsx b/src/user/ticket/index.tsx index 5608210..325bb6e 100644 --- a/src/user/ticket/index.tsx +++ b/src/user/ticket/index.tsx @@ -490,7 +490,7 @@ const UserTicketList = () => { )} - + {/**/} {/* {item.status === 1 ? '冻结' : '正常'}*/} {/**/}