feat 首页公告
This commit is contained in:
parent
6ddc103f0c
commit
e5d4122bd7
@ -10,12 +10,21 @@ import {
|
|||||||
import {
|
import {
|
||||||
getHomeCategoryListApi
|
getHomeCategoryListApi
|
||||||
} from '~/services/home/getHomeCategoryListApi';
|
} from '~/services/home/getHomeCategoryListApi';
|
||||||
|
import {
|
||||||
|
getNoticeList
|
||||||
|
} from '~/services/home/getNoticeList';
|
||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
imgSrcs: [],
|
imgSrcs: [],
|
||||||
tabList: [],
|
tabList: [],
|
||||||
|
noticeList: [],
|
||||||
|
marquee: {
|
||||||
|
speed: 40,
|
||||||
|
loop: -1,
|
||||||
|
delay: 0,
|
||||||
|
},
|
||||||
goodsList: [],
|
goodsList: [],
|
||||||
goodsListLoadStatus: 0,
|
goodsListLoadStatus: 0,
|
||||||
pageLoading: false,
|
pageLoading: false,
|
||||||
@ -95,6 +104,20 @@ Page({
|
|||||||
});
|
});
|
||||||
this.loadGoodsList(true);
|
this.loadGoodsList(true);
|
||||||
});
|
});
|
||||||
|
// 获取公告列表
|
||||||
|
getNoticeList().then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
const _noticeData = res.data.map((v) => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
visible: true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
noticeList: _noticeData,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
tabChangeHandle(e) {
|
tabChangeHandle(e) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||||
"goods-list": "/components/goods-list/index",
|
"goods-list": "/components/goods-list/index",
|
||||||
"load-more": "/components/load-more/index"
|
"load-more": "/components/load-more/index",
|
||||||
|
"t-notice-bar": "tdesign-miniprogram/notice-bar/notice-bar"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,56 +3,28 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="home-page-header">
|
<view class="home-page-header">
|
||||||
<view class="search" bind:tap="navToSearchPage">
|
<view class="search" bind:tap="navToSearchPage">
|
||||||
<t-search
|
<t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="iphone 13 火热发售中" leftIcon="" disabled>
|
||||||
t-class-input="t-search__input"
|
|
||||||
t-class-input-container="t-search__input-container"
|
|
||||||
placeholder="iphone 13 火热发售中"
|
|
||||||
leftIcon=""
|
|
||||||
disabled
|
|
||||||
>
|
|
||||||
<t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" />
|
<t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" />
|
||||||
</t-search>
|
</t-search>
|
||||||
</view>
|
</view>
|
||||||
<view class="swiper-wrap">
|
<view class="swiper-wrap">
|
||||||
<t-swiper
|
<t-swiper wx:if="{{imgSrcs.length > 0}}" current="{{current}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" navigation="{{navigation}}" imageProps="{{swiperImageProps}}" list="{{imgSrcs}}" bind:click="navToActivityDetail" />
|
||||||
wx:if="{{imgSrcs.length > 0}}"
|
|
||||||
current="{{current}}"
|
|
||||||
autoplay="{{autoplay}}"
|
|
||||||
duration="{{duration}}"
|
|
||||||
interval="{{interval}}"
|
|
||||||
navigation="{{navigation}}"
|
|
||||||
imageProps="{{swiperImageProps}}"
|
|
||||||
list="{{imgSrcs}}"
|
|
||||||
bind:click="navToActivityDetail"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="home-page-container">
|
<view class="home-page-container">
|
||||||
<view class="home-page-tabs">
|
<view class="home-page-tabs">
|
||||||
<t-tabs
|
<t-tabs t-class="t-tabs" t-class-active="tabs-external__active" t-class-item="tabs-external__item" defaultValue="{{0}}" space-evenly="{{false}}" bind:change="tabChangeHandle">
|
||||||
t-class="t-tabs"
|
<t-tab-panel wx:for="{{tabList}}" wx:for-index="index" wx:key="index" label="{{item.text}}" value="{{item.key}}" />
|
||||||
t-class-active="tabs-external__active"
|
|
||||||
t-class-item="tabs-external__item"
|
|
||||||
defaultValue="{{0}}"
|
|
||||||
space-evenly="{{false}}"
|
|
||||||
bind:change="tabChangeHandle"
|
|
||||||
>
|
|
||||||
<t-tab-panel
|
|
||||||
wx:for="{{tabList}}"
|
|
||||||
wx:for-index="index"
|
|
||||||
wx:key="index"
|
|
||||||
label="{{item.text}}"
|
|
||||||
value="{{item.key}}"
|
|
||||||
/>
|
|
||||||
</t-tabs>
|
</t-tabs>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="notice-container ">
|
||||||
<goods-list
|
<view wx:for="{{noticeList}}">
|
||||||
wr-class="goods-list-container"
|
<t-notice-bar class="notice-bar" visible="{{item.visible}}" prefixIcon="null" marquee="{{marquee}}" content="{{item.noticeContent}}" suffixIcon="close" bind:click="closeNotice">
|
||||||
goodsList="{{goodsList}}"
|
<view slot="prefix-icon" class="notice-title">{{item.noticeTitle}}</view>
|
||||||
bind:click="goodListClickHandle"
|
</t-notice-bar>
|
||||||
bind:addcart="goodListAddCartHandle"
|
</view>
|
||||||
/>
|
</view>
|
||||||
|
<goods-list wr-class="goods-list-container" goodsList="{{goodsList}}" bind:click="goodListClickHandle" bind:addcart="goodListAddCartHandle" />
|
||||||
<load-more list-is-empty="{{!goodsList.length}}" status="{{goodsListLoadStatus}}" bind:retry="onReTry" />
|
<load-more list-is-empty="{{!goodsList.length}}" status="{{goodsListLoadStatus}}" bind:retry="onReTry" />
|
||||||
<t-toast id="t-toast" />
|
<t-toast id="t-toast" />
|
||||||
</view>
|
</view>
|
@ -60,6 +60,7 @@ page {
|
|||||||
.home-page-container .tab.order-nav .order-nav-item.scroll-width {
|
.home-page-container .tab.order-nav .order-nav-item.scroll-width {
|
||||||
min-width: 165rpx;
|
min-width: 165rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-page-container .tab .order-nav-item.active {
|
.home-page-container .tab .order-nav-item.active {
|
||||||
color: #fa550f !important;
|
color: #fa550f !important;
|
||||||
}
|
}
|
||||||
@ -105,3 +106,13 @@ page {
|
|||||||
--td-tab-item-color: #666;
|
--td-tab-item-color: #666;
|
||||||
--td-tab-track-color: red;
|
--td-tab-track-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice-bar {}
|
||||||
|
|
||||||
|
.notice-bar .t-notice-bar__content {
|
||||||
|
color: #666 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-title {
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
19
services/home/getNoticeList.js
Normal file
19
services/home/getNoticeList.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
|
/** 获取公告列表 */
|
||||||
|
export function getNoticeList() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `NoticeApi/getNoticeList`,
|
||||||
|
method: 'GET',
|
||||||
|
success: function (res) {
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user