index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <view class="home-page">
  3. <!-- 顶部背景与搜索区域 @Author: Antigravity -->
  4. <view class="header-section">
  5. <image src="/static/images/index-header.png" class="header-bg" mode="widthFix"></image>
  6. </view>
  7. <!-- 系统通知栏 @Author: Antigravity -->
  8. <view class="notice-section">
  9. <view class="notice-bar">
  10. <image src="/static/images/index-notice.png" class="notice-icon" mode="aspectFit"></image>
  11. <text class="notice-text">【重要通知】尊敬的用户,由于近期接送需求激增,请各位宠主尽量提前24小时进行服务预约,感谢您的理解与配合!</text>
  12. </view>
  13. </view>
  14. <!-- 业务导航区 (左1右2) @Author: Antigravity -->
  15. <view class="main-nav-section">
  16. <view class="nav-container">
  17. <!-- 左侧大按钮: 宠物接送 -->
  18. <view class="nav-card large-card" @click="goToServiceDetail(transportService)">
  19. <image src="/static/images/pickup-dropoff.png" class="card-bg" mode="aspectFill"></image>
  20. <view class="card-info">
  21. <text class="card-title">{{ transportService?.name || '宠物接送' }}</text>
  22. <text class="card-desc">{{ transportService?.remark || '支持单程/往返服务' }}</text>
  23. </view>
  24. </view>
  25. <!-- 右侧分栏 -->
  26. <view class="right-stack">
  27. <!-- 右上: 上门喂遛 -->
  28. <view class="nav-card small-card" @click="goToServiceDetail(feedingService)">
  29. <image src="/static/images/feed-walk.png" class="card-bg" mode="aspectFill"></image>
  30. <view class="card-info">
  31. <text class="card-title">{{ feedingService?.name || '上门喂遛' }}</text>
  32. <text class="card-desc">{{ feedingService?.remark || '每次上门基础费用' }}</text>
  33. </view>
  34. </view>
  35. <!-- 右下: 上门洗护 -->
  36. <view class="nav-card small-card" @click="goToServiceDetail(washingService)">
  37. <image src="/static/images/laundry-clean.png" class="card-bg" mode="aspectFill"></image>
  38. <view class="card-info">
  39. <text class="card-title">{{ washingService?.name || '上门洗护' }}</text>
  40. <text class="card-desc">{{ washingService?.remark || '每次上门基础费用' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 中间横幅图片 @Author: Antigravity -->
  47. <view class="middle-section">
  48. <image src="/static/images/index-middle.png" class="middle-image" mode="widthFix"></image>
  49. </view>
  50. <!-- 底部居中标志 @Author: Antigravity -->
  51. <view class="symbol-section">
  52. <image src="/static/images/index-symbol.png" class="symbol-img" mode="widthFix"></image>
  53. </view>
  54. <!-- 底部手势与文字 @Author: Antigravity -->
  55. <view class="hand-section">
  56. <view class="hand-wrapper">
  57. <image src="/static/images/index-hand.png" class="hand-img" mode="widthFix"></image>
  58. <view class="hand-text-content">
  59. <text class="hand-title">好萌友提醒您~</text>
  60. <text class="hand-subtitle">懂你的爱,更懂你的小可爱~</text>
  61. </view>
  62. </view>
  63. </view>
  64. <custom-tabbar></custom-tabbar>
  65. <!-- 隐私政策弹窗 -->
  66. <view class="privacy-modal-mask" v-if="showPrivacyModal">
  67. <view class="privacy-modal-content">
  68. <view class="privacy-modal-header">
  69. <text class="privacy-modal-title">服务协议和隐私政策提示</text>
  70. </view>
  71. <scroll-view scroll-y="true" class="privacy-modal-body">
  72. <view class="privacy-text-content">
  73. <text class="text-p">欢迎您选择由重庆盈锐文化传播有限公司运营的“好萌友”!我们非常重视您的个人信息和隐私保护。</text>
  74. <text class="text-p">在您使用“好萌友”产品及相关服务前,请仔细阅读并同意</text>
  75. <text class="text-link-active" @click="goToPrivacy">《好萌友隐私政策》</text>
  76. <text
  77. class="text-p">,以了解我们如何收集、使用、共享及保护您的个人信息,包括收集您的设备制造商、设备型号、设备标识符(OAID/VAID/AAID等)等相关信息。</text>
  78. <text class="text-p">为了给您提供宠物接送、上门服务等核心功能,我们会请求定位、相机、相册及剪切板等权限。如果您同意,请点击“同意并继续”开始使用我们的服务。</text>
  79. </view>
  80. </scroll-view>
  81. <view class="privacy-modal-footer">
  82. <button class="btn-refuse" @click="handleRefuse">不同意并退出</button>
  83. <button class="btn-accept" @click="handleAccept">同意并继续</button>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script setup>
  90. import { ref, computed, onMounted } from 'vue'
  91. import customTabbar from '@/components/custom-tabbar/index.vue'
  92. import { listAll } from '@/api/service/list'
  93. const showPrivacyModal = ref(false)
  94. const transportService = ref(null)
  95. const feedingService = ref(null)
  96. const washingService = ref(null)
  97. const SERVICE_IDS = {
  98. transport: '2026540079472181250',
  99. feeding: '2026541504596017154',
  100. washing: '2026542038396735489'
  101. }
  102. const fetchServices = async () => {
  103. try {
  104. const res = await listAll()
  105. const list = Array.isArray(res) ? res : (res?.data || res?.rows || [])
  106. transportService.value = list.find(item => String(item.id) === SERVICE_IDS.transport) || null
  107. feedingService.value = list.find(item => String(item.id) === SERVICE_IDS.feeding) || null
  108. washingService.value = list.find(item => String(item.id) === SERVICE_IDS.washing) || null
  109. } catch (err) {
  110. console.error('获取首页服务数据失败:', err)
  111. }
  112. }
  113. const goToServiceDetail = (service) => {
  114. if (!service || !service.id) {
  115. uni.showToast({ title: '服务暂不可用', icon: 'none' })
  116. return
  117. }
  118. uni.setStorageSync('currentService', service)
  119. uni.navigateTo({ url: `/pages/service/detail/index?serviceId=${service.id}&buyFlag=false` })
  120. }
  121. onMounted(() => {
  122. fetchServices()
  123. const agreed = uni.getStorageSync('privacy_agreed')
  124. if (!agreed) {
  125. showPrivacyModal.value = true
  126. } else {
  127. // 已同意隐私政策,若未登录,则自动重定向至登录页
  128. const token = uni.getStorageSync('token')
  129. if (!token) {
  130. uni.reLaunch({
  131. url: '/pages/login/index'
  132. })
  133. }
  134. }
  135. })
  136. const goToPrivacy = () => {
  137. uni.navigateTo({
  138. url: `/pages/my/agreement/detail/index?id=2&title=${encodeURIComponent('好萌友隐私政策')}`
  139. })
  140. }
  141. const handleAccept = () => {
  142. uni.setStorageSync('privacy_agreed', true)
  143. showPrivacyModal.value = false
  144. uni.showToast({
  145. title: '已同意隐私政策',
  146. icon: 'success'
  147. })
  148. // 同意协议后,若没有 Token 则在一秒后重定向跳转至登录界面
  149. const token = uni.getStorageSync('token')
  150. if (!token) {
  151. setTimeout(() => {
  152. uni.reLaunch({
  153. url: '/pages/login/index'
  154. })
  155. }, 1000)
  156. }
  157. }
  158. const handleRefuse = () => {
  159. uni.showModal({
  160. title: '提示',
  161. content: '我们需要您的授权同意隐私政策,以保障服务体验。若不同意,您将无法使用本应用服务。确认退出吗?',
  162. confirmText: '确认退出',
  163. cancelText: '重新阅读',
  164. success: (res) => {
  165. if (res.confirm) {
  166. // #ifdef APP-PLUS
  167. if (uni.getSystemInfoSync().platform === 'android') {
  168. plus.runtime.quit()
  169. } else {
  170. uni.showToast({
  171. title: '请手动关闭应用',
  172. icon: 'none'
  173. })
  174. }
  175. // #endif
  176. // #ifndef APP-PLUS
  177. uni.showToast({
  178. title: '已拒绝,将限制部分功能使用',
  179. icon: 'none'
  180. })
  181. showPrivacyModal.value = true
  182. // #endif
  183. }
  184. }
  185. })
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .home-page {
  190. background: #f8f9fb;
  191. min-height: 100vh;
  192. padding-bottom: 120rpx;
  193. }
  194. /* ====== 顶部搜索与背景 ====== */
  195. .header-section {
  196. position: relative;
  197. width: 100%;
  198. }
  199. .header-bg {
  200. width: 100%;
  201. display: block;
  202. }
  203. /* ====== 通知栏 ====== */
  204. .notice-section {
  205. padding: 20rpx 32rpx;
  206. }
  207. .notice-bar {
  208. display: flex;
  209. align-items: center;
  210. background: #fffbef;
  211. border-radius: 20rpx;
  212. padding: 16rpx 24rpx;
  213. gap: 16rpx;
  214. }
  215. .notice-icon {
  216. width: 40rpx;
  217. height: 40rpx;
  218. flex-shrink: 0;
  219. }
  220. .notice-text {
  221. font-size: 24rpx;
  222. color: #e6a23c;
  223. line-height: 1.4;
  224. }
  225. /* ====== 核心卡片布局 @Author: Antigravity ====== */
  226. .main-nav-section {
  227. padding: 10rpx 32rpx;
  228. }
  229. .nav-container {
  230. display: flex;
  231. height: 280rpx;
  232. /* 将之前较高的 380rpx 调低,使整体按钮高度变矮 */
  233. gap: 20rpx;
  234. }
  235. .nav-card {
  236. border-radius: 24rpx;
  237. position: relative;
  238. overflow: hidden;
  239. background: #fff;
  240. }
  241. .card-bg {
  242. position: absolute;
  243. top: 0;
  244. left: 0;
  245. width: 100%;
  246. height: 100%;
  247. z-index: 1;
  248. }
  249. .card-info {
  250. position: relative;
  251. z-index: 2;
  252. padding: 30rpx 24rpx;
  253. }
  254. .large-card {
  255. flex: 1;
  256. }
  257. .right-stack {
  258. flex: 1;
  259. display: flex;
  260. flex-direction: column;
  261. gap: 20rpx;
  262. }
  263. .small-card {
  264. flex: 1;
  265. }
  266. .card-title {
  267. font-size: 32rpx;
  268. font-weight: 800;
  269. color: #333;
  270. margin-bottom: 4rpx;
  271. display: block;
  272. }
  273. /* 根据图片色系微调文字颜色以匹配 UI 稿 */
  274. .large-card .card-title {
  275. color: #d35400;
  276. }
  277. .right-stack .small-card:first-child .card-title {
  278. color: #2c5ba7;
  279. }
  280. .right-stack .small-card:last-child .card-title {
  281. color: #c0392b;
  282. }
  283. .card-desc {
  284. font-size: 20rpx;
  285. color: #8e8e8e;
  286. display: block;
  287. }
  288. /* ====== 中间横幅 @Author: Antigravity ====== */
  289. .middle-section {
  290. padding: 10rpx 0;
  291. /* 缩小自身上下间距 */
  292. display: flex;
  293. justify-content: center;
  294. }
  295. .middle-image {
  296. width: 65%;
  297. /* 进一步缩小宽度到 65% */
  298. border-radius: 20rpx;
  299. display: block;
  300. }
  301. /* ====== 底部标志 @Author: Antigravity ====== */
  302. .symbol-section {
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. padding: 10rpx 32rpx 20rpx;
  307. /* 控制绿色横幅的 padding 以对齐上方 */
  308. }
  309. .symbol-img {
  310. width: 100%;
  311. /* 中间的标志(绿色大横幅)完美等宽于三个按钮 */
  312. border-radius: 20rpx;
  313. display: block;
  314. }
  315. /* ====== 底部手势与文字 @Author: Antigravity ====== */
  316. .hand-section {
  317. padding: 30rpx 32rpx 60rpx;
  318. display: flex;
  319. justify-content: center;
  320. }
  321. .hand-wrapper {
  322. position: relative;
  323. width: 100%;
  324. display: flex;
  325. justify-content: center;
  326. align-items: center;
  327. }
  328. .hand-img {
  329. width: 100%;
  330. display: block;
  331. }
  332. .hand-text-content {
  333. position: absolute;
  334. top: 50%;
  335. left: 50%;
  336. transform: translate(-50%, -50%);
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. gap: 12rpx;
  341. }
  342. .hand-title {
  343. font-size: 28rpx;
  344. color: #333;
  345. font-weight: bold;
  346. }
  347. .hand-subtitle {
  348. font-size: 24rpx;
  349. color: #999;
  350. }
  351. /* ====== 隐私政策弹窗样式 ====== */
  352. .privacy-modal-mask {
  353. position: fixed;
  354. top: 0;
  355. left: 0;
  356. right: 0;
  357. bottom: 0;
  358. background: rgba(0, 0, 0, 0.6);
  359. backdrop-filter: blur(16rpx);
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. z-index: 9999;
  364. padding: 48rpx;
  365. }
  366. .privacy-modal-content {
  367. width: 100%;
  368. max-height: 75vh;
  369. background: #ffffff;
  370. border-radius: 36rpx;
  371. display: flex;
  372. flex-direction: column;
  373. overflow: hidden;
  374. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
  375. animation: modalFadeIn 0.3s ease;
  376. }
  377. @keyframes modalFadeIn {
  378. from {
  379. opacity: 0;
  380. transform: scale(0.9);
  381. }
  382. to {
  383. opacity: 1;
  384. transform: scale(1);
  385. }
  386. }
  387. .privacy-modal-header {
  388. padding: 40rpx 40rpx 24rpx;
  389. text-align: center;
  390. }
  391. .privacy-modal-title {
  392. font-size: 34rpx;
  393. font-weight: 800;
  394. color: #1a1a1a;
  395. letter-spacing: -0.5rpx;
  396. }
  397. .privacy-modal-body {
  398. flex: 1;
  399. overflow-y: auto;
  400. }
  401. .privacy-text-content {
  402. padding: 0 40rpx 32rpx;
  403. line-height: 1.6;
  404. }
  405. .text-p {
  406. font-size: 28rpx;
  407. color: #4a4a4a;
  408. }
  409. .text-link-active {
  410. font-size: 28rpx;
  411. color: #ff9500;
  412. font-weight: 700;
  413. text-decoration: underline;
  414. display: inline-block;
  415. margin: 0 4rpx;
  416. }
  417. .privacy-modal-footer {
  418. padding: 24rpx 40rpx 40rpx;
  419. display: flex;
  420. gap: 20rpx;
  421. border-top: 2rpx solid #f5f6f8;
  422. background: #ffffff;
  423. }
  424. .btn-refuse {
  425. flex: 1;
  426. height: 88rpx;
  427. line-height: 88rpx;
  428. font-size: 28rpx;
  429. color: #666666;
  430. background: #f5f6f8;
  431. border-radius: 44rpx;
  432. border: none;
  433. font-weight: 600;
  434. &::after {
  435. border: none;
  436. }
  437. }
  438. .btn-accept {
  439. flex: 1.2;
  440. height: 88rpx;
  441. line-height: 88rpx;
  442. font-size: 28rpx;
  443. color: #ffffff;
  444. background: linear-gradient(90deg, #ffd53f, #ff9500);
  445. border-radius: 44rpx;
  446. border: none;
  447. font-weight: 700;
  448. box-shadow: 0 8rpx 20rpx rgba(255, 149, 0, 0.2);
  449. &::after {
  450. border: none;
  451. }
  452. }
  453. </style>