百富门答题小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
3.6 KiB

7 months ago
  1. <template>
  2. <uv-radio-group v-model="selectAddress">
  3. <view v-for="item in addressList" :key="item.id" class="address-item">
  4. <view class="address-item-top"
  5. @click="select(item)">
  6. <view class="img-box">
  7. <image src="../../static/address/icon.png" mode="aspectFill"></image>
  8. </view>
  9. <view class="address-info">
  10. <view class="user-info">
  11. <text class="user-name">{{ item.name }}</text>
  12. <text class="user-phone">{{ item.phone }}</text>
  13. <text v-if="item.defaultId == '1'" class="is-default">默认</text>
  14. </view>
  15. <view class="address-detail">
  16. {{ item.address + " " + item.addressDetail }}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="controls"
  21. v-if="controls">
  22. <view class="default-checkbox">
  23. <uv-radio @click="editDefault(item)"
  24. :name="item.id"
  25. label-disabled
  26. size="30rpx"
  27. icon-size="30rpx">
  28. 默认地址
  29. </uv-radio>
  30. </view>
  31. <view class="edit-btn">
  32. <uv-icon name="edit-pen"></uv-icon>
  33. <text @click="editAddress(item.id)" class="control-title">编辑</text>
  34. </view>
  35. <view class="del-btn">
  36. <uv-icon name="trash"></uv-icon>
  37. <text class="control-title" @click="deleteAddress(item.id)">删除</text>
  38. </view>
  39. </view>
  40. </view>
  41. </uv-radio-group>
  42. </template>
  43. <script>
  44. export default {
  45. props : {
  46. controls : {
  47. default : false,
  48. type : Boolean,
  49. },
  50. addressList : {
  51. default : [],
  52. type : Array,
  53. }
  54. },
  55. data() {
  56. return {
  57. selectAddress : 0,
  58. }
  59. },
  60. methods: {
  61. // 删除地址
  62. deleteAddress(e){
  63. this.$emit('deleteAddress', e)
  64. },
  65. // 修改地址
  66. editAddress(e){
  67. this.$emit('editAddress', e)
  68. },
  69. // 切换默认地址
  70. editDefault(e){
  71. this.$emit('editDefault', e)
  72. },
  73. // 选择了地址
  74. select(e){
  75. this.$emit('select', e)
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .address-item {
  82. background: white;
  83. border-radius: 20rpx;
  84. overflow: hidden;
  85. margin-bottom: 20rpx;
  86. padding: 15rpx 15rpx 0rpx 15rpx;
  87. width: 680rpx;
  88. .address-item-top {
  89. border-bottom: 1px dashed #D3D1D1;
  90. display: flex;
  91. align-items: center;
  92. padding: 0rpx 0rpx 15rpx 0rpx;
  93. .img-box {
  94. width: 120rpx;
  95. height: 120rpx;
  96. image {
  97. width: 75%;
  98. height: 75%;
  99. display: block;
  100. margin: 12.5% auto;
  101. }
  102. }
  103. .address-info {
  104. width: calc(100% - 120rpx);
  105. height: 100%;
  106. display: flex;
  107. flex-direction: column;
  108. justify-content: space-between;
  109. .user-info {
  110. display: flex;
  111. align-items: center;
  112. text {
  113. display: block;
  114. line-height: 40rpx;
  115. margin-right: 20rpx;
  116. }
  117. .user-name,
  118. .user-phone {
  119. font-size: 30rpx;
  120. }
  121. .is-default {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. background: #FEB773;
  126. color: white;
  127. width: 80rpx;
  128. height: 35rpx;
  129. border-radius: 20rpx;
  130. font-size: 22rpx;
  131. }
  132. }
  133. .address-detail {
  134. color: #4a4a4a;
  135. font-size: 26rpx;
  136. overflow: hidden;
  137. display: -webkit-box;
  138. -webkit-box-orient: vertical;
  139. -webkit-line-clamp: 2;
  140. text-overflow: ellipsis;
  141. }
  142. }
  143. }
  144. .controls {
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. align-items: center;
  149. font-size: 26rpx;
  150. padding: 15rpx 15rpx 25rpx 15rpx;
  151. .default-checkbox {
  152. display: flex;
  153. text {
  154. margin-left: 8rpx;
  155. }
  156. }
  157. .control-title {
  158. height: 30rpx;
  159. line-height: 30rpx;
  160. color: #666666;
  161. }
  162. view {
  163. display: flex;
  164. align-items: center;
  165. }
  166. image {
  167. width: 23rpx;
  168. height: 23rpx;
  169. vertical-align: middle;
  170. margin-right: 8rpx;
  171. }
  172. }
  173. }
  174. </style>