铝交易,微信公众号
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
10 months ago
  1. <template>
  2. <scroll-view :style="{height: height}" scroll-y="true" @scrolltolower="moreAddress">
  3. <uv-radio-group v-if="addressList.length > 0" v-model="selectAddress" @change="editDefault">
  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 mode="aspectFill" src="/static/image/address/icon.png"></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.defaultFlag == 1" class="is-default">默认</text>
  14. </view>
  15. <view class="address-detail">
  16. {{ item.address + " " + item.addressDetail }}
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 是否开启编辑模式 -->
  21. <view v-if="controls" class="controls">
  22. <view class="default-checkbox" @click="editDefault(item.id)">
  23. <uv-radio :name="item.id" icon-size="30rpx" label-disabled size="30rpx">
  24. 默认地址
  25. </uv-radio>
  26. </view>
  27. <view class="edit-btn">
  28. <uv-icon name="edit-pen"></uv-icon>
  29. <text class="control-title" @click="editAddress(item)">编辑</text>
  30. </view>
  31. <view class="del-btn" @click="deleteAddress(item.id)">
  32. <uv-icon name="trash"></uv-icon>
  33. <text class="control-title">删除</text>
  34. </view>
  35. </view>
  36. </view>
  37. </uv-radio-group>
  38. <view v-else style="padding: 100rpx 0;">
  39. <uv-empty iconSize="100rpx" mode="history" textSize="28rpx" />
  40. </view>
  41. </scroll-view>
  42. </template>
  43. <script>
  44. export default {
  45. props: {
  46. controls: {
  47. default: false,
  48. type: Boolean,
  49. },
  50. height: {
  51. default: 'calc(90vh - 180rpx)'
  52. }
  53. },
  54. data() {
  55. return {
  56. selectAddress: 0,
  57. queryParams: {
  58. pageNo: 1,
  59. pageSize: 10,
  60. },
  61. addressList: [],
  62. total: 0,
  63. }
  64. },
  65. created() {},
  66. methods: {
  67. //获取地址列表
  68. getAddressList() {
  69. return new Promise((success, fail) => {
  70. this.$api('addressList', this.queryParams, res => {
  71. if (res.code == 200) {
  72. this.addressList = res.result.records || [];
  73. this.total = res.result.total || 0;
  74. res.result.records.forEach(n => { //筛选默认地址
  75. if (n.defaultFlag == 1) {
  76. this.selectAddress = n.id
  77. }
  78. })
  79. success(res.result)
  80. }
  81. })
  82. })
  83. },
  84. // 加载更多
  85. moreAddress() {
  86. if (this.queryParams.pageSize > this.total) {
  87. return
  88. }
  89. this.queryParams.pageSize += 10
  90. this.getAddressList()
  91. },
  92. // 删除地址
  93. deleteAddress(e) {
  94. this.$emit('deleteAddress', e)
  95. },
  96. // 修改地址
  97. editAddress(e) {
  98. console.log(e.defaultFlag);
  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>