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.

191 lines
4.1 KiB

10 months ago
  1. <template>
  2. <view class="address">
  3. <u-navbar :title="$t('page.address.address')" @leftClick="leftClick"></u-navbar>
  4. <view v-if="list.length > 0" class="address-list">
  5. <u-radio-group v-model="radiovalue1" placement="column">
  6. <view class="address-item" v-for="(item, index) in list">
  7. <div class="radio">
  8. <u-radio :name="item.id" :key="index" activeColor="#e68534"></u-radio>
  9. </div>
  10. <view class="address-info">
  11. <view class="user-info">
  12. <text>{{ item.name }}</text>
  13. <text>{{ item.phone }}</text>
  14. <u-tag v-if="item.defaultFlag == 'true'" text="默认" size="mini" type="warning"
  15. shape="circle"></u-tag>
  16. </view>
  17. <view class="address-detail">
  18. {{ item.region }}
  19. {{ item.detail_address }}
  20. </view>
  21. </view>
  22. <view class="icon">
  23. <u-icon name="edit-pen" color="#ccc" size="28" @click="toAdd(item.id)"></u-icon>
  24. <u-icon name="trash" color="#ccc" size="28" @click="del(item.id)"></u-icon>
  25. </view>
  26. </view>
  27. </u-radio-group>
  28. </view>
  29. <view v-else class="no-product">
  30. <view class="box">
  31. <view class="no-product-title">{{ $t('page.address.no-address') }}</view>
  32. </view>
  33. </view>
  34. <view class="address-bottom">
  35. <u-button @click="toAdd" type="primary" shape="circle" color="#ED7A2F"
  36. :text="$t('page.address.addAddress')"></u-button>
  37. </view>
  38. <u-modal :show="delShow" @confirm="confirm" ref="uModal" :title="$t('myToactTitle')" @cancel="delCancel"
  39. :showCancelButton="true" :confirmText="$t('page.address.confirm')" :cancelText="$t('page.address.cancel')"
  40. :asyncClose="true">
  41. <view class="slot-content">
  42. <rich-text :nodes="$t('page.address.del_content')"></rich-text>
  43. </view>
  44. </u-modal>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. radiovalue1: '',
  52. total: 0,
  53. list: [],
  54. delShow: false,
  55. delId: ''
  56. }
  57. },
  58. onShow() {
  59. this.getAddressList();
  60. },
  61. methods: {
  62. getAddressList() { //获取地址列表
  63. this.request('addressPage', {}, {
  64. "pageSize": 10,
  65. "pageNo": 0
  66. }).then(res => {
  67. this.total = res.result.total
  68. this.list = res.result.records;
  69. })
  70. },
  71. toAdd(id) {
  72. uni.navigateTo({
  73. url: '/pages/user/address/addAddres?id=' + id
  74. })
  75. },
  76. leftClick() {
  77. uni.switchTab({
  78. url: '/pages/user/user'
  79. })
  80. },
  81. del(id) {
  82. this.delShow = true;
  83. this.delId = id
  84. },
  85. confirm() {
  86. this.request('deleAddress', {
  87. id: this.delId
  88. }).then(res => {
  89. this.delShow = false;
  90. if (res.code == 200) {
  91. this.getAddressList();
  92. uni.$u.toast(this.$t('success-operation'))
  93. }
  94. })
  95. },
  96. delCancel() {
  97. this.delShow = false;
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .address {
  104. .address-list {
  105. margin-top: 54px;
  106. .address-item {
  107. display: flex;
  108. justify-content: space-between;
  109. background: white;
  110. border-radius: 10rpx;
  111. box-sizing: border-box;
  112. padding: 15px 15px;
  113. font-size: 25rpx;
  114. border-bottom: 1px solid #eaeaea;
  115. &:nth-last-child(1) {
  116. border: none;
  117. }
  118. .radio {
  119. display: flex;
  120. align-items: center;
  121. }
  122. .address-info {
  123. width: calc(100% - 60px);
  124. .user-info {
  125. display: flex;
  126. align-items: center;
  127. text {
  128. margin-right: 10rpx;
  129. }
  130. }
  131. }
  132. .icon {
  133. display: flex;
  134. width: 70px;
  135. justify-content: space-between;
  136. }
  137. }
  138. }
  139. .no-product {
  140. height: calc(100vh - 124px);
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. box-sizing: border-box;
  145. padding: 0px 15px;
  146. .box {
  147. font-size: 26rpx;
  148. text-align: center;
  149. .to-home {
  150. padding: 20rpx 140rpx;
  151. border: 1px solid #ccc;
  152. border-radius: 5px;
  153. text-align: center;
  154. margin: 20rpx 0px;
  155. }
  156. }
  157. }
  158. .address-bottom {
  159. display: flex;
  160. align-items: center;
  161. position: fixed;
  162. left: 0;
  163. bottom: 0;
  164. width: 100%;
  165. height: 80px;
  166. background: white;
  167. box-shadow: -1px -1px 1px rgba(0, 0, 0, .1);
  168. box-sizing: border-box;
  169. padding: 0px 15px;
  170. &::v-deep .u-button {
  171. height: 70%;
  172. }
  173. }
  174. }
  175. </style>