consignee-list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="container">
  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. export default {
  43. data() {
  44. return {
  45. loading: false,
  46. list: []
  47. }
  48. },
  49. onShow() {
  50. this.loadList()
  51. },
  52. methods: {
  53. async loadList() {
  54. this.loading = true
  55. try {
  56. const res = await consigneeList()
  57. if (res.code === 200) {
  58. this.list = res.data || []
  59. }
  60. } catch (e) {
  61. console.error(e)
  62. } finally {
  63. this.loading = false
  64. }
  65. },
  66. goAdd() {
  67. uni.navigateTo({ url: '/pages/shop/consignee-edit/consignee-edit' })
  68. },
  69. goEdit(id) {
  70. uni.navigateTo({ url: '/pages/shop/consignee-edit/consignee-edit?id=' + id })
  71. },
  72. handleDelete(id) {
  73. var that = this
  74. uni.showModal({
  75. title: '确认删除',
  76. content: '确定要删除该收货人吗?',
  77. success: function(res) {
  78. if (res.confirm) {
  79. that.doDelete(id)
  80. }
  81. }
  82. })
  83. },
  84. async doDelete(id) {
  85. try {
  86. const res = await consigneeDelete(id)
  87. if (res.code === 200) {
  88. uni.showToast({ title: '删除成功', icon: 'success' })
  89. this.loadList()
  90. }
  91. } catch (e) {
  92. console.error(e)
  93. }
  94. },
  95. maskIdCard(card) {
  96. if (!card || card.length < 8) return card
  97. return card.substring(0, 4) + '********' + card.substring(card.length - 4)
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. .container {
  104. min-height: 100vh;
  105. background: #f5f7fa;
  106. padding: 20rpx;
  107. }
  108. .loading-wrap, .empty-wrap {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. justify-content: center;
  113. padding: 200rpx 60rpx;
  114. }
  115. .empty-icon {
  116. font-size: 100rpx;
  117. margin-bottom: 30rpx;
  118. }
  119. .empty-text {
  120. font-size: 32rpx;
  121. font-weight: bold;
  122. color: #333;
  123. margin-bottom: 16rpx;
  124. }
  125. .empty-desc {
  126. font-size: 26rpx;
  127. color: #999;
  128. margin-bottom: 60rpx;
  129. }
  130. .add-btn {
  131. width: 60%;
  132. background: linear-gradient(135deg, #667eea, #764ba2);
  133. color: #fff;
  134. border-radius: 50rpx;
  135. font-size: 30rpx;
  136. padding: 24rpx;
  137. line-height: 1.5;
  138. }
  139. .consignee-card {
  140. background: #fff;
  141. border-radius: 16rpx;
  142. padding: 24rpx;
  143. margin-bottom: 20rpx;
  144. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  145. }
  146. .card-header {
  147. display: flex;
  148. align-items: center;
  149. gap: 16rpx;
  150. margin-bottom: 16rpx;
  151. }
  152. .card-name {
  153. font-size: 32rpx;
  154. font-weight: bold;
  155. color: #333;
  156. }
  157. .card-phone {
  158. font-size: 28rpx;
  159. color: #666;
  160. }
  161. .default-tag {
  162. font-size: 22rpx;
  163. color: #F97316;
  164. background: #FFF7ED;
  165. padding: 4rpx 12rpx;
  166. border-radius: 8rpx;
  167. border: 1rpx solid #FED7AA;
  168. }
  169. .card-body {
  170. display: flex;
  171. flex-wrap: wrap;
  172. gap: 8rpx;
  173. margin-bottom: 16rpx;
  174. }
  175. .card-info {
  176. font-size: 24rpx;
  177. color: #999;
  178. background: #f5f5f5;
  179. padding: 6rpx 12rpx;
  180. border-radius: 8rpx;
  181. }
  182. .card-info-muted {
  183. color: #ccc;
  184. background: transparent;
  185. }
  186. .card-footer {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. padding-top: 16rpx;
  191. border-top: 1rpx solid #f5f5f5;
  192. }
  193. .delete-btn {
  194. font-size: 26rpx;
  195. color: #f56c6c;
  196. padding: 8rpx 16rpx;
  197. }
  198. .arrow {
  199. font-size: 28rpx;
  200. color: #ccc;
  201. }
  202. .add-btn-bottom {
  203. margin-top: 20rpx;
  204. width: 80%;
  205. }
  206. </style>