checkNumber.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <div class="bgColor">
  3. <div slot="content" class="scroll-wrapper">
  4. <div class="demo">
  5. <div class="scroll-list-wrap">
  6. <!-- <cube-scroll
  7. ref="scroll"
  8. :data="items"
  9. :options="options"
  10. @pulling-down="onPullingDown"
  11. @pulling-up="onPullingUp"
  12. > -->
  13. <cube-scroll
  14. ref="scroll"
  15. :data="items"
  16. :options="options"
  17. >
  18. <div class="search">
  19. <input
  20. type="text"
  21. placeholder="可简拼、名称搜索"
  22. v-model="search"
  23. @input="searchFnDebounce()"
  24. @click="clickSearch()"
  25. />
  26. <span v-if="isShow" @click="cancel()" class="cancel">取消</span>
  27. </div>
  28. <ul class="searchList" v-show="isShow">
  29. <li v-for="item in searchList" :key="item.id" @click="clickSearchItem(item)">
  30. <i class="dash dash-fangdajing"></i>
  31. <div class="s_c">
  32. <template v-if="item.unit.id">
  33. <div class="searchListItem" v-if="item.unit"><strong>单位:</strong><em>{{item.unit.unit}}</em></div>
  34. <div class="searchListItem"><strong>部门:</strong><em>{{item.dept}}</em></div>
  35. </template>
  36. <template v-else><div class="searchListItem"><strong>单位:</strong><em>{{item.unit}}</em></div></template>
  37. </div>
  38. </li>
  39. <li class="wushuju" v-show="wushuju1">
  40. <img src="./../../static/images/wushuju.svg" alt="" />
  41. <div class="noDataFont">暂无数据</div>
  42. </li>
  43. </ul>
  44. <ul class="foods-wrapper" :style="{paddingTop:wushuju?'2.4rem':'0'}">
  45. <li
  46. v-for="data in items"
  47. class="food-item border-1px"
  48. :key="data.id"
  49. >
  50. <div class="food-content">
  51. <div class="title">
  52. <div>
  53. <i class="iconfont icon-changjianwenti1"></i>
  54. </div>
  55. <div class="title_t">
  56. <span>{{ data.dept }}</span>
  57. <span v-if="data.phone"
  58. ><a :href="'tel:' + data.phone"
  59. ><i class="iconfont icon-shouji"></i
  60. >{{ data.phone }}</a
  61. ></span
  62. >
  63. </div>
  64. </div>
  65. <div class="content">
  66. <span>单位名称:{{data.unit.unit}}</span>
  67. </div>
  68. <div class="content">
  69. <span>办公地址:{{data.address}}</span>
  70. <span></span>
  71. </div>
  72. </div>
  73. </li>
  74. <li class="wushuju" v-show="wushuju">
  75. <img src="./../../static/images/wushuju.svg" alt="" />
  76. <div class="noDataFont">暂无数据</div>
  77. </li>
  78. </ul>
  79. <template v-if="customPullDown" slot="pulldown" slot-scope="props">
  80. <div
  81. v-if="props.pullDownRefresh"
  82. class="cube-pulldown-wrapper"
  83. :style="props.pullDownStyle"
  84. >
  85. <div
  86. v-show="props.beforePullDown"
  87. class="before-trigger"
  88. :style="{ paddingTop: props.bubbleY + 'px' }"
  89. >
  90. <span
  91. :class="{
  92. rotate: props.bubbleY > pullDownRefreshThreshold - 40
  93. }"
  94. >↓</span
  95. >
  96. </div>
  97. <div class="after-trigger" v-show="!props.beforePullDown">
  98. <div v-show="props.isPullingDown" class="loading">
  99. <cube-loading></cube-loading>
  100. </div>
  101. <div v-show="!props.isPullingDown" class="text">
  102. <span class="refresh-text">更新成功</span>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. </cube-scroll>
  108. </div>
  109. </div>
  110. </div>
  111. <load-ing v-show="loadShow"></load-ing>
  112. </div>
  113. </template>
  114. <script>
  115. import Vue from "vue";
  116. import debounce from "lodash/debounce";
  117. import CubePage from "../components/cube-page.vue";
  118. import SwitchOption from "../components/switch-option";
  119. import InputOption from "../components/input-option";
  120. import SelectOption from "../components/select-option";
  121. import LoadIng from "./../views/loading.vue";
  122. export default {
  123. data() {
  124. return {
  125. items: [],
  126. pullDownRefresh: true,
  127. pullDownRefreshThreshold: 60,
  128. pullDownRefreshStop: 40,
  129. pullDownRefreshTxt: "Refresh success",
  130. pullUpLoad: true,
  131. pullUpLoadThreshold: 0,
  132. pullUpLoadMoreTxt: "Load more",
  133. pullUpLoadNoMoreTxt: "没有更多数据",
  134. wushuju: true,
  135. wushuju1: true,
  136. customPullDown: true,
  137. search: "",
  138. sum: 10,
  139. idx: 0,
  140. loadShow: false,
  141. lastSearchKey: "",
  142. searchFnDebounce: null,
  143. isShow:false,//是否显示下拉框
  144. searchList:[],//下拉框内容
  145. };
  146. },
  147. components: {
  148. CubePage,
  149. SwitchOption,
  150. InputOption,
  151. SelectOption,
  152. LoadIng
  153. },
  154. computed: {
  155. options() {
  156. return {
  157. // pullDownRefresh: this.pullDownRefreshObj,
  158. // pullUpLoad: this.pullUpLoadObj,
  159. // scrollbar: true
  160. };
  161. },
  162. pullDownRefreshObj: function() {
  163. return this.pullDownRefresh
  164. ? {
  165. threshold: parseInt(this.pullDownRefreshThreshold),
  166. txt: this.pullDownRefreshTxt
  167. }
  168. : false;
  169. },
  170. pullUpLoadObj: function() {
  171. return this.pullUpLoad
  172. ? {
  173. threshold: parseInt(this.pullUpLoadThreshold),
  174. txt: {
  175. more: this.pullUpLoadMoreTxt,
  176. noMore: this.pullUpLoadNoMoreTxt
  177. }
  178. }
  179. : false;
  180. }
  181. },
  182. methods: {
  183. // getParams() {
  184. // if (this.$route.params.keword) {
  185. // this.search = this.$route.params.keword;
  186. // }
  187. // },
  188. clickSearch(){
  189. this.isShow = true;
  190. this.items = [];
  191. },
  192. //点击搜索出来的项
  193. clickSearchItem(item){
  194. this.isShow = false;
  195. this.wushuju = false;
  196. this.items = [];
  197. if(item.unit.id){
  198. //部门
  199. this.items = [item];
  200. }else{
  201. //单位
  202. this.loadShow = true;
  203. this.$http
  204. .post("service/user/queryPhone", {unitId:item.id})
  205. .then((res) => {
  206. this.items = res.data.data;
  207. this.loadShow = false;
  208. });
  209. }
  210. },
  211. // 取消
  212. cancel(){
  213. this.isShow = false;
  214. this.search = '';
  215. this.searchList = [];
  216. },
  217. searchFn() {
  218. var that = this;
  219. this.isShow = true;
  220. that.loadShow = true;
  221. this.idx = 0;
  222. this.lastSearchKey = that.search;
  223. let postData = {};
  224. if(that.search){
  225. postData.keyword = that.search;
  226. }
  227. this.$http
  228. .post("service/user/queryPhone", postData)
  229. .then(function(res) {
  230. if (that.lastSearchKey == that.search) {
  231. if (res.data.data.length > 0) {
  232. that.searchList = res.data.data;
  233. that.wushuju1 = false;
  234. } else {
  235. that.wushuju1 = true;
  236. that.searchList = [];
  237. }
  238. that.loadShow = false;
  239. }
  240. });
  241. },
  242. toKnowDetails(data) {
  243. this.$router.push({
  244. name: "KnowDetails",
  245. params: {
  246. data: JSON.stringify(data)
  247. }
  248. });
  249. },
  250. // onPullingDown() {
  251. // // 模拟更新数据
  252. // this.idx = 0;
  253. // setTimeout(() => {
  254. // var that = this;
  255. // this.$http
  256. // .post("service/user/data/fetchDataList/phoneDirectory", {
  257. // idx: 0,
  258. // sum: 10,
  259. // phoneDirectory: {
  260. // keyword: that.search
  261. // }
  262. // })
  263. // .then(function(res) {
  264. // if (res.data.list.length > 0) {
  265. // that.items = res.data.list;
  266. // that.wushuju = false;
  267. // } else {
  268. // that.$refs.scroll.forceUpdate();
  269. // that.wushuju = true;
  270. // }
  271. // });
  272. // }, 1000);
  273. // },
  274. // getData(idx, sum) {
  275. // var that = this;
  276. // this.$http
  277. // .post("service/user/data/fetchDataList/phoneDirectory", {
  278. // idx: idx,
  279. // sum: sum,
  280. // phoneDirectory: {
  281. // keyword: that.search
  282. // }
  283. // })
  284. // .then(function(res) {
  285. // if (res.data.list.length > 0) {
  286. // that.items = res.data.list;
  287. // that.wushuju = false;
  288. // } else {
  289. // that.wushuju = true;
  290. // }
  291. // that.loadShow = false;
  292. // });
  293. // },
  294. // onPullingUp() {
  295. // var that = this;
  296. // that.idx = that.idx + 1;
  297. // this.$http
  298. // .post("service/user/data/fetchDataList/phoneDirectory", {
  299. // idx: that.idx,
  300. // sum: that.sum,
  301. // phoneDirectory: {
  302. // keyword: that.search
  303. // }
  304. // })
  305. // .then(function(res) {
  306. // setTimeout(() => {
  307. // if (res.data.list.length > 0) {
  308. // that.items = that.items.concat(res.data.list);
  309. // } else {
  310. // that.$refs.scroll.forceUpdate();
  311. // }
  312. // }, 1000);
  313. // });
  314. // },
  315. updatePullDownRefresh(val) {
  316. this.pullDownRefresh = val;
  317. },
  318. updatePullDownRefreshThreshold(val) {
  319. this.pullDownRefreshThreshold = val;
  320. },
  321. updatePullDownRefreshTxt(val) {
  322. this.pullDownRefreshTxt = val;
  323. },
  324. updatePullUpLoad(val) {
  325. this.pullUpLoad = val;
  326. },
  327. updatePullUpLoadThreshold(val) {
  328. this.pullUpLoadThreshold = val;
  329. },
  330. updatePullUpLoadMoreTxt(val) {
  331. this.pullUpLoadMoreTxt = val;
  332. },
  333. updatePullUpLoadNoMoreTxt(val) {
  334. this.pullUpLoadNoMoreTxt = val;
  335. },
  336. updateCustomPullDown(val) {
  337. this.customPullDown = val;
  338. },
  339. rebuildScroll() {
  340. Vue.nextTick(() => {
  341. this.$refs.scroll.destroy();
  342. this.$refs.scroll.initScroll();
  343. });
  344. }
  345. },
  346. created() {
  347. this.searchFnDebounce = debounce(this.searchFn, 500);
  348. // this.getParams();
  349. // this.getData(this.idx, this.sum);
  350. },
  351. beforeDestroy() {
  352. this.searchFnDebounce.cancel();
  353. }
  354. };
  355. </script>
  356. <style lang="stylus" rel="stylesheet/stylus" scoped>
  357. .scroll-list-wrap
  358. /* height: 350px */
  359. height:100vh
  360. /* border: 1px solid rgba(0, 0, 0, 0.1) */
  361. border-radius: 5px
  362. transform: rotate(0deg) // fix 子元素超出边框圆角部分不隐藏的问题
  363. overflow: hidden
  364. .foods-wrapper
  365. .food-item
  366. display: flex
  367. /* min-width: 0 */
  368. /* padding: 18px
  369. border-bottom: 1px solid rgba(7, 17, 27, 0.1) */
  370. &:last-child
  371. border-none()
  372. margin-bottom: 0
  373. .food-content
  374. flex: 1
  375. min-width: 0;
  376. .cartcontrol-wrapper
  377. position: absolute
  378. right: 0
  379. bottom: 12px
  380. .scroll-wrapper{
  381. .cube-pulldown-wrapper{
  382. .before-trigger{
  383. font-size: 30px;
  384. line-height: 30px;
  385. align-self: flex-end;
  386. span{
  387. display: inline-block;
  388. transition: all 0.3s;
  389. color: #666;
  390. &.rotate{
  391. transform: rotate(180deg)
  392. }
  393. }
  394. }
  395. .after-trigger{
  396. .refresh-text{
  397. color: grey
  398. }
  399. }
  400. }
  401. }
  402. </style>
  403. <style scoped>
  404. .bgColor {
  405. background-color: white;
  406. }
  407. .search {
  408. padding: 0.16rem 0.24rem;
  409. height: 0.6rem;
  410. background-color: #eeeeee;
  411. border-bottom: 0.01rem #999999 solid;
  412. display: flex;
  413. }
  414. .search input {
  415. flex: 1;
  416. height: 0.56rem;
  417. border-radius: 4px;
  418. text-align: center;
  419. font-size: 0.28rem;
  420. }
  421. .search .cancel{
  422. line-height: 0.56rem;
  423. text-align: center;
  424. margin-left: 0.1rem;
  425. }
  426. .search:focus {
  427. outline: none;
  428. }
  429. .food-item {
  430. border-top: 0.16rem rgb(238, 238, 238) solid;
  431. }
  432. .food-content {
  433. border-top: 0.01rem rgb(223, 222, 222) solid;
  434. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  435. }
  436. .title {
  437. display: flex;
  438. min-width: 0;
  439. padding: 0.2rem 0.24rem;
  440. line-height: 0.45rem;
  441. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  442. }
  443. .title .title_t {
  444. display: flex;
  445. justify-content: space-between;
  446. }
  447. .title div:nth-child(1) {
  448. width: 6%;
  449. }
  450. .title div:nth-child(1) i {
  451. font-size: 0.32rem;
  452. color: #005395;
  453. line-height: 0.49rem;
  454. }
  455. .title div:nth-child(2) {
  456. width: 94%;
  457. font-size: 0.32rem;
  458. overflow: hidden;
  459. /* white-space: nowrap; */
  460. /* text-overflow: ellipsis; */
  461. }
  462. .content {
  463. font-size: 0.28rem;
  464. /* margin-top: .3rem; */
  465. line-height: 0.39rem;
  466. overflow: hidden;
  467. display: -webkit-box;
  468. -webkit-line-clamp: 2;
  469. -webkit-box-orient: vertical;
  470. word-break: break-all;
  471. padding: 0 0.64rem;
  472. margin: 0.24rem 0;
  473. max-height: 0.78rem;
  474. }
  475. .timeBox {
  476. display: flex;
  477. justify-content: space-between;
  478. /* margin-top: .3rem; */
  479. border-top: 0.01rem rgb(223, 222, 222) solid;
  480. padding: 0.2rem 0.64rem;
  481. }
  482. .timeBox .time {
  483. color: #999999;
  484. font-size: 0.24rem;
  485. }
  486. .timeBox .good i {
  487. font-size: 0.3rem;
  488. color: #a37200;
  489. }
  490. .timeBox .good span {
  491. color: #a37200;
  492. font-size: 0.24rem;
  493. }
  494. .wushuju {
  495. box-sizing: border-box;
  496. width: 100%;
  497. height: 100%;
  498. display: flex;
  499. flex-direction: column;
  500. justify-content: center;
  501. align-items: center;
  502. }
  503. .wushuju img {
  504. width: 5.12rem;
  505. height: 2.84rem;
  506. }
  507. .searchList{
  508. position: absolute;
  509. top: 0.92rem;
  510. width: 100%;
  511. height: calc(100vh - 0.92rem);
  512. font-size: 0.3rem;
  513. background-color: #eee;
  514. box-shadow: 0 0.05rem 0.05rem #ccc;
  515. overflow: hidden;
  516. }
  517. .searchList li {
  518. padding: 0.2rem;
  519. border-bottom: 0.02rem solid #fff;
  520. line-height: 1.5;
  521. display: flex;
  522. align-items: center;
  523. }
  524. .searchList li .s_c{
  525. flex: 1;
  526. }
  527. .searchList li .dash-fangdajing{
  528. margin-right: 0.2rem;
  529. }
  530. .searchList .searchListItem{
  531. display: flex;
  532. }
  533. .searchList .searchListItem em{
  534. flex: 1;
  535. font-style: normal;
  536. word-break: break-all;
  537. }
  538. </style>