consignee-list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <view v-if="loading" class="loading-wrap">
  4. <text>加载中...</text>
  5. </view>
  6. <view v-else-if="list.length === 0" class="empty-wrap">
  7. <text class="empty-icon">📍</text>
  8. <text class="empty-text">暂无收货人信息</text>
  9. <text class="empty-desc">添加收货人后可在购买时快速选择</text>
  10. <button class="add-btn" @click="goAdd">添加收货人</button>
  11. </view>
  12. <view v-else class="list-wrap">
  13. <view
  14. v-for="item in list"
  15. :key="item.id"
  16. class="consignee-card"
  17. @click="goEdit(item.id)"
  18. >
  19. <view class="card-header">
  20. <text class="card-name">{{ item.name || '未填写' }}</text>
  21. <text class="card-phone">{{ item.phone || '' }}</text>
  22. <text v-if="item.isDefault === 1" class="default-tag">默认</text>
  23. </view>
  24. <view class="card-body">
  25. <text v-if="item.idCard" class="card-info">身份证: {{ maskIdCard(item.idCard) }}</text>
  26. <text v-if="item.ethnicity" class="card-info">民族: {{ item.ethnicity }}</text>
  27. <text v-if="item.bloodType" class="card-info">血型: {{ item.bloodType }}</text>
  28. <text v-if="item.handSignature" class="card-info">已设置手签名</text>
  29. <text v-if="!item.idCard && !item.ethnicity && !item.bloodType && !item.handSignature" class="card-info card-info-muted">暂无详细信息</text>
  30. </view>
  31. <view class="card-footer">
  32. <text class="delete-btn" @click.stop="handleDelete(item.id)">删除</text>
  33. <text class="arrow">›</text>
  34. </view>
  35. </view>
  36. <button class="add-btn add-btn-bottom" @click="goAdd">添加收货人</button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { consigneeList, consigneeDelete } from '../../../utils/api.js'
  42. import fontScaleMixin from '@/mixins/font-scale.js'
  43. export default {
  44. mixins: [fontScaleMixin],
  45. data() {
  46. return {
  47. loading: false,
  48. list: []
  49. }
  50. },
  51. onShow() {
  52. this.loadList()
  53. },
  54. methods: {
  55. async loadList() {
  56. this.loading = true
  57. try {
  58. const res = await consigneeList()
  59. if (res.code === 200) {
  60. this.list = res.data || []
  61. }
  62. } catch (e) {
  63. console.error(e)
  64. } finally {
  65. this.loading = false
  66. }
  67. },
  68. goAdd() {
  69. uni.navigateTo({ url: '/pages/shop/consignee-edit/consignee-edit' })
  70. },
  71. goEdit(id) {
  72. uni.navigateTo({ url: '/pages/shop/consignee-edit/consignee-edit?id=' + id })
  73. },
  74. handleDelete(id) {
  75. var that = this
  76. uni.showModal({
  77. title: '确认删除',
  78. content: '确定要删除该收货人吗?',
  79. success: function(res) {
  80. if (res.confirm) {
  81. that.doDelete(id)
  82. }
  83. }
  84. })
  85. },
  86. async doDelete(id) {
  87. try {
  88. const res = await consigneeDelete(id)
  89. if (res.code === 200) {
  90. uni.showToast({ title: '删除成功', icon: 'success' })
  91. this.loadList()
  92. }
  93. } catch (e) {
  94. console.error(e)
  95. }
  96. },
  97. maskIdCard(card) {
  98. if (!card || card.length < 8) return card
  99. return card.substring(0, 4) + '********' + card.substring(card.length - 4)
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .container {
  106. min-height: 100vh;
  107. background: $app-bg;
  108. padding: 20rpx;
  109. }
  110. .loading-wrap, .empty-wrap {
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. justify-content: center;
  115. padding: 200rpx 60rpx;
  116. }
  117. .empty-icon {
  118. font-size: calc($uni-font-size-6xl * var(--font-scale, 1));
  119. margin-bottom: $uni-space-lg;
  120. }
  121. .empty-text {
  122. font-size: calc(32rpx * var(--font-scale, 1));
  123. font-weight: bold;
  124. color: $facade-text-strong;
  125. margin-bottom: 16rpx;
  126. }
  127. .empty-desc {
  128. font-size: calc(26rpx * var(--font-scale, 1));
  129. color: $facade-text-muted;
  130. margin-bottom: 60rpx;
  131. }
  132. .add-btn {
  133. width: 60%;
  134. background: linear-gradient(135deg, $accent-indigo, $accent-indigo-deep);
  135. color: $app-surface;
  136. border-radius: 24rpx;
  137. font-size: calc(30rpx * var(--font-scale, 1));
  138. padding: 24rpx;
  139. line-height: 1.5;
  140. }
  141. .consignee-card {
  142. background: $app-surface;
  143. border-radius: 16rpx;
  144. padding: 24rpx;
  145. margin-bottom: 20rpx;
  146. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  147. }
  148. .card-header {
  149. display: flex;
  150. align-items: center;
  151. gap: 16rpx;
  152. margin-bottom: 16rpx;
  153. }
  154. .card-name {
  155. font-size: calc(32rpx * var(--font-scale, 1));
  156. font-weight: bold;
  157. color: $facade-text-strong;
  158. }
  159. .card-phone {
  160. font-size: calc(28rpx * var(--font-scale, 1));
  161. color: $facade-text-body;
  162. }
  163. .default-tag {
  164. font-size: calc(22rpx * var(--font-scale, 1));
  165. color: $brand-primary;
  166. background: $uni-primary-pale;
  167. padding: 4rpx 12rpx;
  168. border-radius: 8rpx;
  169. border: 1rpx solid $brand-primary-light-2;
  170. }
  171. .card-body {
  172. display: flex;
  173. flex-wrap: wrap;
  174. gap: 8rpx;
  175. margin-bottom: 16rpx;
  176. }
  177. .card-info {
  178. font-size: calc(24rpx * var(--font-scale, 1));
  179. color: $facade-text-muted;
  180. background: $facade-fill-2;
  181. padding: 6rpx 12rpx;
  182. border-radius: 8rpx;
  183. }
  184. .card-info-muted {
  185. color: $facade-text-ghost;
  186. background: transparent;
  187. }
  188. .card-footer {
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. padding-top: 16rpx;
  193. border-top: 1rpx solid $facade-fill-2;
  194. }
  195. .delete-btn {
  196. font-size: calc(26rpx * var(--font-scale, 1));
  197. color: $el-danger;
  198. padding: 8rpx 16rpx;
  199. }
  200. .arrow {
  201. font-size: calc(28rpx * var(--font-scale, 1));
  202. color: $facade-text-ghost;
  203. }
  204. .add-btn-bottom {
  205. margin-top: 20rpx;
  206. width: 80%;
  207. }
  208. </style>