|
|
|
@ -25,6 +25,9 @@ export default function UserExchangeModal({ isOpen, setIsOpen }: Props) { |
|
|
|
|
// 兑换成功弹窗
|
|
|
|
|
const [isUserExchangeSuccessModalOpen, setisUserExchangeSuccessModalOpen] = useState(false) |
|
|
|
|
|
|
|
|
|
// 兑换接口返回的state
|
|
|
|
|
const [exchangeState, setExchangeState] = useState('') |
|
|
|
|
|
|
|
|
|
// 兑换成功的商品名称字符串
|
|
|
|
|
const [prdtNames, setPrdtNames] = useState('') |
|
|
|
|
|
|
|
|
@ -51,19 +54,16 @@ export default function UserExchangeModal({ isOpen, setIsOpen }: Props) { |
|
|
|
|
change_code: res.path.slice(-8) |
|
|
|
|
}, |
|
|
|
|
success: (s_res: any) => { |
|
|
|
|
console.log('兑换成功=>', s_res.data) |
|
|
|
|
if (s_res.data.state === '200') { |
|
|
|
|
const list = s_res.data.data.Subscribed |
|
|
|
|
const { state, data } = s_res.data |
|
|
|
|
setExchangeState(state) |
|
|
|
|
// 有返回商品名称,则显示;否则只显示提示语
|
|
|
|
|
if(data && data.Subscribed){ |
|
|
|
|
const list = data.Subscribed |
|
|
|
|
setPrdtNames(list.map((e: any) => e.PrdtTitle).join(';')) |
|
|
|
|
setPrdtList(list) |
|
|
|
|
setIsOpen(false) |
|
|
|
|
setisUserExchangeSuccessModalOpen(true) |
|
|
|
|
}else if(s_res.data.state === '207'){ |
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '兑换码已使用', |
|
|
|
|
icon: 'error' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setIsOpen(false) |
|
|
|
|
setisUserExchangeSuccessModalOpen(true) |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('兑换失败=>', err) |
|
|
|
@ -88,19 +88,16 @@ export default function UserExchangeModal({ isOpen, setIsOpen }: Props) { |
|
|
|
|
change_code: inputValue |
|
|
|
|
}, |
|
|
|
|
success: (res: any) => { |
|
|
|
|
if(res.data.state === '200'){ |
|
|
|
|
const list = res.data.data.Subscribed |
|
|
|
|
console.log('兑换成功=>', list) |
|
|
|
|
const { state, data } = res.data |
|
|
|
|
setExchangeState(state) |
|
|
|
|
// 有返回商品名称,则显示;否则只显示提示语
|
|
|
|
|
if(data && data.Subscribed){ |
|
|
|
|
const list = data.Subscribed |
|
|
|
|
setPrdtNames(list.map((e: any) => e.PrdtTitle).join(';')) |
|
|
|
|
setPrdtList(list) |
|
|
|
|
setIsOpen(false) |
|
|
|
|
setisUserExchangeSuccessModalOpen(true) |
|
|
|
|
}else if(res.data.state === '207'){ |
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '兑换码已使用', |
|
|
|
|
icon: 'error' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setIsOpen(false) |
|
|
|
|
setisUserExchangeSuccessModalOpen(true) |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('兑换失败=>', err) |
|
|
|
@ -159,7 +156,7 @@ export default function UserExchangeModal({ isOpen, setIsOpen }: Props) { |
|
|
|
|
</View> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<UserExchangeSuccessModal prdtList={prdtList} prdtNames={prdtNames} isOpen={isUserExchangeSuccessModalOpen} setIsOpen={setisUserExchangeSuccessModalOpen}></UserExchangeSuccessModal> |
|
|
|
|
<UserExchangeSuccessModal exchangeState={exchangeState} prdtList={prdtList} prdtNames={prdtNames} isOpen={isUserExchangeSuccessModalOpen} setIsOpen={setisUserExchangeSuccessModalOpen}></UserExchangeSuccessModal> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|