yujialong 3 weeks ago
parent 3d377ecbbd
commit 88e639c9ea
  1. 39
      src/components/UserExchangeModal/index.tsx
  2. 10
      src/components/UserExchangeSuccessModal/index.less
  3. 53
      src/components/UserExchangeSuccessModal/index.tsx
  4. 21
      src/pages/Home/index.tsx
  5. 12
      src/pages/UserHome/UserSubscribe/index.tsx
  6. 15
      src/pages/Vip/index.tsx

@ -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>
</>
)
}

@ -23,14 +23,16 @@
gap: .5rem;
.exchange_header {
position: relative;
width: 100%;
height: 1.625rem;
display: flex;
text-align: center;
.exchange_close {
position: absolute;
top: 0;
right: 0;
width: 1.5rem;
height: 1.5rem;
margin: auto 0 auto auto;
background-image: url(https://oss.jm-kid.com/wx_5colorflower/close.png);
background-size: cover;
background-repeat: no-repeat;
@ -39,7 +41,7 @@
.exchange_content {
display: flex;
margin-bottom: 1rem;
margin: .5rem 0;
}
.exchange_suc {
font-size: .9rem;

@ -5,22 +5,27 @@ import './index.less'
interface Props{
isOpen: boolean,
setIsOpen: (isOpen: boolean) => void,
exchangeState: string,
prdtNames: string,
prdtList: any[]
}
export default function UserExchangeModal({ isOpen, setIsOpen, prdtNames, prdtList }: Props) {
export default function UserExchangeModal({ isOpen, setIsOpen, exchangeState, prdtNames, prdtList }: Props) {
const handleExchange = () => {
if (prdtList[0].PrdtType === '03') {
if (prdtList.length) {
if (prdtList[0].PrdtType === '03') {
setIsOpen(false)
Taro.navigateTo({
url: '/pages/ListenDetail/index?prdtId=' + prdtList[0].PrdtId
})
}else if(prdtList[0].PrdtType === '05'){
setIsOpen(false)
Taro.navigateTo({
url: '/pages/CollectionDetail/index?id=' + prdtList[0].PrdtId
})
}
} else {
setIsOpen(false)
Taro.navigateTo({
url: '/pages/ListenDetail/index?prdtId=' + prdtList[0].PrdtId
})
}else if(prdtList[0].PrdtType === '05'){
setIsOpen(false)
Taro.navigateTo({
url: '/pages/CollectionDetail/index?id=' + prdtList[0].PrdtId
})
}
}
@ -36,29 +41,33 @@ export default function UserExchangeModal({ isOpen, setIsOpen, prdtNames, prdtLi
></View>
<View className='exchangee_sucess_modal'>
<View className='exchange_header'>
<View className='exchange_title'></View>
<View className='exchange_title'>{exchangeState === '200' ? '成功' : '失败'}</View>
<View
className='exchange_close'
onClick={() => setIsOpen(false)}
></View>
</View>
{
prdtList.length ?
<View
className='exchange_content'
>
<Text className='exchange_suc'></Text>
<Text className='exchange_prod_name'>{prdtNames}</Text>
</View> :
null
}
<View className='exchange_content'>
<Text className='exchange_suc'>{
exchangeState === '207' ?
'该兑换码已被使用,请核对后再来兑换' :
exchangeState === '205' ?
'兑换码/二维码有误,请核对后再来兑换' :
exchangeState === '206' ?
'兑换码已过有效期' :
exchangeState === '217' ?
'该兑换码你已兑换过,兑换商品:' :
'兑换商品:'
}</Text>
{prdtNames !== '' && <Text className='exchange_prod_name'>{prdtNames}</Text>}
</View>
<View
className='exchange_exchange'
onClick={handleExchange}
>
<Text className='exchange_exchange_text'></Text>
<Text className='exchange_exchange_text'>{prdtList.length ? '立即查看' : '我知道了'}</Text>
</View>
</View>
</>

@ -60,18 +60,15 @@ export default function Home() {
change_code: userCode
},
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)
setisUserExchangeSuccessModalOpen(true)
}else if(s_res.data.state === '207'){
Taro.showToast({
title: '兑换码已使用',
icon: 'error'
})
}
setisUserExchangeSuccessModalOpen(true)
},
fail: (err: any) => {
console.log('兑换失败=>', err)
@ -106,6 +103,9 @@ export default function Home() {
// 兑换成功弹窗
const [isUserExchangeSuccessModalOpen, setisUserExchangeSuccessModalOpen] = useState(false)
// 兑换接口返回的state
const [exchangeState, setExchangeState] = useState('')
// 兑换成功的商品名称字符串
const [prdtNames, setPrdtNames] = useState('')
@ -402,8 +402,7 @@ export default function Home() {
<Gift />
<UserExchangeSuccessModal prdtList={prdtList} prdtNames={prdtNames} isOpen={isUserExchangeSuccessModalOpen} setIsOpen={setisUserExchangeSuccessModalOpen}></UserExchangeSuccessModal>
<UserExchangeSuccessModal exchangeState={exchangeState} prdtList={prdtList} prdtNames={prdtNames} isOpen={isUserExchangeSuccessModalOpen} setIsOpen={setisUserExchangeSuccessModalOpen}></UserExchangeSuccessModal>
<GetPhoneNumber
onClose={setisGetUsePhone}

@ -54,7 +54,8 @@ export default function UserSubscribe() {
}
if (isFilter !== 'reset') data = {
...data,
...isFilter
...isFilter,
title: searchValue
}
Taro.request({
url: 'https://interapi.jm-kid.com/api/user/subscribed',
@ -77,16 +78,9 @@ export default function UserSubscribe() {
getList()
}, [isFilter])
// 搜索逻辑
const handleSearch = () => {
// const searchSingle = searchValue ? userSubuscribed.filter(( item:any ) => item.PrdtTitle.includes(searchValue)) : []
// console.log('searchSingle=>', searchSingle)
// setSearchSingleResults(searchSingle)
};
useEffect(() => {
clearTimeout(timer)
setTimer(setTimeout(handleSearch, 300))
setTimer(setTimeout(getList, 300))
}, [searchValue])
//跳转详情页

@ -21,6 +21,19 @@ export default function Share() {
// 开通记录
const [records, setRecords] = useState<RecordProps[]>()
const handleNavigateToMiniProgram = () => {
Taro.navigateToMiniProgram({
appId: 'wxbd3d383851fea776',
path: '',
success: (res) => {
console.log('打开成功=>',res)
},
fail: (res) => {
console.log('打开失败=>',res)
}
})
}
useLoad(()=> {
setuserAvator(Taro.getStorageSync('UserAvatar'))
setuserNickName(Taro.getStorageSync('UserNickName'))
@ -55,7 +68,7 @@ export default function Share() {
<View className='vip_name'>{userNickName}</View>
<View className='vip_status'>{info?.SubscribedState ? info?.PrdtDeadline.split(' ')[0] + '日到期' : '未开通'}</View>
</View>
<View className='vip_open'>{info?.SubscribedState ? '续费' : '开通'}</View>
<View className='vip_open' onClick={handleNavigateToMiniProgram}>{info?.SubscribedState ? '续费' : '开通'}</View>
</View>
{

Loading…
Cancel
Save