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

138 lines
2.8 KiB

8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
  1. <template>
  2. <uv-popup ref="addPopup" :round="30">
  3. <!-- 地址 -->
  4. <view class="address" @click="openAddress">
  5. <image src="/static/image/address/selectIcon.png" mode=""></image>
  6. <view class="">
  7. {{ address.name }}
  8. </view>
  9. <view class="">
  10. {{ address.addressDetail }}
  11. </view>
  12. <view class="icon">
  13. <uv-icon size="30rpx" name="arrow-right"></uv-icon>
  14. </view>
  15. </view>
  16. <uv-popup ref="addressPopup" :round="30">
  17. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  18. </uv-popup>
  19. <addLeaseForm ref="addLeaseForm"/>
  20. <view class="btn" @click="submit">
  21. <button class="a">添加</button>
  22. </view>
  23. </uv-popup>
  24. </template>
  25. <script>
  26. import addLeaseForm from './addLeaseForm.vue'
  27. import addressList from '@/components/address/addressList.vue'
  28. export default {
  29. components : {
  30. addLeaseForm,
  31. addressList,
  32. },
  33. data() {
  34. return {
  35. address: {
  36. name: '请选择联系人',
  37. addressDetail: '',
  38. },
  39. addressTotal: 0,
  40. }
  41. },
  42. methods: {
  43. // 打开选择地址
  44. openAddress() {
  45. if (this.addressTotal == 0) {
  46. this.$refs.popup.close()
  47. return uni.navigateTo({
  48. url: '/pages_order/mine/address?type=back'
  49. })
  50. }
  51. this.$refs.addressPopup.open('bottom')
  52. },
  53. // 选择地址
  54. selectAddress(e) {
  55. this.address = e
  56. this.$refs.addressPopup.close()
  57. },
  58. submit() {
  59. if(!this.address.id){
  60. return uni.showToast({
  61. title: '请选择地址'
  62. })
  63. }
  64. this.$refs.addLeaseForm.submit(form => {
  65. form.addressId = this.address.id, //地址id
  66. this.$api('tablecloth', form, res => {
  67. if (res.code == 200) {
  68. this.$emit('submit')
  69. this.$refs.addPopup.close()
  70. }
  71. })
  72. })
  73. },
  74. open() {
  75. this.$refs.addLeaseForm.closeForm()
  76. this.$refs.addPopup.open('bottom')
  77. // 获取地址列表
  78. this.$refs.addressList.getAddressList().then(res => {
  79. this.addressTotal = res.total
  80. if (this.addressTotal != 0) {
  81. this.address = res.records[0]
  82. }
  83. })
  84. },
  85. }
  86. }
  87. </script>
  88. <style scoped lang="scss">
  89. .address {
  90. display: flex;
  91. padding: 20rpx;
  92. background-color: #fff;
  93. border-bottom: 20rpx solid #f3f3f3;
  94. image {
  95. width: 30rpx;
  96. height: 30rpx;
  97. margin: 20rpx;
  98. }
  99. view {
  100. margin: 20rpx;
  101. overflow: hidden; //超出的文本隐藏
  102. text-overflow: ellipsis; //溢出用省略号显示
  103. white-space: nowrap; //溢出不换行
  104. }
  105. .icon {
  106. margin-left: auto;
  107. }
  108. }
  109. .btn {
  110. display: flex;
  111. justify-content: center;
  112. width: 100%;
  113. .a {
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. width: 90%;
  118. height: 100rpx;
  119. color: #FFF;
  120. background-color: $uni-color;
  121. border: 1px solid red;
  122. border-radius: 100rpx;
  123. font-size: 30rpx;
  124. }
  125. }
  126. </style>