From 062e145773fb109916dfc5441ad942e28acf5d2e Mon Sep 17 00:00:00 2001 From: hflllll Date: Wed, 17 Sep 2025 17:41:48 +0800 Subject: [PATCH] =?UTF-8?q?'=E8=81=94=E8=B0=83=E4=B8=80=E5=8D=8A=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BA=86'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/modules/book.js | 86 ++++++++++++++ api/modules/promotion.js | 20 +++- api/request.js | 8 +- config/index.js | 4 +- mixins/list.js | 8 +- pages/index/desk.vue | 214 ++++++++++++++++++++--------------- pages/index/home.vue | 270 +++++++++++++++++++++----------------------- pages/index/member.vue | 24 ++++ pages/index/user.vue | 5 +- subPages/home/directory.vue | 104 +++++++++-------- subPages/home/search.vue | 75 ++++++++++-- subPages/user/discount.vue | 106 ++++------------- subPages/user/promote.vue | 74 ++++-------- subPages/user/team.vue | 20 +++- 14 files changed, 580 insertions(+), 438 deletions(-) diff --git a/api/modules/book.js b/api/modules/book.js index 9dd301e..87b657b 100644 --- a/api/modules/book.js +++ b/api/modules/book.js @@ -1,5 +1,91 @@ import request from "@/api/request"; +import http from "@/api/http"; export default { + // 删除书桌 + async delStand(data){ + return request({ + url: "/books/delStand", + method: "POST", + data, + needToken: true, + }) + }, + + // 加入书桌 + async addStand(data){ + return request({ + url: "/books/addStand", + method: "POST", + data, + needToken: true, + }) + }, + + // 查询书桌列表 + async stand(data){ + return request({ + url: "/books/stand", + method: "GET", + data, + needToken: true, + }) + }, + + // 查询书籍列表 + async list(data, isDebounce = true){ + if(isDebounce){ + return http({ + url: "/books/list", + method: "GET", + data, + debounce: 200 + }) + }else { + return request({ + url: "/books/list", + method: "GET", + data + }) + } + }, + + // 查询书籍标签 + async label(data){ + return request({ + url: "/books/label", + method: "GET", + data + }) + }, + +// 获取课程列表 + async course(data){ + return request({ + url: "/books/course", + method: "GET", + data + }) + }, + + + // 查询书籍分类 + async category(data){ + return request({ + url: "/books/category", + method: "GET", + data + }) + }, + + + // 查询书籍详情 + async detail(data){ + return request({ + url: "/books/detail", + method: "GET", + data + }) + } } \ No newline at end of file diff --git a/api/modules/promotion.js b/api/modules/promotion.js index 84c5c3e..513851f 100644 --- a/api/modules/promotion.js +++ b/api/modules/promotion.js @@ -1,5 +1,23 @@ import request from "@/api/request"; export default { - + async water(data){ + return request({ + url: "/promotion/water", + method: "GET", + data, + needToken: true + }) + }, + + + // 我的团队 + async team(data){ + return request({ + url: "/promotion/team", + method: "GET", + data, + needToken: true + }) + } } \ No newline at end of file diff --git a/api/request.js b/api/request.js index 314ae79..7677f26 100644 --- a/api/request.js +++ b/api/request.js @@ -24,7 +24,10 @@ export default function request({ icon: 'none' }) uni.reLaunch({ url: '/subPages/login/login' }) - return + return Promise.reject({ + code: 401, + message: '请先登录' + }) } } return new Promise((resolve, reject) => { @@ -79,6 +82,9 @@ export default function request({ switch (res.statusCode) { case 401: + uni.reLaunch({ url: '/subPages/login/login' }) + error.message = '请先登录' + break; case 403: uni.removeStorageSync('token') uni.reLaunch({ url: '/subPages/login/login' }) diff --git a/config/index.js b/config/index.js index c8ac0d1..01a536e 100644 --- a/config/index.js +++ b/config/index.js @@ -12,14 +12,14 @@ const envParam = { prod: 'production', } -const env = envParam['test'] +const env = envParam['dev'] // 全局配置 const config = { // 网络全局配置 netConfig: { development: { - baseURL: 'http://h5.xzaiyp.top/englishread-admin/doc.html', + baseURL: 'http://h5.xzaiyp.top/englishread-admin/appletApi', }, testing: { baseURL: 'https://www.multipleculture.com/englishread-admin/appletApi', diff --git a/mixins/list.js b/mixins/list.js index e647bce..d358b63 100644 --- a/mixins/list.js +++ b/mixins/list.js @@ -23,7 +23,9 @@ export default { // 列表是否需要上拉加载 isReachBottomLoad: true, // 额外返回出去的数据的路径 - extraDataPath: '' + extraDataPath: '' , + // 自定义onShow + customOnShow: false, } } }, @@ -113,11 +115,11 @@ export default { }, }, async onShow() { - // if (!this.list.length) { + if (!this.mixinListConfig.customOnShow) { if (this.mixinFnBeforePageShow) this.mixinFnBeforePageShow() this.initPage() await this.getList(true) - // } + } }, async onPullDownRefresh() { // 在下拉还没结束前 不做任何操作 diff --git a/pages/index/desk.vue b/pages/index/desk.vue index e088505..d9919b4 100644 --- a/pages/index/desk.vue +++ b/pages/index/desk.vue @@ -14,8 +14,12 @@ color="#C6C6C6" height="32" margin="0" + v-model="searchKeyword" searchIconColor="#8B8B8B" placeholderColor="#c6c6c6" + @search="handleSearch" + @clear="handleSearch" + @custom="handleSearch" > @@ -24,122 +28,125 @@ - + + + + + - {{ book.title }} + {{ book.book.booksName }} - {{ book.grade }}/ + {{ book.book.categoryName }}/ - {{ book.duration }} + {{ book.book.duration }} + + @@ -189,11 +196,30 @@ export default { border-radius: 16rpx; overflow: hidden; margin-bottom: 16rpx; + position: relative; image { width: 100%; height: 100%; } + + .delete-btn { + position: absolute; + top: 8rpx; + right: 8rpx; + width: 32rpx; + height: 32rpx; + background: rgba(0, 0, 0, 0.6); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + z-index: 10; + + &:active { + background: rgba(0, 0, 0, 0.8); + } + } } .book-grid-info { diff --git a/pages/index/home.vue b/pages/index/home.vue index 0c45bde..798b46a 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -31,7 +31,7 @@ :class="{ active: activeTab === index }" @click="switchTab(index)" > - {{ tab }} + {{ tab.title }} @@ -53,93 +53,90 @@ > - - - - 今日更新 + + + + {{ labelData.labelInfo.title }} 更多 - + + + - + - {{ item.title }} - {{ item.author }} - {{ item.duration }} + {{ item.booksName }} + {{ item.booksAuthor }} + + + {{ item.duration }} + - - - - - - 推荐书籍 - - 更多 - - - - + + + - - + {{ book.duration }} - {{ book.title }} + {{ book.booksName }} - - - - - - 四级精讲短文合集书 - - 更多 - - - - + + + - + - {{ book.title }} + {{ book.booksName }} - {{ book.grade }}/ + {{ book.categoryName }}/ {{ book.duration }} @@ -169,7 +166,7 @@ export default { data() { return { // Tab数据 - tabs: ['为你推荐', '精选', '短文', '专栏', '初中', '四六级'], + tabs: [ ], activeTab: 0, // 轮播图数据 @@ -177,97 +174,15 @@ export default { ], - - - // 今日更新数据 - todayUpdates: [ - { - cover: '/static/默认图片.png', - title: '全脑孩子:12项革命性策略...', - author: 'Daniel J. Siegel / Tina Payne Bryso...', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '全脑孩子:12项革命性策略...', - author: 'Daniel J. Siegel / Tina Payne Bryso...', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '全脑孩子:12项革命性策略...', - author: 'Daniel J. Siegel / Tina Payne Bryso...', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '全脑孩子:12项革命性策略...', - author: 'Daniel J. Siegel / Tina Payne Bryso...', - duration: '03:24' - }, + // 书籍分类 + labels: [ + ], - // 推荐书籍数据 - recommendBooks: [ - { - cover: '/static/默认图片.png', - title: 'The Power of Now 擦拭才:The Power of Now :The Power of Now :', - - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: 'Dealing in Desire 擦擦:The Power of Now :The Power of Now :', - - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: 'A New Earth擦超2 :The Power of Now :The Power of Now :', + // 根据label获取的书籍数据(二维数组) + labelBooksData: [], + - duration: '03:24' - } - ], - - // 书籍网格数据 - bookGridList: [ - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - }, - { - cover: '/static/默认图片.png', - title: '精讲短文', - grade: '四级', - duration: '03:24' - } - ], // 推荐列表数据 recommendList: [ @@ -278,8 +193,9 @@ export default { methods: { // 切换Tab - switchTab(index) { + async switchTab(index) { this.activeTab = index + await this.getBooksByLabels() }, // 轮播图点击事件 @@ -298,9 +214,9 @@ export default { url: '/subPages/home/search' }) }, - goBook() { + goBook(book) { uni.navigateTo({ - url: '/subPages/home/directory' + url: '/subPages/home/directory?id=' + book.id }) }, async getBanner() { @@ -321,11 +237,85 @@ export default { type: item.type })) } + }, + // 获取书籍分类 + async getCategory() { + const categoryRes = await this.$api.book.category() + if (categoryRes.code === 200){ + this.tabs = categoryRes.result.map(item => ({ + title:item.title, + id: item.id + })) + } + }, + // 获取书籍标签 + async getLabel() { + const labelRes = await this.$api.book.label() + if (labelRes.code === 200){ + this.labels = labelRes.result.map(item => ({ + title:item.lable, + id: item.id + })) + } + }, + + + // 根据label数组获取书籍数据 + async getBooksByLabels() { + if (!this.labels || this.labels.length === 0) { + console.log('labels数据为空,无法获取书籍') + return + } + + try { + // 创建请求数组,每个label发起一次请求 + const requests = this.labels.map(label => + this.$api.book.list({ + label: label.id, + pageNo: 1, + pageSize: 6, + category: this.tabs[this.activeTab].id + }, false) + ) + + // 并发执行所有请求 + const responses = await Promise.all(requests) + + // 创建二维数组存储结果 + this.labelBooksData = responses.map((response, index) => { + if (response.code === 200) { + return { + labelInfo: this.labels[index], + books: response.result.records || [] + } + } else { + console.error(`获取label ${this.labels[index].title} 的书籍失败:`, response) + return { + labelInfo: this.labels[index], + books: [] + } + } + }) + + console.log('根据label获取的书籍数据:', this.labelBooksData) + } catch (error) { + console.error('获取书籍数据失败:', error) + this.labelBooksData = [] + } + }, + goLabel(label){ + uni.navigateTo({ + url: '/subPages/home/search?label=' + label.id + }) } }, async onShow() { - Promise.all([this.getBanner(), this.getSignup()]) + // 先获取基础数据 + await Promise.all([this.getBanner(), this.getSignup(), this.getCategory(), this.getLabel()]) + + // 根据label数据获取对应的书籍 + await this.getBooksByLabels() } } diff --git a/pages/index/member.vue b/pages/index/member.vue index c21d67b..09c25d9 100644 --- a/pages/index/member.vue +++ b/pages/index/member.vue @@ -53,6 +53,25 @@ + + + + + + 会员权益 @@ -345,6 +364,11 @@ export default{ } } } +/* 立即开通会员按钮样式 */ +.member-button-section { + margin: 40rpx 50rpx; +} + /* 会员权益样式 */ .benefits-section { margin-top: 40rpx; diff --git a/pages/index/user.vue b/pages/index/user.vue index d3177db..8821c1a 100644 --- a/pages/index/user.vue +++ b/pages/index/user.vue @@ -12,7 +12,7 @@ {{ isLogin ? userInfo.name : displayInfo.name }} 手机号:{{ isLogin ? userInfo.phone || displayInfo.phone : displayInfo.phone }} - {{ displayInfo.description }} + @@ -151,8 +151,7 @@ export default { displayInfo: { name: '点击登录', phone: 'xxxxxxxxx', - avatar: '/static/默认头像.png', - description: '世界这么美,我想去看看~' + avatar: '/static/默认头像.png' } } }, diff --git a/subPages/home/directory.vue b/subPages/home/directory.vue index 1ed31b7..5917f00 100644 --- a/subPages/home/directory.vue +++ b/subPages/home/directory.vue @@ -3,13 +3,13 @@ - + - {{ bookInfo.title }} - {{ bookInfo.subtitle }} - {{ bookInfo.author }} - {{ bookInfo.level }} + {{ bookInfo.translate }} + {{ bookInfo.booksName }} + {{ bookInfo.booksAuthor }} + {{ bookInfo.vipInfo.title }} @@ -41,19 +41,19 @@ {{ String(index + 1).padStart(2, '0') }} - {{ course.name }} - {{ course.subtitle }} + {{ course.english }} + {{ course.chinese }} - 全部课程 · {{ courseList.length }}节 + 全部课程 · {{ courseList.total }}节 @@ -62,7 +62,7 @@ 简介 - {{ bookInfo.introduction }} + {{ bookInfo.booksIntro }} @@ -71,15 +71,15 @@ 作者 - + - John Steinbeck - 约翰·斯坦贝克 + {{ bookInfo.enAuthor }} + {{ bookInfo.booksAuthor }} - 约翰·斯坦贝克(1902 — 1968)是美国现代小说家,1962 年荣获诺贝尔文学奖。斯坦贝克一生创作出了 27 部作品,它们大多着眼于美国底层人民的生活,对贫穷而善良的劳苦大众展现出了强烈的同情心。不仅为被压迫者申辩,而且还歌颂了他们在困境中生存的勇气和斗志。斯坦贝克最为优秀的几部作品都发表于 20世纪30年代之后,例如荣获美国国家图书奖、普利策奖的长篇小说《愤怒的葡萄》,具有浓厚乡土气息的短篇集《小红马》和中篇小说《人鼠之间》,以反法西斯战争为题材的中篇小说《月亮下去了》等。斯坦贝克既是地位崇高的文学大师,也是深受美国民众爱戴的畅销作家,他的作品不仅深刻影响了美国文学的发展,也启发了人们对社会、人性、生死等话题的思考。 + {{ bookInfo.aouthorIntro }} @@ -89,7 +89,7 @@ - + 加入课程 @@ -122,43 +122,59 @@ export default { '盛放会员': 'book-level-3', }, bookInfo: { - cover: '/static/默认图片.png', - title: 'The Little Prince', - subtitle: '小王子', - author: '圣-埃克苏佩里', - level: '朵蕾会员', - vocabularyRange: '1.6K~2.5K', - // 我是富文本字符串 - knowledgePoints: '
1. 41天读完法国作家圣埃克苏佩里文学作品
2. 掌握400+单词英文文本,收获对于法语的
3. 感受英文文学作品的魅力,在阅读中提升英语语感和文学素养
4. 通过英文原著,在生活中,对语言使用的文学性
5. 名作阅读
', - introduction: '在阿尔卑斯山上住着一个可爱的女孩小海蒂。她自幼失去父母,同性格倔强但心地善良的爷爷一起生活。后来,因为姨妈介绍的一个机会,海蒂去到了法兰克福,和一个叫克拉拉的女孩儿作伴。克拉拉自小患病无法行走,虽然两个孩子感情很好,但海蒂却因为想家患上了梦游症。最终海蒂回到了阿尔卑斯山,同山里的亲友们找回了幸福的生活。随后,克拉拉也如约前来拜访,在海蒂和爷爷的悉心照料下,奇迹发生了...' + }, + id: '', courseList: [ - { - name: 'Look, George!', - subtitle: '你瞧,乔治' - }, - { - name: 'A Live Mouse?', - subtitle: '活老鼠?' - }, - { - name: 'Beans with Ketchup', - subtitle: '豆子配番茄酱' - }, - { - name: 'Aunt Clara', - subtitle: '卡莉拉姑姑' - }, - { - name: 'No Ketchup', - subtitle: '无番茄酱' - } + ] } }, methods: { goBack() { uni.navigateBack() + }, + // 加入课程 + async joinCourse() { + const joinRes = await this.$api.book.addStand({ + id: this.id + }) + if (joinRes.code === 200){ + uni.showToast({ + title: '加入成功', + icon: 'success', + duration: 2000 + }) + } + }, + // 获取书籍详情 + async getDetail() { + const detailRes = await this.$api.book.detail({ + id: this.id + }) + if (detailRes.code === 200){ + this.bookInfo = detailRes.result + } + }, + // 获取书籍的课程 + async getCourse() { + const courseRes = await this.$api.book.course({ + id: this.id, + pageNo: 1, + pageSize: 5 + }) + if (courseRes.code === 200){ + this.courseList = courseRes.result + } + }, + }, + onLoad(options) { + if (options.id){ + this.id = options.id + Promise.all([ + this.getDetail(), + this.getCourse() + ]) } } } diff --git a/subPages/home/search.vue b/subPages/home/search.vue index 800d1c3..f96f000 100644 --- a/subPages/home/search.vue +++ b/subPages/home/search.vue @@ -25,6 +25,7 @@ }" @search="handleSearch" @custom="handleSearch" + @clear="handleSearch" >
@@ -39,7 +40,7 @@ :class="{ active: currentTab === index }" @click="switchTab(index)" > - {{ tab }} + {{ tab.title }}
@@ -48,42 +49,53 @@ - + - {{ book.title }} - {{ book.author }} + {{ book.booksName }} + {{ book.booksAuthor }} {{ book.duration }} - - {{ book.membership }} + + {{ book.vipInfo.title }} + + diff --git a/subPages/user/discount.vue b/subPages/user/discount.vue index ede5885..41640fb 100644 --- a/subPages/user/discount.vue +++ b/subPages/user/discount.vue @@ -17,36 +17,36 @@ ¥ - {{ coupon.amount }} + {{ coupon.money }} - {{ coupon.title }} - 有效期至 {{ coupon.expireDate }} + {{ coupon.name }} + 有效期至 {{ coupon.endTime }} - {{ coupon.status === 'used' ? '已使用' : '已过期' }} + {{ currentTab === 1 ? '已使用' : '已过期' }} @@ -67,9 +67,10 @@ + - + - - {{ item.avatarName }} + + {{ item.user_dictText }} {{ item.title }} - {{ item.date }} + {{ item.createTime }} - {{ item.amount }} - {{ item.status }} + +{{ item.money }} + {{ getText(item.withdrawal) }} @@ -109,56 +109,12 @@ diff --git a/subPages/user/team.vue b/subPages/user/team.vue index 436a7b5..8111206 100644 --- a/subPages/user/team.vue +++ b/subPages/user/team.vue @@ -12,7 +12,7 @@ bg-color="#f5f5f5" @search="handleSearch" @custom="handleSearch" - + @clear="handleCancel" :action-style="{color: '#fff', backgroundColor: '#06DADC', borderRadius:'8rpx', width:'100rpx', height: '64rpx', lineHeight: '64rpx', borderRadius: '198rpx', text:'white', fontSize:'26rpx'}" action > @@ -25,7 +25,7 @@ @@ -37,14 +37,19 @@ {{ member.name }} + +