展品维保小程序前端代码接口
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.

65 lines
1.5 KiB

2 weeks 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. if (!uni.getStorageSync('token')) {
  30. // 还没登陆
  31. this.userPoints = '未登录'
  32. }else{
  33. // 实际项目中这里应该调用API
  34. const res = await this.$api.user.queryUser()
  35. this.userPoints = res?.result?.score || 0
  36. }
  37. }
  38. },
  39. async onShow() {
  40. // 获取用户积分
  41. await this.getUserPoints()
  42. this.$refs.shopContentRef.initData()
  43. await this.$refs.shopContentRef.getGoodsList({isRefresh : true})
  44. },
  45. async onPullDownRefresh() {
  46. // 下拉刷新时调用
  47. this.$refs.shopContentRef.initData()
  48. await this.$refs.shopContentRef.getGoodsList({isRefresh : true})
  49. uni.stopPullDownRefresh()
  50. },
  51. onReachBottom() {
  52. this.$refs.shopContentRef.getGoodsList()
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .shop-page {
  58. min-height: 100vh;
  59. background: #f8f8f8;
  60. }
  61. </style>