木邻有你前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="shop-page">
  3. <!-- 导航栏 -->
  4. <HomePageNav />
  5. <!-- 可用积分卡片 -->
  6. <PointsCard :points="userPoints"/>
  7. <!-- 商城内容 -->
  8. <ShopContent ref="shopContentRef" />
  9. </view>
  10. </template>
  11. <script>
  12. import HomePageNav from '@/pages/components/HomePageNav.vue'
  13. import PointsCard from '@/pages/components/shop/PointsCard.vue'
  14. import ShopContent from '@/pages/components/shop/ShopContent.vue'
  15. export default {
  16. name: 'Shop',
  17. components: {
  18. HomePageNav,
  19. PointsCard,
  20. ShopContent
  21. },
  22. data() {
  23. return {
  24. userPoints: 1385
  25. }
  26. },
  27. methods: {
  28. async getUserPoints() {
  29. // 模拟获取用户积分
  30. // 实际项目中这里应该调用API
  31. const res = await this.$api.user.queryUser()
  32. this.userPoints = res?.result?.score || 0
  33. }
  34. },
  35. async onShow() {
  36. // 获取用户积分
  37. await this.getUserPoints()
  38. this.$refs.shopContentRef.initData()
  39. await this.$refs.shopContentRef.getGoodsList({isRefresh : true})
  40. },
  41. async onPullDownRefresh() {
  42. // 下拉刷新时调用
  43. this.$refs.shopContentRef.initData()
  44. await this.$refs.shopContentRef.getGoodsList({isRefresh : true})
  45. uni.stopPullDownRefresh()
  46. },
  47. onReachBottom() {
  48. this.$refs.shopContentRef.getGoodsList()
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .shop-page {
  54. min-height: 100vh;
  55. background: #f8f8f8;
  56. }
  57. </style>