shopList.vue 3.4 KB

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