surpermarket.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view>
  3. <view class="top-box">
  4. <!-- <u-search placeholder="日照香炉生紫烟" v-model="keyword"></u-search> -->
  5. <u-field icon='search' @blur='serachBlur' label-width='0' v-model="search" trim border
  6. border-color='black' placeholder='请搜索' />
  7. <u-sticky>
  8. <!-- <u-dropdown >
  9. <u-dropdown-item v-model="value1" title="距离" :options="options1"></u-dropdown-item>
  10. <u-dropdown-item v-model="value2" title="温度" :options="options2"></u-dropdown-item>
  11. </u-dropdown> -->
  12. <u-tabs :list="list" active-color='orange' :current="current" @change="tabsChange"></u-tabs>
  13. <slFilter @result='result' @changeICon='changeICon' :themeColor="themeColor" :menuList='menuList'>
  14. </slFilter>
  15. </u-sticky>
  16. </view>
  17. <view class="content">
  18. <scroll-view scroll-y="true" class="mode-center">
  19. <template v-for="item in 10">
  20. <view class="" v-if="flag">
  21. aaa
  22. </view>
  23. <view class="" v-else>
  24. bbbb
  25. </view>
  26. </template>
  27. </scroll-view>
  28. <!-- <view v-for="(item, index) in newList" :key="index" class="newList">
  29. <view>
  30. {{item.id}}
  31. </view>
  32. <view>
  33. {{item.name}}
  34. </view>
  35. <view>
  36. {{item.address}}
  37. </view>
  38. </view>
  39. <view class="loading" v-if="loading">{{ loadingTxt }}</view> -->
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import slFilter from '@/components/sl-filter/sl-filter.vue';
  45. import {
  46. getOrderList
  47. } from "../../utils/service.js";
  48. export default {
  49. components: {
  50. slFilter
  51. },
  52. data() {
  53. return {
  54. value1: 1,
  55. value2: 2,
  56. search: '',
  57. touchmove: false,
  58. options1: [{
  59. label: '默认排序',
  60. value: 1,
  61. },
  62. {
  63. label: '距离优先',
  64. value: 2,
  65. },
  66. {
  67. label: '价格优先',
  68. value: 3,
  69. }
  70. ],
  71. options2: [{
  72. label: '去冰',
  73. value: 1,
  74. },
  75. {
  76. label: '加冰',
  77. value: 2,
  78. },
  79. ],
  80. newList: [],
  81. loading: false,
  82. finished: false,
  83. loadingTxt: '加载更多',
  84. page: 1,
  85. add: [{
  86. name: '张wwww三',
  87. title: '啊啊啊啊'
  88. },
  89. {
  90. name: '张三22222',
  91. title: '啊啊啊2222啊'
  92. },
  93. ],
  94. list: [{
  95. name: '全部'
  96. }, {
  97. name: '政采待'
  98. }, {
  99. name: '小微数贷',
  100. }, {
  101. name: '抵押贷',
  102. },
  103. {
  104. name: '信用贷',
  105. },
  106. {
  107. name: '畜牧贷',
  108. },
  109. {
  110. name: '个转企',
  111. },
  112. {
  113. name: '复工复商',
  114. },
  115. {
  116. name: '电力贷',
  117. },
  118. ],
  119. current: 0,
  120. themeColor: 'orange',
  121. flag: true,
  122. filterResult: {},
  123. menuList: [{
  124. 'title': '排序',
  125. 'key': 'key_1',
  126. 'isSort': true,
  127. 'isMutiple': false,
  128. 'detailList': [{
  129. 'title': '成功对接企业高到底',
  130. 'value': 'val1'
  131. },
  132. {
  133. 'title': '参考利率从低到高',
  134. 'value': 'val_3_2'
  135. },
  136. {
  137. 'title': '贷款额度从高到低',
  138. 'value': 'val_3_3'
  139. }
  140. ]
  141. },
  142. {
  143. 'title': '金融机构',
  144. 'key': 'key_2',
  145. 'isMutiple': true,
  146. 'detailList': [{
  147. 'title': '长春市',
  148. 'children': [{
  149. id: '200',
  150. value: '朝阳区'
  151. },
  152. {
  153. id: '201',
  154. value: '南关区'
  155. },
  156. {
  157. id: '203',
  158. value: '南关区'
  159. },
  160. {
  161. id: '204',
  162. value: '南关区'
  163. },
  164. ]
  165. },
  166. {
  167. 'title': '北京市',
  168. 'children': [{
  169. id: '300',
  170. value: '朝阳区'
  171. },
  172. {
  173. id: '301',
  174. value: '南关区'
  175. },
  176. {
  177. id: '303',
  178. value: '南关区'
  179. },
  180. {
  181. id: '304',
  182. value: '南关区'
  183. },
  184. ]
  185. },
  186. {
  187. 'title': '条件_2_2',
  188. 'children': [{
  189. id: '400',
  190. value: '朝阳区'
  191. },
  192. {
  193. id: '401',
  194. value: '南关区'
  195. },
  196. {
  197. id: '403',
  198. value: '南关区'
  199. },
  200. {
  201. id: '404',
  202. value: '南关区'
  203. },
  204. ]
  205. },
  206. ]
  207. },
  208. {
  209. 'title': '地区',
  210. 'key': 'key_3',
  211. 'isMutiple': true,
  212. 'detailList': [{
  213. 'title': '长春市',
  214. 'children': [{
  215. id: '200',
  216. value: '朝阳区'
  217. },
  218. {
  219. id: '201',
  220. value: '南关区'
  221. },
  222. {
  223. id: '203',
  224. value: '南关区'
  225. },
  226. {
  227. id: '204',
  228. value: '南关区'
  229. },
  230. ]
  231. },
  232. {
  233. 'title': '北京市',
  234. 'children': [{
  235. id: '300',
  236. value: '朝阳区'
  237. },
  238. {
  239. id: '301',
  240. value: '南关区'
  241. },
  242. {
  243. id: '303',
  244. value: '南关区'
  245. },
  246. {
  247. id: '304',
  248. value: '南关区'
  249. },
  250. ]
  251. },
  252. {
  253. 'title': '条件_2_2',
  254. 'children': [{
  255. id: '400',
  256. value: '朝阳区'
  257. },
  258. {
  259. id: '401',
  260. value: '南关区'
  261. },
  262. {
  263. id: '403',
  264. value: '南关区'
  265. },
  266. {
  267. id: '404',
  268. value: '南关区'
  269. },
  270. ]
  271. },
  272. ]
  273. },
  274. {
  275. 'title': '更多',
  276. 'key': 'key_4',
  277. 'isMutiple': true,
  278. 'detailList': [{
  279. 'title': '长春市',
  280. 'children': [{
  281. id: '200',
  282. value: '朝阳区'
  283. },
  284. {
  285. id: '201',
  286. value: '南关区'
  287. },
  288. {
  289. id: '203',
  290. value: '南关区'
  291. },
  292. {
  293. id: '204',
  294. value: '南关区'
  295. },
  296. ]
  297. },
  298. {
  299. 'title': '北京市',
  300. 'children': [{
  301. id: '300',
  302. value: '朝阳区'
  303. },
  304. {
  305. id: '301',
  306. value: '南关区'
  307. },
  308. {
  309. id: '303',
  310. value: '南关区'
  311. },
  312. {
  313. id: '304',
  314. value: '南关区'
  315. },
  316. ]
  317. },
  318. {
  319. 'title': '更多',
  320. 'children': [{
  321. id: '400',
  322. value: '朝阳区'
  323. },
  324. {
  325. id: '401',
  326. value: '南关区'
  327. },
  328. {
  329. id: '403',
  330. value: '南关区'
  331. },
  332. {
  333. id: '404',
  334. value: '南关区'
  335. },
  336. ]
  337. },
  338. ]
  339. },
  340. ]
  341. };
  342. },
  343. onLoad(e) {
  344. //this.getNews();
  345. },
  346. onPullDownRefresh() {
  347. this.loading = true;
  348. //下拉的生命周期
  349. this.getNews();
  350. },
  351. onReachBottom() {
  352. //阻止重复加载
  353. // if (timer !== null) {
  354. // clearTimeout(timer);
  355. // }
  356. //timer = setTimeout(() => this.getMoreNews(), 500);
  357. this.getMoreNews()
  358. },
  359. methods: {
  360. //下拉刷新事件
  361. async getNews() {
  362. this.finished = false;
  363. this.loadingTxt = '加载中';
  364. this.page = 1;
  365. //标题读取样式激活
  366. uni.showNavigationBarLoading();
  367. const result = await getOrderList();
  368. let {
  369. data,
  370. code
  371. } = result
  372. if (data && code == 0) {
  373. this.newList = data.tableData
  374. uni.stopPullDownRefresh();
  375. //隐藏标题读取
  376. uni.hideNavigationBarLoading();
  377. this.loading = false;
  378. }
  379. },
  380. //加载更多的新闻
  381. async getMoreNews() {
  382. if (this.finished) return;
  383. this.loadingTxt = '加载中';
  384. this.loading = true;
  385. uni.showNavigationBarLoading();
  386. this.page++;
  387. const result = await getOrderList();
  388. let {
  389. data,
  390. code
  391. } = result
  392. if (data && code == 0) {
  393. uni.stopPullDownRefresh();
  394. //隐藏标题读取
  395. uni.hideNavigationBarLoading();
  396. if (this.newList.length == data.total) {
  397. this.loadingTxt = '已经加载全部';
  398. this.finished = true;
  399. return;
  400. }
  401. this.newList = [...this.newList, ...data.tableData]
  402. this.loading = false
  403. }
  404. // setTimeout(() => {
  405. // //停止下拉样式
  406. // uni.stopPullDownRefresh();
  407. // //隐藏标题读取
  408. // uni.hideNavigationBarLoading();
  409. // if (that.newList.length > 30) {
  410. // that.loadingTxt = '已经加载全部';
  411. // that.finished = true;
  412. // return;
  413. // }
  414. // that.newList = that.newList.concat(that.add)
  415. // that.loading = false;
  416. // }, 1500);
  417. },
  418. tabsChange(index) {
  419. console.log(this.filterResult)
  420. this.current = index;
  421. let data = {
  422. ...this.filterResult,
  423. tab: this.current,
  424. search: this.search,
  425. }
  426. console.log(data, 11111)
  427. },
  428. serachBlur() {
  429. console.log(this.search,"该死")
  430. let data = {
  431. ...this.filterResult,
  432. tab: this.current,
  433. search: this.search,
  434. }
  435. console.log(data, 11111)
  436. },
  437. changeICon(flag) {
  438. flag ? this.flag = true : this.flag = false
  439. },
  440. result(val) {
  441. // console.log(JSON.stringify(val));
  442. // this.filterResult = JSON.stringify(val, null, 2)
  443. let data = {
  444. tab: this.current,
  445. search: this.search,
  446. ...val
  447. }
  448. this.filterResult = val
  449. console.log(data)
  450. },
  451. }
  452. };
  453. </script>
  454. <style lang="scss" scoped>
  455. @import '../../common/box.scss';
  456. .top-box {
  457. background: white;
  458. overflow: hidden;
  459. }
  460. ::v-deep .u-dropdown__menu {
  461. background: white;
  462. }
  463. ::v-deep .u-field {
  464. border: 1rpx solid black;
  465. border-radius: 10rpx;
  466. margin: 20rpx 4%;
  467. }
  468. ::v-deep .u-dropdown__content {
  469. height: 700px !important;
  470. }
  471. // ::v-deep .u-sticky-wrap {
  472. // height: auto!important;
  473. // }
  474. .fixed-box {
  475. position: fixed;
  476. z-index: 99;
  477. width: 100%;
  478. }
  479. .newList {
  480. border: 1rpx solid black;
  481. padding: 20px;
  482. }
  483. .loading {
  484. line-height: 2em;
  485. text-align: center;
  486. color: #888;
  487. margin-top: 30rpx;
  488. }
  489. </style>