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

227 lines
4.7 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 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/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 @click="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" @click="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. .address-item-top {
  117. border-bottom: 1px dashed #D3D1D1;
  118. display: flex;
  119. align-items: center;
  120. padding: 0rpx 0rpx 15rpx 0rpx;
  121. .img-box {
  122. width: 100rpx;
  123. height: 100rpx;
  124. image {
  125. width: 100%;
  126. height: 100%;
  127. display: block;
  128. }
  129. }
  130. .address-info {
  131. width: calc(100% - 100rpx);
  132. height: 100%;
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: space-between;
  136. box-sizing: border-box;
  137. padding-left: 10rpx;
  138. .user-info {
  139. display: flex;
  140. align-items: center;
  141. text {
  142. display: block;
  143. line-height: 40rpx;
  144. margin-right: 20rpx;
  145. }
  146. .user-name,
  147. .user-phone {
  148. font-size: 30rpx;
  149. }
  150. .is-default {
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. background: #FEB773;
  155. color: white;
  156. width: 80rpx;
  157. height: 35rpx;
  158. border-radius: 20rpx;
  159. font-size: 22rpx;
  160. }
  161. }
  162. .address-detail {
  163. color: #4a4a4a;
  164. font-size: 26rpx;
  165. overflow: hidden;
  166. display: -webkit-box;
  167. -webkit-box-orient: vertical;
  168. -webkit-line-clamp: 2;
  169. text-overflow: ellipsis;
  170. }
  171. }
  172. }
  173. .controls {
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. align-items: center;
  178. font-size: 26rpx;
  179. padding: 15rpx 15rpx 25rpx 15rpx;
  180. .default-checkbox {
  181. display: flex;
  182. text {
  183. margin-left: 8rpx;
  184. }
  185. }
  186. .control-title {
  187. height: 30rpx;
  188. line-height: 30rpx;
  189. color: #666666;
  190. }
  191. view {
  192. display: flex;
  193. align-items: center;
  194. }
  195. image {
  196. width: 23rpx;
  197. height: 23rpx;
  198. vertical-align: middle;
  199. margin-right: 8rpx;
  200. }
  201. }
  202. }
  203. </style>