From 7edbade4d2b1c74360d0cf40cdaa2eb0de379132 Mon Sep 17 00:00:00 2001 From: unknown <unknown@example.com> Date: 星期二, 27 二月 2024 09:32:14 +0800 Subject: [PATCH] 中台 --- assets/js/middleGround/api/ugc.js | 11 pages/home/home.js | 185 +++++++++++----------- pages/home/home.json | 4 static/images/home/shuzijiaocai.png | 0 static/images/home/zhuantitaolun.png | 0 static/images/home/tushufuwu.png | 0 assets/js/middleGround/api/store.js | 28 +- services/home/home.js | 52 +++++- assets/js/middleGround/tool.js | 3 custom-tab-bar/data.js | 2 app.json | 2 static/images/home/jingxuankecheng.png | 0 assets/js/middleGround/api/job.js | 4 static/images/home/1.png | 0 pages/home/home.wxml | 52 +++-- project.config.json | 3 pages/home/home.wxss | 107 +++--------- 17 files changed, 225 insertions(+), 228 deletions(-) diff --git a/app.json b/app.json index 7bd9cf8..252d23e 100644 --- a/app.json +++ b/app.json @@ -48,7 +48,7 @@ }, { "pagePath": "pages/goods/category/index", - "text": "鍒嗙被" + "text": "瀛︿範" }, { "pagePath": "pages/cart/index", diff --git a/assets/js/middleGround/api/job.js b/assets/js/middleGround/api/job.js index 5e455cf..2f30f78 100644 --- a/assets/js/middleGround/api/job.js +++ b/assets/js/middleGround/api/job.js @@ -14,7 +14,7 @@ }, newSession(data) { - let token = toolClass.getCookie(tokenKey); + let token = wx.getStorageSync(config.tokenKey) ? wx.getStorageSync(config.tokenKey) : '' return request({ url: token ? "/job/api/AppUserNewSession" : "/job/api/NewSession", method: "post", @@ -22,7 +22,7 @@ }); }, - newJobWithApiNewEvent(data){ + newJobWithApiNewEvent(data) { return request({ url: "/job/api/NewJobWithApiNewEvent", method: "post", diff --git a/assets/js/middleGround/api/store.js b/assets/js/middleGround/api/store.js index aecc4a2..a2c791e 100644 --- a/assets/js/middleGround/api/store.js +++ b/assets/js/middleGround/api/store.js @@ -48,10 +48,10 @@ : sort ? [sort] : [ - { - LinkOrder: 'Desc' - } - ], + { + LinkOrder: 'Desc' + } + ], CreateDate: [], Description: [], Name: [], @@ -110,7 +110,7 @@ ] }) } - let token = localStorage.getItem(tokenKey) + let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : ''; let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' return request({ url: url, @@ -192,10 +192,10 @@ SortQuery: cmsSort ? [cmsSort] : [ - { - ProductLinkOrder: 'Asc' - } - ], + { + ProductLinkOrder: 'Asc' + } + ], ProductLinkInfo: [], ...itemFields } @@ -264,10 +264,10 @@ SortQuery: sort ? [sort] : [ - { - LinkOrder: 'Desc' - } - ], + { + LinkOrder: 'Desc' + } + ], CreateDate: [], Description: [], Name: [], @@ -301,7 +301,7 @@ ] }) } - let token = localStorage.getItem(tokenKey) + let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : ''; let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' return request({ url: url, diff --git a/assets/js/middleGround/api/ugc.js b/assets/js/middleGround/api/ugc.js index 35d3b48..3ccce0d 100644 --- a/assets/js/middleGround/api/ugc.js +++ b/assets/js/middleGround/api/ugc.js @@ -1,11 +1,12 @@ import request from "../../../request/index"; import { tokenKey } from "../../config"; import toolClass from "../../toolClass"; +let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : '' const ugcApi = { // 鑾峰彇鍟嗗搧鐐硅禐Topic getProductLikesTopic(data) { return request({ - url: localStorage.getItem(tokenKey) + url: token ? "/ugc/api/ApiAppUserGetProductLikesTopic" : "/ugc/api/ApiGetProductLikesTopic", method: "post", @@ -16,7 +17,7 @@ // 鑾峰彇鍟嗗搧璇勮Topic getProductCommentTopic(data) { return request({ - url: localStorage.getItem(tokenKey) + url: token ? "/ugc/api/ApiAppUserGetProductCommentTopic" : "/ugc/api/ApiGetProductCommentTopic", method: "post", @@ -27,7 +28,7 @@ // 鑾峰彇MessageList getTopicMessageList(data) { return request({ - url: localStorage.getItem(tokenKey) + url: token ? "/ugc/api/ApiAppUserGetTopicMessageList" : "/ugc/api/ApiGetTopicMessageList", method: "post", @@ -63,8 +64,8 @@ // 鏇存柊message updateTopicMessage(data) { return request({ - url:'/ugc/api/ApiUpdateTopicMessage', - method:'post', + url: '/ugc/api/ApiUpdateTopicMessage', + method: 'post', data }) }, diff --git a/assets/js/middleGround/tool.js b/assets/js/middleGround/tool.js index af7e928..c9dfde1 100644 --- a/assets/js/middleGround/tool.js +++ b/assets/js/middleGround/tool.js @@ -6,7 +6,7 @@ datas, fields, path, - storeInfo, + storeInfo, repositoryInfo, coverSize, handelEBooK, @@ -419,6 +419,7 @@ if (md5) { src = requestCtx + `/file/GetPreViewImage?md5=${md5}`; } else { + return "" // return defaultImg; } if (width) src += `&width=${width}`; diff --git a/custom-tab-bar/data.js b/custom-tab-bar/data.js index d3c5032..023a451 100644 --- a/custom-tab-bar/data.js +++ b/custom-tab-bar/data.js @@ -11,7 +11,7 @@ }, { icon: 'sort', - text: '鍒嗙被', + text: '瀛︿範', url: 'pages/goods/category/index', }, { diff --git a/pages/home/home.js b/pages/home/home.js index 68bb735..d55db36 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -1,21 +1,19 @@ import { fetchHome } from '../../services/home/home'; -import { fetchGoodsList } from '../../services/good/fetchGoods'; -import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp() Page({ data: { - imgSrcs: [], - tabList: [], - goodsList: [], - goodsListLoadStatus: 0, + tabList: [], //鐩綍 pageLoading: false, - current: 1, - autoplay: true, - duration: '500', - interval: 5000, - navigation: { type: 'dots' }, - swiperImageProps: { mode: 'scaleToFill' }, - bannerList: [], + current: 1,//杞挱鍥惧弬鏁� + autoplay: true, //杞挱鍥惧弬鏁� + duration: '500',//杞挱鍥惧弬鏁� + interval: 5000,//杞挱鍥惧弬鏁� + navigation: { type: 'dots' },//杞挱鍥惧弬鏁� + bannerList: [], //杞挱鍥惧垪琛� + specialSubjectList: [],//涓撻璁ㄨ + courseList: [], + booksList: [], + textbookList: [] }, goodListPagination: { @@ -29,6 +27,7 @@ onShow() { this.getTabBar().init(); + this.loadHomePage(); this.getBannerList() }, @@ -37,17 +36,13 @@ }, onReachBottom() { - if (this.data.goodsListLoadStatus === 0) { - this.loadGoodsList(); - } }, - onPullDownRefresh() { this.init(); }, - init() { - this.loadHomePage(); + this.getSubjectList(); + this.getCourseList(); }, getBannerList() { const list = [] @@ -69,82 +64,12 @@ }) console.log('杞挱鍥�', this.data.bannerList); }, - loadHomePage() { - wx.stopPullDownRefresh(); - - this.setData({ - pageLoading: true, - }); - fetchHome().then(({ swiper, tabList }) => { - this.setData({ - tabList, - imgSrcs: swiper, - pageLoading: false, - }); - this.loadGoodsList(true); - }); - }, - - tabChangeHandle(e) { - this.privateData.tabIndex = e.detail; - this.loadGoodsList(true); - }, - - onReTry() { - this.loadGoodsList(); - }, - - async loadGoodsList(fresh = false) { - if (fresh) { - wx.pageScrollTo({ - scrollTop: 0, - }); - } - - this.setData({ goodsListLoadStatus: 1 }); - - const pageSize = this.goodListPagination.num; - let pageIndex = this.privateData.tabIndex * pageSize + this.goodListPagination.index + 1; - if (fresh) { - pageIndex = 0; - } - - try { - const nextList = await fetchGoodsList(pageIndex, pageSize); - this.setData({ - goodsList: fresh ? nextList : this.data.goodsList.concat(nextList), - goodsListLoadStatus: 0, - }); - - this.goodListPagination.index = pageIndex; - this.goodListPagination.num = pageSize; - } catch (err) { - this.setData({ goodsListLoadStatus: 3 }); - } - }, - - goodListClickHandle(e) { - const { index } = e.detail; - const { spuId } = this.data.goodsList[index]; - wx.navigateTo({ - url: `/pages/goods/details/index?spuId=${spuId}`, - }); - }, - - goodListAddCartHandle() { - Toast({ - context: this, - selector: '#t-toast', - message: '鐐瑰嚮鍔犲叆璐墿杞�', - }); - }, - + //鎼滅储 navToSearchPage() { wx.navigateTo({ url: '/pages/goods/search/index' }); }, - + //杞挱鍥捐烦杞� navToActivityDetail({ detail }) { - const data = this.data.bannerList[detail.index] console.log('璺宠浆', data.link); // const { index: promotionID = 0 } = detail || {}; @@ -152,4 +77,82 @@ // url: `/pages/promotion-detail/index?promotion_id=${promotionID}`, // }); }, + //鑾峰彇鐩綍 + loadHomePage() { + wx.stopPullDownRefresh(); + this.setData({ + pageLoading: true, + }); + fetchHome().then(({ tabList }) => { + this.setData({ + tabList, + pageLoading: false, + }); + }); + }, + //鐐瑰嚮鐩綍 + toPages(item) { + let info = item.target.dataset.info + if (info.url) { + wx.navigateTo({ + url: info.url + }) + } else { + wx.showToast({ + title: "寤鸿涓�", + icon: 'none', + duration: 2000 + }) + } + }, + //涓撻璁ㄨ + getSubjectList() { + const obj = { + storeInfo: "jsek_seminar", + path: 'jsek_homepageSeminar', + coverSize: { + width: 400 + }, + paging: { + start: 0, + size: 3 + }, + fields: { + liveTime: [], + lecturer: [], + startTime: [], + jsek_link: [] + } + } + app.MG.store.getProductList(obj).then((res) => { + this.setData({ + specialSubjectList: res.datas + }) + }) + }, + //绮鹃�夎绋嬪垪琛� + getCourseList(item) { + const obj = { + storeInfo: "app.config.goodsStore", + path: 'jsek_homepageDigitalTextbooks', + coverSize: { + width: 260 + }, + paging: { + start: 0, + size: 4 + }, + fields: { + courseLeader: [], + affiliatedUnit: [], + publishingUnit: [], + classHours: [] + } + } + app.MG.store.getProductList(obj).then((res) => { + this.setData({ + courseList: res.datas + }) + }) + } }); diff --git a/pages/home/home.json b/pages/home/home.json index e722c9a..24ccee4 100644 --- a/pages/home/home.json +++ b/pages/home/home.json @@ -14,6 +14,8 @@ "t-tabs": "tdesign-miniprogram/tabs/tabs", "t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel", "goods-list": "/components/goods-list/index", - "load-more": "/components/load-more/index" + "load-more": "/components/load-more/index", + "t-grid": "tdesign-miniprogram/grid/grid", + "t-grid-item": "tdesign-miniprogram/grid-item/grid-item" } } \ No newline at end of file diff --git a/pages/home/home.wxml b/pages/home/home.wxml index f92982d..63c8cd3 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -2,35 +2,43 @@ <t-loading theme="circular" size="40rpx" text="鍔犺浇涓�..." inherit-color /> </view> <view class="home-page-header"> - <view class="search" bind:tap="navToSearchPage"> - <t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="璇疯緭鍏ュ叧閿瘝/涔﹀悕/ISBN/浣滆��" leftIcon="" disabled> - <t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" /> + <view class="search"> + <t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="璇疯緭鍏ュ叧閿瘝/涔﹀悕/ISBN/浣滆��" leftIcon=""> + <t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" bind:tap="navToSearchPage" /> </t-search> </view> <view class="swiper-wrap"> - <t-swiper - wx:if="{{bannerList.length > 0}}" - list="{{bannerList}}" - current="{{current}}" - autoplay="{{autoplay}}" - duration="{{duration}}" - interval="{{interval}}" - navigation="{{navigation}}" - bind:click="navToActivityDetail" - /> - </view> - <view class="headerList"> - + <t-swiper wx:if="{{bannerList.length > 0}}" list="{{bannerList}}" current="{{current}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" navigation="{{navigation}}" bind:click="navToActivityDetail" /> </view> </view> +<view class="home-page-menu"> + <t-grid class="t-grid-block" theme="card" border="{{border}}" column="{{5}}"> + <t-grid-item wx:for="{{tabList}}" wx:for-index="index" wx:key="index" text="{{item.text}}" image="{{item.icon}}" data-info="{{item}}" bindtap="toPages" /> + </t-grid> +</view> <view class="home-page-container"> - <view class="home-page-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-tab-panel wx:for="{{tabList}}" wx:for-index="index" wx:key="index" label="{{item.text}}" value="{{item.key}}" /> - </t-tabs> - </view> + <view class="home-page-list"> + <view class="tabCardPublic"> + <view class="icon"> + <t-image src="/static/images/home/zhuantitaolun.png" mode="heightFix" class="iconImage" /> + </view> + <view bindtap="onMoreGuide"> + <text class="more">鏇村</text> + </view> + </view> + <view> + <view wx:for="{{specialSubjectList}}" wx:for-item="item" wx:for-index="index" wx:key="index" bindtap="toList" data-info="{{item}}"> + <view class="specialSubject-img"> + <t-image src="{{item.icon}}" mode="aspectFill" width="50" height="50" /> + </view> + <view class="body-info"> + <view>{{item.name}}</view> + </view> + </view> + </view> - <goods-list wr-class="goods-list-container" goodsList="{{goodsList}}" bind:click="goodListClickHandle" bind:addcart="goodListAddCartHandle" /> + + </view> <load-more list-is-empty="{{!goodsList.length}}" status="{{goodsListLoadStatus}}" bind:retry="onReTry" /> <t-toast id="t-toast" /> </view> \ No newline at end of file diff --git a/pages/home/home.wxss b/pages/home/home.wxss index bc25a36..bf3e88f 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -3,30 +3,21 @@ padding-bottom: calc(env(safe-area-inset-bottom) + 96rpx); } -.t-tabs.t-tabs--top .t-tabs__scroll { - border-bottom: none !important; -} - .home-page-header { - background: linear-gradient(#fff, #f5f5f5); + position: relative; } -.home-page-container { - background: #f5f5f5; -} - - -.home-page-header { - display: block; -} - -.home-page-container { - display: block; - padding: 0 24rpx; +.home-page-header .search { + position: absolute; + top: 20rpx; + left: 0; + width: 100%; + z-index: 99; } .home-page-header .t-search__input-container { - border-radius: 32rpx !important; + border-radius: 15rpx !important; + margin: 0 24rpx; height: 64rpx !important; } @@ -35,78 +26,40 @@ color: rgb(116, 116, 116) !important; } -.home-page-header .swiper-wrap { - margin-top: 20rpx; +.home-page-header .swiper-wrap .t-swiper-host { + border-radius: 0; } .home-page-header .t-image__swiper { width: 100%; height: 300rpx; - /* border-radius: 10rpx; */ } -.home-page-container .t-tabs { - background: #f5f5f5 !important; +.home-page-container { + display: block; + padding: 0 24rpx; } -.home-page-container .t-tabs .t-tabs-nav { - background-color: transparent; - line-height: 80rpx; - font-size: 28rpx; - color: #333; +.tabCardPublic { + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + padding: 20rpx 5rpx; + box-sizing: border-box; } -.home-page-container .t-tabs .t-tabs-scroll { - border: none !important; +.tabCardPublic .icon { + width: 246rpx; + height: 72rpx; } -/* 鍗婁釜瀛� */ -.home-page-container .tab.order-nav .order-nav-item.scroll-width { - min-width: 165rpx; +.tabCardPublic .icon .t-image { + width: 100%; + height: 100% } -.home-page-container .tab .order-nav-item.active { - color: #fa550f !important; -} - -.home-page-container .tab .bottom-line { - border-radius: 4rpx; -} - -.home-page-container .tab .order-nav-item.active .bottom-line { - background-color: #fa550f !important; -} - -.home-page-container .tabs-external__item { - /* color: #666 !important; */ - font-size: 28rpx; -} - -.home-page-container .tabs-external__active { - color: #333333 !important; - font-size: 32rpx; -} - -.home-page-container .tabs-external__track { - /* background-color: #fa4126 !important; */ - height: 6rpx !important; - border-radius: 4rpx !important; - width: 48rpx !important; -} - -.t-tabs.t-tabs--top .t-tabs__item, -.t-tabs.t-tabs--bottom .t-tabs__item { - height: 86rpx !important; -} - -.home-page-container .goods-list-container { - background: #f5f5f5 !important; - margin-top: 16rpx; -} - -.home-page-tabs { - --td-tab-nav-bg-color: transparent; - --td-tab-border-color: transparent; - --td-tab-item-color: #666; - --td-tab-track-color: red; +.tabCardPublic .more { + font-size: 24rpx; + color: #999; } \ No newline at end of file diff --git a/project.config.json b/project.config.json index edfa5da..941a45c 100644 --- a/project.config.json +++ b/project.config.json @@ -43,7 +43,8 @@ "showES6CompileOption": false, "useCompilerPlugins": false, "ignoreUploadUnusedFiles": true, - "useStaticServer": true + "useStaticServer": true, + "condition": false }, "compileType": "miniprogram", "libVersion": "2.23.1", diff --git a/services/home/home.js b/services/home/home.js index 7d4469d..5bb98db 100644 --- a/services/home/home.js +++ b/services/home/home.js @@ -1,43 +1,71 @@ -import { config, cdnBase } from '../../config/index'; - +import { config } from '../../config/index'; /** 鑾峰彇棣栭〉鏁版嵁 */ function mockFetchHome() { const { delay } = require('../_utils/delay'); - const { genSwiperImageList } = require('../../model/swiper'); return delay().then(() => { return { - swiper: genSwiperImageList(), tabList: [ { - text: '绮鹃�夋帹鑽�', + text: '鍥句功鏈嶅姟', key: 0, + icon: '/static/images/home/1.png', + url: '/pages/bookServices/index', }, { - text: '澶忔棩闃叉檼', + text: '鏁板瓧闃呰', key: 1, + icon: '', + url: '', }, { - text: '浜岃儙澶т綔鎴�', + text: '鏁板瓧璇剧▼', key: 2, + icon: "", + url: '', }, { - text: '浜烘皵姒�', + text: '鏁板瓧鏁欐潗', key: 3, + icon: "", + url: '', }, { - text: '濂借瘎姒�', + text: '涓撻璁ㄨ', key: 4, + icon: "", + url: '', }, { - text: 'RTX 30', + text: '绾夸笂涔﹀睍', key: 5, + icon: "", + url: '', }, { - text: '鎵嬫満涔熺柉鐙�', + text: '涔︾洰涓嬭浇', key: 6, + icon: "", + url: '', }, + { + text: '鏁欏笀璁よ瘉', + key: 7, + icon: "", + url: '', + }, + { + text: '鏍蜂功鐢宠', + key: 8, + icon: "", + url: '', + }, + { + text: '鎴戣鍑轰功', + key: 9, + icon: "", + url: '', + } ], - activityImg: `${cdnBase}/activity/banner.png`, }; }); } diff --git a/static/images/home/1.png b/static/images/home/1.png new file mode 100644 index 0000000..58d15dd --- /dev/null +++ b/static/images/home/1.png Binary files differ diff --git a/static/images/home/jingxuankecheng.png b/static/images/home/jingxuankecheng.png new file mode 100644 index 0000000..0d3c329 --- /dev/null +++ b/static/images/home/jingxuankecheng.png Binary files differ diff --git a/static/images/home/shuzijiaocai.png b/static/images/home/shuzijiaocai.png new file mode 100644 index 0000000..f687cff --- /dev/null +++ b/static/images/home/shuzijiaocai.png Binary files differ diff --git a/static/images/home/tushufuwu.png b/static/images/home/tushufuwu.png new file mode 100644 index 0000000..895c92f --- /dev/null +++ b/static/images/home/tushufuwu.png Binary files differ diff --git a/static/images/home/zhuantitaolun.png b/static/images/home/zhuantitaolun.png new file mode 100644 index 0000000..03da36c --- /dev/null +++ b/static/images/home/zhuantitaolun.png Binary files differ -- Gitblit v1.9.1