铝交易,微信公众号
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.

211 lines
4.0 KiB

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