address.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view>
  3. <navbar :iSimmersive="false" title-color="#ffffff" background="#1b43c4" :placeholder="true" title="我的地址"></navbar>
  4. <view v-if="!isLoading && isError == false">
  5. <view class="address-list">
  6. <view class="address-box" v-for="(item,index) in list" :key="index">
  7. <view class="t">
  8. <view class="t-1">
  9. <text>{{item.name}}</text>
  10. <text>{{item.tel}}</text>
  11. </view>
  12. <view class="desc">{{item.address}}</view>
  13. </view>
  14. <view class="b">
  15. <view v-if="item.is_default" class="b-1">默认地址</view>
  16. <view class="b-2">
  17. <text @click="onEdit(item.id)">修改</text>
  18. <text @click="onDelete(item.id)">删除</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="btn">
  24. <view class="add" @click="onAdd">新增地址</view>
  25. </view>
  26. </view>
  27. <loading v-if="isLoading"></loading>
  28. <empty-box type="address" v-if="isError && isLoading == false" @onEvents="onAdd"></empty-box>
  29. </view>
  30. </template>
  31. <script>
  32. import loading from '../../components/tool/loading'
  33. import navbar from "@/components/navbar/navbar";
  34. export default {
  35. components:{
  36. loading,navbar
  37. },
  38. data() {
  39. return {
  40. isLoading:true,
  41. isError: false,
  42. list: []
  43. };
  44. },
  45. onShow() {
  46. let users = this.$storage.getJson("users");
  47. if(users == null){
  48. this.$utils.navigateTo('public/login');
  49. }else{
  50. this.$http.getAddress().then(res=>{
  51. if(res.status){
  52. this.list = res.data;
  53. if(this.list.length){
  54. this.isLoading = false;
  55. this.isError = false;
  56. }else{
  57. this.isLoading = false;
  58. this.isError = true;
  59. }
  60. }else{
  61. this.isLoading = false;
  62. this.isError = true;
  63. }
  64. }).catch(err=>{
  65. this.isLoading = false;
  66. this.isError = true;
  67. });
  68. }
  69. },
  70. methods: {
  71. onDelete(id){
  72. this.list = this.list.filter(function (item) {
  73. if(item.id != id){
  74. return item;
  75. }
  76. });
  77. this.$http.editorAddressDelete({ id: id });
  78. if(this.list.length){
  79. this.isLoading = false;
  80. this.isError = false;
  81. }else{
  82. this.isLoading = false;
  83. this.isError = true;
  84. }
  85. },
  86. onAdd(){
  87. this.$utils.navigateTo('ucenter/address_editor');
  88. },
  89. onEdit(id) {
  90. this.$utils.navigateTo('ucenter/address_editor',{ id: id });
  91. }
  92. },
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .address-list{
  97. .address-box{
  98. background-color: #fff;
  99. width: 100%;
  100. height: auto !important;
  101. height: 260rpx;
  102. float: left;
  103. margin-top: 30rpx;
  104. min-height: 260rpx;
  105. .t{
  106. padding: 30rpx;
  107. border-bottom: 2rpx solid #e8e8e8;
  108. color:#777;
  109. font-size: 30rpx;
  110. .t-1{
  111. height: 52rpx;
  112. min-height: 52rpx;
  113. text:first-child{
  114. float: left;
  115. }
  116. text:last-child{
  117. float: right;
  118. }
  119. }
  120. .desc{
  121. }
  122. }
  123. .b{
  124. height: 100rpx;
  125. color:#777;
  126. font-size: 30rpx;
  127. padding: 0 30rpx;
  128. .b-1 {
  129. float: left;
  130. display: inline-block;
  131. color: #1b43c4;
  132. border: 1rpx solid #1b43c4;
  133. border-radius: 10rpx;
  134. font-size: 24rpx;
  135. width: 130rpx;
  136. height: 50rpx;
  137. line-height: 50rpx;
  138. text-align: center;
  139. margin-top: 24rpx;
  140. }
  141. .b-2{
  142. float: right;
  143. text {
  144. display: inline-block;
  145. color: #777777;
  146. border: 1rpx solid #777777;
  147. border-radius: 10rpx;
  148. font-size: 24rpx;
  149. width: 130rpx;
  150. height: 50rpx;
  151. line-height: 50rpx;
  152. text-align: center;
  153. margin-top: 24rpx;
  154. margin-left: 20rpx;
  155. }
  156. text:last-child{
  157. }
  158. }
  159. }
  160. }
  161. }
  162. .btn{
  163. width: 100%;
  164. background-color: #fff;
  165. position: fixed;
  166. left: 0;
  167. bottom: 0;
  168. height: 120rpx;
  169. padding-top: 20rpx;
  170. .add{
  171. display: block;
  172. height: 100rpx;
  173. line-height: 100rpx;
  174. text-align: center;
  175. background-color: #1b43c4;
  176. color: #fff;
  177. margin: 0 30rpx;
  178. border-radius: 10rpx;
  179. }
  180. }
  181. </style>