shopList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="content b-t">
  3. <view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
  4. <view class="wrapper">
  5. <view class="address-box">
  6. <text class="name">{{ item.name }}</text>
  7. <text class="mobile">{{ item.phone }}</text>
  8. </view>
  9. <view class="u-box">
  10. <view class="address">{{ item.address }}</view>
  11. <view class="address">{{ item.detailed_address }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { getAddressList } from '@/api/address.js';
  19. export default {
  20. data() {
  21. return {
  22. source: 0,
  23. addressList: [], //显示的地址数据
  24. value: '', //保存查询值
  25. addressListAll: [] //保存地址数据
  26. };
  27. },
  28. // #ifdef APP-PLUS || H5
  29. onNavigationBarButtonTap(e) {
  30. if (e.text === '搜索') {
  31. this.searchAddressList();
  32. }
  33. },
  34. // 监听原生标题栏搜索输入框输入内容变化事件
  35. onNavigationBarSearchInputChanged(e) {
  36. this.value = e.text;
  37. },
  38. // 监听原生标题栏搜索输入框搜索事件,用户点击软键盘上的“搜索”按钮时触发
  39. onNavigationBarSearchInputConfirmed() {
  40. this.searchAddressList();
  41. },
  42. // #endif
  43. onLoad(option) {
  44. this.addressListAll = this.addressList = this.$api.prePage().system_store;
  45. console.log(this.addressListAll);
  46. },
  47. methods: {
  48. // 地址查询功能
  49. searchAddressList() {
  50. let obj = this;
  51. obj.addressList = obj.addressListAll.filter(e => {
  52. // 判断客户是否有输入值并且能查询到
  53. if (e.name.indexOf(obj.value) >= 0 && obj.value) {
  54. return true;
  55. } else if (obj.value.length == 0) {
  56. return true;
  57. }
  58. });
  59. console.log(obj.addressList);
  60. },
  61. //选择地址
  62. checkAddress(item) {
  63. // 设置商品页面地址
  64. this.$api.prePage().shopAddress = item;
  65. uni.navigateBack();
  66. }
  67. }
  68. };
  69. </script>
  70. <style lang="scss">
  71. page {
  72. padding-bottom: 120rpx;
  73. padding-top: 20rpx;
  74. }
  75. .content {
  76. position: relative;
  77. }
  78. .list {
  79. align-items: center;
  80. padding: 20rpx 30rpx;
  81. background: #fff;
  82. margin: 20rpx;
  83. margin-top: 0;
  84. .buttom {
  85. display: flex;
  86. align-items: center;
  87. justify-content: space-between;
  88. padding-top: 10rpx;
  89. .checkbox {
  90. font-size: 44rpx;
  91. line-height: 1;
  92. padding: 4rpx;
  93. color: $font-color-disabled;
  94. background: #fff;
  95. border-radius: 50px;
  96. }
  97. .checkbox.checked {
  98. color: $base-color;
  99. }
  100. .default-buttom {
  101. display: flex;
  102. align-items: center;
  103. }
  104. .operation {
  105. display: flex;
  106. align-items: center;
  107. .blank {
  108. width: 30rpx;
  109. }
  110. }
  111. .text {
  112. padding-left: 10rpx;
  113. font-size: 24rpx;
  114. color: #666666;
  115. }
  116. }
  117. }
  118. .wrapper {
  119. display: flex;
  120. flex-direction: column;
  121. flex: 1;
  122. // border-bottom: 1px solid #f0f0f0;
  123. // padding-bottom: 20rpx;
  124. }
  125. .address-box {
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. .address {
  130. font-size: $font-base + 2rpx;
  131. color: $font-color-dark;
  132. }
  133. .mobile {
  134. font-size: $font-base;
  135. color: rgba(51, 51, 51, 1);
  136. }
  137. }
  138. .u-box {
  139. font-size: $font-base;
  140. color: $font-color-light;
  141. margin-top: 16rpx;
  142. .name {
  143. margin-right: 30rpx;
  144. }
  145. }
  146. .icon-bianji {
  147. display: flex;
  148. align-items: center;
  149. height: 80rpx;
  150. font-size: 40rpx;
  151. color: $font-color-light;
  152. padding-left: 30rpx;
  153. }
  154. .add-btn {
  155. position: fixed;
  156. left: 30rpx;
  157. right: 30rpx;
  158. bottom: 16rpx;
  159. z-index: 95;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. width: 690rpx;
  164. height: 80rpx;
  165. font-size: $font-lg;
  166. color: #fff;
  167. background-color: $base-color;
  168. border-radius: 10rpx;
  169. }
  170. </style>