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

210 lines
4.0 KiB

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