index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. // @Author: Antigravity
  101. if (!serviceInfo.value) return;
  102. // 根据服务的模式(mode为1代表接送)或名称关键字判断跳转类型,以匹配下单页的分类逻辑
  103. let serviceType = 'feed';
  104. const name = serviceInfo.value.name || '';
  105. const mode = String(serviceInfo.value.mode);
  106. if (mode === '1' || name.includes('接送') || name.includes('托运')) {
  107. serviceType = 'transport';
  108. } else if (name.includes('洗') || name.includes('护')) {
  109. serviceType = 'wash';
  110. }
  111. uni.navigateTo({
  112. url: `/pages/order/apply/index?service=${serviceType}&serviceId=${serviceInfo.value.id}`
  113. })
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .service-detail-page {
  118. background-color: #f5f5f5;
  119. min-height: 100vh;
  120. padding-bottom: 160rpx;
  121. }
  122. .hero-section {
  123. position: relative;
  124. width: 100%;
  125. height: 640rpx;
  126. overflow: hidden;
  127. }
  128. .hero-img {
  129. width: 100%;
  130. height: 100%;
  131. }
  132. .hero-overlay {
  133. position: absolute;
  134. top: 0;
  135. left: 0;
  136. right: 0;
  137. bottom: 0;
  138. 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%);
  139. }
  140. .hero-title-box {
  141. position: absolute;
  142. bottom: 48rpx;
  143. left: 40rpx;
  144. right: 40rpx;
  145. z-index: 2;
  146. }
  147. .hero-main-title {
  148. display: block;
  149. font-size: 52rpx;
  150. font-weight: 900;
  151. color: #fff;
  152. margin-bottom: 12rpx;
  153. }
  154. .hero-sub-title {
  155. display: block;
  156. font-size: 28rpx;
  157. color: rgba(255, 255, 255, 0.9);
  158. font-weight: 600;
  159. }
  160. .card {
  161. background-color: #fff;
  162. margin-bottom: 20rpx;
  163. }
  164. .info-section {
  165. padding: 32rpx 40rpx;
  166. position: relative;
  167. z-index: 3;
  168. border-radius: 24rpx 24rpx 0 0;
  169. margin-top: -24rpx;
  170. }
  171. .service-price-row {
  172. display: flex;
  173. justify-content: space-between;
  174. align-items: flex-end;
  175. margin-bottom: 20rpx;
  176. }
  177. .price-box {
  178. display: flex;
  179. align-items: baseline;
  180. color: #f44336;
  181. }
  182. .price-label {
  183. font-size: 26rpx;
  184. color: #333;
  185. font-weight: bold;
  186. margin-right: 12rpx;
  187. }
  188. .price-symbol {
  189. font-size: 28rpx;
  190. font-weight: bold;
  191. }
  192. .price-num {
  193. font-size: 56rpx;
  194. font-weight: 900;
  195. line-height: 1;
  196. }
  197. .price-unit {
  198. font-size: 24rpx;
  199. color: #999;
  200. margin-left: 4rpx;
  201. }
  202. .bought-count {
  203. font-size: 24rpx;
  204. color: #999;
  205. background: #f5f5f5;
  206. padding: 4rpx 16rpx;
  207. border-radius: 20rpx;
  208. }
  209. .service-name-text {
  210. font-size: 32rpx;
  211. color: #111;
  212. font-weight: bold;
  213. }
  214. .tab-section {
  215. padding: 0;
  216. }
  217. .tab-header {
  218. display: flex;
  219. border-bottom: 2rpx solid #EEEEEE;
  220. }
  221. .tab-btn {
  222. flex: 1;
  223. text-align: center;
  224. padding: 24rpx 0;
  225. font-size: 28rpx;
  226. color: #666;
  227. position: relative;
  228. }
  229. .tab-btn.active {
  230. color: #fcd53f;
  231. font-weight: bold;
  232. }
  233. .tab-btn.active::after {
  234. content: '';
  235. position: absolute;
  236. bottom: 0;
  237. left: 50%;
  238. transform: translateX(-50%);
  239. width: 60rpx;
  240. height: 6rpx;
  241. background: #fcd53f;
  242. border-radius: 6rpx;
  243. }
  244. .tab-content {
  245. padding: 40rpx 32rpx;
  246. }
  247. .content-title {
  248. display: block;
  249. font-size: 32rpx;
  250. color: #333;
  251. font-weight: 900;
  252. margin-bottom: 24rpx;
  253. padding-left: 20rpx;
  254. position: relative;
  255. }
  256. .content-title::before {
  257. content: '';
  258. position: absolute;
  259. left: 0;
  260. top: 4rpx;
  261. bottom: 4rpx;
  262. width: 8rpx;
  263. background: #fcd53f;
  264. border-radius: 4rpx;
  265. }
  266. .content-text {
  267. font-size: 28rpx;
  268. color: #555;
  269. line-height: 1.8;
  270. }
  271. .intro-images {
  272. margin-top: 32rpx;
  273. display: flex;
  274. flex-direction: column;
  275. gap: 24rpx;
  276. }
  277. .intro-img {
  278. width: 100%;
  279. border-radius: 20rpx;
  280. }
  281. .footer-bar {
  282. position: fixed;
  283. bottom: 0;
  284. left: 0;
  285. right: 0;
  286. padding: 20rpx 32rpx 40rpx;
  287. background-color: #fff;
  288. z-index: 10;
  289. box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
  290. }
  291. .buy-btn {
  292. width: 100%;
  293. height: 92rpx;
  294. font-size: 32rpx;
  295. font-weight: bold;
  296. color: #fff;
  297. background: linear-gradient(90deg, #ffd53f, #ff9500);
  298. border: none;
  299. border-radius: 46rpx;
  300. line-height: 92rpx;
  301. }
  302. </style>