s-order-card.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!-- 装修用户组件:用户订单 -->
  2. <template>
  3. <view class="ss-order-menu-wrap ss-flex ss-col-center" :style="[style, { marginLeft: `${data.space}px` }]">
  4. <view
  5. class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
  6. v-for="item in orderMap"
  7. :key="item.title"
  8. @tap="sheep.$router.go(item.path, { type: item.value })"
  9. >
  10. <uni-badge
  11. class="uni-badge-left-margin"
  12. :text="numData.orderCount[item.count]"
  13. absolute="rightTop"
  14. size="small"
  15. >
  16. <image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit" />
  17. </uni-badge>
  18. <view class="menu-title ss-m-t-28">{{ item.title }}</view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. /**
  24. * 装修组件 - 订单菜单组
  25. */
  26. import sheep from '@/sheep';
  27. import { computed } from 'vue';
  28. import { onLoad } from '@dcloudio/uni-app';
  29. const orderMap = [
  30. {
  31. title: '待付款',
  32. value: '1',
  33. icon: '/static/img/shop/order/no_pay.png',
  34. path: '/pages/order/list',
  35. type: 'unpaid',
  36. count: 'unpaidCount',
  37. },
  38. {
  39. title: '待收货',
  40. value: '3',
  41. icon: '/static/img/shop/order/no_take.png',
  42. path: '/pages/order/list',
  43. type: 'noget',
  44. count: 'deliveredCount',
  45. },
  46. {
  47. title: '待评价',
  48. value: '4',
  49. icon: '/static/img/shop/order/no_comment.png',
  50. path: '/pages/order/list',
  51. type: 'nocomment',
  52. count: 'uncommentedCount',
  53. },
  54. {
  55. title: '售后单',
  56. value: '0',
  57. icon: '/static/img/shop/order/change_order.png',
  58. path: '/pages/order/aftersale/list',
  59. type: 'aftersale',
  60. count: 'afterSaleCount',
  61. },
  62. {
  63. title: '全部订单',
  64. value: '0',
  65. icon: '/static/img/shop/order/all_order.png',
  66. path: '/pages/order/list',
  67. },
  68. ];
  69. // 接收参数
  70. const props = defineProps({
  71. // 装修数据
  72. data: {
  73. type: Object,
  74. default: () => ({}),
  75. },
  76. // 装修样式
  77. styles: {
  78. type: Object,
  79. default: () => ({}),
  80. },
  81. });
  82. // 设置角标
  83. const numData = computed(() => sheep.$store('user').numData);
  84. // 设置背景样式
  85. const style = computed(() => {
  86. // 直接从 props.styles 解构
  87. const { bgType, bgImg, bgColor } = props.styles;
  88. // 根据 bgType 返回相应的样式
  89. return {
  90. background: bgType === 'img'
  91. ? `url(${bgImg}) no-repeat top center / 100% 100%`
  92. : bgColor
  93. };
  94. });
  95. onLoad(() => {
  96. // 获取订单数量
  97. sheep.$store('user').getNumData()
  98. })
  99. </script>
  100. <style lang="scss" scoped>
  101. .ss-order-menu-wrap {
  102. .menu-item {
  103. height: 160rpx;
  104. position: relative;
  105. z-index: 10;
  106. .menu-title {
  107. font-size: 24rpx;
  108. line-height: 24rpx;
  109. color: #333333;
  110. }
  111. .item-icon {
  112. width: 44rpx;
  113. height: 44rpx;
  114. }
  115. .num-icon {
  116. position: absolute;
  117. right: 18rpx;
  118. top: 18rpx;
  119. // width: 40rpx;
  120. padding: 0 8rpx;
  121. height: 26rpx;
  122. background: #ff4d4f;
  123. border-radius: 13rpx;
  124. color: #fefefe;
  125. display: flex;
  126. align-items: center;
  127. .num {
  128. font-size: 24rpx;
  129. transform: scale(0.8);
  130. }
  131. }
  132. }
  133. }
  134. </style>