index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view class="content">
  3. <view class="search-box flex align-center">
  4. <!-- mSearch组件 如果使用原样式,删除组件元素-->
  5. <!-- <mSearch class="mSearch-input-box" :mode="2" button="inside" :placeholder="defaultKeyword"
  6. @search="doSearch(false)" @input="inputChange" @confirm="doSearch(false)" v-model="keyword"></mSearch> -->
  7. <!-- 原样式 如果使用原样式,恢复下方注销代码 -->
  8. <!-- <view class="input-box">
  9. <input type="text" :adjust-position="true" :placeholder="defaultKeyword" @input="inputChange" v-model="keyword" @confirm="doSearch(false)"
  10. placeholder-class="placeholder-class" confirm-type="search">
  11. </view>
  12. <view class="search-btn" @tap="doSearch(false)">搜索</view> -->
  13. <!-- <view style="width: 6%;" @click="goBack()">
  14. <u-icon name="arrow-left" color="#909399" size="28"></u-icon>
  15. </view> -->
  16. <u-search style="width: 100%;" placeholder="搜索需要的师傅" :focus="true" v-model="keyword" :show-action="true"
  17. :animation="true" shape="square" bg-color="#F7F7F7" color="#1A1A1A" action-text="取消" @custom="goBack()"
  18. @search="doSearch(false)"></u-search>
  19. <!-- 原样式 end -->
  20. </view>
  21. <view v-show="isShowKeywordList">
  22. <!-- <ren-dropdown-filter :filterData='filterData' :border="false" :defaultIndex='defaultIndex'
  23. @onSelected='change' class="u-skeleton-rect" v-if="type==1">
  24. </ren-dropdown-filter>
  25. <ren-dropdown-filter :filterData='filterDatas' :border="false" :defaultIndex='defaultIndexs'
  26. @onSelected='changes' class="u-skeleton-rect" v-if="type==2">
  27. </ren-dropdown-filter> -->
  28. <view class="bg flex align-center justify-between padding-lr padding-tb-sm">
  29. <view v-for="(item,index) in list" :key="index" @click="change(index)"
  30. :style="listIndex==index?'color:#20C675;font-size:30rpx;':''">
  31. {{item.name}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="search-keyword">
  36. <scroll-view class="keyword-list-box" v-show="isShowKeywordList" scroll-y>
  37. <view class="flex align-center bg padding-sm margin-lr-sm padding-bottom margin-top-sm" style="border-radius:24rpx;"
  38. v-for="(item,index) in keywordList" :key='index' @click="goOrderdetail(item)">
  39. <view style="width: 130upx;height: 130upx;">
  40. <image :src="item.artificerImg?item.artificerImg: '../../../static/logo.png'"
  41. style="width: 130upx;height: 130upx;border-radius: 50%;" mode="aspectFill"></image>
  42. </view>
  43. <view class="margin-left text-black flex flex-direction" style="width: 80%;">
  44. <view class="flex ">
  45. <image src="../../../static/images/geren.png" style="width: 35rpx;height: 35rpx;">
  46. </image>
  47. <view class="text-bold text-df margin-left-xs">{{item.artificerName}}</view>
  48. </view>
  49. <view class="flex justify-between margin-tb-sm">
  50. <view class="flex align-center">
  51. <view v-if="item.ordersScore" class="margin-right-sm">
  52. <image src="../../../static/images/start.png" style="width: 24upx;height: 22upx;">
  53. </image>
  54. <text class="margin-left-xs" style="color: #FF1200;">{{item.ordersScore}}</text>
  55. </view>
  56. <view style="color: #999999;">已服务:{{item.ordersCount}}单</view>
  57. </view>
  58. <view class="flex align-center">
  59. <image src="../../../static/images/address.png" style="width: 24rpx;height: 29rpx;">
  60. </image>
  61. <view style="color: #999999;margin-left: 8rpx;">{{item.distance}}</view>
  62. </view>
  63. </view>
  64. <view style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
  65. <view class="flex flex-wrap" style="margin-top: 10rpx;">
  66. <text class="margin-bottom-xs box">健康理疗师</text>
  67. </view>
  68. <view class="text-center text-sm"
  69. style="background: #2FB57A;color: #ffffff;width: 135upx;border-radius: 16upx;line-height: 50upx;"
  70. @click.stop="goOrderdetail(item)" v-if="XCXIsSelect !='否'">
  71. 立即预约
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <empty v-if="keywordList.length == 0"></empty>
  77. </scroll-view>
  78. <scroll-view class="keyword-box" v-show="!isShowKeywordList" scroll-y>
  79. <view class="keyword-block">
  80. <view class="keyword-list-header">
  81. <view>热门搜索</view>
  82. <!-- <view>
  83. <image @tap="hotToggle" :src="'/static/images/index/attention'+forbid+'.png'">
  84. </image>
  85. </view> -->
  86. </view>
  87. <view class="keyword" v-if="forbid==''">
  88. <view v-for="(keyword,index) in hotKeywordList" @tap="doSearch(keyword)" :key="index">
  89. {{keyword}}
  90. </view>
  91. </view>
  92. <view class="hide-hot-tis" v-else>
  93. <view>当前搜热已隐藏</view>
  94. </view>
  95. </view>
  96. <view class="keyword-block" v-if="oldKeywordList.length>0">
  97. <view class="keyword-list-header">
  98. <view>历史记录</view>
  99. <view>
  100. <image @tap="oldDelete" src="/static/images/index/delete.png"></image>
  101. </view>
  102. </view>
  103. <view class="keyword">
  104. <view v-for="(keyword,index) in oldKeywordList" @tap="doSearch(keyword)" :key="index">
  105. {{keyword}}
  106. </view>
  107. </view>
  108. </view>
  109. </scroll-view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import empty from '@/components/empty.vue'
  115. export default {
  116. components: {
  117. empty
  118. },
  119. data() {
  120. return {
  121. defaultKeyword: "",
  122. keyword: "",
  123. oldKeywordList: [], //历史记录
  124. hotKeywordList: [], //热搜
  125. keywordList: [], //搜索列表
  126. forbid: '',
  127. isShowKeywordList: false,
  128. limit: 10,
  129. page: 1,
  130. userId: '',
  131. isVip: false,
  132. defaultIndex: [0, 0, 0],
  133. filterData: [
  134. [{
  135. label: '智能优选',
  136. value: '',
  137. },
  138. {
  139. label: '距离优先',
  140. value: 3,
  141. },
  142. {
  143. label: '销量优先',
  144. value: 2,
  145. },
  146. ],
  147. [{
  148. label: '价格',
  149. value: '0',
  150. },
  151. {
  152. label: '从高到低',
  153. value: '1',
  154. },
  155. {
  156. label: '从低到高',
  157. value: '2',
  158. }
  159. ],
  160. [{
  161. label: '销量',
  162. value: '0',
  163. },
  164. {
  165. label: '从高到低',
  166. value: '1',
  167. },
  168. {
  169. label: '从低到高',
  170. value: '2',
  171. }
  172. ],
  173. ],
  174. defaultIndexs: [0, 0, 0],
  175. filterDatas: [
  176. [{
  177. label: '智能优选',
  178. value: '',
  179. },
  180. {
  181. label: '距离优先',
  182. value: 3,
  183. },
  184. {
  185. label: '人气优先',
  186. value: 2,
  187. },
  188. {
  189. label: '同城',
  190. value: 1,
  191. }
  192. ],
  193. [{
  194. label: '服务人数',
  195. value: '0',
  196. },
  197. {
  198. label: '从高到低',
  199. value: '1',
  200. },
  201. {
  202. label: '从低到高',
  203. value: '2',
  204. }
  205. ],
  206. [{
  207. label: '距离',
  208. value: '0',
  209. },
  210. {
  211. label: '从远到近',
  212. value: '1',
  213. },
  214. {
  215. label: '从近到远',
  216. value: '2',
  217. }
  218. ],
  219. ],
  220. value1: 0,
  221. value2: 0,
  222. value3: 0,
  223. city: '',
  224. type: '',
  225. longitude: '',
  226. latitude: '',
  227. list: [{
  228. name: '综合',
  229. id: 1
  230. }, {
  231. name: '距离',
  232. id: 2
  233. }, {
  234. name: '销量',
  235. id: 3
  236. }, {
  237. name: '好评',
  238. id: 4
  239. }],
  240. listIndex: 0,
  241. }
  242. },
  243. onLoad(option) {
  244. console.log(option)
  245. this.type = option.index
  246. this.userId = uni.getStorageSync('userId')
  247. this.city = uni.getStorageSync('city')
  248. if (this.userId) {
  249. this.getSearchList()
  250. }
  251. this.isVip = uni.getStorageSync('isVIP')
  252. let that = this
  253. uni.getLocation({
  254. type: 'gcj02',
  255. geocode: true, //设置该参数为true可直接获取经纬度及城市信息
  256. success: function(res) {
  257. console.log(res, '地理位置')
  258. that.latitude = res.latitude
  259. that.longitude = res.longitude
  260. },
  261. fail: function() {
  262. console.log('获取地址失败')
  263. }
  264. })
  265. },
  266. methods: {
  267. // 获取搜索历史
  268. getSearchList() {
  269. let data = {
  270. userId: this.userId
  271. }
  272. this.$Request.get("/app/Search/selectAppSearchNum", data).then(res => {
  273. console.log(res)
  274. if (res.code == 0) {
  275. this.oldKeywordList = res.data.userSearchName
  276. // for (let i = 0; i < this.oldKeywordList.length; i++) {
  277. // this.oldKeywordList[i].gameName = this.oldKeywordList[i].gameName.split(",");
  278. // }
  279. this.hotKeywordList = res.data.allSerchName
  280. }
  281. });
  282. },
  283. //清除历史搜索
  284. oldDelete() {
  285. uni.showModal({
  286. content: '确定清除历史搜索记录?',
  287. success: (res) => {
  288. if (res.confirm) {
  289. console.log('用户点击确定');
  290. this.$Request.get("/app/Search/deleteAppSearch").then(res => {
  291. if (res.code == 0) {
  292. this.getSearchList()
  293. }
  294. })
  295. } else if (res.cancel) {
  296. console.log('用户点击取消');
  297. }
  298. }
  299. });
  300. },
  301. // 筛选
  302. change(index) {
  303. this.listIndex = index
  304. // this.value1 = e[0][0].value
  305. // this.value3 = e[1][0].value
  306. // this.value2 = e[2][0].value
  307. this.page = 1
  308. this.doSearch(false)
  309. },
  310. // 筛选
  311. changes(e) {
  312. this.value1 = e[0][0].value
  313. this.value2 = e[1][0].value
  314. this.value3 = e[2][0].value
  315. this.mescroll.resetUpScroll()
  316. },
  317. //执行搜索
  318. doSearch(keyword) {
  319. this.keyword = keyword === false ? this.keyword : keyword;
  320. this.isShowKeywordList = true;
  321. if (!this.keyword) {
  322. uni.showToast({
  323. title: '请输入内容',
  324. icon: 'none',
  325. duration: 1000
  326. })
  327. return
  328. }
  329. console.log(this.type)
  330. if (this.type == 1) {
  331. let data = {
  332. title: this.keyword,
  333. limit: this.limit,
  334. page: this.page,
  335. userId: this.userId,
  336. condition: this.value1, //智能优选
  337. by: this.value2, //销量
  338. authentication: this.value3, //价格
  339. city: this.city,
  340. }
  341. this.$Request.get("/app/artificer/selectMassageTypePage", data).then(res => {
  342. if (res.code == 0) {
  343. if (this.page == 1) this.keywordList = [];
  344. this.keywordList = [...this.keywordList, ...res.data.list]
  345. for (let i = 0; i < this.keywordList.length; i++) {
  346. this.keywordList[i].labels = this.keywordList[i].labels.split(",");
  347. }
  348. }
  349. });
  350. } else if (this.type == 2) {
  351. let data = {
  352. // title: this.keyword,
  353. limit: this.limit,
  354. page: this.page,
  355. userId: this.userId,
  356. condition: this.value1, //智能优选
  357. by: this.value2, //销量
  358. authentication: this.value3, //价格
  359. latitude: this.latitude,
  360. longitude: this.longitude,
  361. city: this.city,
  362. artificerName: this.keyword,
  363. }
  364. this.$Request.get("/app/artificer/selectArtificerList", data).then(res => {
  365. if (res.code == 0) {
  366. for (var a = 0; a < res.data.list.length; a++) {
  367. if (res.data.list[a].distance > 1000) {
  368. res.data.list[a].distance = (res.data.list[a].distance / 1000).toFixed(1) +
  369. 'km'
  370. console.log(res.data.list[a].distance)
  371. } else {
  372. res.data.list[a].distance = (res.data.list[a].distance).toFixed(1) + 'm'
  373. }
  374. }
  375. if (this.page == 1) this.keywordList = [];
  376. this.keywordList = [...this.keywordList, ...res.data.list]
  377. // for (let i = 0; i < this.keywordList.length; i++) {
  378. // this.keywordList[i].labels = this.keywordList[i].labels.split(",");
  379. // }
  380. }
  381. });
  382. }
  383. },
  384. // 点击取消返回首页
  385. goBack() {
  386. uni.navigateBack()
  387. },
  388. //热门搜索开关
  389. hotToggle() {
  390. this.forbid = this.forbid ? '' : '_forbid';
  391. },
  392. // 跳转订单
  393. goOrder(e) {
  394. if (this.userId) {
  395. uni.navigateTo({
  396. url: '/pages/index/order/order?massageTypeId=' + e.massageTypeId
  397. });
  398. } else {
  399. uni.navigateTo({
  400. url: '/pages/public/login'
  401. });
  402. }
  403. },
  404. // 跳转订单
  405. goOrderdetail(e) {
  406. console.log(e)
  407. if (this.userId) {
  408. uni.navigateTo({
  409. url: '/pages/therapist/orderDetail?artificerId=' + e.artificerId
  410. });
  411. } else {
  412. uni.navigateTo({
  413. url: '/pages/public/login'
  414. });
  415. }
  416. },
  417. },
  418. onReachBottom: function() {
  419. this.page = this.page + 1;
  420. this.doSearch(false);
  421. },
  422. onPullDownRefresh: function() {
  423. this.page = 1;
  424. this.doSearch(false);
  425. },
  426. }
  427. </script>
  428. <style>
  429. page {
  430. background-color: #FFFFFF;
  431. }
  432. .bg {
  433. background-color: #FFFFFF;
  434. }
  435. .search-box {
  436. width: 100%;
  437. /* background-color: rgb(242, 242, 242); */
  438. padding: 15upx 2.5%;
  439. display: flex;
  440. justify-content: space-between;
  441. position: sticky;
  442. background-color: #FFFFFF;
  443. }
  444. .search-box .mSearch-input-box {
  445. width: 100%;
  446. }
  447. .search-box .input-box {
  448. width: 85%;
  449. flex-shrink: 1;
  450. display: flex;
  451. justify-content: center;
  452. align-items: center;
  453. }
  454. .search-box .search-btn {
  455. width: 15%;
  456. margin: 0 0 0 2%;
  457. display: flex;
  458. justify-content: center;
  459. align-items: center;
  460. flex-shrink: 0;
  461. font-size: 28upx;
  462. color: #fff;
  463. background: linear-gradient(to right, #ff9801, #ff570a);
  464. border-radius: 60upx;
  465. }
  466. .search-box .input-box>input {
  467. width: 100%;
  468. height: 60upx;
  469. font-size: 32upx;
  470. border: 0;
  471. border-radius: 60upx;
  472. -webkit-appearance: none;
  473. -moz-appearance: none;
  474. appearance: none;
  475. padding: 0 3%;
  476. margin: 0;
  477. background-color: #ffffff;
  478. }
  479. .placeholder-class {
  480. color: #9e9e9e;
  481. }
  482. .search-keyword {
  483. width: 100%;
  484. /* background-color: #FFFFFF; */
  485. }
  486. .keyword-list-box {
  487. height: calc(100vh - 110upx);
  488. /* padding-top: 10upx; */
  489. background-color: #F5F5F5;
  490. /* border-radius: 20upx 20upx 0 0; */
  491. /* background-color: #fff; */
  492. }
  493. .keyword-entry-tap {
  494. background-color: #eee;
  495. }
  496. .keyword-entry {
  497. width: 94%;
  498. height: 80upx;
  499. margin: 0 3%;
  500. font-size: 30upx;
  501. color: #333;
  502. display: flex;
  503. justify-content: space-between;
  504. align-items: center;
  505. border-bottom: solid 1upx #e7e7e7;
  506. }
  507. .keyword-entry image {
  508. width: 60upx;
  509. height: 60upx;
  510. }
  511. .keyword-entry .keyword-text,
  512. .keyword-entry .keyword-img {
  513. height: 80upx;
  514. display: flex;
  515. align-items: center;
  516. }
  517. .keyword-entry .keyword-text {
  518. width: 90%;
  519. }
  520. .keyword-entry .keyword-img {
  521. width: 10%;
  522. justify-content: center;
  523. }
  524. .keyword-box {
  525. /* height: calc(100vh - 110upx); */
  526. height: fit-content;
  527. /* border-radius: 20upx 20upx 0 0; */
  528. background-color: #FFFFFF;
  529. }
  530. .keyword-box .keyword-block {
  531. padding: 10upx 0;
  532. }
  533. .keyword-box .keyword-block .keyword-list-header {
  534. width: 94%;
  535. padding: 10upx 3%;
  536. font-size: 27upx;
  537. font-weight: 700;
  538. /* color: #FFFFFF; */
  539. display: flex;
  540. justify-content: space-between;
  541. }
  542. .keyword-box .keyword-block .keyword-list-header image {
  543. width: 40upx;
  544. height: 40upx;
  545. }
  546. .keyword-box .keyword-block .keyword {
  547. width: 94%;
  548. padding: 3px 3%;
  549. display: flex;
  550. flex-flow: wrap;
  551. justify-content: flex-start;
  552. }
  553. .keyword-box .keyword-block .hide-hot-tis {
  554. display: flex;
  555. justify-content: center;
  556. font-size: 28upx;
  557. color: #FFFFFF;
  558. }
  559. .keyword-box .keyword-block .keyword>view {
  560. display: flex;
  561. justify-content: center;
  562. align-items: center;
  563. border-radius: 10upx;
  564. padding: 0 20upx;
  565. margin: 10upx 20upx 10upx 0;
  566. height: 60upx;
  567. font-size: 28upx;
  568. background-color: #F7F7F7;
  569. color: #343546;
  570. /* box-shadow: 0 0 10rpx #CCCCCC; */
  571. }
  572. .box {
  573. background: #E8FAE1;
  574. color: #2FB57A;
  575. padding: 5rpx 15rpx;
  576. font-size: 26rpx;
  577. letter-spacing: 2rpx;
  578. border-radius: 8rpx;
  579. margin-right: 8upx;
  580. }
  581. </style>