景徳镇旅游微信小程序
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.

202 lines
3.8 KiB

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