feat: move project

This commit is contained in:
ckaaaa 2025-09-16 13:41:49 +08:00
commit 4a940f28ba
97 changed files with 5047 additions and 0 deletions

106
pages/home/home.js Normal file
View file

@ -0,0 +1,106 @@
import R from '../../utils/request';
import C from '../../utils/constant';
Page({
data: {
cdnHost: C.cdnHost,
loadFlag: false,
swiperList: [],
list: [],
},
onShow() {
this.getTabBar().init();
// this.init();
this.fetchBanner();
},
onLoad() {
R.login().then(() => {
this.init();
})
},
fetchBanner() {
R.get('/index.php/api/v1/banner_list', {}).then(({ model }) => {
const swiperList = [];
model.forEach(item => {
swiperList.push({
...item,
value: C.cdnHost + item.img,
ariaLabel: item.title,
id: item.id,
});
});
if (JSON.stringify(swiperList) != JSON.stringify(this.data.swiperList)) {
this.setData({ swiperList });
}
});
},
init() {
if (this.data.loadFlag) return;
this.data.loadFlag = false;
this.fetchList(1);
this.fetchBanner();
},
fetchList(page) {
R.get('/index.php/api/v1/news_list', { page, pageSize: 5 }).then(({ model }) => {
const list = [];
model.forEach(item => {
list.push({
...item,
});
});
this.setData({ list });
});
},
goDetail(e) {
const { id } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/detail/detail?id=${id}`
});
},
onSwiperTap(e) {
const { index } = e.detail;
this.data.swiperList.forEach((o, i) => {
if (i == index) {
console.log(o)
if(o.action_type == 'newsId'){
wx.navigateTo({
url: '/pages/detail/detail?id=' + o.action_item,
});
}
if(o.action_type == 'url'){
wx.navigateTo({
url: '/pages/webview/webview?url=' + encodeURIComponent(o.action_item),
});
}
if(o.action_type == 'path'){
wx.navigateTo({
url: o.action_item,
});
}
}
})
},
goUrl(e) {
const { url } = e.currentTarget.dataset;
wx.navigateTo({
url
});
},
goMore() {
wx.navigateTo({
url: '/pages/news_list/home'
});
},
refresh() {
this.fetchList(1);
this.fetchBanner();
wx.showToast({ icon: 'none', title: '刷新成功' });
},
onPullDownRefresh() {
this.init();
wx.stopPullDownRefresh();
},
onShareAppMessage() { },
onShareTimeline() { },
});

12
pages/home/home.json Normal file
View file

@ -0,0 +1,12 @@
{
"navigationBarTitleText": "首页",
"backgroundTextStyle": "light",
"usingComponents": {
"t-swiper": "tdesign-miniprogram/swiper/swiper",
"t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-image": "tdesign-miniprogram/image/image",
"t-divider": "tdesign-miniprogram/divider/divider"
},
"enablePullDownRefresh": true
}

101
pages/home/home.less Normal file
View file

@ -0,0 +1,101 @@
page {
box-sizing: border-box;
background-color: linear-gradient(180deg, #f0f4fc, #fff);
padding: 0 20rpx;
padding-top: 10rpx;
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
}
.title_bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 32rpx;
}
.title_bar .title {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-position: left center;
background-size: 100% 100%;
font-size: 32rpx;
color: rgb(53, 58, 71);
height: 34rpx;
display: flex;
align-items: center;
font-weight: bold;
.t-icon {
margin-left: 10rpx;
}
}
.title_bar .btn {
color: #71737b;
font-size: 28rpx;
display: flex;
align-items: center;
}
.title_bar .btn .t-icon {
margin-left: 10rpx;
}
.list {
margin-top: 20rpx;
}
.list .item .item-main {
display: flex;
}
.list .item .item-main .right {
flex: 1;
padding-left: 32rpx;
}
.list .item .item-main .right .text {
padding-top: 0rpx;
font-size: 28rpx;
line-height: 46rpx;
margin-bottom: 10rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
color: #363a44;
}
.list .item .item-main .right .info {
display: flex;
font-size: 24rpx;
justify-content: space-between;
color: #71737b;
}
.list .item .item-main .right .info .viewcnt {
display: flex;
align-items: center;
}
.list .item .viewcnt .t-icon {
margin-right: 10rpx;
}
.t-tab-bar {
border-top: 1px solid #eee;
position: relative;
}
.activity {
display: flex;
justify-content: space-between;
padding: 20rpx 0;
border-bottom: 1px solid #eee;
.t-image {
width: 100%;
}
}

31
pages/home/home.wxml Normal file
View file

@ -0,0 +1,31 @@
<view>
<t-swiper wx:if="{{swiperList.length > 0}}" current="{{current}}" autoplay="{{true}}" duration="{{500}}" height="{{180}}" interval="{{3000}}" list="{{swiperList}}" navigation="{{ { type: 'dots-bar' } }}" bind:click="onSwiperTap" />
<view class="title_bar" wx:if="{{list.length}}">
<view class="title" bind:tap="refresh">
公司动态
<t-icon name="refresh" size="28rpx" color="71737b"></t-icon>
</view>
<view class="btn" bind:tap="goMore">
查看全部
<t-icon name="chevron-right" size="28rpx" color="71737b"></t-icon>
</view>
</view>
<view class="list" wx:if="{{list.length}}">
<view class="item" wx:for="{{list}}" wx:key="id">
<view class="item-main" data-id="{{item.id}}" bind:tap="goDetail">
<t-image mode="aspectFill" src="{{cdnHost+item.poster}}" width="108" height="72" shape="round" />
<view class="right">
<view class="text">{{item.title}}</view>
<view class="info">
<view>{{item.create_time}}</view>
<view class="viewcnt">
<t-icon name="browse" size="28rpx" color="71737b"></t-icon>
{{item.view_cnt}}
</view>
</view>
</view>
</view>
<t-divider />
</view>
</view>
</view>

84
pages/home/home.wxss Normal file
View file

@ -0,0 +1,84 @@
page {
box-sizing: border-box;
background-color: linear-gradient(180deg, #f0f4fc, #fff);
padding: 0 20rpx;
padding-top: 10rpx;
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
}
.title_bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 32rpx;
}
.title_bar .title {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-position: left center;
background-size: 100% 100%;
font-size: 32rpx;
color: #353a47;
height: 34rpx;
display: flex;
align-items: center;
font-weight: bold;
}
.title_bar .title .t-icon {
margin-left: 10rpx;
}
.title_bar .btn {
color: #71737b;
font-size: 28rpx;
display: flex;
align-items: center;
}
.title_bar .btn .t-icon {
margin-left: 10rpx;
}
.list {
margin-top: 20rpx;
}
.list .item .item-main {
display: flex;
}
.list .item .item-main .right {
flex: 1;
padding-left: 32rpx;
}
.list .item .item-main .right .text {
padding-top: 0rpx;
font-size: 28rpx;
line-height: 46rpx;
margin-bottom: 10rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
color: #363a44;
}
.list .item .item-main .right .info {
display: flex;
font-size: 24rpx;
justify-content: space-between;
color: #71737b;
}
.list .item .item-main .right .info .viewcnt {
display: flex;
align-items: center;
}
.list .item .viewcnt .t-icon {
margin-right: 10rpx;
}
.t-tab-bar {
border-top: 1px solid #eee;
position: relative;
}
.activity {
display: flex;
justify-content: space-between;
padding: 20rpx 0;
border-bottom: 1px solid #eee;
}
.activity .t-image {
width: 100%;
}

8
pages/home/readme Normal file
View file

@ -0,0 +1,8 @@
首页功能设定
1. loading入场
2. 下拉刷新
3. 搜索栏
4. 分类切换
5. 商品列表
6. 规格弹层
7. 加载更多