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

199 lines
3.7 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. <template>
  2. <view class="address">
  3. <navbar title="地址管理" leftClick @leftClick="leftClick" />
  4. <view class="address-list">
  5. <addressList
  6. controls
  7. ref="addressList"
  8. @deleteAddress="deleteAddress"
  9. @editAddress="editAddress"
  10. @editDefault="editDefault"/>
  11. </view>
  12. <redactAddress
  13. ref="addressPopup"
  14. :addressDetail="addressDetail"
  15. @saveOrUpdate="saveOrUpdate"
  16. :title="title"></redactAddress>
  17. <view class="add-btn">
  18. <view @click="addBtn" class="btn">
  19. 新增地址
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import redactAddress from '../components/address/redactAddress.vue'
  26. import addressList from '../components/address/addressList.vue'
  27. export default {
  28. components: {
  29. redactAddress,
  30. addressList
  31. },
  32. data() {
  33. return {
  34. title: '新增地址'
  35. }
  36. },
  37. onShow() {
  38. this.getAddressList()
  39. },
  40. methods: {
  41. //获取地址列表
  42. getAddressList() {
  43. this.$refs.addressList.getAddressList()
  44. },
  45. //获取地址详情
  46. editAddress(address) {
  47. this.$refs.addressPopup.open({...address})
  48. },
  49. //返回个人中心
  50. leftClick() {
  51. uni.navigateBack(-1)
  52. },
  53. //添加和修改地址
  54. saveOrUpdate(addressDetail) {
  55. let data = {
  56. name: addressDetail.name,
  57. phone: addressDetail.phone,
  58. address: addressDetail.address,
  59. addressDetail: addressDetail.addressDetail,
  60. defaultId: addressDetail.defaultId || '0',
  61. latitude: addressDetail.latitude,
  62. longitude: addressDetail.longitude
  63. }
  64. if (addressDetail.id) {
  65. data.id = addressDetail.id
  66. }
  67. this.$api(data.id ? 'addressEdit' : 'addressAdd', data, res => {
  68. if (res.code == 200) {
  69. this.$refs.addressPopup.close()
  70. this.getAddressList()
  71. uni.showToast({
  72. title: '操作成功',
  73. icon: 'none'
  74. })
  75. }
  76. })
  77. },
  78. //修改默认地址
  79. editDefault(id) {
  80. this.$api('addressDefault', {
  81. id: id,
  82. }, res => {
  83. if (res.code == 200) {
  84. this.$refs.addressPopup.close()
  85. uni.showToast({
  86. title: '操作成功',
  87. icon: 'none'
  88. })
  89. this.getAddressList()
  90. }
  91. })
  92. },
  93. //删除地址
  94. deleteAddress(id) {
  95. let self = this
  96. uni.showModal({
  97. title: '删除地址',
  98. content: '确认删除此地址?删除后数据不可恢复',
  99. success(e) {
  100. if(e.confirm){
  101. self.$api('addressDelete', {
  102. id
  103. }, res => {
  104. if (res.code == 200) {
  105. uni.showToast({
  106. title: '删除成功',
  107. icon: 'none'
  108. })
  109. self.getAddressList()
  110. }
  111. })
  112. }
  113. }
  114. })
  115. },
  116. //点击新增按钮
  117. addBtn() {
  118. this.title = '新增地址'
  119. this.$refs.addressPopup.open({ //初始化数据
  120. name: '',
  121. phone: '',
  122. address: '',
  123. addressDetail: '',
  124. defaultId: '',
  125. latitude: '',
  126. longitude: ''
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .address {
  134. width: 750rpx;
  135. margin: 0rpx auto;
  136. background: #F5F5F5;
  137. box-sizing: border-box;
  138. min-height: 100vh;
  139. .address-list {
  140. padding: 40rpx 20rpx 120rpx 20rpx;
  141. }
  142. .add-btn {
  143. position: fixed;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. left: 0;
  148. bottom: 0;
  149. width: 750rpx;
  150. height: 100rpx;
  151. background: white;
  152. .btn {
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. width: 85%;
  157. height: 80rpx;
  158. border-radius: 40rpx;
  159. color: white;
  160. text-align: center;
  161. font-size: 28rpx;
  162. background: $uni-color;
  163. }
  164. }
  165. }
  166. @media all and (min-width: 961px) {
  167. .add-btn {
  168. left: 50% !important;
  169. transform: translateX(-50%);
  170. }
  171. }
  172. //选择位置地图样式
  173. :deep(.uni-system-choose-location) {
  174. z-index: 99999 !important;
  175. }
  176. </style>