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

213 lines
4.0 KiB

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