logisticsCompany.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <!-- 物流公司页面 -->
  2. <template>
  3. <view class="logistics_company">
  4. <!-- 搜索 start-->
  5. <view class="logistics_company_search">
  6. <view class="compnay_search">
  7. <view class="logistics_company_left">
  8. <image :src="imgUrl+'order-detail/search.png'" mode=""></image>
  9. <input type="text" :value="inputVal" :placeholder="$L('请输入物流公司')" @input="getValue" @blur="goSearch" />
  10. </view>
  11. <image :src="imgUrl+'order-detail/guanbi.png'" mode="" class="close_btn" v-if="inputVal!=''" @click="clearVal"></image>
  12. </view>
  13. <view class="go_search" @click="goSearch">{{$L('搜索')}}</view>
  14. </view>
  15. <!-- 搜索 end -->
  16. <!-- 物流公司列表 start -->
  17. <view class="logistics_company_list" v-if="LogisticsCompany.length > 0">
  18. <view class="logistics_company_pre" v-for="(item,index) in LogisticsCompany" :key="index" @click="selectLogCom(item.expressName,item.expressId)">
  19. <rich-text :nodes="item.expressName" ></rich-text>
  20. </view>
  21. <loadingState :state='loadingState'/>
  22. </view>
  23. <view class="logistics_company_list" v-if="LogisticsCompany.length == 0">
  24. <view class="no_data">
  25. {{$L('暂无数据')}}~
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import loadingState from "@/components/loading-state.vue";
  32. import {
  33. mapState
  34. } from 'vuex';
  35. export default {
  36. components: {
  37. loadingState
  38. },
  39. data() {
  40. return {
  41. imgUrl: getApp().globalData.imgUrl,
  42. LogisticsCompany:[], //物流公司
  43. inputVal:'', //输入框的值
  44. current:1, //当前为第1页
  45. loadingState: 'first_loading',
  46. pageSize: 20,
  47. loading: false,//是否加载数据
  48. hasMore: true,//是否还有数据
  49. };
  50. },
  51. onLoad(options) {
  52. /**
  53. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  54. * 替换onLoad下代码即可
  55. */
  56. this.getLogisticsCompany()
  57. },
  58. computed: {
  59. ...mapState(['userInfo'])
  60. },
  61. methods: {
  62. //获取物流公司数据信息
  63. getLogisticsCompany(){
  64. // if (this.loadingState === 'loading') {
  65. // //防止重复加载
  66. // return;
  67. // }
  68. // if (this.loadingState == 'no_more_data') {
  69. // //已经没有数据,无需再请求
  70. // return;
  71. // }
  72. let param = {};
  73. param.url = 'v3/system/front/express/list';
  74. param.method = 'GET';
  75. param.data = {};
  76. param.data.pageSize = 20;
  77. param.data.current = this.current;
  78. param.data.expressName = this.inputVal;
  79. this.loadingState = this.loadingState == 'first_loading' ? this.loadingState : 'loading';
  80. this.$request(param).then(res => {
  81. if (res.state == 200) {
  82. if(this.current == 1){
  83. this.LogisticsCompany = res.data.list;
  84. }else{
  85. this.LogisticsCompany = this.LogisticsCompany.concat(res.data.list);
  86. }
  87. this.hasMore = this.$checkPaginationHasMore(res.data.pagination);//是否还有数据
  88. if(this.hasMore){
  89. this.current++;
  90. this.loadingState = 'allow_loading_more';
  91. }else{
  92. this.loadingState = 'no_more_data';
  93. }
  94. } else {
  95. this.$api.msg(res.msg);
  96. }
  97. }).catch((e) => {
  98. //异常处理
  99. })
  100. },
  101. //获取输入框的值
  102. getValue(e){
  103. let that = this;
  104. that.inputVal = e.detail.value;
  105. that.current = 1;
  106. that.getLogisticsCompany();
  107. let searchArr = [];
  108. searchArr = that.LogisticsCompany.filter(item=>item.expressName.includes(that.inputVal));
  109. if(searchArr.length > 0){
  110. searchArr.map(item=>{
  111. item.expressName = that.join(item.expressName,that.inputVal);
  112. })
  113. that.LogisticsCompany = searchArr;
  114. }
  115. },
  116. // 拼接
  117. join(str,key){
  118. var reg = new RegExp((`(${key})`), "gm");
  119. var replace = '<text style="color:#FD463E;font-weight:bold;">$1</text>';
  120. return str.replace(reg, replace);
  121. },
  122. //去搜索
  123. goSearch(e){
  124. this.current = 1;
  125. this.getLogisticsCompany();
  126. },
  127. //清空输入框
  128. clearVal(){
  129. let that = this;
  130. that.inputVal = '';
  131. that.current = 1;
  132. that.getLogisticsCompany();
  133. },
  134. //选择物流公司
  135. selectLogCom(expressName,expressId){
  136. let pages = getCurrentPages();
  137. let prevPage = pages[pages.length - 2]; //上一个页面
  138. prevPage.$vm.logisticsCompanyData = {
  139. 'expressName':expressName,
  140. 'expressId':expressId
  141. }
  142. uni.navigateBack({//返回
  143. delta: 1
  144. })
  145. },
  146. //触底
  147. onReachBottom(){
  148. if(this.hasMore){
  149. this.getLogisticsCompany();
  150. }
  151. }
  152. },
  153. }
  154. </script>
  155. <style lang='scss'>
  156. page {
  157. background: #FFFFFF;
  158. height: 100%;
  159. width: 750rpx;
  160. margin: 0 auto;
  161. }
  162. .logistics_company{
  163. width: 100%;
  164. background: #FFFFFF;
  165. .logistics_company_search{
  166. position: fixed;
  167. background: #FFFFFF;
  168. top: 0;
  169. /* #ifdef H5*/
  170. top: calc(44px + env(safe-area-inset-top));
  171. /* #endif */
  172. z-index: 10;
  173. width: 100%;
  174. height: 76rpx;
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. padding: 20rpx 30rpx;
  179. box-sizing: border-box;
  180. z-index:999;
  181. .compnay_search{
  182. display: flex;
  183. justify-content: space-between;
  184. padding: 0 20rpx;
  185. align-items: center;
  186. width: 617rpx;
  187. height: 65rpx;
  188. background: #F5F5F5;
  189. border-radius: 33rpx;
  190. .logistics_company_left{
  191. display: flex;
  192. align-items: center;
  193. image{
  194. width: 28rpx;
  195. height: 29rpx;
  196. margin-right: 17rpx;
  197. }
  198. input{
  199. font-size: 28rpx;
  200. font-family: PingFang SC;
  201. font-weight: 500;
  202. color: #333333;
  203. line-height: 65rpx;
  204. }
  205. }
  206. .close_btn{
  207. width: 30rpx;
  208. height: 30rpx;
  209. }
  210. }
  211. .go_search{
  212. font-size: 28rpx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #333333;
  216. line-height: 32rpx;
  217. }
  218. }
  219. .logistics_company_list{
  220. margin-top: 88rpx;
  221. width: 100%;
  222. background: #FFFFFF;
  223. border-top: 20rpx solid #F5F5F5;
  224. .logistics_company_pre{
  225. height: 88rpx;
  226. background: #FFFFFF;
  227. border-bottom: 1rpx solid #F8F8F8;
  228. font-size: 28rpx;
  229. font-family: PingFang SC;
  230. font-weight: 500;
  231. color: #333333;
  232. line-height: 88rpx;
  233. margin: 0 29rpx;
  234. }
  235. .no_data{
  236. font-size: 28rpx;
  237. font-family: PingFang SC;
  238. font-weight: 500;
  239. color: #333333;
  240. line-height: 88rpx;
  241. width: 100%;
  242. display: flex;
  243. justify-content: center;
  244. margin-top: 300rpx;
  245. }
  246. }
  247. }
  248. </style>