铝交易,微信公众号
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.

231 lines
4.7 KiB

11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
  1. <template>
  2. <scroll-view scroll-y="true" :style="{height: height}" @scrolltolower="moreAddress">
  3. <uv-radio-group v-model="selectAddress" @change="editDefault" v-if="addressList.length > 0">
  4. <view v-for="item in addressList" :key="item.id" class="address-item">
  5. <view class="address-item-top" @click="select(item)">
  6. <view class="img-box">
  7. <image src="/static/image/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.id == selectAddress" 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" v-if="controls">
  21. <view class="default-checkbox">
  22. <uv-radio :name="item.id" label-disabled size="30rpx" icon-size="30rpx">
  23. 默认地址
  24. </uv-radio>
  25. </view>
  26. <view class="edit-btn">
  27. <uv-icon name="edit-pen"></uv-icon>
  28. <text @click="editAddress(item)" class="control-title">编辑</text>
  29. </view>
  30. <view class="del-btn" @click="deleteAddress(item.id)">
  31. <uv-icon name="trash"></uv-icon>
  32. <text class="control-title">删除</text>
  33. </view>
  34. </view>
  35. </view>
  36. </uv-radio-group>
  37. <view style="padding: 100rpx 0;" v-else>
  38. <uv-empty mode="history" textSize="28rpx" iconSize="100rpx" />
  39. </view>
  40. </scroll-view>
  41. </template>
  42. <script>
  43. export default {
  44. props: {
  45. controls: {
  46. default: false,
  47. type: Boolean,
  48. },
  49. height: {
  50. default: 'calc(90vh - 180rpx)'
  51. }
  52. },
  53. data() {
  54. return {
  55. selectAddress: 0,
  56. queryParams: {
  57. pageNo: 1,
  58. pageSize: 10,
  59. },
  60. addressList: [],
  61. total: 0,
  62. }
  63. },
  64. created() {
  65. },
  66. methods: {
  67. //获取地址列表
  68. getAddressList() {
  69. return new Promise((success, fail) => {
  70. this.$api('addressList', this.queryParams, res => {
  71. if (res.code == 200) {
  72. console.log("res.result.records", res.result.records)
  73. this.addressList = res.result.records || [];
  74. this.total = res.result.total || 0;
  75. this.addressList.forEach(n => { //筛选默认地址
  76. if (n.defaultFlag == 1) {
  77. this.selectAddress = n.id
  78. }
  79. })
  80. success(res.result)
  81. }
  82. })
  83. })
  84. },
  85. // 加载更多
  86. moreAddress() {
  87. if (this.queryParams.pageSize > this.total) {
  88. return
  89. }
  90. this.queryParams.pageSize += 10
  91. this.getAddressList()
  92. },
  93. // 删除地址
  94. deleteAddress(e) {
  95. this.$emit('deleteAddress', e)
  96. },
  97. // 修改地址
  98. editAddress(e) {
  99. this.$emit('editAddress', e)
  100. },
  101. // 切换默认地址
  102. editDefault(e) {
  103. this.$emit('editDefault', e)
  104. },
  105. // 选择了地址
  106. select(e) {
  107. this.$emit('select', e)
  108. },
  109. }
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. .address-item {
  114. background: white;
  115. border-radius: 20rpx;
  116. overflow: hidden;
  117. margin-bottom: 20rpx;
  118. padding: 15rpx 15rpx 0rpx 15rpx;
  119. width: 680rpx;
  120. .address-item-top {
  121. border-bottom: 1px dashed #D3D1D1;
  122. display: flex;
  123. align-items: center;
  124. padding: 0rpx 0rpx 15rpx 0rpx;
  125. .img-box {
  126. width: 120rpx;
  127. height: 120rpx;
  128. image {
  129. width: 75%;
  130. height: 75%;
  131. display: block;
  132. margin: 12.5% auto;
  133. }
  134. }
  135. .address-info {
  136. width: calc(100% - 120rpx);
  137. height: 100%;
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: space-between;
  141. .user-info {
  142. display: flex;
  143. align-items: center;
  144. text {
  145. display: block;
  146. line-height: 40rpx;
  147. margin-right: 20rpx;
  148. }
  149. .user-name,
  150. .user-phone {
  151. font-size: 30rpx;
  152. }
  153. .is-default {
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. background: #FEB773;
  158. color: white;
  159. width: 80rpx;
  160. height: 35rpx;
  161. border-radius: 20rpx;
  162. font-size: 22rpx;
  163. }
  164. }
  165. .address-detail {
  166. color: #4a4a4a;
  167. font-size: 26rpx;
  168. overflow: hidden;
  169. display: -webkit-box;
  170. -webkit-box-orient: vertical;
  171. -webkit-line-clamp: 2;
  172. text-overflow: ellipsis;
  173. }
  174. }
  175. }
  176. .controls {
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. align-items: center;
  181. font-size: 26rpx;
  182. padding: 15rpx 15rpx 25rpx 15rpx;
  183. .default-checkbox {
  184. display: flex;
  185. text {
  186. margin-left: 8rpx;
  187. }
  188. }
  189. .control-title {
  190. height: 30rpx;
  191. line-height: 30rpx;
  192. color: #666666;
  193. }
  194. view {
  195. display: flex;
  196. align-items: center;
  197. }
  198. image {
  199. width: 23rpx;
  200. height: 23rpx;
  201. vertical-align: middle;
  202. margin-right: 8rpx;
  203. }
  204. }
  205. }
  206. </style>