listModel.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-x="true" class="topSearch">
  4. <view class="itemBox flex">
  5. <view class="typeTtem flex" @click="changeType(item,ind)" :key='ind' v-for="(item,ind) in workTypeList" :class="{action:typeIndex==ind}">
  6. <text>
  7. {{item.title}}
  8. </text>
  9. </view>
  10. <view class="itemTip flex" @click="$refs.popup.open()">
  11. <uni-icons type="bars" size="40rpx"></uni-icons>
  12. </view>
  13. </view>
  14. </scroll-view>
  15. <scroll-view scroll-y="true" :style="{'height':height}" class="scroll-wrap" @scrolltolower="getKcList">
  16. <cmy-mys-list :list='navList[currentIndex].list'></cmy-mys-list>
  17. <uni-load-more :status="navList[currentIndex].loadingType"></uni-load-more>
  18. </scroll-view>
  19. <uni-popup ref="popup" type="bottom">
  20. <view class="alertBox">
  21. <view class="flex position-relative padding-c-20">
  22. <text class="alertTitle">全部筛选</text>
  23. <image @click="closeAlert" class="alertClose" src="/static/icon/goodsExit.png" mode="scaleToFill"></image>
  24. </view>
  25. <view class="padding-t-20">
  26. <view class="alertItemTitle">
  27. 职业类型
  28. </view>
  29. <view class="flex alertTypeBox" >
  30. <view class="alertTypeItem" @click="search.work_type_id=ltt.id" :key='inde' v-for="(ltt,inde) in workTypeList" :class="{action:search.work_type_id==ltt.id}">
  31. <text>
  32. {{ltt.title}}
  33. </text>
  34. </view>
  35. </view>
  36. <view class="alertItemTitle">
  37. 价格类型
  38. </view>
  39. <view class="flex alertTypeBox" >
  40. <view class="alertTypeItem" :class="{action:search.timetype===''}" @click="search.timetype=''">
  41. <text>
  42. </text>
  43. </view>
  44. <view class="alertTypeItem" :class="{action:search.timetype==='hour'}" @click="search.timetype='hour'">
  45. <text>
  46. 小时
  47. </text>
  48. </view>
  49. <view class="alertTypeItem" :class="{action:search.timetype==='day'}" @click="search.timetype='day'">
  50. <text>
  51. 每天
  52. </text>
  53. </view>
  54. <view class="alertTypeItem" :class="{action:search.timetype==='month'}" @click="search.timetype='month'">
  55. <text>
  56. 每月
  57. </text>
  58. </view>
  59. </view>
  60. <view class="alertItemTitle" v-if="search.timetype!==''">
  61. 最低价格
  62. </view>
  63. <input v-if="search.timetype!==''" v-model="search.servicePrice" class="minMoney" type="number" placeholder-class="placeholderText" placeholder="自定义最低价格">
  64. <view class="alertItemTitle">
  65. 服务区域
  66. </view>
  67. <view class="flex alertTypeBox" >
  68. <view class="alertTypeItem" :class="{action:search.is_china===''}" @click="search.is_china=''">
  69. <text>
  70. 全部
  71. </text>
  72. </view>
  73. <view class="alertTypeItem" :class="{action:search.is_china===1}" @click="search.is_china=1">
  74. <text>
  75. 国内
  76. </text>
  77. </view>
  78. <view class="alertTypeItem" :class="{action:search.is_china===0}" @click="search.is_china=0">
  79. <text>
  80. 国外
  81. </text>
  82. </view>
  83. </view>
  84. <view v-if="search.is_china===1" class="alertItemTitle">
  85. 区域选择
  86. </view>
  87. <view v-if="search.is_china===1" class="right">
  88. <view class="citylist">
  89. <view class="">
  90. <view class="flex margin-b-20" v-for="(item,ind) in search.service_area" :key="ind">
  91. <view>
  92. {{item.province+item.city+item.district}}
  93. <text class="margin-l-10 del" @click="search.service_area.splice(ind,1)">
  94. 删除
  95. </text>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="flex">
  100. <pickerAddress class="buttom" @change="onCityClick">选择地区</pickerAddress>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="flex alertButtomBox">
  106. <view class="cancel" @click="cancelSearch">
  107. 清空选择
  108. </view>
  109. <view class="confirm" @click="confirmSearch">
  110. 确定
  111. </view>
  112. </view>
  113. </view>
  114. </uni-popup>
  115. </view>
  116. </template>
  117. <script>
  118. import {
  119. getWorkerList,
  120. } from '@/api/index.js'
  121. import {
  122. getUserWorkTypeList
  123. } from '@/api/model.js';
  124. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  125. import{mapState} from "vuex"
  126. export default {
  127. components: {
  128. pickerAddress
  129. },
  130. data() {
  131. return {
  132. typeIndex: -1,
  133. workTypeList: [],
  134. height: '',
  135. currentIndex: 0,
  136. navList: [{
  137. page: 1,
  138. pageSize: 10,
  139. list: [],
  140. loadingType: 'morde',
  141. loaded: false
  142. }
  143. ],
  144. alertIndex:0,
  145. search:{
  146. timetype:'',//hour,month,day
  147. servicePrice:'',
  148. work_type_id:'',
  149. service_area:[],
  150. is_china:'',
  151. },
  152. };
  153. },
  154. onLoad(opt) {
  155. if(opt.timetype!==''){
  156. this.search.timetype=opt.timetype
  157. }
  158. if(opt.servicePrice!==''){
  159. this.search.servicePrice=opt.servicePrice
  160. }
  161. if(opt.work_type_id!==''){
  162. this.search.work_type_id=opt.work_type_id
  163. }
  164. if(opt.is_china!==''){
  165. this.search.is_china=opt.is_china
  166. }
  167. if(opt.service_area!==''){
  168. this.search.service_area=opt.service_area.split('-').map((re)=>{
  169. const ar = re.split(',')
  170. return {
  171. province:ar[0],
  172. city:ar[1],
  173. district:ar[2],
  174. }
  175. })
  176. }
  177. this.init();
  178. },
  179. onShow() {
  180. this.getKcList()
  181. },
  182. onReady(res) {
  183. var that = this;
  184. uni.getSystemInfo({
  185. success: resu => {
  186. const query = uni.createSelectorQuery();
  187. query.select('.scroll-wrap').boundingClientRect();
  188. query.exec(function(res) {
  189. that.height = resu.windowHeight - res[0].top + 'px';
  190. });
  191. },
  192. fail: res => {}
  193. });
  194. },
  195. onReachBottom() {
  196. },
  197. methods: {
  198. onCityClick({
  199. data
  200. }) {
  201. let address = {};
  202. address.province = data[0];
  203. address.city = data[1];
  204. address.district = data[2];
  205. this.search.service_area.push(address)
  206. },
  207. cancelSearch(){
  208. this.search = {
  209. servicePrice:'',
  210. work_type_id:'',
  211. timetype:'',
  212. service_area:[],
  213. is_china:'',
  214. }
  215. },
  216. closeAlert(){
  217. this.$refs.popup.close();
  218. },
  219. confirmSearch(){
  220. this.initData()
  221. this.closeAlert()
  222. this.getKcList()
  223. },
  224. //初始化查询数据
  225. initData(){
  226. const data = this.navList[this.currentIndex]
  227. data.page=1;
  228. data.list =[];
  229. data.loadingType='morde'
  230. },
  231. changeType(item,ind){
  232. if(ind==this.typeIndex){
  233. this.typeIndex=-1;
  234. this.search.work_type_id = '';
  235. }else{
  236. this.typeIndex=ind;
  237. this.cancelSearch();
  238. this.search.work_type_id = item.id;
  239. }
  240. this.initData()
  241. this.getKcList()
  242. },
  243. init() {
  244. const that = this;
  245. getUserWorkTypeList().then(
  246. (res) => {
  247. that.workTypeList = res.data.list
  248. }
  249. ).catch(
  250. (res) => {
  251. console.log(res);
  252. }
  253. )
  254. },
  255. async getKcList() {
  256. let that = this;
  257. let item = that.navList[that.currentIndex]
  258. if (item.loadingType == 'noMore' || item.loadingType == 'loading') {
  259. return
  260. }
  261. item.loadingType = 'loading'
  262. let res = {}
  263. const search= {
  264. ...that.search
  265. }
  266. search.service_area = search.service_area.map(
  267. (item) => {
  268. return `${item.province},${item.city},${item.district}`
  269. }
  270. )
  271. res = await getWorkerList({
  272. ...search,
  273. page: item.page,
  274. pageSize: item.pageSize
  275. })
  276. item.list = item.list.concat(res.data.list)
  277. item.page++
  278. if (item.pageSize == res.data.list.length) {
  279. item.loadingType = 'more'
  280. } else {
  281. item.loadingType = 'noMore'
  282. }
  283. item.loaded = true
  284. }
  285. }
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. .alert{
  290. background-color: red;
  291. }
  292. .scroll-wrap{
  293. padding: 30rpx;
  294. }
  295. .alertBox{
  296. line-height: 1;
  297. background-color: #FFF;
  298. padding: 20rpx 0 30rpx;
  299. border-radius: 20rpx 20rpx 0 0;
  300. .right {
  301. color: $font-color-light;
  302. font-size: $font-base;
  303. flex-grow: 1;
  304. justify-content: flex-end;
  305. padding: 20rpx;
  306. .timetype {
  307. width: 100%;
  308. justify-content: flex-end;
  309. }
  310. .citylist {
  311. .del {
  312. font-size: $font-sm;
  313. border-radius: 10rpx;
  314. background-color: #eee;
  315. line-height: 1;
  316. padding: 5rpx 15rpx;
  317. }
  318. }
  319. .img {
  320. width: 26rpx;
  321. }
  322. .buttom {
  323. border-radius: 10rpx;
  324. line-height: 1;
  325. padding: 10rpx 20rpx;
  326. background-color: #eee;
  327. }
  328. }
  329. .alertTitle{
  330. font-weight: bold;
  331. font-size: 32rpx;
  332. flex-grow: 1;
  333. text-align: center;
  334. }
  335. .alertClose{
  336. width: 40rpx;
  337. height: 40rpx;
  338. }
  339. .alertItemTitle{
  340. font-size: 28rpx;
  341. padding-left: 20rpx;
  342. font-weight: bold;
  343. }
  344. .minMoney{
  345. margin: 20rpx;
  346. font-size: 24rpx;
  347. border-bottom: 1px solid #e9e9e9;
  348. }
  349. .placeholderText{
  350. font-size: 24rpx;
  351. }
  352. .alertTypeBox{
  353. flex-wrap: wrap;
  354. justify-content: flex-start;
  355. padding: 0 20rpx 10rpx;
  356. margin-top: 20rpx;
  357. .alertTypeItem{
  358. font-size: 24rpx;
  359. padding: 10rpx 20rpx;
  360. background-color: #eee;
  361. border-radius: 10rpx;
  362. margin-bottom: 14rpx;
  363. margin-right: 14rpx;
  364. &.action{
  365. background-color: #fee7e4;
  366. color: #F86859;
  367. }
  368. }
  369. }
  370. .moneyTitle{
  371. font-size: 28rpx;
  372. }
  373. .alertButtomBox{
  374. color: #FFF;
  375. padding: 20rpx;
  376. border-top: 1px solid #e3e3e3;
  377. .confirm{
  378. background-color: #F86859;
  379. }
  380. .cancel{
  381. background-color:orange;
  382. }
  383. .cancel,.confirm{
  384. padding: 10rpx;
  385. text-align: center;
  386. width: 350rpx;
  387. border-radius: 10rpx;
  388. font-size: 28rpx;
  389. }
  390. }
  391. }
  392. .topSearch{
  393. position: sticky;
  394. top: 0;
  395. background-color: #FFF;
  396. padding-right: 100rpx;
  397. height: 80rpx;
  398. .itemBox{
  399. padding-left: 30rpx;
  400. align-items: center;
  401. .itemTip{
  402. background-color: #FFF;
  403. position: fixed;
  404. right: 0;
  405. top: 0;
  406. align-items: center;
  407. height: 80rpx;
  408. padding: 0 30rpx;
  409. }
  410. .typeTtem {
  411. flex-shrink: 0;
  412. height: 80rpx;
  413. align-items: center;
  414. margin-right: 30rpx;
  415. &.action{
  416. color:#F86859;
  417. border-bottom: 1px solid #F86859;
  418. }
  419. }
  420. }
  421. }
  422. </style>