address.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="content b-t">
  3. <hx-navbar left-text="收货地址" backTabbarUrl="/pages/user/center/center" :backgroundColor="[241,241,241]"></hx-navbar>
  4. <view class="bb15">
  5. </view>
  6. <view class="list-box">
  7. <view class="list b-b" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
  8. <view class="wrapper">
  9. <view class="address-box">
  10. <text v-if="item.default" class="tag">默认</text>
  11. <text class="address">{{item.addressName}} {{item.area}}</text>
  12. </view>
  13. <view class="u-box">
  14. <text class="name">{{item.name}}</text>
  15. <text class="mobile">{{item.mobile}}</text>
  16. </view>
  17. </view>
  18. <text class="hxicon-edit" @click.stop="addAddress('edit', item)"></text>
  19. </view>
  20. </view>
  21. <view class="add-btn" @click="addAddress('add')">
  22. <text>新增地址</text>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. source: 0,
  31. addressList: [
  32. {
  33. name: '刘晓晓',
  34. mobile: '18666666666',
  35. addressName: '贵族皇仕牛排(东城店)',
  36. address: '北京市东城区',
  37. area: 'B区',
  38. default: true
  39. },{
  40. name: '刘大大',
  41. mobile: '18667766666',
  42. addressName: '龙回1区12号楼',
  43. address: '山东省济南市历城区',
  44. area: '西单元302',
  45. default: false,
  46. }
  47. ]
  48. }
  49. },
  50. onLoad(option){
  51. console.log(option.source);
  52. this.source = option.source;
  53. },
  54. methods: {
  55. //选择地址
  56. checkAddress(item){
  57. if(this.source == 1){
  58. //this.$api.prePage()获取上一页实例,在App.vue定义
  59. this.$api.prePage().addressData = item;
  60. uni.navigateBack()
  61. }
  62. },
  63. addAddress(type, item){
  64. uni.navigateTo({
  65. url: `/pages/user/address/addressManage?type=${type}&data=${JSON.stringify(item)}`
  66. })
  67. },
  68. //添加或修改成功之后回调
  69. refreshList(data, type){
  70. //添加或修改后事件,这里直接在最前面添加了一条数据,实际应用中直接刷新地址列表即可
  71. this.addressList.unshift(data);
  72. console.log(data, type);
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang='scss'>
  78. .bb15{
  79. padding-bottom: 30upx;
  80. }
  81. .content{
  82. position: relative;
  83. }
  84. .list-box{
  85. display: flex;
  86. flex-direction: column;
  87. background-color: #fff;
  88. border-radius: 10px;
  89. overflow: hidden;
  90. margin: 0 15px;
  91. }
  92. .list{
  93. display: flex;
  94. align-items: center;
  95. padding: 14px 15px;
  96. background: #fff;
  97. position: relative;
  98. }
  99. .wrapper{
  100. display: flex;
  101. flex-direction: column;
  102. flex: 1;
  103. }
  104. .address-box{
  105. display: flex;
  106. align-items: center;
  107. .tag{
  108. font-size: 24upx;
  109. color: $base-color;
  110. margin-right: 10upx;
  111. background: #fffafb;
  112. border: 1px solid #ffc107;
  113. border-radius: 4upx;
  114. padding: 4upx 10upx;
  115. line-height: 1;
  116. }
  117. .address{
  118. font-size: 30upx;
  119. color: $font-color-dark;
  120. }
  121. }
  122. .u-box{
  123. font-size: 28upx;
  124. color: $font-color-light;
  125. margin-top: 16upx;
  126. .name{
  127. margin-right: 30upx;
  128. }
  129. }
  130. .icon-edit{
  131. display: flex;
  132. align-items: center;
  133. height: 80upx;
  134. font-size: 40upx;
  135. color: $font-color-light;
  136. padding-left: 30upx;
  137. }
  138. .add-btn{
  139. position: fixed;
  140. display: flex;
  141. flex-direction: row;
  142. justify-content: center;
  143. align-items: center;
  144. border-radius: 10px;
  145. overflow: hidden;
  146. bottom: 15px;
  147. left: 15px;
  148. right: 15px;
  149. height: 45px;
  150. font-size: 16px;
  151. font-weight: bold;
  152. color: #333;
  153. background: linear-gradient(45deg, #ffd900, #ffc107);
  154. }
  155. </style>