diff --git a/src/components/UserExchangeModal/index.tsx b/src/components/UserExchangeModal/index.tsx
index 259c06b..f9a6c9f 100644
--- a/src/components/UserExchangeModal/index.tsx
+++ b/src/components/UserExchangeModal/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) {
)}
-
+
>
)
}
diff --git a/src/components/UserExchangeSuccessModal/index.less b/src/components/UserExchangeSuccessModal/index.less
index 5a08479..227d894 100644
--- a/src/components/UserExchangeSuccessModal/index.less
+++ b/src/components/UserExchangeSuccessModal/index.less
@@ -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;
diff --git a/src/components/UserExchangeSuccessModal/index.tsx b/src/components/UserExchangeSuccessModal/index.tsx
index 46450b9..692b8d5 100644
--- a/src/components/UserExchangeSuccessModal/index.tsx
+++ b/src/components/UserExchangeSuccessModal/index.tsx
@@ -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
>
-
+ 兑换{exchangeState === '200' ? '成功' : '失败'}
setIsOpen(false)}
>
- {
- prdtList.length ?
-
- 兑换成功:
- {prdtNames}
- :
- null
- }
+
+ {
+ exchangeState === '207' ?
+ '该兑换码已被使用,请核对后再来兑换' :
+ exchangeState === '205' ?
+ '兑换码/二维码有误,请核对后再来兑换' :
+ exchangeState === '206' ?
+ '兑换码已过有效期' :
+ exchangeState === '217' ?
+ '该兑换码你已兑换过,兑换商品:' :
+ '兑换商品:'
+ }
+ {prdtNames !== '' && {prdtNames}}
+
- 立即阅读
+ {prdtList.length ? '立即查看' : '我知道了'}
>
diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx
index d489546..59698dc 100644
--- a/src/pages/Home/index.tsx
+++ b/src/pages/Home/index.tsx
@@ -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() {
-
-
+
{
- // 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])
//跳转详情页
diff --git a/src/pages/Vip/index.tsx b/src/pages/Vip/index.tsx
index 360804b..34ab1a7 100644
--- a/src/pages/Vip/index.tsx
+++ b/src/pages/Vip/index.tsx
@@ -21,6 +21,19 @@ export default function Share() {
// 开通记录
const [records, setRecords] = useState()
+ 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() {
{userNickName}
{info?.SubscribedState ? info?.PrdtDeadline.split(' ')[0] + '日到期' : '未开通'}
- 立即{info?.SubscribedState ? '续费' : '开通'}
+ 立即{info?.SubscribedState ? '续费' : '开通'}
{