bug(ECX-7321):

This commit is contained in:
zhangjing1
2025-09-18 16:38:49 +08:00
parent c44304632d
commit ffb94f677a
3 changed files with 68 additions and 13 deletions

View File

@@ -11,7 +11,8 @@ import {
SpImage, SpImage,
SpPrice, SpPrice,
SpInputNumber, SpInputNumber,
SpGoodsPrice SpGoodsPrice,
SpLogin
} from '@/components' } from '@/components'
import { import {
addCart, addCart,
@@ -23,7 +24,7 @@ import {
import { BUY_TOOL_BTNS } from '@/consts' import { BUY_TOOL_BTNS } from '@/consts'
import api from '@/api' import api from '@/api'
import { useAsyncCallback } from '@/hooks' import { useAsyncCallback } from '@/hooks'
import { classNames, showToast, entryLaunch, getDistributorId, VERSION_STANDARD } from '@/utils' import { classNames, showToast, entryLaunch, getDistributorId, VERSION_STANDARD, isWeb } from '@/utils'
import './index.scss' import './index.scss'
// 数据类型 // 数据类型
@@ -45,22 +46,23 @@ const initialState = {
loading: false, loading: false,
minNum: 1 minNum: 1
} }
const $instance = Taro.getCurrentInstance()
function SpSkuSelect(props) { function SpSkuSelect(props) {
const { const {
info, info,
open = false, open = false,
onClose = () => {}, onClose = () => { },
onChange = () => {}, onChange = () => { },
refreshs = true,
type, type,
hideInputNumber = false, hideInputNumber = false,
salesman = false salesman = false,
onSubscribe = () => { }
} = props } = props
console.log('SpSkuSelect:info', info) console.log('SpSkuSelect:info', info)
// const [state, setState] = useImmer(initialState) // const [state, setState] = useImmer(initialState)
const [state, setState] = useAsyncCallback(initialState) const [state, setState] = useAsyncCallback(initialState)
const { selection, curImage, disabledSet, curItem, skuText, num, loading, minNum } = state const { selection, disabledSet, curItem, skuText, num, loading, minNum } = state
const { customerLnformation } = useSelector((state) => state.cart) const { customerLnformation } = useSelector((state) => state.cart)
const dispatch = useDispatch() const dispatch = useDispatch()
const skuDictRef = useRef({}) const skuDictRef = useRef({})
@@ -162,7 +164,6 @@ function SpSkuSelect(props) {
return Object.keys(skuDictRef.current).some((key) => { return Object.keys(skuDictRef.current).some((key) => {
return ( return (
key.match(reg) && key.match(reg) &&
skuDictRef.current[key].store > 0 &&
['onsale'].includes(skuDictRef.current[key].approveStatus) ['onsale'].includes(skuDictRef.current[key].approveStatus)
) )
}) })
@@ -390,14 +391,48 @@ function SpSkuSelect(props) {
}) })
} }
const handleSubscribe = async() => {
const { subscribe } = info
const { dtid } = $instance.router.params
console.log('onSubscribe:subscribe', subscribe)
if (subscribe) return false
if (isWeb) {
showToast('请在小程序完成商品到货通知')
return
}
await api.user.subscribeGoods(info.itemId, { distributor_id: dtid })
const { template_id } = await api.user.newWxaMsgTmpl({
temp_name: 'yykweishop',
source_type: 'goods'
})
Taro.requestSubscribeMessage({
tmplIds: template_id,
success: () => {
onSubscribe()
},
fail: () => {
onSubscribe()
}
})
}
const renderFooter = () => { const renderFooter = () => {
console.log('curItem111:', curItem)
let btnTxt = '' let btnTxt = ''
Object.keys(BUY_TOOL_BTNS()).forEach((key) => { Object.keys(BUY_TOOL_BTNS()).forEach((key) => {
if (BUY_TOOL_BTNS()[key].key == type) { if (BUY_TOOL_BTNS()[key].key == type) {
btnTxt = BUY_TOOL_BTNS()[key].title btnTxt = BUY_TOOL_BTNS()[key].title
} }
}) })
if (type == 'picker') { if (curItem?.store <= 0) {
return (
<AtButton circle type='primary' onChange={handleSubscribe}>
{BUY_TOOL_BTNS().NOTICE.title}
</AtButton>
)
} else if (type == 'picker') {
return ( return (
<AtButton circle type='primary' onClick={onClose}> <AtButton circle type='primary' onClick={onClose}>
确定 确定
@@ -464,6 +499,8 @@ function SpSkuSelect(props) {
max = parseInt(curItem ? curItem.store : info.store) max = parseInt(curItem ? curItem.store : info.store)
} }
console.log('curItem:', curItem)
return ( return (
<View className='buy-count'> <View className='buy-count'>
<View className='label'> <View className='label'>
@@ -472,6 +509,7 @@ function SpSkuSelect(props) {
</View> </View>
<SpInputNumber <SpInputNumber
disabled={curItem?.store <= 0}
value={num} value={num}
min={minNum} min={minNum}
max={max} max={max}

View File

@@ -252,4 +252,15 @@
color: #fff !important; color: #fff !important;
} }
} }
.btn-item {
width: 100%;
border-radius: 40px;
height: 80px;
line-height: 80px;
text-align: center;
font-size: 26px;
border: 1PX solid var(--color-primary);
background: var(--color-primary);
color: #fff;
}
} }

View File

@@ -645,18 +645,21 @@ function EspierDetail(props) {
{!info.nospec && ( {!info.nospec && (
<View className='sku-block'> <View className='sku-block'>
<SpCell <SpLogin
title='规格' onChange={() => {
isLink
onClick={() => {
setState((draft) => { setState((draft) => {
draft.skuPanelOpen = true draft.skuPanelOpen = true
draft.selectType = 'picker' draft.selectType = 'picker'
}) })
}} }}
>
<SpCell
title='规格'
isLink
> >
<Text className='cell-value'>{skuText}</Text> <Text className='cell-value'>{skuText}</Text>
</SpCell> </SpCell>
</SpLogin>
</View> </View>
)} )}
@@ -804,6 +807,9 @@ function EspierDetail(props) {
draft.curItem = curItem draft.curItem = curItem
}) })
}} }}
onSubscribe={() => {
fetch()
}}
/> />
{/* 分享 */} {/* 分享 */}