RepurchaseReminder.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="repurchase-container" v-if="reminders.length > 0">
  3. <view class="rr-header">
  4. <text class="rr-title">复购提醒</text>
  5. </view>
  6. <view
  7. class="rr-item"
  8. v-for="item in reminders"
  9. :key="item.id"
  10. @click="goProduct(item)">
  11. <image class="rr-image" :src="item.coverImage" mode="aspectFill" />
  12. <view class="rr-info">
  13. <text class="rr-name">{{ item.productName }}</text>
  14. <text class="rr-price" v-if="item.price">¥{{ (item.price / 100).toFixed(2) }}</text>
  15. <text class="rr-hint">上次购买已过 {{ item.reminderDays }} 天,需要补货吗?</text>
  16. </view>
  17. <view class="rr-action">
  18. <text class="rr-btn">去看看</text>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { getRepurchaseReminders, clickRepurchaseReminder } from '../utils/api.js'
  25. export default {
  26. data() {
  27. return {
  28. reminders: []
  29. }
  30. },
  31. mounted() {
  32. this.loadReminders()
  33. },
  34. methods: {
  35. loadReminders: function() {
  36. var self = this
  37. getRepurchaseReminders().then(function(res) {
  38. if (res.code === 200 && res.data) {
  39. self.reminders = res.data
  40. }
  41. }).catch(function() {})
  42. },
  43. goProduct: function(item) {
  44. clickRepurchaseReminder({ id: item.id })
  45. uni.navigateTo({
  46. url: '/pages/shop/detail?id=' + item.productId + '&from=repurchase'
  47. })
  48. }
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .repurchase-container {
  54. background: #fff;
  55. border-radius: 20rpx;
  56. margin: 20rpx 30rpx;
  57. padding: 24rpx;
  58. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  59. }
  60. .rr-header {
  61. margin-bottom: 16rpx;
  62. }
  63. .rr-title {
  64. font-size: 30rpx;
  65. font-weight: 700;
  66. color: #333;
  67. }
  68. .rr-item {
  69. display: flex;
  70. align-items: center;
  71. padding: 16rpx 0;
  72. border-top: 1rpx solid #f5f5f5;
  73. }
  74. .rr-image {
  75. width: 120rpx;
  76. height: 120rpx;
  77. border-radius: 12rpx;
  78. flex-shrink: 0;
  79. }
  80. .rr-info {
  81. flex: 1;
  82. margin-left: 16rpx;
  83. min-width: 0;
  84. }
  85. .rr-name {
  86. font-size: 26rpx;
  87. font-weight: 600;
  88. color: #333;
  89. display: block;
  90. overflow: hidden;
  91. text-overflow: ellipsis;
  92. white-space: nowrap;
  93. }
  94. .rr-price {
  95. font-size: 24rpx;
  96. color: #F97316;
  97. margin-top: 4rpx;
  98. display: block;
  99. }
  100. .rr-hint {
  101. font-size: 22rpx;
  102. color: #999;
  103. margin-top: 4rpx;
  104. display: block;
  105. }
  106. .rr-action {
  107. flex-shrink: 0;
  108. margin-left: 12rpx;
  109. }
  110. .rr-btn {
  111. background: #F97316;
  112. color: #fff;
  113. font-size: 22rpx;
  114. padding: 8rpx 20rpx;
  115. border-radius: 24rpx;
  116. }
  117. </style>