Commit 352ed039 authored by 王能飞's avatar 王能飞

Merge branch 'c_client_taro-pack' into 'c_client_taro'

我的奖品增加专属商品奖品处理逻辑

See merge request !41
parents 50543a16 e64e572b
......@@ -62,5 +62,6 @@ export const PRIZE_CONFIG = {
contentTop: '208rpx',
blankTxt: '暂无奖品',
hasLogistic: false, // 是否展示物流信息
isShowPirzeId: false // 是否显示奖品编号
isShowPirzeId: false, // 是否显示奖品编号
hasGoodPrize: false, // 是否含有专属商品
}
\ No newline at end of file
......@@ -95,7 +95,6 @@ export default function ComsTest(props) {
/* 背景音乐 */
const {playAudio,musicUrl,setOpenStatus,openStatus} = useAudio(BGMUSIC_URL.MUSIC,true)
const [endTime, setEndTime] = useState('')
const [prizeModalVisible,setPrizeModalVisible] = useState(false)
......
import React, { useState, useEffect } from 'react'
import React, { useState, useEffect, useRef } from 'react'
import { Image, ScrollView, View } from '@tarojs/components'
import API from '@/api'
import DeliveryModal from '@/components/_tb_modal/DeliveryModal/DeliveryModal'
......@@ -8,15 +8,15 @@ import tbccTs from 'tbcc-sdk-ts'
import { useThrottle } from '@/hooks/useThrottle'
import { dateFormatter } from '@/utils/date'
import styles from './myPrize.module.less'
import { useDidHide, getApp } from '@tarojs/taro'
import { useDidHide, useDidShow, getApp } from '@tarojs/taro'
import useReceive from '@/hooks/useReceive'
import { PRIZE_CONFIG, DRAW_STATUS, PRIZE_TYPE } from '@/config/myPrize.config'
const { objectStatus: _objectStatus, enameStatus: _enameStatus, orderStatus, commonStatus } = PRIZE_CONFIG
const { objectStatus: _objectStatus, enameStatus: _enameStatus, orderStatus, commonStatus, hasGoodPrize } = PRIZE_CONFIG
const objectStatus = { ..._objectStatus, ...commonStatus }
const enameStatus = { ..._enameStatus, ...commonStatus }
const { commonToast, navigateToOutside, setClipboard } = tbccTs.tb
const { commonToast, navigateToOutside, setClipboard, openDetail } = tbccTs.tb
function Empty(blankTxt) {
return <View className={styles['my-prize-item__empty']}>{blankTxt}</View>
......@@ -30,6 +30,7 @@ function MyPrizeList() {
const [ currentPrize, setCurrentPrize ] = useState({})
const [ memberVisible, setMemberVisible ] = useState(false)
const [ deliveryModalVisible, setDeliveryModalVisible ] = useState(false)
const flashList = useRef(false)
useEffect(() => {
fetchMyPriceList()
......@@ -44,6 +45,13 @@ function MyPrizeList() {
setExpiredTime(dateFormatter(res?.data?.expiredTime, 'yyyy/MM/dd hh:mm:ss'))
}
}
// 页面显示
useDidShow(() => {
if(flashList.current) {
flashList.current = false
fetchMyPriceList()
}
})
// 复制编码
const handleCopyId = async(text) => {
await setClipboard(text)
......@@ -68,6 +76,12 @@ function MyPrizeList() {
if (!(drawStatus === DRAW_STATUS.RETRY || drawStatus === DRAW_STATUS.WAITAWARD)) {
return
}
// 含有专属商品
if(hasGoodPrize && itemId) {
flashList.current = true
await openDetail(String(itemId))
}
// 执行奖品领取
receivePrize(item,{
vipCallback:()=>{
......@@ -91,6 +105,15 @@ function MyPrizeList() {
setMemberVisible(false)
}
// 获取btn img
const getItmImg = (itm) => {
const { type, itemId, drawStatus, useUrl = '' } = itm
if(itemId && hasGoodPrize) return orderStatus[drawStatus]
if(type === PRIZE_TYPE.OBJECT) return objectStatus[drawStatus]
if(type === PRIZE_TYPE.ENAME && drawStatus === DRAW_STATUS.SUCCESS && !useUrl) return PRIZE_CONFIG.receiveBtn
if(type === PRIZE_TYPE.ENAME) return enameStatus[drawStatus]
}
return (
<>
<ContainerFit bg={PRIZE_CONFIG.bg}>
......@@ -121,11 +144,8 @@ function MyPrizeList() {
{item.drawStatus === DRAW_STATUS.EXPIRED && <View className={styles['my-prize-item__tip']}>奖品已过期失效</View>}
</View>
<View className={styles['prize-item__status']} style={PRIZE_CONFIG.btnStyle}>
{item.type === PRIZE_TYPE.OBJECT
? <Image onTap={() => handleClick(item)} src={objectStatus[item.drawStatus]} mode='widthFix' />
: <Image onTap={() => handleClick(item)} src={(item.drawStatus === 3 && !item.useUrl) ? PRIZE_CONFIG.receiveBtn : enameStatus[item.drawStatus]} mode='widthFix' />}
<Image onTap={() => handleClick(item)} src={getItmImg(item)} mode='widthFix' />
</View>
</View>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment