shopList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 { shopList } from '@/api/user.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. console.log(this.addressListAll);
  45. this.shopList();
  46. },
  47. methods: {
  48. // 获取地址列表
  49. shopList(){
  50. uni.showLoading({
  51. title: '加载中',
  52. mask: true
  53. });
  54. shopList({}).then((e) => {
  55. uni.hideLoading()
  56. this.addressListAll = this.addressList= e.data.list;
  57. }).catch((e) => {
  58. console.log(e);
  59. });
  60. },
  61. // 地址查询功能
  62. searchAddressList() {
  63. let obj = this;
  64. obj.addressList = obj.addressListAll.filter(e => {
  65. // 判断客户是否有输入值并且能查询到
  66. if (e.name.indexOf(obj.value) >= 0 && obj.value) {
  67. return true;
  68. } else if (obj.value.length == 0) {
  69. return true;
  70. }
  71. });
  72. console.log(obj.addressList);
  73. },
  74. //选择地址
  75. checkAddress(item) {
  76. // 设置商品页面地址
  77. this.$api.prePage().shopAddress = item;
  78. uni.navigateBack();
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="scss">
  84. page {
  85. padding-bottom: 120rpx;
  86. padding-top: 20rpx;
  87. }
  88. .content {
  89. position: relative;
  90. }
  91. .list {
  92. align-items: center;
  93. padding: 20rpx 30rpx;
  94. background: #fff;
  95. margin: 20rpx;
  96. margin-top: 0;
  97. .buttom {
  98. display: flex;
  99. align-items: center;
  100. justify-content: space-between;
  101. padding-top: 10rpx;
  102. .checkbox {
  103. font-size: 44rpx;
  104. line-height: 1;
  105. padding: 4rpx;
  106. color: $font-color-disabled;
  107. background: #fff;
  108. border-radius: 50px;
  109. }
  110. .checkbox.checked {
  111. color: $base-color;
  112. }
  113. .default-buttom {
  114. display: flex;
  115. align-items: center;
  116. }
  117. .operation {
  118. display: flex;
  119. align-items: center;
  120. .blank {
  121. width: 30rpx;
  122. }
  123. }
  124. .text {
  125. padding-left: 10rpx;
  126. font-size: 24rpx;
  127. color: #666666;
  128. }
  129. }
  130. }
  131. .wrapper {
  132. display: flex;
  133. flex-direction: column;
  134. flex: 1;
  135. // border-bottom: 1px solid #f0f0f0;
  136. // padding-bottom: 20rpx;
  137. }
  138. .address-box {
  139. display: flex;
  140. align-items: center;
  141. justify-content: space-between;
  142. .address {
  143. font-size: $font-base + 2rpx;
  144. color: $font-color-dark;
  145. }
  146. .mobile {
  147. font-size: $font-base;
  148. color: rgba(51, 51, 51, 1);
  149. }
  150. }
  151. .u-box {
  152. font-size: $font-base;
  153. color: $font-color-light;
  154. margin-top: 16rpx;
  155. .name {
  156. margin-right: 30rpx;
  157. }
  158. }
  159. .icon-bianji {
  160. display: flex;
  161. align-items: center;
  162. height: 80rpx;
  163. font-size: 40rpx;
  164. color: $font-color-light;
  165. padding-left: 30rpx;
  166. }
  167. .add-btn {
  168. position: fixed;
  169. left: 30rpx;
  170. right: 30rpx;
  171. bottom: 16rpx;
  172. z-index: 95;
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. width: 690rpx;
  177. height: 80rpx;
  178. font-size: $font-lg;
  179. color: #fff;
  180. background-color: $base-color;
  181. border-radius: 10rpx;
  182. }
  183. </style>