index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <template>
  2. <view class="sell-container">
  3. <!-- 顶部背景图 -->
  4. <image class="top-bg-image" src="/pages-sell/static/top-bg.png" mode="widthFix"></image>
  5. <!-- 导航栏 -->
  6. <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
  7. <view class="navbar-content">
  8. <text class="navbar-title">书嗨</text>
  9. <!-- 右侧胶囊占位,保持布局平衡 -->
  10. <view class="nav-right-placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 主要内容区域 -->
  14. <view class="main-content" :style="{ marginTop: (statusBarHeight + 44) + 'px' }">
  15. <!-- 搜索框 -->
  16. <view class="search-wrapper" @click="navigateTo('/pages-sell/pages/search')">
  17. <view class="search-box-uview">
  18. <u-search placeholder="搜索关键字" :show-action="false" bg-color="transparent" height="40"
  19. :clearabled="true" v-model="keyword" :disabled="true"
  20. search-icon="/pages-sell/static/search-icon.png"></u-search>
  21. <view class="search-btn-overlay">
  22. <text>搜索</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- tab标签 -->
  27. <!-- <view class="tabs-wrapper">
  28. <u-tabs :list="hotTagList" :current="currentHotTag" @change="changeHotTag" bgColor="transparent"
  29. lineColor="transparent" :active-item-style="{ fontWeight: 'bold', color: '#333' }"
  30. inactive-color="#3C4F3E" :barStyle="barStyle" :bar-height="27" :bar-width="52"></u-tabs>
  31. </view> -->
  32. <!-- 顶部横幅 Banner -->
  33. <view class="top-banner-wrapper">
  34. <image src="/pages-sell/static/top-banner.png" class="top-banner-img" mode="widthFix"></image>
  35. </view>
  36. <!-- 金刚区分类图标 (2行5列) -->
  37. <view class="category-grid">
  38. <view class="grid-item" v-for="(item, index) in categoryList" :key="index"
  39. @click="handleCategory(item)">
  40. <view class="icon-circle">
  41. <image :src="item.imgUrl" class="cat-icon" mode="aspectFit"></image>
  42. </view>
  43. <text class="cat-name">{{ item.showCateName || '-' }}</text>
  44. </view>
  45. </view>
  46. <!-- 推广与热销双卡片 -->
  47. <view class="promo-dual-card">
  48. <!-- 左侧:推广卖书 -->
  49. <view class="card-left">
  50. <view class="card-content">
  51. <u-swiper :list="swiperList" :autoplay="true" :interval="3000" name="imgUrl"></u-swiper>
  52. </view>
  53. </view>
  54. <!-- 右侧:热销商品 -->
  55. <view class="card-right">
  56. <view class="right-header" @click="navigateTo('/pages-sell/pages/hot-sell')">
  57. <image src="/pages-sell/static/icon-fire.png" class="fire-icon" mode="widthFix"></image>
  58. <text class="right-title">热销商品</text>
  59. <image src="/pages-sell/static/icon-fire.png" class="fire-icon flip" mode="widthFix"></image>
  60. </view>
  61. <view class="products-container">
  62. <!-- 使用网络图片作为书的封面占位 -->
  63. <image v-for="(item, index) in bookList" :key="index" :src="item.imgUrl" class="product-cover" mode="aspectFill" @click="navigateTo(item.jumpUrl)"></image>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 健康与成长双卡片 -->
  68. <view class="info-dual-card">
  69. <swiper class="info-card-swiper" :autoplay="true" :interval="3000" :circular="true" >
  70. <swiper-item v-for="(item, index) in leftBookList" :key="index">
  71. <view class="info-card bg-orange" @click="navigateTo(item.jumpUrl)">
  72. <view class="info-text-group">
  73. <text class="info-title text-orange">{{ item.showCateName }}</text>
  74. <text class="info-desc text-orange-light">{{ item.remark }}</text>
  75. </view>
  76. <image :src="item.imgUrl" class="info-icon" mode="aspectFit"
  77. style="width: 125rpx;height: 111rpx;"></image>
  78. </view>
  79. </swiper-item>
  80. </swiper>
  81. <swiper class="info-card-swiper" :autoplay="true" :interval="3500" :circular="true">
  82. <swiper-item v-for="(item, index) in rightBookList" :key="index">
  83. <view class="info-card bg-green" @click="navigateTo(item.jumpUrl)">
  84. <view class="info-text-group">
  85. <text class="info-title text-green">{{ item.showCateName }}</text>
  86. <text class="info-desc text-green-light">{{ item.remark }}</text>
  87. </view>
  88. <image :src="item.imgUrl" class="info-icon" mode="aspectFit"></image>
  89. </view>
  90. </swiper-item>
  91. </swiper>
  92. </view>
  93. <!-- 公众号横幅 -->
  94. <view class="gzh-section" @click="navigateToOfficialAccount">
  95. <view class="gzh-bg-wrapper">
  96. <image src="/pages-sell/static/gzh-banner.png" class="gzh-img-bg" mode="aspectFill"></image>
  97. <view class="gzh-content-overlay">
  98. <text class="gzh-title">关注公众号 ,定期领红包</text>
  99. <view class="gzh-subtitle-pill">
  100. <text class="gzh-subtitle">别让好书蒙尘 ,书嗨陪你逐页品读</text>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 书嗨推荐 -->
  106. <view class="recommend-section" @click="navigateTo(item.jumpUrl)" v-for="(item, index) in topicList" :key="index">
  107. <view class="section-header">
  108. <text class="section-title">{{item.showCateName}}</text>
  109. <view class="view-more">
  110. <text>查看全部</text>
  111. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  112. </view>
  113. </view>
  114. <view class="book-list">
  115. <view class="book-item" v-for="(book, index) in getDisplayBooks(item)" :key="index" @click="navigateTo('/pages-sell/pages/detail?isbn=' + book.bookIsbn)">
  116. <image :src="book.bookImg" class="book-image" mode="aspectFill"></image>
  117. <text class="book-name">{{ book.bookName }}</text>
  118. <view class="price-row">
  119. <text class="currency">¥</text>
  120. <text class="price-val">{{ book.bookPrice }}</text>
  121. <text class="price-old">¥{{ book.bookOriginalPrice }}</text>
  122. </view>
  123. <view class="add-btn">
  124. <text>加入购物车</text>
  125. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <!-- 底部留白,防止遮挡 -->
  131. <view class="bottom-safe-area"></view>
  132. </view>
  133. </view>
  134. </template>
  135. <script>
  136. export default {
  137. name: 'SellContainer',
  138. data() {
  139. return {
  140. barStyle: {
  141. backgroundColor: 'transparent',
  142. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  143. backgroundSize: '100% 100%',
  144. position: 'relative',
  145. top: '-6rpx',
  146. },
  147. swiperList: [],
  148. statusBarHeight: 20,
  149. keyword: '',
  150. // u-tabs 需要对象数组 [{name: 'xxx'}]
  151. hotTagList: [
  152. { name: '热搜' },
  153. { name: '励志' },
  154. { name: '绘本' },
  155. { name: '诺贝尔文学奖' },
  156. { name: '茅盾奖' },
  157. { name: '童书' }
  158. ],
  159. currentHotTag: 0,
  160. // 临时的网络书封面图片
  161. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  162. categoryList: [], //金刚区
  163. bookList: [], // 右侧推荐书籍
  164. recommendBooks: [
  165. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  166. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  167. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  168. ],
  169. topicList:[], //专题推荐
  170. leftBookList:[], // 左侧推荐书籍
  171. rightBookList:[] // 右侧推荐书籍
  172. }
  173. },
  174. created() {
  175. const systemInfo = uni.getSystemInfoSync();
  176. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  177. this.getIndexCateInfo()
  178. },
  179. methods: {
  180. handleCategory(item) {
  181. if(!item.jumpUrl) return
  182. this.navigateTo(item.jumpUrl)
  183. },
  184. changeHotTag(index) {
  185. this.currentHotTag = index;
  186. console.log('切换标签:', index);
  187. },
  188. //跳转 URL
  189. navigateTo(url) {
  190. if(!url) return
  191. console.log(url)
  192. uni.navigateTo({
  193. url: url
  194. });
  195. },
  196. navigateToOfficialAccount() {
  197. uni.navigateTo({
  198. url: '/pages-mine/pages/customer-service'
  199. });
  200. },
  201. goRecommend() {
  202. uni.navigateTo({
  203. url: '/pages-sell/pages/recommend'
  204. });
  205. },
  206. goHotSell() {
  207. uni.navigateTo({
  208. url: '/pages-sell/pages/hot-sell'
  209. });
  210. },
  211. //获取首页装修信息
  212. getIndexCateInfo() {
  213. uni.$u.http.get('/token/shop/showIndex/getIndexCateInfo').then(res => {
  214. console.log(res)
  215. if (res.code == 200) {
  216. console.log(res.data)
  217. this.categoryList = res.data.find(item => item.position == 'diamond_area')?.shopIndexCateVo || []
  218. this.swiperList = res.data.find(item => item.position == 'left_banner')?.shopIndexCateVo || []
  219. this.bookList = res.data.find(item => item.position == 'right_banner')?.shopIndexCateVo || []
  220. this.leftBookList = res.data.find(item => item.position == 'left_book_list')?.shopIndexCateVo || []
  221. this.rightBookList = res.data.find(item => item.position == 'right_book_list')?.shopIndexCateVo || []
  222. //获取专题推荐
  223. this.topicList = res.data.find(item => item.position == 'topic')?.shopIndexCateVo || []
  224. }
  225. })
  226. },
  227. getDisplayBooks(item) {
  228. if (!item.bookInfoList) return []
  229. let limit = 3
  230. if (item.topicType === 2) {
  231. limit = 6
  232. }
  233. return item.bookInfoList.slice(0, limit)
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .sell-container {
  240. position: relative;
  241. min-height: 100vh;
  242. background-color: #F6F6F6;
  243. overflow-x: hidden;
  244. }
  245. /* 顶部大背景图 */
  246. .top-bg-image {
  247. position: absolute;
  248. top: 0;
  249. left: 0;
  250. width: 100%;
  251. z-index: 0;
  252. display: block;
  253. }
  254. /* 导航栏 */
  255. .custom-navbar {
  256. position: fixed;
  257. top: 0;
  258. left: 0;
  259. width: 100%;
  260. z-index: 100;
  261. display: flex;
  262. align-items: center;
  263. justify-content: center;
  264. .navbar-content {
  265. height: 44px;
  266. width: 100%;
  267. display: flex;
  268. align-items: center;
  269. justify-content: center;
  270. position: relative;
  271. .navbar-title {
  272. color: #fff;
  273. font-size: 36rpx;
  274. font-weight: 600;
  275. }
  276. }
  277. }
  278. .main-content {
  279. position: relative;
  280. z-index: 1;
  281. padding: 0 24rpx;
  282. }
  283. /* 搜索框 */
  284. .search-wrapper {
  285. margin-top: 10rpx;
  286. margin-bottom: 20rpx;
  287. .search-box-uview {
  288. height: 80rpx;
  289. background-color: #fff;
  290. border-radius: 40rpx;
  291. display: flex;
  292. align-items: center;
  293. padding: 0 10rpx 0 16rpx;
  294. position: relative;
  295. /* 覆盖 u-search 的 padding 以适配 */
  296. ::v-deep .u-search {
  297. flex: 1;
  298. /* 让输入框不遮挡右侧按钮 */
  299. padding-right: 140rpx !important;
  300. }
  301. .search-btn-overlay {
  302. position: absolute;
  303. right: 8rpx;
  304. top: 50%;
  305. transform: translateY(-50%);
  306. width: 140rpx;
  307. height: 64rpx;
  308. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  309. border-radius: 32rpx;
  310. display: flex;
  311. align-items: center;
  312. justify-content: center;
  313. z-index: 2;
  314. text {
  315. color: #fff;
  316. font-size: 28rpx;
  317. font-weight: 500;
  318. }
  319. }
  320. }
  321. }
  322. /* 顶部横幅 */
  323. .top-banner-wrapper {
  324. width: 100%;
  325. margin-bottom: 30rpx;
  326. position: relative;
  327. .top-banner-img {
  328. width: 100%;
  329. border-radius: 40rpx;
  330. display: block;
  331. }
  332. }
  333. /* 分类图标 */
  334. .category-grid {
  335. display: flex;
  336. flex-wrap: wrap;
  337. margin-bottom: 10rpx;
  338. .grid-item {
  339. width: 20%;
  340. display: flex;
  341. flex-direction: column;
  342. align-items: center;
  343. margin-bottom: 30rpx;
  344. .icon-circle {
  345. width: 96rpx;
  346. height: 96rpx;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. margin-bottom: 12rpx;
  351. .cat-icon {
  352. width: 100%;
  353. height: 100%;
  354. }
  355. }
  356. .cat-name {
  357. font-size: 24rpx;
  358. color: #333;
  359. font-weight: 500;
  360. }
  361. }
  362. }
  363. /* 推广双卡片 */
  364. .promo-dual-card {
  365. display: flex;
  366. justify-content: space-between;
  367. margin-bottom: 24rpx;
  368. .card-left {
  369. width: 48%;
  370. height: 252rpx;
  371. border-radius: 20rpx;
  372. position: relative;
  373. overflow: hidden;
  374. }
  375. .card-right {
  376. width: 48%;
  377. height: 252rpx;
  378. /* Updated background per request */
  379. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  380. border-radius: 20rpx;
  381. padding: 20rpx;
  382. box-sizing: border-box;
  383. .right-header {
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. margin-bottom: 20rpx;
  388. .right-title {
  389. font-size: 30rpx;
  390. font-weight: bold;
  391. color: #333;
  392. margin: 0 10rpx;
  393. }
  394. .fire-icon {
  395. width: 30rpx;
  396. height: 30rpx;
  397. }
  398. .flip {
  399. transform: scaleX(-1);
  400. }
  401. }
  402. .products-container {
  403. display: flex;
  404. justify-content: space-between;
  405. gap: 20rpx;
  406. .product-cover {
  407. flex: 1;
  408. height: 160rpx;
  409. border-radius: 12rpx;
  410. background-color: #f0f0f0;
  411. }
  412. }
  413. }
  414. }
  415. /* 信息双卡片 */
  416. .info-dual-card {
  417. display: flex;
  418. justify-content: space-between;
  419. margin-bottom: 24rpx;
  420. .info-card-swiper {
  421. width: 48%;
  422. height: 140rpx;
  423. border-radius: 12px;
  424. overflow: hidden;
  425. }
  426. .info-card {
  427. width: 100%;
  428. padding: 24rpx;
  429. border-radius: 12px;
  430. /* Updated radius */
  431. display: flex;
  432. justify-content: space-between;
  433. align-items: center;
  434. height: 140rpx;
  435. box-sizing: border-box;
  436. position: relative;
  437. /* For absolute icon */
  438. overflow: hidden;
  439. &.bg-orange {
  440. background: #FFF3E0;
  441. border: 1px solid #FFB72A;
  442. }
  443. &.bg-green {
  444. background: #D4F1D8;
  445. border: 1px solid #54A94E;
  446. }
  447. .info-text-group {
  448. flex: 1;
  449. z-index: 1;
  450. /* Ensure text is above */
  451. .info-title {
  452. font-size: 28rpx;
  453. font-weight: bold;
  454. display: block;
  455. margin-bottom: 6rpx;
  456. }
  457. .info-desc {
  458. font-size: 22rpx;
  459. line-height: 1.2;
  460. }
  461. .text-orange {
  462. color: #DB832D;
  463. }
  464. .text-orange-light {
  465. color: #DB832D;
  466. }
  467. .text-green {
  468. color: #1F8049;
  469. }
  470. .text-green-light {
  471. color: #1F8049;
  472. }
  473. }
  474. .info-icon {
  475. width: 100rpx;
  476. /* Slightly larger maybe */
  477. height: 100rpx;
  478. position: absolute;
  479. right: 0;
  480. bottom: 0;
  481. z-index: 0;
  482. opacity: 0.8;
  483. }
  484. }
  485. }
  486. /* 公众号 */
  487. .gzh-section {
  488. margin-bottom: 30rpx;
  489. height: 180rpx;
  490. /* Fixed height for consistency */
  491. border-radius: 20rpx;
  492. overflow: hidden;
  493. .gzh-bg-wrapper {
  494. width: 100%;
  495. height: 100%;
  496. position: relative;
  497. .gzh-img-bg {
  498. width: 100%;
  499. height: 100%;
  500. position: absolute;
  501. top: 0;
  502. left: 0;
  503. }
  504. .gzh-content-overlay {
  505. position: absolute;
  506. top: 0;
  507. left: 0;
  508. width: 60%;
  509. /* Only cover left side */
  510. height: 100%;
  511. padding: 30rpx;
  512. display: flex;
  513. flex-direction: column;
  514. justify-content: center;
  515. .gzh-title {
  516. font-size: 32rpx;
  517. font-weight: bold;
  518. color: #134E13;
  519. /* Dark green */
  520. margin-bottom: 16rpx;
  521. }
  522. .gzh-subtitle-pill {
  523. background: #FFF;
  524. border-radius: 24rpx;
  525. padding: 0 14rpx;
  526. line-height: 1.4;
  527. align-self: flex-start;
  528. .gzh-subtitle {
  529. font-size: 22rpx;
  530. color: #134E13;
  531. font-weight: 500;
  532. }
  533. }
  534. }
  535. }
  536. }
  537. /* 书嗨推荐 */
  538. .recommend-section {
  539. background-color: #fff;
  540. border-radius: 20rpx;
  541. padding: 30rpx;
  542. margin-bottom: 24rpx;
  543. .section-header {
  544. display: flex;
  545. justify-content: space-between;
  546. align-items: center;
  547. margin-bottom: 24rpx;
  548. .section-title {
  549. font-size: 32rpx;
  550. font-weight: bold;
  551. color: #333;
  552. }
  553. .view-more {
  554. display: flex;
  555. align-items: center;
  556. font-size: 24rpx;
  557. color: #8D8D8D;
  558. .arrow-icon {
  559. width: 12rpx;
  560. margin-left: 6rpx;
  561. }
  562. }
  563. }
  564. .book-list {
  565. display: flex;
  566. flex-wrap: wrap;
  567. justify-content: space-between;
  568. }
  569. .book-item {
  570. width: 200rpx;
  571. margin-bottom: 24rpx;
  572. display: flex;
  573. flex-direction: column;
  574. .book-image {
  575. width: 200rpx;
  576. height: 255rpx;
  577. border-radius: 2rpx;
  578. margin-bottom: 16rpx;
  579. background-color: #f9f9f9;
  580. }
  581. .book-name {
  582. font-family: 'Source Han Sans SC';
  583. font-weight: bold;
  584. font-size: 28rpx;
  585. color: #303030;
  586. margin-bottom: 10rpx;
  587. overflow: hidden;
  588. text-overflow: ellipsis;
  589. white-space: nowrap;
  590. }
  591. .price-row {
  592. display: flex;
  593. align-items: baseline;
  594. margin-bottom: 12rpx;
  595. .currency {
  596. font-family: 'Source Han Sans SC';
  597. font-weight: 500;
  598. font-size: 22rpx;
  599. color: #D81A00;
  600. }
  601. .price-val {
  602. font-family: 'Source Han Sans SC';
  603. font-weight: 500;
  604. font-size: 28rpx;
  605. color: #D81A00;
  606. margin-right: 12rpx;
  607. }
  608. .price-old {
  609. font-family: 'Source Han Sans SC';
  610. font-weight: 500;
  611. font-size: 22rpx;
  612. color: #999999;
  613. text-decoration: line-through;
  614. }
  615. }
  616. .add-btn {
  617. width: fit-content;
  618. height: 36rpx;
  619. line-height: 36rpx;
  620. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  621. border-radius: 18rpx;
  622. padding: 0 20rpx;
  623. display: flex;
  624. align-items: center;
  625. justify-content: center;
  626. text {
  627. font-size: 22rpx;
  628. color: #fff;
  629. }
  630. .cart-symbol {
  631. width: 24rpx;
  632. height: 24rpx;
  633. margin-left: 6rpx;
  634. }
  635. }
  636. }
  637. }
  638. .bottom-safe-area {
  639. height: 30rpx
  640. }
  641. </style>