detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="detail-page">
  3. <!-- Top Background -->
  4. <view class="header-bg"></view>
  5. <!-- Custom Navbar -->
  6. <Navbar title="非暴力沟通" :titleSize="32" title-color="#fff" back-icon-color="#fff" background="transparent">
  7. </Navbar>
  8. <!-- Notification Bar -->
  9. <view class="notification-bar">
  10. <u-avatar size="40" src="https://img.yzcdn.cn/vant/cat.jpeg"></u-avatar>
  11. <text class="notif-text">微 ** 用户 购买了 《苏菲的世界》</text>
  12. </view>
  13. <view class="content-scroll">
  14. <!-- Book Cover Area -->
  15. <view class="cover-area">
  16. <image class="book-cover" :src="product.cover" mode="aspectFill"></image>
  17. <view class="share-btn" @click="openSharePopup">
  18. <image src="/pages-sell/static/goods/icon-share.png" class="share-icon"></image>
  19. <text>分享</text>
  20. </view>
  21. </view>
  22. <!-- Product Info Card -->
  23. <InfoCard :product="product"></InfoCard>
  24. <!-- Banner -->
  25. <view class="banner-area">
  26. <image src="/pages-sell/static/top-banner.png" class="banner-img" mode="widthFix"></image>
  27. </view>
  28. <!-- Service Info -->
  29. <ServiceCard @click="showServicePopup"></ServiceCard>
  30. <!-- Customer Service Float -->
  31. <FloatingDrag :width="120" :height="120" :initial-position="servicePosition"
  32. @position-change="handlePositionChange" :z-index="20">
  33. <!-- #ifdef MP-ALIPAY -->
  34. <button class="service-btn" @click="navigateToCustomerService">
  35. <image src="/pages-sell/static/goods/icon-kefu.png" class="cs-icon" style="width: 100rpx;" mode="widthFix"></image>
  36. </button>
  37. <!-- #endif -->
  38. <!-- #ifndef MP-ALIPAY -->
  39. <button class="service-btn" open-type="contact">
  40. <image src="/pages-sell/static/goods/icon-kefu.png" class="cs-icon" style="width: 100rpx" mode="widthFix"></image>
  41. </button>
  42. <!-- #endif -->
  43. </FloatingDrag>
  44. <!-- Tabs -->
  45. <view class="tabs-header">
  46. <view class="tab-item" :class="{ active: currentTab === 0 }" @click="switchTab(0)">
  47. <text>商品详情</text>
  48. <view class="indicator" v-if="currentTab === 0"></view>
  49. </view>
  50. <view class="tab-item" :class="{ active: currentTab === 1 }" @click="switchTab(1)">
  51. <text>相关推荐</text>
  52. <view class="indicator" v-if="currentTab === 1"></view>
  53. </view>
  54. </view>
  55. <!-- Product Detail Content -->
  56. <ProductContent
  57. :currentTab="currentTab"
  58. :product="product"
  59. :tipsContent="tipsContent"
  60. :relatedBooksList="relatedBooksList"
  61. @bookClick="onBookClick">
  62. </ProductContent>
  63. <u-gap height="220"></u-gap>
  64. </view>
  65. <!-- Footer -->
  66. <FooterBar :hasStock="hasStock" @addCart="openSelectPopup" @notify="handleNotify"></FooterBar>
  67. <!-- Select Popup -->
  68. <SelectGoodPopup ref="selectPopup" @confirm="onPopupConfirm"></SelectGoodPopup>
  69. <!-- Share Popup -->
  70. <SharePopup ref="sharePopup" :product="product"></SharePopup>
  71. </view>
  72. </template>
  73. <script>
  74. import Navbar from '@/components/navbar/navbar.vue'
  75. import SelectGoodPopup from '../components/select-good-popup/index.vue'
  76. import InfoCard from '../components/detail/info-card.vue'
  77. import ServiceCard from '../components/detail/service-card.vue'
  78. import ProductContent from '../components/detail/product-content.vue'
  79. import FooterBar from '../components/detail/footer-bar.vue'
  80. import FloatingDrag from "@/components/floating-drag.vue";
  81. import SharePopup from '../components/detail/share-popup.vue';
  82. export default {
  83. components: {
  84. Navbar,
  85. SelectGoodPopup,
  86. InfoCard,
  87. ServiceCard,
  88. ProductContent,
  89. FooterBar,
  90. FloatingDrag,
  91. SharePopup
  92. },
  93. data() {
  94. return {
  95. currentTab: 0,
  96. hasStock: true, // Toggle this to test stock status
  97. tipsContent: [
  98. '印刷版次较多,二手图书封面、版次、原价等信息可能与商品介绍有差异,具体以收到实物为准;',
  99. '二手图书性质特殊,不保证随新书赠送的光盘、海报、卡片等内容,仅支持图书质量问题退款,否则将扣除运费成本;',
  100. '收到的图书如有质量问题,请于七天内联系客服处理,超出售后时效,不予处理。'
  101. ],
  102. relatedBooksList: [
  103. { title: '工程数学线性代数第六版', edition: '同济大学数学系编', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  104. { title: '高等数学第七版(上册)', edition: '同济大学数学系', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  105. { title: 'C++ Primer Plus', edition: '第6版 中文版', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  106. { title: '深入理解计算机系统', edition: '原书第3版', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  107. { title: '算法导论', edition: '原书第3版', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  108. { title: 'Java编程思想', edition: '第4版', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  109. ],
  110. product: {
  111. id: 1,
  112. title: '非暴力沟通',
  113. author: '美 · 马歇尔 XXXX',
  114. authorFull: '马歇尔·卢森堡著 阮胤华',
  115. price: '13.80',
  116. balancePrice: '6.8',
  117. originalPrice: '36.80',
  118. cover: 'https://img.yzcdn.cn/vant/cat.jpeg', // Using placeholder for now
  119. publisher: '华夏出版社',
  120. publishDate: '2018-08',
  121. isbn: '9787508095226',
  122. intro: '作为一个遵纪守法的好人,也许我们从来没有把谈话和“暴力”扯上关系。不过如果稍微留意一下现实生活中的谈话方式,并且用心体会各种谈话方式给我们的不同感受,我们一定会发现,有些话确实伤人!言语上的指责、嘲讽、否定、说教以及任意打断、拒不回应、随意出口的评价和结论给我们带来的情感和精神上的创伤甚至比肉体的伤害更加令人痛苦。',
  123. catalog: '前言\n第一章 让爱融入生活\n第二章 是什么蒙蔽了爱?\n第三章 区分观察和评论\n第四章 体会和表达感受\n第五章 感受的根源\n第六章 请求帮助\n...'
  124. },
  125. servicePosition: {
  126. left: "auto",
  127. right: 0,
  128. bottom: "300rpx",
  129. },
  130. }
  131. },
  132. methods: {
  133. switchTab(index) {
  134. this.currentTab = index;
  135. },
  136. openSelectPopup() {
  137. this.$refs.selectPopup.open(this.product);
  138. },
  139. handleNotify() {
  140. uni.showToast({
  141. title: '已订阅到货通知',
  142. icon: 'success'
  143. });
  144. },
  145. onPopupConfirm(data) {
  146. console.log('Added to cart:', data);
  147. uni.showToast({
  148. title: '已加入购物车',
  149. icon: 'success'
  150. });
  151. },
  152. showServicePopup() {
  153. // Placeholder for service popup
  154. },
  155. onBookClick(book) {
  156. console.log('Book clicked:', book);
  157. uni.navigateTo({
  158. url: '/pages-sell/pages/detail?id=' + encodeURIComponent(book.title)
  159. });
  160. },
  161. openSharePopup() {
  162. this.$refs.sharePopup.open();
  163. },
  164. // 处理位置变更
  165. handlePositionChange(position) {
  166. this.servicePosition = position;
  167. },
  168. //支付宝小程序的客服
  169. navigateToCustomerService() {
  170. uni.navigateTo({
  171. url: "/pages-mine/pages/customer-service",
  172. });
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .detail-page {
  179. min-height: 100vh;
  180. background-color: #f5f5f5;
  181. position: relative;
  182. padding-bottom: 100rpx;
  183. }
  184. .header-bg {
  185. position: absolute;
  186. top: 0;
  187. left: 0;
  188. width: 100%;
  189. height: 664rpx;
  190. background: linear-gradient(0deg, #4ED868 0%, #D1FFE5 100%);
  191. z-index: 0;
  192. }
  193. .notification-bar {
  194. position: fixed;
  195. top: 180rpx;
  196. /* Adjust based on navbar height */
  197. left: 30rpx;
  198. z-index: 10;
  199. background: rgba(0, 0, 0, 0.3);
  200. border-radius: 30rpx;
  201. padding: 6rpx 20rpx 6rpx 6rpx;
  202. display: flex;
  203. align-items: center;
  204. .notif-text {
  205. font-size: 24rpx;
  206. color: #fff;
  207. margin-left: 10rpx;
  208. }
  209. }
  210. .content-scroll {
  211. position: relative;
  212. z-index: 1;
  213. height: 100vh;
  214. }
  215. .cover-area {
  216. position: relative;
  217. display: flex;
  218. justify-content: center;
  219. padding-top: 60rpx;
  220. padding-bottom: 40rpx;
  221. .book-cover {
  222. width: 360rpx;
  223. height: 360rpx;
  224. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, 0.1);
  225. }
  226. .share-btn {
  227. position: absolute;
  228. right: 50rpx;
  229. top: 50rpx;
  230. display: flex;
  231. flex-direction: column;
  232. align-items: center;
  233. z-index: 10; // Ensure it's clickable
  234. .share-icon {
  235. width: 40rpx;
  236. height: 40rpx;
  237. margin-bottom: 4rpx;
  238. }
  239. text {
  240. font-size: 20rpx;
  241. color: #333;
  242. }
  243. }
  244. }
  245. .banner-area {
  246. background: #f5f5f5;
  247. padding: 20rpx;
  248. .banner-img {
  249. width: 100%;
  250. border-radius: 20rpx;
  251. }
  252. }
  253. .service-btn {
  254. padding: 0;
  255. margin: 0;
  256. background-color: transparent;
  257. line-height: 1;
  258. border-radius: 0;
  259. &::after {
  260. border: none;
  261. }
  262. }
  263. .tabs-header {
  264. display: flex;
  265. justify-content: center;
  266. /* Center the tabs */
  267. background: #F8F8F8;
  268. padding: 20rpx 0;
  269. /* Remove horizontal padding as we center items */
  270. .tab-item {
  271. padding: 0 30rpx;
  272. /* Add internal padding for hit area */
  273. position: relative;
  274. text {
  275. font-family: 'Source Han Sans SC';
  276. font-size: 30rpx;
  277. /* Assuming 30px from design tool = 30rpx */
  278. color: #666666;
  279. transition: all 0.3s;
  280. }
  281. &.active {
  282. text {
  283. font-size: 30rpx;
  284. /* Keep consistent size or adjust if 'big' effect needed, user said 30px */
  285. font-weight: bold;
  286. color: #333333;
  287. }
  288. .indicator {
  289. position: absolute;
  290. bottom: 2rpx;
  291. /* Adjust vertical position */
  292. left: 50%;
  293. transform: translateX(-50%);
  294. width: 120rpx;
  295. /* Make it wider or relative to text? Usually fixed or text width. Let's try matching text width visually or a fixed width */
  296. height: 8rpx;
  297. /* Slightly thicker for gradient visibility */
  298. background: linear-gradient(90deg, rgba(78, 217, 100, 0.1) 0%, #4ED964 100%);
  299. border-radius: 4rpx;
  300. }
  301. }
  302. }
  303. }
  304. </style>