points-mall.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view class="points-mall">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-icon" @click="handleBack"></view>
  6. <text class="header-title">积分商城</text>
  7. <view class="header-right">
  8. <view class="search-icon"></view>
  9. <view class="cart-icon">
  10. <text class="cart-badge">{{ cartCount }}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- 积分显示区域 -->
  15. <view class="points-section">
  16. <view class="points-header">
  17. <text class="points-label">我的积分</text>
  18. <text class="points-value">{{ userPoints }}</text>
  19. <text class="points-icon">💰</text>
  20. </view>
  21. <view class="points-actions">
  22. <view class="action-btn" @click="handlePointsDetail">积分明细</view>
  23. <view class="action-btn" @click="handleEarnPoints">赚取积分</view>
  24. </view>
  25. </view>
  26. <!-- 分类标签 -->
  27. <view class="category-tabs">
  28. <view
  29. v-for="(category, index) in categories"
  30. :key="index"
  31. class="category-tab"
  32. :class="{ active: activeCategory === index }"
  33. @click="activeCategory = index"
  34. >
  35. {{ category }}
  36. </view>
  37. </view>
  38. <!-- 推荐商品区域 -->
  39. <scroll-view scroll-y class="products-container">
  40. <!-- 推荐商品标题 -->
  41. <view class="section-header">
  42. <text class="section-title">推荐商品</text>
  43. <view class="view-more" @click="handleViewMore">
  44. <text class="view-more-text">查看更多</text>
  45. <text class="arrow">›</text>
  46. </view>
  47. </view>
  48. <!-- 商品网格 -->
  49. <view class="products-grid">
  50. <view
  51. v-for="(product, index) in recommendedProducts"
  52. :key="index"
  53. class="product-card"
  54. @click="handleProductClick(product)"
  55. >
  56. <view class="product-image">
  57. <image :src="product.image" mode="aspectFill"></image>
  58. </view>
  59. <view class="product-info">
  60. <text class="product-name">{{ product.name }}</text>
  61. <view class="product-price">
  62. <text class="price-value">{{ product.points }}</text>
  63. <text class="price-unit">💰</text>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 底部空白 -->
  69. <view class="bottom-spacer"></view>
  70. </scroll-view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. name: 'points-mall',
  76. data() {
  77. return {
  78. userPoints: 5000,
  79. cartCount: 0,
  80. activeCategory: 0,
  81. categories: ['全部', '实物商品', '虚拟商品'],
  82. recommendedProducts: [
  83. {
  84. id: 1,
  85. name: '清风原色无尘纸',
  86. points: 1000,
  87. image: 'https://via.placeholder.com/200x200?text=纸巾'
  88. },
  89. {
  90. id: 2,
  91. name: 'OPPO Enco Air2耳机',
  92. points: 7000,
  93. image: 'https://via.placeholder.com/200x200?text=耳机'
  94. },
  95. {
  96. id: 3,
  97. name: '五常大米',
  98. points: 3000,
  99. image: 'https://via.placeholder.com/200x200?text=大米'
  100. },
  101. {
  102. id: 4,
  103. name: '脸盆',
  104. points: 30,
  105. image: 'https://via.placeholder.com/200x200?text=脸盆'
  106. }
  107. ]
  108. }
  109. },
  110. methods: {
  111. // 返回上一页
  112. handleBack() {
  113. uni.navigateBack()
  114. },
  115. // 查看积分明细
  116. handlePointsDetail() {
  117. uni.showToast({
  118. title: '查看积分明细',
  119. icon: 'none'
  120. })
  121. },
  122. // 赚取积分
  123. handleEarnPoints() {
  124. uni.showToast({
  125. title: '赚取积分',
  126. icon: 'none'
  127. })
  128. },
  129. // 查看更多
  130. handleViewMore() {
  131. uni.showToast({
  132. title: '查看更多商品',
  133. icon: 'none'
  134. })
  135. },
  136. // 商品点击
  137. handleProductClick(product) {
  138. uni.showToast({
  139. title: `已添加 ${product.name} 到购物车`,
  140. icon: 'success'
  141. })
  142. this.cartCount++
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .points-mall {
  149. min-height: 100vh;
  150. background: #FFF9F9;
  151. display: flex;
  152. flex-direction: column;
  153. }
  154. /* 顶部导航栏 */
  155. .header {
  156. display: flex;
  157. align-items: center;
  158. justify-content: space-between;
  159. padding: 25rpx 30rpx;
  160. padding-top: calc(25rpx + env(safe-area-inset-top));
  161. background: #FFF9F9;
  162. border-bottom: 1rpx solid #F0F0F0;
  163. .back-icon {
  164. width: 44rpx;
  165. height: 44rpx;
  166. display: flex;
  167. align-items: center;
  168. justify-content: center;
  169. font-size: 32rpx;
  170. color: #333;
  171. &::before {
  172. content: '‹';
  173. }
  174. }
  175. .header-title {
  176. font-size: 38rpx;
  177. font-weight: bold;
  178. color: #333;
  179. }
  180. .header-right {
  181. display: flex;
  182. align-items: center;
  183. gap: 20rpx;
  184. .search-icon {
  185. width: 44rpx;
  186. height: 44rpx;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. font-size: 32rpx;
  191. color: #999;
  192. &::before {
  193. content: '🔍';
  194. }
  195. }
  196. .cart-icon {
  197. width: 44rpx;
  198. height: 44rpx;
  199. display: flex;
  200. align-items: center;
  201. justify-content: center;
  202. font-size: 32rpx;
  203. color: #999;
  204. position: relative;
  205. &::before {
  206. content: '🛒';
  207. }
  208. .cart-badge {
  209. position: absolute;
  210. top: -8rpx;
  211. right: -8rpx;
  212. width: 32rpx;
  213. height: 32rpx;
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. background-color: #FF4444;
  218. color: #FFFFFF;
  219. font-size: 20rpx;
  220. font-weight: bold;
  221. border-radius: 50%;
  222. }
  223. }
  224. }
  225. }
  226. /* 积分显示区域 */
  227. .points-section {
  228. background: linear-gradient(135deg, #FCE4EC 0%, #F8BBD0 100%);
  229. padding: 40rpx 30rpx;
  230. border-radius: 0 0 30rpx 30rpx;
  231. .points-header {
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. gap: 20rpx;
  236. margin-bottom: 30rpx;
  237. .points-label {
  238. font-size: 28rpx;
  239. color: #666666;
  240. }
  241. .points-value {
  242. font-size: 64rpx;
  243. font-weight: bold;
  244. color: #333333;
  245. }
  246. .points-icon {
  247. font-size: 48rpx;
  248. }
  249. }
  250. .points-actions {
  251. display: flex;
  252. justify-content: space-around;
  253. .action-btn {
  254. padding: 15rpx 40rpx;
  255. background-color: rgba(255, 255, 255, 0.8);
  256. color: #9C27B0;
  257. border-radius: 30rpx;
  258. font-size: 28rpx;
  259. font-weight: bold;
  260. transition: all 0.3s;
  261. &:active {
  262. background-color: rgba(255, 255, 255, 1);
  263. }
  264. }
  265. }
  266. }
  267. /* 分类标签 */
  268. .category-tabs {
  269. display: flex;
  270. gap: 20rpx;
  271. padding: 20rpx 30rpx;
  272. background: #FFFFFF;
  273. overflow-x: auto;
  274. white-space: nowrap;
  275. .category-tab {
  276. padding: 12rpx 24rpx;
  277. background: #F5F5F5;
  278. color: #666;
  279. border-radius: 20rpx;
  280. font-size: 26rpx;
  281. white-space: nowrap;
  282. transition: all 0.3s;
  283. &.active {
  284. background: #9C27B0;
  285. color: #FFFFFF;
  286. font-weight: bold;
  287. }
  288. }
  289. }
  290. /* 商品容器 */
  291. .products-container {
  292. flex: 1;
  293. background: #FFFFFF;
  294. padding: 20rpx 30rpx;
  295. }
  296. /* 分类标题 */
  297. .section-header {
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. margin-bottom: 20rpx;
  302. .section-title {
  303. font-size: 32rpx;
  304. font-weight: bold;
  305. color: #333;
  306. }
  307. .view-more {
  308. display: flex;
  309. align-items: center;
  310. gap: 5rpx;
  311. .view-more-text {
  312. font-size: 24rpx;
  313. color: #9C27B0;
  314. }
  315. .arrow {
  316. font-size: 28rpx;
  317. color: #9C27B0;
  318. }
  319. }
  320. }
  321. /* 商品网格 */
  322. .products-grid {
  323. display: grid;
  324. grid-template-columns: repeat(2, 1fr);
  325. gap: 20rpx;
  326. margin-bottom: 20rpx;
  327. .product-card {
  328. background: #FFFFFF;
  329. border-radius: 16rpx;
  330. overflow: hidden;
  331. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  332. transition: all 0.3s;
  333. &:active {
  334. transform: translateY(-4rpx);
  335. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.12);
  336. }
  337. .product-image {
  338. width: 100%;
  339. height: 200rpx;
  340. background: #F5F5F5;
  341. overflow: hidden;
  342. image {
  343. width: 100%;
  344. height: 100%;
  345. object-fit: cover;
  346. }
  347. }
  348. .product-info {
  349. padding: 15rpx;
  350. .product-name {
  351. display: block;
  352. font-size: 24rpx;
  353. color: #333;
  354. margin-bottom: 10rpx;
  355. overflow: hidden;
  356. text-overflow: ellipsis;
  357. white-space: nowrap;
  358. }
  359. .product-price {
  360. display: flex;
  361. align-items: center;
  362. gap: 5rpx;
  363. .price-value {
  364. font-size: 28rpx;
  365. font-weight: bold;
  366. color: #9C27B0;
  367. }
  368. .price-unit {
  369. font-size: 24rpx;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. /* 底部空白 */
  376. .bottom-spacer {
  377. height: 40rpx;
  378. }
  379. </style>