敢为人鲜小程序前端代码仓库
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.

229 lines
4.7 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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" @tap="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.defaultFlag == 1" class="is-default">默认</text>
  14. </view>
  15. <view class="address-detail">
  16. {{ item.address + " " + item.addressDetails }}
  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" activeColor="#E3441A">
  23. 默认地址
  24. </uv-radio>
  25. </view>
  26. <view class="edit-btn">
  27. <uv-icon name="edit-pen"></uv-icon>
  28. <text @tap="editAddress(item)" class="control-title">编辑</text>
  29. </view>
  30. <view class="del-btn">
  31. <uv-icon name="trash"></uv-icon>
  32. <text class="control-title" @tap="deleteAddress(item.id)">删除</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. methods: {
  65. //获取地址列表
  66. getAddressList() {
  67. return new Promise((success, fail) => {
  68. this.$api('getAddressPageList', this.queryParams, res => {
  69. if (res.code == 200) {
  70. this.addressList = res.result.records || [];
  71. this.total = res.result.total || 0;
  72. res.result.records.forEach(n => { //筛选默认地址
  73. if (n.defaultFlag == 1) {
  74. this.selectAddress = n.id
  75. }
  76. })
  77. success(res.result)
  78. }
  79. })
  80. })
  81. },
  82. // 加载更多
  83. moreAddress() {
  84. if (this.queryParams.pageSize > this.total) {
  85. return
  86. }
  87. this.queryParams.pageSize += 10
  88. this.getAddressList()
  89. },
  90. // 删除地址
  91. deleteAddress(e) {
  92. this.$emit('deleteAddress', e)
  93. },
  94. // 修改地址
  95. editAddress(e) {
  96. this.$emit('editAddress', e)
  97. },
  98. // 切换默认地址
  99. editDefault(e) {
  100. this.$emit('editDefault', e)
  101. },
  102. // 选择了地址
  103. select(e) {
  104. this.$emit('select', e)
  105. },
  106. }
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. .address-item {
  111. background: white;
  112. border-radius: 20rpx;
  113. overflow: hidden;
  114. margin-bottom: 20rpx;
  115. padding: 15rpx 15rpx 0rpx 15rpx;
  116. width: 100%;
  117. box-sizing: border-box;
  118. .address-item-top {
  119. border-bottom: 1px dashed #D3D1D1;
  120. display: flex;
  121. align-items: center;
  122. padding: 0rpx 0rpx 15rpx 0rpx;
  123. .img-box {
  124. width: 100rpx;
  125. height: 100rpx;
  126. image {
  127. width: 100%;
  128. height: 100%;
  129. display: block;
  130. }
  131. }
  132. .address-info {
  133. width: calc(100% - 100rpx);
  134. height: 100%;
  135. display: flex;
  136. flex-direction: column;
  137. justify-content: space-between;
  138. box-sizing: border-box;
  139. padding-left: 10rpx;
  140. .user-info {
  141. display: flex;
  142. align-items: center;
  143. text {
  144. display: block;
  145. line-height: 40rpx;
  146. margin-right: 20rpx;
  147. }
  148. .user-name,
  149. .user-phone {
  150. font-size: 30rpx;
  151. }
  152. .is-default {
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. background: #FEB773;
  157. color: white;
  158. width: 80rpx;
  159. height: 35rpx;
  160. border-radius: 20rpx;
  161. font-size: 22rpx;
  162. }
  163. }
  164. .address-detail {
  165. color: #4a4a4a;
  166. font-size: 26rpx;
  167. overflow: hidden;
  168. display: -webkit-box;
  169. -webkit-box-orient: vertical;
  170. -webkit-line-clamp: 2;
  171. text-overflow: ellipsis;
  172. }
  173. }
  174. }
  175. .controls {
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. align-items: center;
  180. font-size: 26rpx;
  181. padding: 15rpx 15rpx 25rpx 15rpx;
  182. .default-checkbox {
  183. display: flex;
  184. text {
  185. margin-left: 8rpx;
  186. }
  187. }
  188. .control-title {
  189. height: 30rpx;
  190. line-height: 30rpx;
  191. color: #666666;
  192. }
  193. view {
  194. display: flex;
  195. align-items: center;
  196. }
  197. image {
  198. width: 23rpx;
  199. height: 23rpx;
  200. vertical-align: middle;
  201. margin-right: 8rpx;
  202. }
  203. }
  204. }
  205. </style>