selShop.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="selSupplier">
  3. <view class="search-view">
  4. <view class="input-view">
  5. <input type="text" @confirm="search" confirm-type="search" placeholder-class="input-pl" placeholder="商铺名称" v-model="keyword" />
  6. <u-icon class="add-icon" name="search" size="40" color="#666666" @click="search"></u-icon>
  7. </view>
  8. </view>
  9. <view class="customer-ul" :style="{ paddingBottom: is_check ? '90rpx' : '0' }">
  10. <view class="customer-li" v-for="(item, index) in shop_list" :key="index" @click="changeData(item)">
  11. <view class="customer-name">{{ item.name }}</view>
  12. <view class="other" :style="{ paddingLeft: is_check ? '80rpx' : '20rpx' }">
  13. <view class="check-tag" v-if="!!is_check">
  14. <text v-if="!item.check" class="custom-icon custom-icon-xuanze"></text>
  15. <text v-else class="custom-icon custom-icon-xuanze_xuanzhong"></text>
  16. </view>
  17. <view class="concat clearfix">
  18. <text class="float_left">{{ item.contactName }}</text>
  19. <view class="float_right" v-if="item.mobile">
  20. <u-icon name="phone-fill" size="26"></u-icon>
  21. <text class="phone-text">{{ item.mobile }}</text>
  22. </view>
  23. </view>
  24. <view class="address">{{ item.area.provinceName }}-{{ item.area.cityName }}-{{ item.area.districtName }}-{{ item.area.address }}</view>
  25. </view>
  26. </view>
  27. <u-loadmore :status="load_status" />
  28. </view>
  29. <view class="bottom-view" @click="checkConfirm" v-if="is_check">确定</view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. keyword: '',
  37. load_status: 'nomore',
  38. page: 1,
  39. pageSize: 10,
  40. total: 0,
  41. shop_list: [],
  42. is_check: '',
  43. sel_id: []
  44. };
  45. },
  46. onLoad(options) {
  47. this.is_check = options.check || '';
  48. if (options.selId) {
  49. this.sel_id = JSON.parse(options.selId);
  50. }
  51. this.getAllShop();
  52. },
  53. onPullDownRefresh() {
  54. this.page = 1;
  55. this.getAllShop();
  56. },
  57. // 上拉加载
  58. onReachBottom() {
  59. if (this.total / this.pageSize > this.page) {
  60. this.page += 1;
  61. this.getAllShop();
  62. }
  63. },
  64. methods: {
  65. changeData(item) {
  66. if (this.is_check) {
  67. item.check = !item.check;
  68. } else {
  69. // 选择返回上一页
  70. this._prePage().shopData = item;
  71. uni.navigateBack();
  72. }
  73. },
  74. checkConfirm() {
  75. const list = this.shop_list.filter(item => item.check);
  76. // 选择返回上一页
  77. this._prePage().shopData = list;
  78. uni.navigateBack();
  79. },
  80. search() {
  81. this.page = 1;
  82. if(this.keyword){
  83. this.shopSearch();
  84. }else{
  85. this.getAllShop();
  86. }
  87. },
  88. shopSearch() {
  89. this.loading_status = 'loading';
  90. this.$u.api
  91. .shopSearch({
  92. page: this.page,
  93. pageSize: this.pageSize,
  94. enableStatus: 5,
  95. name:this.keyword
  96. })
  97. .then(res => {
  98. uni.stopPullDownRefresh();
  99. if (this.page === 1) {
  100. this.shop_list = res.data;
  101. } else {
  102. this.shop_list = this.shop_list.concat(res.data);
  103. }
  104. this.shop_list = this.shop_list.map(item => {
  105. return {
  106. ...item,
  107. check: this.sel_id.findIndex(selId => parseInt(selId) === parseInt(item.id)) > -1
  108. };
  109. });
  110. this.total = res.pageTotal;
  111. this.load_status = this.$utils.loadStatus(this.page, this.pageSize, this.total);
  112. })
  113. .catch(err => {
  114. uni.stopPullDownRefresh();
  115. });
  116. },
  117. getAllShop() {
  118. this.loading_status = 'loading';
  119. this.$u.api
  120. .getAllShop({
  121. page: this.page,
  122. pageSize: this.pageSize,
  123. enableStatus: 5
  124. })
  125. .then(res => {
  126. uni.stopPullDownRefresh();
  127. if (this.page === 1) {
  128. this.shop_list = res.data;
  129. } else {
  130. this.shop_list = this.shop_list.concat(res.data);
  131. }
  132. this.shop_list = this.shop_list.map(item => {
  133. return {
  134. ...item,
  135. check: this.sel_id.findIndex(selId => parseInt(selId) === parseInt(item.id)) > -1
  136. };
  137. });
  138. this.total = res.pageTotal;
  139. this.load_status = this.$utils.loadStatus(this.page, this.pageSize, this.total);
  140. })
  141. .catch(err => {
  142. uni.stopPullDownRefresh();
  143. });
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. .search-view {
  150. position: fixed;
  151. z-index: 99;
  152. top: 0;
  153. left: 0;
  154. width: 100%;
  155. background-color: #ffffff;
  156. border-bottom: 1px solid #f5f5f5;
  157. padding: 20rpx 0;
  158. .input-view {
  159. padding: 0 24rpx;
  160. input {
  161. height: 60rpx;
  162. line-height: 60rpx;
  163. padding: 0 24rpx;
  164. display: inline-block;
  165. width: 580rpx;
  166. border: 1px solid #f5f5f5;
  167. vertical-align: middle;
  168. border-radius: 8rpx;
  169. background-color: #f7f8fa;
  170. }
  171. .add-icon {
  172. margin-left: 14rpx;
  173. display: inline-block;
  174. vertical-align: middle;
  175. }
  176. }
  177. }
  178. .bottom-view {
  179. z-index: 99;
  180. width: 100%;
  181. position: fixed;
  182. left: 0;
  183. bottom: 0;
  184. line-height: 90rpx;
  185. color: #ffffff;
  186. background-color: $uni-color-primary;
  187. text-align: center;
  188. }
  189. .customer-ul {
  190. padding-top: 90rpx;
  191. padding-bottom: 20rpx;
  192. .customer-li {
  193. width: 702rpx;
  194. margin: 0 auto;
  195. background-color: #ffffff;
  196. border-radius: 10rpx;
  197. margin-top: 20rpx;
  198. .customer-name {
  199. padding: 0 20rpx;
  200. line-height: 80rpx;
  201. border-bottom: 1px solid #f5f5f5;
  202. }
  203. .other {
  204. font-size: 24rpx;
  205. padding: 10rpx 20rpx;
  206. line-height: 50rpx;
  207. position: relative;
  208. .check-tag {
  209. position: absolute;
  210. left: 20rpx;
  211. top: 50%;
  212. transform: translateY(-50%);
  213. font-size: 40rpx;
  214. color: #999999;
  215. .custom-icon-xuanze_xuanzhong {
  216. color: $uni-color-primary;
  217. }
  218. }
  219. .concat {
  220. .float_right {
  221. color: $uni-color-primary;
  222. .phone-text {
  223. margin-left: 10rpx;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. </style>