酒店桌布为微信小程序
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.

244 lines
4.6 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
  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">
  42. <uv-icon name="trash"></uv-icon>
  43. <text class="control-title" @click="deleteAddress(item.id)">删除</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('addressPage', this.queryParams, res => {
  85. if (res.code == 200) {
  86. this.addressList = res.result.records || [];
  87. this.total = res.result.total || 0;
  88. this.addressList.forEach(n => { //筛选默认地址
  89. if (n.defaultFlag == 1) {
  90. this.selectAddress = n.id
  91. }
  92. })
  93. success(res.result)
  94. }
  95. })
  96. })
  97. },
  98. // 加载更多
  99. moreAddress(){
  100. if(this.queryParams.pageSize > this.total){
  101. return
  102. }
  103. this.queryParams.pageSize += 10
  104. this.getAddressList()
  105. },
  106. // 删除地址
  107. deleteAddress(e){
  108. this.$emit('deleteAddress', e)
  109. },
  110. // 修改地址
  111. editAddress(e){
  112. this.$emit('editAddress', e)
  113. },
  114. // 切换默认地址
  115. editDefault(e){
  116. this.$emit('editDefault', e)
  117. },
  118. // 选择了地址
  119. select(e){
  120. this.$emit('select', e)
  121. },
  122. }
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .address-item {
  127. background: white;
  128. border-radius: 20rpx;
  129. overflow: hidden;
  130. margin-bottom: 20rpx;
  131. padding: 15rpx 15rpx 0rpx 15rpx;
  132. width: 680rpx;
  133. .address-item-top {
  134. border-bottom: 1px dashed #D3D1D1;
  135. display: flex;
  136. align-items: center;
  137. padding: 0rpx 0rpx 15rpx 0rpx;
  138. .img-box {
  139. width: 120rpx;
  140. height: 120rpx;
  141. image {
  142. width: 75%;
  143. height: 75%;
  144. display: block;
  145. margin: 12.5% auto;
  146. }
  147. }
  148. .address-info {
  149. width: calc(100% - 120rpx);
  150. height: 100%;
  151. display: flex;
  152. flex-direction: column;
  153. justify-content: space-between;
  154. .user-info {
  155. display: flex;
  156. align-items: center;
  157. text {
  158. display: block;
  159. line-height: 40rpx;
  160. margin-right: 20rpx;
  161. }
  162. .user-name,
  163. .user-phone {
  164. font-size: 30rpx;
  165. }
  166. .is-default {
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. background: #FEB773;
  171. color: white;
  172. width: 80rpx;
  173. height: 35rpx;
  174. border-radius: 20rpx;
  175. font-size: 22rpx;
  176. }
  177. }
  178. .address-detail {
  179. color: #4a4a4a;
  180. font-size: 26rpx;
  181. overflow: hidden;
  182. display: -webkit-box;
  183. -webkit-box-orient: vertical;
  184. -webkit-line-clamp: 2;
  185. text-overflow: ellipsis;
  186. }
  187. }
  188. }
  189. .controls {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. align-items: center;
  194. font-size: 26rpx;
  195. padding: 15rpx 15rpx 25rpx 15rpx;
  196. .default-checkbox {
  197. display: flex;
  198. text {
  199. margin-left: 8rpx;
  200. }
  201. }
  202. .control-title {
  203. height: 30rpx;
  204. line-height: 30rpx;
  205. color: #666666;
  206. }
  207. view {
  208. display: flex;
  209. align-items: center;
  210. }
  211. image {
  212. width: 23rpx;
  213. height: 23rpx;
  214. vertical-align: middle;
  215. margin-right: 8rpx;
  216. }
  217. }
  218. }
  219. </style>