index.vue 17 KB

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