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

247 lines
5.4 KiB

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