index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="discover-container">
  3. <!-- 品牌头部 -->
  4. <view class="brand-header">
  5. <image class="brand-logo" src="/static/logo.png" mode="aspectFit" />
  6. <text class="brand-title">汐艾福</text>
  7. <text class="brand-slogan">遵循五行节律,陪伴孩子自然成长</text>
  8. </view>
  9. <!-- 五行沙盘预览 -->
  10. <wuxing-sandbox mode="preview" badgeText="登录查看完整报告" @point-click="handleLogin" />
  11. <!-- 活动/商品推荐 -->
  12. <view class="recommend-section">
  13. <view class="section-header">
  14. <text class="section-title">🔥 热门推荐</text>
  15. <text class="section-more" @click="goShop">查看更多 ›</text>
  16. </view>
  17. <scroll-view scroll-x enable-flex show-scrollbar="false" class="type-filter-scroll">
  18. <view
  19. v-for="item in typeList"
  20. :key="item.value"
  21. :class="['filter-chip', currentType === item.value ? 'active' : '']"
  22. @click="onTypeChange(item.value)"
  23. >
  24. {{ item.label }}
  25. </view>
  26. </scroll-view>
  27. <view v-if="loading" class="loading-state">
  28. <text class="loading-text">加载中...</text>
  29. </view>
  30. <view v-else-if="products.length === 0" class="empty-state">
  31. <text class="empty-text">暂无商品,去商城看看吧</text>
  32. </view>
  33. <view v-else class="product-grid">
  34. <view
  35. v-for="item in products"
  36. :key="item.id"
  37. class="product-card"
  38. @click="goDetail(item.id)"
  39. >
  40. <image class="product-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
  41. <view class="product-info">
  42. <text class="product-name">{{ item.name }}</text>
  43. <view class="product-price-row">
  44. <text class="product-price">¥{{ item.price }}</text>
  45. <text v-if="item.memberPrice" class="product-member">会员¥{{ item.memberPrice }}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 为何选择汐艾福 -->
  52. <view class="why-section">
  53. <view class="section-header">
  54. <text class="section-title">💡 为什么选择汐艾福</text>
  55. </view>
  56. <view class="feature-grid">
  57. <view class="feature-item">
  58. <text class="feature-icon">🎯</text>
  59. <text class="feature-title">科学评估</text>
  60. <text class="feature-desc">DAN少儿核心素养评估体系</text>
  61. </view>
  62. <view class="feature-item">
  63. <text class="feature-icon">🏆</text>
  64. <text class="feature-title">积分激励</text>
  65. <text class="feature-desc">完成任务得积分,兑换心愿</text>
  66. </view>
  67. <view class="feature-item">
  68. <text class="feature-icon">👨‍👩‍👧‍👦</text>
  69. <text class="feature-title">家庭参与</text>
  70. <text class="feature-desc">全家一起见证成长每一步</text>
  71. </view>
  72. <view class="feature-item">
  73. <text class="feature-icon">🌟</text>
  74. <text class="feature-title">专业规划</text>
  75. <text class="feature-desc">成长规划师一对一指导</text>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 底部登录按钮 -->
  80. <view class="login-footer">
  81. <button class="login-btn" @click="handleLogin">登录 / 注册</button>
  82. <text class="login-footer-text">登录即表示同意《用户协议》和《隐私政策》</text>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import { productList } from '@/utils/api.js'
  88. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  89. export default {
  90. components: { WuxingSandbox },
  91. data() {
  92. return {
  93. typeList: [
  94. { label: '全部', value: '' },
  95. { label: '活动', value: 'activity' },
  96. { label: '课程', value: 'course' },
  97. { label: '实物', value: 'physical' },
  98. { label: '数字', value: 'digital' },
  99. { label: '服务', value: 'service' }
  100. ],
  101. currentType: '',
  102. products: [],
  103. loading: false
  104. }
  105. },
  106. onShow() {
  107. this.resetTabBar()
  108. this.loadProducts()
  109. },
  110. methods: {
  111. resetTabBar() {
  112. uni.setTabBarItem({ index: 1, text: '发现' })
  113. uni.setTabBarItem({ index: 2, text: '商城' })
  114. },
  115. loadProducts() {
  116. this.loading = true
  117. const params = { page: 1, size: 10 }
  118. if (this.currentType) {
  119. params.productType = this.currentType
  120. }
  121. productList(params).then(res => {
  122. this.loading = false
  123. if (res.code === 200 && res.data) {
  124. this.products = res.data.records || []
  125. }
  126. }).catch(() => {
  127. this.loading = false
  128. })
  129. },
  130. onTypeChange(value) {
  131. this.currentType = value
  132. this.loadProducts()
  133. },
  134. goShop() {
  135. uni.switchTab({ url: '/pages/shop/index' })
  136. },
  137. goDetail(id) {
  138. uni.navigateTo({ url: '/pages/discover/product-detail/product-detail?id=' + id })
  139. },
  140. handleLogin() {
  141. uni.navigateTo({ url: '/pages/login/login' })
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped>
  147. .discover-container {
  148. min-height: 100vh;
  149. background: #f5f7fa;
  150. padding-bottom: 100rpx;
  151. }
  152. /* ===== 品牌头部 ===== */
  153. .brand-header {
  154. display: flex;
  155. flex-direction: column;
  156. align-items: center;
  157. padding: 60rpx 30rpx 30rpx;
  158. background: linear-gradient(180deg, #1a1a2e 0%, #16213e 60%, #f5f7fa 100%);
  159. }
  160. .brand-logo {
  161. width: 120rpx;
  162. height: 120rpx;
  163. border-radius: 24rpx;
  164. margin-bottom: 16rpx;
  165. }
  166. .brand-title {
  167. font-size: 44rpx;
  168. font-weight: bold;
  169. color: #FFD700;
  170. letter-spacing: 8rpx;
  171. }
  172. .brand-slogan {
  173. font-size: 24rpx;
  174. color: rgba(255, 215, 0, 0.7);
  175. margin-top: 10rpx;
  176. }
  177. /* ===== 推荐 ===== */
  178. .recommend-section {
  179. margin: 20rpx 30rpx;
  180. }
  181. .section-header {
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. margin-bottom: 20rpx;
  186. }
  187. .section-title {
  188. font-size: 30rpx;
  189. font-weight: bold;
  190. color: #333;
  191. }
  192. .section-more {
  193. font-size: 24rpx;
  194. color: #F97316;
  195. }
  196. .type-filter-scroll {
  197. white-space: nowrap;
  198. margin-bottom: 20rpx;
  199. }
  200. .filter-chip {
  201. display: inline-block;
  202. padding: 8rpx 24rpx;
  203. font-size: 24rpx;
  204. color: #666;
  205. background: #f0f0f0;
  206. border-radius: 30rpx;
  207. margin-right: 16rpx;
  208. }
  209. .filter-chip.active {
  210. background: #F97316;
  211. color: #fff;
  212. }
  213. .loading-state,
  214. .empty-state {
  215. display: flex;
  216. justify-content: center;
  217. padding: 60rpx 0;
  218. }
  219. .loading-text,
  220. .empty-text {
  221. font-size: 26rpx;
  222. color: #999;
  223. }
  224. .product-grid {
  225. display: flex;
  226. flex-wrap: wrap;
  227. justify-content: space-between;
  228. }
  229. .product-card {
  230. width: 48%;
  231. background: #fff;
  232. border-radius: 16rpx;
  233. overflow: hidden;
  234. margin-bottom: 20rpx;
  235. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  236. }
  237. .product-cover {
  238. width: 100%;
  239. height: 200rpx;
  240. background: #f0f0f0;
  241. }
  242. .product-info {
  243. padding: 14rpx;
  244. }
  245. .product-name {
  246. display: block;
  247. font-size: 26rpx;
  248. color: #333;
  249. margin-bottom: 10rpx;
  250. overflow: hidden;
  251. text-overflow: ellipsis;
  252. white-space: nowrap;
  253. }
  254. .product-price-row {
  255. display: flex;
  256. align-items: baseline;
  257. }
  258. .product-price {
  259. font-size: 28rpx;
  260. color: #F97316;
  261. font-weight: bold;
  262. margin-right: 10rpx;
  263. }
  264. .product-member {
  265. font-size: 20rpx;
  266. color: #999;
  267. }
  268. .recommend-scroll {
  269. display: flex;
  270. white-space: nowrap;
  271. overflow-x: auto;
  272. padding-bottom: 10rpx;
  273. }
  274. .recommend-card {
  275. display: inline-flex;
  276. flex-direction: column;
  277. width: 260rpx;
  278. background: #fff;
  279. border-radius: 20rpx;
  280. overflow: hidden;
  281. margin-right: 20rpx;
  282. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  283. }
  284. .card-banner {
  285. padding: 14rpx 20rpx;
  286. background: #F97316;
  287. color: #fff;
  288. font-size: 22rpx;
  289. font-weight: bold;
  290. text-align: center;
  291. }
  292. .card-body {
  293. padding: 16rpx;
  294. white-space: normal;
  295. }
  296. .card-title {
  297. font-size: 24rpx;
  298. font-weight: bold;
  299. color: #333;
  300. display: block;
  301. margin-bottom: 6rpx;
  302. }
  303. .card-desc {
  304. font-size: 20rpx;
  305. color: #999;
  306. display: block;
  307. margin-bottom: 10rpx;
  308. }
  309. .card-meta {
  310. display: flex;
  311. align-items: center;
  312. justify-content: space-between;
  313. }
  314. .card-price {
  315. font-size: 26rpx;
  316. color: #F97316;
  317. font-weight: bold;
  318. }
  319. .card-tag {
  320. font-size: 18rpx;
  321. color: #F97316;
  322. background: rgba(255,107,107,0.1);
  323. padding: 2rpx 10rpx;
  324. border-radius: 10rpx;
  325. }
  326. /* ===== 为何选择 ===== */
  327. .why-section {
  328. margin: 30rpx;
  329. }
  330. .feature-grid {
  331. display: grid;
  332. grid-template-columns: 1fr 1fr;
  333. gap: 20rpx;
  334. }
  335. .feature-item {
  336. background: #fff;
  337. border-radius: 20rpx;
  338. padding: 24rpx;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. text-align: center;
  343. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  344. }
  345. .feature-icon {
  346. font-size: 48rpx;
  347. margin-bottom: 10rpx;
  348. }
  349. .feature-title {
  350. font-size: 24rpx;
  351. font-weight: bold;
  352. color: #333;
  353. margin-bottom: 6rpx;
  354. }
  355. .feature-desc {
  356. font-size: 20rpx;
  357. color: #999;
  358. }
  359. /* ===== 底部登录 ===== */
  360. .login-footer {
  361. margin: 40rpx 30rpx;
  362. display: flex;
  363. flex-direction: column;
  364. align-items: center;
  365. }
  366. .login-btn {
  367. width: 100%;
  368. height: 88rpx;
  369. line-height: 88rpx;
  370. background: linear-gradient(135deg, #F97316, #FB923C);
  371. color: #fff;
  372. font-size: 32rpx;
  373. font-weight: bold;
  374. border-radius: 44rpx;
  375. text-align: center;
  376. border: none;
  377. }
  378. .login-btn::after {
  379. border: none;
  380. }
  381. .login-footer-text {
  382. font-size: 20rpx;
  383. color: #bbb;
  384. margin-top: 16rpx;
  385. }
  386. </style>