s-order-card.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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: '2',
  41. icon: '/static/img/shop/order/no_comment.png',
  42. path: '/pages/order/list',
  43. type: 'noget',
  44. count: 'undeliveredCount',
  45. },
  46. {
  47. title: '待收货',
  48. value: '3',
  49. icon: '/static/img/shop/order/no_take.png',
  50. path: '/pages/order/list',
  51. type: 'noget',
  52. count: 'deliveredCount',
  53. },
  54. // {
  55. // title: '待评价',
  56. // value: '4',
  57. // icon: '/static/img/shop/order/no_comment.png',
  58. // path: '/pages/order/list',
  59. // type: 'nocomment',
  60. // count: 'uncommentedCount',
  61. // },
  62. {
  63. title: '售后单',
  64. value: '0',
  65. icon: '/static/img/shop/order/change_order.png',
  66. path: '/pages/order/aftersale/list',
  67. type: 'aftersale',
  68. count: 'afterSaleCount',
  69. },
  70. {
  71. title: '全部订单',
  72. value: '0',
  73. icon: '/static/img/shop/order/all_order.png',
  74. path: '/pages/order/list',
  75. },
  76. ];
  77. // 接收参数
  78. const props = defineProps({
  79. // 装修数据
  80. data: {
  81. type: Object,
  82. default: () => ({}),
  83. },
  84. // 装修样式
  85. styles: {
  86. type: Object,
  87. default: () => ({}),
  88. },
  89. });
  90. // 设置角标
  91. const numData = computed(() => sheep.$store('user').numData);
  92. // 设置背景样式
  93. const style = computed(() => {
  94. // 直接从 props.styles 解构
  95. const { bgType, bgImg, bgColor } = props.styles;
  96. // 根据 bgType 返回相应的样式
  97. return {
  98. background: bgType === 'img'
  99. ? `url(${bgImg}) no-repeat top center / 100% 100%`
  100. : bgColor
  101. };
  102. });
  103. onLoad(() => {
  104. // 获取订单数量
  105. sheep.$store('user').getNumData()
  106. })
  107. </script>
  108. <style lang="scss" scoped>
  109. .ss-order-menu-wrap {
  110. .menu-item {
  111. height: 160rpx;
  112. position: relative;
  113. z-index: 10;
  114. .menu-title {
  115. font-size: 24rpx;
  116. line-height: 24rpx;
  117. color: #333333;
  118. }
  119. .item-icon {
  120. width: 44rpx;
  121. height: 44rpx;
  122. }
  123. .num-icon {
  124. position: absolute;
  125. right: 18rpx;
  126. top: 18rpx;
  127. // width: 40rpx;
  128. padding: 0 8rpx;
  129. height: 26rpx;
  130. background: #ff4d4f;
  131. border-radius: 13rpx;
  132. color: #fefefe;
  133. display: flex;
  134. align-items: center;
  135. .num {
  136. font-size: 24rpx;
  137. transform: scale(0.8);
  138. }
  139. }
  140. }
  141. }
  142. </style>