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.

259 lines
5.0 KiB

8 months ago
8 months ago
8 months ago
  1. <template>
  2. <van-popup v-model:show="showBottom" round position="bottom" @close="close" :style="{ height: '75%' }">
  3. <view class="box">
  4. <view class="title">
  5. {{ title || '选择地址' }}
  6. </view>
  7. <view v-if="list.length > 0" class="list">
  8. <van-list v-model:loading="loading" :finished="finished" @load="onLoad">
  9. <view v-for="item in list" :key="item.id" @click="$emit('select', item)" class="address-item">
  10. <view class="address-item-top">
  11. <view class="img-box">
  12. <image src="@/static/address/address-icon.png" mode="aspectFill"></image>
  13. </view>
  14. <view class="address-info">
  15. <view class="user-info">
  16. <text class="user-name">{{ item.name }}</text>
  17. <text class="user-phone">{{ item.phone }}</text>
  18. <text v-if="item.defaultId == '1'" class="is-default">默认</text>
  19. </view>
  20. <view class="address-detail">
  21. {{ item.address + " " + item.addressDetail }}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </van-list>
  27. </view>
  28. <van-empty v-else image="/static/empty/address.png" image-size="400rpx">
  29. <template #description>
  30. <view style="color: white;">
  31. 暂无服务地址请添加
  32. </view>
  33. </template>
  34. </van-empty>
  35. </view>
  36. <view class="add-btn">
  37. <view @click="toAddress" class="btn">
  38. 新增地址
  39. </view>
  40. </view>
  41. </van-popup>
  42. </template>
  43. <script>
  44. import couponList from "../couponList.vue"
  45. export default {
  46. components: {
  47. couponList
  48. },
  49. name: "selectCouponPopup",
  50. props: ['show', 'title'],
  51. data() {
  52. return {
  53. showBottom: false,
  54. i: 0,
  55. queryParams: {
  56. pageNo: 1,
  57. pageSize: 10,
  58. title: ''
  59. },
  60. list: [],
  61. loading: false,
  62. finished: false,
  63. }
  64. },
  65. created() {
  66. this.getAddressList();
  67. },
  68. methods: {
  69. //滑动到底部
  70. onLoad() {
  71. this.queryParams.pageSize += 10
  72. this.getAddressList()
  73. },
  74. //获取地址列表
  75. getAddressList() {
  76. this.$api('getAddressList', {
  77. ...this.queryParams,
  78. }, res => {
  79. if (res.code == 200) {
  80. this.list = res.result.records;
  81. if (this.queryParams.pageSize > res.result.total) {
  82. this.finished = true
  83. }
  84. if (this.list.length == 0) {
  85. this.toAddress()
  86. }
  87. }
  88. this.loading = false
  89. })
  90. },
  91. //选择地址
  92. select(e) {
  93. this.$emit('select', e)
  94. },
  95. //关闭地址弹窗
  96. close() {
  97. this.$emit('close')
  98. },
  99. //跳转新增地址页面
  100. toAddress(){
  101. uni.navigateTo({
  102. url: `/pages/mine/address?current=payOrder&orderId=${this.$route.query.orderId}`
  103. })
  104. }
  105. },
  106. watch: {
  107. show: {
  108. handler(newValue, oldValue) {
  109. this.showBottom = newValue
  110. if (newValue) this.getAddressList()
  111. },
  112. immediate: true
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .box {
  119. width: 100%;
  120. height: 100%;
  121. background: #F1B8BD;
  122. box-sizing: border-box;
  123. padding: 40rpx 40rpx 140rpx 40rpx;
  124. .title {
  125. font-size: 32rpx;
  126. text-align: center;
  127. color: #fff;
  128. margin-bottom: 40rpx;
  129. }
  130. .list {
  131. overflow: auto;
  132. width: 100%;
  133. height: calc(100% - 45rpx);
  134. .address-item {
  135. background: white;
  136. border-radius: 20rpx;
  137. overflow: hidden;
  138. margin-bottom: 20rpx;
  139. padding: 15rpx;
  140. .address-item-top {
  141. border-bottom: 1px dashed #D3D1D1;
  142. display: flex;
  143. align-items: center;
  144. padding: 15rpx 0rpx;
  145. &:nth-last-child(1) {
  146. border: none;
  147. }
  148. .img-box {
  149. width: 120rpx;
  150. height: 120rpx;
  151. image {
  152. width: 75%;
  153. height: 75%;
  154. display: block;
  155. margin: 12.5% auto;
  156. }
  157. }
  158. .address-info {
  159. width: calc(100% - 120rpx);
  160. height: 100%;
  161. display: flex;
  162. flex-direction: column;
  163. justify-content: space-between;
  164. .user-info {
  165. display: flex;
  166. align-items: center;
  167. text {
  168. display: block;
  169. line-height: 40rpx;
  170. margin-right: 20rpx;
  171. }
  172. .user-name,
  173. .user-phone {
  174. font-size: 30rpx;
  175. }
  176. .is-default {
  177. display: flex;
  178. align-items: center;
  179. justify-content: center;
  180. background: #FEB773;
  181. color: white;
  182. width: 80rpx;
  183. height: 35rpx;
  184. border-radius: 20rpx;
  185. font-size: 22rpx;
  186. }
  187. }
  188. .address-detail {
  189. color: #4a4a4a;
  190. font-size: 26rpx;
  191. overflow: hidden;
  192. display: -webkit-box;
  193. -webkit-box-orient: vertical;
  194. -webkit-line-clamp: 2;
  195. text-overflow: ellipsis;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. .add-btn {
  203. position: fixed;
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. left: 0;
  208. bottom: 0;
  209. width: 750rpx;
  210. height: 100rpx;
  211. .btn {
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. width: 85%;
  216. height: 80rpx;
  217. border-radius: 40rpx;
  218. color: white;
  219. text-align: center;
  220. font-size: 28rpx;
  221. background: #EF8C94;
  222. }
  223. }
  224. @media all and (min-width: 961px) {
  225. .add-btn {
  226. left: 50% !important;
  227. transform: translateX(-50%);
  228. }
  229. }
  230. </style>