Commit 81145048 authored by 俞嘉婷's avatar 俞嘉婷

feat: 奖品页接口

parent dbb02403
...@@ -71,5 +71,59 @@ export const homeJs = [ ...@@ -71,5 +71,59 @@ export const homeJs = [
} }
} }
}, },
},
{
url: '/activity/tabQuery', //请求地址
response: () => {
return {
"ok": true,
"code": 200,
"msg": 'nodano',
"timestamp": +new Date(),
"data": {
"tabList": [
{
"id": 1,
"name": "财神红包雨星",
},
{
"id": 2,
"name": "tab1",
},
{
"id": 3,
"name": "tab2",
},
{
"id": 4,
"name": "tab3",
},
{
"id": 5,
"name": "tab4",
}
]
}
}
}
},
{
url: '/activity/prizeRecords', //请求地址
response: () => {
return {
"ok": true,
"code": 200,
"msg": 'nodano',
"timestamp": +new Date(),
"data": {
"prizeRecords": new Array(20).fill(0).map((item, index) => ({
"id": index + 1,
"prizeName": `奖品名称${index + 1}`,
"prizeImage": index == 0 ? `https://yun.duiba.com.cn/polaris/medal4.3c2dd506dd8ee372e3e523e4990254b8f3cfcbf2.png` : `https://yun.duiba.com.cn/spark/assets/f77861647e7b55e9c95e9c49d891a21526157a76.jpg`,
"prizeType": 1,
}))
}
}
}
} }
] ]
\ No newline at end of file
...@@ -9,6 +9,7 @@ export const login = (data) => { ...@@ -9,6 +9,7 @@ export const login = (data) => {
}) })
} }
// 首页
export const indexApi = (data) => { export const indexApi = (data) => {
return request({ return request({
method: 'get', method: 'get',
...@@ -17,6 +18,7 @@ export const indexApi = (data) => { ...@@ -17,6 +18,7 @@ export const indexApi = (data) => {
}) })
} }
// 未来展品
export const futureActivityApi = (data) => { export const futureActivityApi = (data) => {
return request({ return request({
method: 'post', method: 'post',
...@@ -24,3 +26,21 @@ export const futureActivityApi = (data) => { ...@@ -24,3 +26,21 @@ export const futureActivityApi = (data) => {
data data
}) })
} }
// 奖品tab列表
export const tabQueryApi = (data) => {
return request({
method: 'get',
url: '/activity/tabQuery',
data
})
}
// 奖品列表
export const prizeRecordsApi = (data) => {
return request({
method: 'get',
url: '/activity/prizeRecords',
data
})
}
\ No newline at end of file
...@@ -21,7 +21,9 @@ class FuturePage extends Component { ...@@ -21,7 +21,9 @@ class FuturePage extends Component {
async componentDidMount() { async componentDidMount() {
sensorMdExpouse("xcxPage", { pageName: `未来展品` }) sensorMdExpouse("xcxPage", { pageName: `未来展品` })
const res = await futureActivityApi(); const res = await futureActivityApi({
channel: CFG.channel
});
if (res.ok) { if (res.ok) {
this.setState({ activityList: res.data?.activityInfoList || [] }) this.setState({ activityList: res.data?.activityInfoList || [] })
} }
......
...@@ -69,8 +69,12 @@ ...@@ -69,8 +69,12 @@
} }
.prize_img { .prize_img {
width: 100%; position: absolute;
height: 100%; left: 2px;
top: 0px;
width: 112px;
height: 112px;
border-radius: 16px;
object-fit: contain; object-fit: contain;
} }
......
...@@ -6,23 +6,54 @@ import store from '../../store'; ...@@ -6,23 +6,54 @@ import store from '../../store';
import { PAGE_MAP } from '../../utils/constants'; import { PAGE_MAP } from '../../utils/constants';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { sensorMdClick, sensorMdExpouse } from '../../utils/sensorMd'; import { sensorMdClick, sensorMdExpouse } from '../../utils/sensorMd';
import { prizeRecordsApi, tabQueryApi } from '../../api/api';
import Toast from '../../components/toast';
@observer @observer
class PrizePage extends Component { class PrizePage extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
tabList: [],
curTab: 0, curTab: 0,
prizeList: [],
} }
} }
async componentDidMount() { async componentDidMount() {
sensorMdExpouse("xcxPage", { pageName: `奖品页` }) sensorMdExpouse("xcxPage", { pageName: `奖品页` })
const res = await tabQueryApi({
channel: CFG.channel
});
if (res.ok) {
const { tabList } = res.data || {};
this.setState({ tabList: tabList || [] }, () => {
if (tabList.length > 0) {
this.toggleTab(0)
}
})
}
} }
// 切换tab // 切换tab
toggleTab = _asyncThrottle((index) => { toggleTab = _asyncThrottle(async (index) => {
this.setState({ curTab: index }) this.setState({ curTab: index, prizeList: [] })
const { tabList } = this.state;
const res = await prizeRecordsApi({
channel: CFG.channel,
id: tabList[index].id
});
if (res.ok) {
this.setState({ prizeList: res.data?.prizeRecords || [] })
}
})
// 奖品详情
prizeDetail = _asyncThrottle((item) => {
const { curTab, tabList } = this.state;
Toast(`前往${tabList[curTab].name}活动查看`)
}) })
// 返回 // 返回
...@@ -32,7 +63,7 @@ class PrizePage extends Component { ...@@ -32,7 +63,7 @@ class PrizePage extends Component {
}) })
render() { render() {
const { curTab } = this.state; const { curTab, tabList, prizeList } = this.state;
const { prize_img_bg, tab_active_bg, title, item_bg } = skinStore.prizePage; const { prize_img_bg, tab_active_bg, title, item_bg } = skinStore.prizePage;
const { back, sub_page_bg_cover, sub_page_bg } = skinStore.common; const { back, sub_page_bg_cover, sub_page_bg } = skinStore.common;
return ( return (
...@@ -46,25 +77,26 @@ class PrizePage extends Component { ...@@ -46,25 +77,26 @@ class PrizePage extends Component {
<div className="title" style={{ 'backgroundImage': `url(${title})` }}></div> <div className="title" style={{ 'backgroundImage': `url(${title})` }}></div>
{/* tab */} {/* tab */}
<div className="tab_list"> <div className="tab_list">
{new Array(10).fill(0).map((item, index) => ( {tabList?.map((item, index) => (
<div <div
className={`tab_item ${curTab === index ? 'active' : ''}`} className={`tab_item ${curTab === index ? 'active' : ''}`}
key={`tab_item_${item.id}`}
onClick={() => this.toggleTab(index)} onClick={() => this.toggleTab(index)}
style={{ 'backgroundImage': `url(${curTab === index ? tab_active_bg : ''})` }} style={{ 'backgroundImage': `url(${curTab === index ? tab_active_bg : ''})` }}
>财神红包雨星{index + 1} >
{item.name}
</div> </div>
))} ))}
</div> </div>
{/* 奖品列表 */} {/* 奖品列表 */}
<div className="prize_list"> <div className="prize_list">
{new Array(20).fill(0).map((item, index) => ( {prizeList?.map((item, index) => (
<div className="prize_item" style={{ 'backgroundImage': `url(${item_bg})` }}> <div className="prize_item" style={{ 'backgroundImage': `url(${item_bg})` }} key={index} onClick={() => this.prizeDetail(item)}>
<div className="prize_img_box" style={{ 'backgroundImage': `url(${prize_img_bg})` }}> <div className="prize_img_box" style={{ 'backgroundImage': `url(${prize_img_bg})` }}>
<img className="prize_img" src="//yun.duiba.com.cn/polaris/medal4.3c2dd506dd8ee372e3e523e4990254b8f3cfcbf2.png" alt="" /> <img className="prize_img" src={item.prizeImage} alt="" />
</div> </div>
<div className="prize_info"> <div className="prize_info">
<div className="prize_name">奖品名称奖品名称奖品名称奖品名称${index + 1}</div> <div className="prize_name">{item.prizeName}</div>
<div className="prize_desc">奖品描述奖品描述奖品描述奖品描述奖品描述奖品描述奖品描述</div>
</div> </div>
</div> </div>
))} ))}
......
...@@ -100,8 +100,12 @@ ...@@ -100,8 +100,12 @@
} }
.prize_img { .prize_img {
width: 100%; position: absolute;
height: 100%; left: 2px;
top: 0px;
width: 112px;
height: 112px;
border-radius: 16px;
object-fit: contain; object-fit: contain;
} }
......
...@@ -33,7 +33,9 @@ const store = makeAutoObservable({ ...@@ -33,7 +33,9 @@ const store = makeAutoObservable({
indexInfo: {}, indexInfo: {},
async getIndexInfo() { async getIndexInfo() {
const res = await indexApi() const res = await indexApi({
channel: CFG.channel
})
console.log(res) console.log(res)
if (res.ok) { if (res.ok) {
store.indexInfo = res.data || {} store.indexInfo = res.data || {}
......
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