index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="service-detail-page">
  3. <nav-bar title="服务详情"></nav-bar>
  4. <!-- 顶部主图区域 -->
  5. <view class="hero-section">
  6. <image :src="serviceData.heroImg" class="hero-img" mode="aspectFill"></image>
  7. <view class="hero-overlay"></view>
  8. <view class="hero-title-box">
  9. <text class="hero-main-title">{{ serviceData.heroTitle }}</text>
  10. <text class="hero-sub-title">{{ serviceData.heroSubTitle }}</text>
  11. </view>
  12. </view>
  13. <!-- 购买数据 -->
  14. <view class="info-section card">
  15. <view class="service-price-row">
  16. <view class="price-box">
  17. <text class="price-label">订单服务费:</text>
  18. <text class="price-symbol">¥</text>
  19. <text class="price-num">{{ serviceData.price }}</text>
  20. <text class="price-unit">{{ serviceData.unit }}</text>
  21. </view>
  22. </view>
  23. <text class="service-name-text">{{ serviceData.title }}</text>
  24. </view>
  25. <!-- 详情选项卡 -->
  26. <view class="tab-section card">
  27. <view class="tab-header">
  28. <view :class="['tab-btn', { active: activeTab === 'intro' }]" @click="activeTab = 'intro'">
  29. <text>服务介绍</text>
  30. </view>
  31. <view :class="['tab-btn', { active: activeTab === 'notice' }]" @click="activeTab = 'notice'">
  32. <text>下单须知</text>
  33. </view>
  34. </view>
  35. <view class="tab-content" v-if="activeTab === 'intro'">
  36. <text class="content-title">服务介绍</text>
  37. <rich-text :nodes="serviceData.intro" class="content-text"></rich-text>
  38. <view class="intro-images" v-if="serviceData.introImages && serviceData.introImages.length">
  39. <image v-for="(img, idx) in serviceData.introImages" :key="idx" :src="img" class="intro-img"
  40. mode="widthFix"></image>
  41. </view>
  42. </view>
  43. <view class="tab-content" v-if="activeTab === 'notice'">
  44. <text class="content-title">下单须知</text>
  45. <rich-text :nodes="serviceData.notice" class="content-text"></rich-text>
  46. </view>
  47. </view>
  48. <!-- 底部操作栏 -->
  49. <view class="footer-bar safe-bottom">
  50. <button class="buy-btn" @click="goToOrderApply">立即预约</button>
  51. </view>
  52. </view>
  53. </template>
  54. <script setup>
  55. import { ref, computed } from 'vue'
  56. import navBar from '@/components/nav-bar/index.vue'
  57. import { onLoad } from '@dcloudio/uni-app'
  58. const activeTab = ref('intro')
  59. const serviceInfo = ref(null)
  60. const defaultHeroImg = 'https://images.unsplash.com/photo-1544568100-847a948585b9?q=80&w=600&auto=format&fit=crop'
  61. onLoad((options) => {
  62. const storedService = uni.getStorageSync('currentService')
  63. if (storedService) {
  64. serviceInfo.value = storedService
  65. console.log('获取到的服务数据:', storedService)
  66. }
  67. })
  68. const serviceData = computed(() => {
  69. if (!serviceInfo.value) {
  70. return {
  71. heroImg: defaultHeroImg,
  72. heroTitle: '服务详情',
  73. heroSubTitle: '加载中...',
  74. price: '0',
  75. unit: '',
  76. booked: '0 人已约',
  77. title: '服务名称',
  78. intro: '加载中...',
  79. notice: '加载中...',
  80. introImages: []
  81. }
  82. }
  83. const service = serviceInfo.value
  84. const priceInYuan = service.price ? (service.price / 100).toFixed(2) : '0.00'
  85. return {
  86. type: service.id,
  87. title: service.name,
  88. heroTitle: service.name,
  89. heroSubTitle: service.remark || '专业服务',
  90. heroImg: service.iconUrl || defaultHeroImg,
  91. price: priceInYuan,
  92. unit: '',
  93. booked: '0 人已约',
  94. intro: service.introduction || '暂无介绍',
  95. introImages: [],
  96. notice: service.orderInstruction || '暂无须知'
  97. }
  98. })
  99. const goToOrderApply = () => {
  100. uni.navigateTo({
  101. url: `/pages/order/apply/index?service=${serviceData.value.type}`
  102. })
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .service-detail-page {
  107. background-color: #f5f5f5;
  108. min-height: 100vh;
  109. padding-bottom: 160rpx;
  110. }
  111. .hero-section {
  112. position: relative;
  113. width: 100%;
  114. height: 640rpx;
  115. overflow: hidden;
  116. }
  117. .hero-img {
  118. width: 100%;
  119. height: 100%;
  120. }
  121. .hero-overlay {
  122. position: absolute;
  123. top: 0;
  124. left: 0;
  125. right: 0;
  126. bottom: 0;
  127. background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.4) 80%, rgba(0, 0, 0, 0.7) 100%);
  128. }
  129. .hero-title-box {
  130. position: absolute;
  131. bottom: 48rpx;
  132. left: 40rpx;
  133. right: 40rpx;
  134. z-index: 2;
  135. }
  136. .hero-main-title {
  137. display: block;
  138. font-size: 52rpx;
  139. font-weight: 900;
  140. color: #fff;
  141. margin-bottom: 12rpx;
  142. }
  143. .hero-sub-title {
  144. display: block;
  145. font-size: 28rpx;
  146. color: rgba(255, 255, 255, 0.9);
  147. font-weight: 600;
  148. }
  149. .card {
  150. background-color: #fff;
  151. margin-bottom: 20rpx;
  152. }
  153. .info-section {
  154. padding: 32rpx 40rpx;
  155. position: relative;
  156. z-index: 3;
  157. border-radius: 24rpx 24rpx 0 0;
  158. margin-top: -24rpx;
  159. }
  160. .service-price-row {
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: flex-end;
  164. margin-bottom: 20rpx;
  165. }
  166. .price-box {
  167. display: flex;
  168. align-items: baseline;
  169. color: #f44336;
  170. }
  171. .price-label {
  172. font-size: 26rpx;
  173. color: #333;
  174. font-weight: bold;
  175. margin-right: 12rpx;
  176. }
  177. .price-symbol {
  178. font-size: 28rpx;
  179. font-weight: bold;
  180. }
  181. .price-num {
  182. font-size: 56rpx;
  183. font-weight: 900;
  184. line-height: 1;
  185. }
  186. .price-unit {
  187. font-size: 24rpx;
  188. color: #999;
  189. margin-left: 4rpx;
  190. }
  191. .bought-count {
  192. font-size: 24rpx;
  193. color: #999;
  194. background: #f5f5f5;
  195. padding: 4rpx 16rpx;
  196. border-radius: 20rpx;
  197. }
  198. .service-name-text {
  199. font-size: 32rpx;
  200. color: #111;
  201. font-weight: bold;
  202. }
  203. .tab-section {
  204. padding: 0;
  205. }
  206. .tab-header {
  207. display: flex;
  208. border-bottom: 1rpx solid #f0f0f0;
  209. }
  210. .tab-btn {
  211. flex: 1;
  212. text-align: center;
  213. padding: 24rpx 0;
  214. font-size: 28rpx;
  215. color: #666;
  216. position: relative;
  217. }
  218. .tab-btn.active {
  219. color: #fcd53f;
  220. font-weight: bold;
  221. }
  222. .tab-btn.active::after {
  223. content: '';
  224. position: absolute;
  225. bottom: 0;
  226. left: 50%;
  227. transform: translateX(-50%);
  228. width: 60rpx;
  229. height: 6rpx;
  230. background: #fcd53f;
  231. border-radius: 6rpx;
  232. }
  233. .tab-content {
  234. padding: 40rpx 32rpx;
  235. }
  236. .content-title {
  237. display: block;
  238. font-size: 32rpx;
  239. color: #333;
  240. font-weight: 900;
  241. margin-bottom: 24rpx;
  242. padding-left: 20rpx;
  243. position: relative;
  244. }
  245. .content-title::before {
  246. content: '';
  247. position: absolute;
  248. left: 0;
  249. top: 4rpx;
  250. bottom: 4rpx;
  251. width: 8rpx;
  252. background: #fcd53f;
  253. border-radius: 4rpx;
  254. }
  255. .content-text {
  256. font-size: 28rpx;
  257. color: #555;
  258. line-height: 1.8;
  259. }
  260. .intro-images {
  261. margin-top: 32rpx;
  262. display: flex;
  263. flex-direction: column;
  264. gap: 24rpx;
  265. }
  266. .intro-img {
  267. width: 100%;
  268. border-radius: 20rpx;
  269. }
  270. .footer-bar {
  271. position: fixed;
  272. bottom: 0;
  273. left: 0;
  274. right: 0;
  275. padding: 20rpx 32rpx 40rpx;
  276. background-color: #fff;
  277. z-index: 10;
  278. box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
  279. }
  280. .buy-btn {
  281. width: 100%;
  282. height: 92rpx;
  283. font-size: 32rpx;
  284. font-weight: bold;
  285. color: #333;
  286. background: linear-gradient(90deg, #ffd53f, #ff9500);
  287. border: none;
  288. border-radius: 46rpx;
  289. line-height: 92rpx;
  290. }
  291. </style>