index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="content">
  3. <view class="search-box">
  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. <u-search style="width: 100%;" placeholder="输入搜索内容" :focus="true" v-model="keyword" :show-action="true"
  14. :animation="true" shape="square" bg-color="#F7F7F7" color="#1A1A1A" action-text="取消" @custom="goBack()"
  15. @search="doSearch(false)"></u-search>
  16. <!-- 原样式 end -->
  17. </view>
  18. <!-- #ifdef MP-WEIXIN -->
  19. <view style="position: relative;top: 90upx;left: 0;right: 0;z-index:1;">
  20. <!-- #endif -->
  21. <!-- #ifndef MP-WEIXIN -->
  22. <view style="position: relative;top: 46px;left: 0;right: 0;z-index:1;">
  23. <!-- #endif -->
  24. <view v-show="isShowKeywordList">
  25. <ren-dropdown-filter :filterData='filterData' :border="false" :defaultIndex='defaultIndex'
  26. @onSelected='change' class="u-skeleton-rect">
  27. </ren-dropdown-filter>
  28. </view>
  29. <view class="search-keyword">
  30. <scroll-view class="keyword-list-box" v-show="isShowKeywordList" scroll-y>
  31. <view class="margin-lr-sm padding-top-16 ">
  32. <view class="flex justify-between padding-sm radius margin-top-xs" v-for="(item, index) in keywordList"
  33. :key="index" @click="goOrder(item)" style="background-color: #FFFFFF;">
  34. <image :src="item.homepageImg?item.homepageImg: '../../../static/logo.png'"
  35. style="width: 200rpx;height: 200rpx;border-radius: 10rpx;"></image>
  36. <view class="flex-sub margin-left text-white flex flex-direction justify-between">
  37. <view class="flex justify-between align-center">
  38. <view class="flex ">
  39. <view v-if="item.authentication == 2||item.authentication == 3">
  40. <image src="../../../static/images/qi.png" style="width: 28rpx;height: 28rpx;">
  41. </image>
  42. </view>
  43. <view class="" v-if="item.authentication == 1||item.authentication == 3">
  44. <image src="../../../static/images/geren.png"
  45. style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"></image>
  46. </view>
  47. <view class="margin-right-xs u-line-1"
  48. style="margin-top: -2px;display: inline-block;margin-left: 10rpx;width: 260rpx;">
  49. {{item.myLevel}}
  50. </view>
  51. </view>
  52. <view>
  53. {{item.distance/1000}}km
  54. </view>
  55. </view>
  56. <view class="flex radius flex-wrap" style="line-height: 34upx;">
  57. <!-- <image :src="item.gameImg" style="width: 34rpx;height: 32rpx;" ></image> -->
  58. <text class="margin-right-xs margin-top-xs" v-for="(item,index) in item.gameName"
  59. :key="index">{{item}}</text>
  60. <!-- <text>{{item.myLevel}}</text> -->
  61. </view>
  62. <view class="flex" style="align-items: center;font-size: 24rpx;" v-if="item.count">
  63. <view style="color: #999999;background: #F2F2F2; padding: 5rpx 10rpx;">
  64. 已服务{{item.count}}人
  65. </view>
  66. </view>
  67. <view style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
  68. <view style="color:#FF1200;font-size: 31rpx;">
  69. ¥{{isVip? item.memberMoney :item.money}}/<text>{{item.unit}}</text>
  70. </view>
  71. <view
  72. style="background: #557EFD;color: #ffffff;padding: 15rpx 25rpx;border-radius: 45rpx;">
  73. 预约服务
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- <view v-if="keywordList.length == 0">
  80. 暂无数据
  81. </view> -->
  82. <empty v-if="keywordList.length == 0"></empty>
  83. </scroll-view>
  84. <scroll-view class="keyword-box" v-show="!isShowKeywordList" scroll-y>
  85. <view class="keyword-block">
  86. <view class="keyword-list-header">
  87. <view>热门搜索</view>
  88. <view>
  89. <image @tap="hotToggle" :src="'/static/images/index/attention'+forbid+'.png'"></image>
  90. </view>
  91. </view>
  92. <view class="keyword" v-if="forbid==''">
  93. <view v-for="(keyword,index) in hotKeywordList" @tap="doSearch(keyword)" :key="index">
  94. {{keyword}}
  95. </view>
  96. </view>
  97. <view class="hide-hot-tis" v-else>
  98. <view>当前搜热已隐藏</view>
  99. </view>
  100. </view>
  101. <view class="keyword-block" v-if="oldKeywordList.length>0">
  102. <view class="keyword-list-header">
  103. <view>历史记录</view>
  104. <view>
  105. <image @tap="oldDelete" src="/static/images/index/delete.png"></image>
  106. </view>
  107. </view>
  108. <view class="keyword">
  109. <view v-for="(keyword,index) in oldKeywordList" @tap="doSearch(keyword)" :key="index">
  110. {{keyword}}
  111. </view>
  112. </view>
  113. </view>
  114. </scroll-view>
  115. </view>
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. import empty from '@/components/empty.vue'
  121. export default {
  122. components: {
  123. empty
  124. },
  125. data() {
  126. return {
  127. defaultKeyword: "",
  128. keyword: "",
  129. oldKeywordList: [], //历史记录
  130. hotKeywordList: [], //热搜
  131. keywordList: [], //搜索列表
  132. forbid: '',
  133. isShowKeywordList: false,
  134. limit: 10,
  135. page: 1,
  136. userId: '',
  137. isVip: false,
  138. value1: '',
  139. value2: '',
  140. value3: '',
  141. defaultIndex: [0, 0, 0],
  142. filterData: [
  143. [{
  144. label: '智能优选',
  145. value: '',
  146. },
  147. {
  148. label: '距离优先',
  149. value: 3,
  150. },
  151. {
  152. label: '人气优先',
  153. value: 2,
  154. },
  155. {
  156. label: '同城',
  157. value: 1,
  158. }
  159. ],
  160. [{
  161. label: '销量',
  162. value: '',
  163. },
  164. {
  165. label: '从高到低',
  166. value: 'desc',
  167. },
  168. {
  169. label: '从低到高',
  170. value: 'asc',
  171. }
  172. ],
  173. [{
  174. label: '价格',
  175. value: '',
  176. },
  177. {
  178. label: '从高到低',
  179. value: 'desc',
  180. },
  181. {
  182. label: '从低到高',
  183. value: 'asc',
  184. }
  185. ],
  186. ],
  187. }
  188. },
  189. onLoad() {
  190. this.userId = uni.getStorageSync('userId')
  191. if (this.userId) {
  192. this.getSearchList()
  193. }
  194. this.isVip = uni.getStorageSync('isVIP')
  195. },
  196. methods: {
  197. // 筛选
  198. change(e) {
  199. this.value1 = e[0][0].value
  200. this.value2 = e[1][0].value
  201. this.value3 = e[2][0].value
  202. this.doSearch(this.keyword)
  203. // this.mescroll.resetUpScroll()
  204. },
  205. // 获取搜索历史
  206. getSearchList() {
  207. this.$Request.get("/app/Search/selectAppSearchNum").then(res => {
  208. console.log(res)
  209. if (res.code == 0) {
  210. this.oldKeywordList = res.data.userSearchName
  211. // for (let i = 0; i < this.oldKeywordList.length; i++) {
  212. // this.oldKeywordList[i].gameName = this.oldKeywordList[i].gameName.split(",");
  213. // }
  214. this.hotKeywordList = res.data.allSerchName
  215. }
  216. });
  217. },
  218. //清除历史搜索
  219. oldDelete() {
  220. uni.showModal({
  221. content: '确定清除历史搜索记录?',
  222. success: (res) => {
  223. if (res.confirm) {
  224. console.log('用户点击确定');
  225. this.$Request.get("/app/Search/deleteAppSearch").then(res => {
  226. if (res.code == 0) {
  227. this.getSearchList()
  228. }
  229. })
  230. } else if (res.cancel) {
  231. console.log('用户点击取消');
  232. }
  233. }
  234. });
  235. },
  236. //执行搜索
  237. doSearch(keyword) {
  238. this.keyword = keyword === false ? this.keyword : keyword;
  239. this.isShowKeywordList = true;
  240. if (!this.keyword) {
  241. uni.showToast({
  242. title: '请输入内容',
  243. icon: 'none',
  244. duration: 1000
  245. })
  246. return
  247. }
  248. let data = {
  249. like: this.keyword,
  250. limit: this.limit,
  251. page: this.page,
  252. condition: this.value1, //智能优选
  253. salesNum: this.value2, //不限男女
  254. by: this.value3, //价格
  255. city: uni.getStorageSync('city'),
  256. latitude: uni.getStorageSync('latitude'),
  257. longitude: uni.getStorageSync('longitude')
  258. }
  259. if (this.userId) {
  260. this.$Request.get("/app/orderTaking/queryTaking", data).then(res => {
  261. if (res.code == 0) {
  262. if (this.page == 1) this.keywordList = [];
  263. this.keywordList = [...this.keywordList, ...res.data.list]
  264. for (let i = 0; i < this.keywordList.length; i++) {
  265. this.keywordList[i].gameName = this.keywordList[i].gameName.split(",");
  266. }
  267. }
  268. });
  269. } else {
  270. this.$Request.get("/app/orderTaking/queryTakings", data).then(res => {
  271. if (res.code == 0) {
  272. if (this.page == 1) this.keywordList = [];
  273. this.keywordList = [...this.keywordList, ...res.data.list]
  274. for (let i = 0; i < this.keywordList.length; i++) {
  275. this.keywordList[i].gameName = this.keywordList[i].gameName.split(",");
  276. }
  277. }
  278. });
  279. }
  280. },
  281. // 点击取消返回首页
  282. goBack() {
  283. uni.navigateBack()
  284. },
  285. //热门搜索开关
  286. hotToggle() {
  287. this.forbid = this.forbid ? '' : '_forbid';
  288. },
  289. // 跳转订单
  290. goOrder(e) {
  291. if (this.userId) {
  292. uni.navigateTo({
  293. url: '/pages/index/game/order?id=' + e.id
  294. });
  295. } else {
  296. this.$queue.toLogin('navigateTo')
  297. }
  298. },
  299. },
  300. onReachBottom: function() {
  301. this.page = this.page + 1;
  302. this.doSearch(false);
  303. },
  304. onPullDownRefresh: function() {
  305. this.page = 1;
  306. this.doSearch(false);
  307. },
  308. }
  309. </script>
  310. <style>
  311. page {
  312. background-color: #F7F7F7;
  313. }
  314. .bg {
  315. background-color: #FFFFFF;
  316. }
  317. .search-box {
  318. width: 100%;
  319. /* background-color: rgb(242, 242, 242); */
  320. padding: 15upx 2.5%;
  321. display: flex;
  322. justify-content: space-between;
  323. position: sticky;
  324. top: 0;
  325. background-color: #FFFFFF;
  326. position: fixed;
  327. top: 0;
  328. left: 0;
  329. right: 0;
  330. z-index: 9;
  331. /* #ifdef H5 */
  332. position: fixed;
  333. top: 45px;
  334. left: 0;
  335. right: 0;
  336. /* #endif */
  337. }
  338. .search-box .mSearch-input-box {
  339. width: 100%;
  340. }
  341. .search-box .input-box {
  342. width: 85%;
  343. flex-shrink: 1;
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. }
  348. .search-box .search-btn {
  349. width: 15%;
  350. margin: 0 0 0 2%;
  351. display: flex;
  352. justify-content: center;
  353. align-items: center;
  354. flex-shrink: 0;
  355. font-size: 28upx;
  356. color: #fff;
  357. background: linear-gradient(to right, #ff9801, #ff570a);
  358. border-radius: 60upx;
  359. }
  360. .search-box .input-box>input {
  361. width: 100%;
  362. height: 60upx;
  363. font-size: 32upx;
  364. border: 0;
  365. border-radius: 60upx;
  366. -webkit-appearance: none;
  367. -moz-appearance: none;
  368. appearance: none;
  369. padding: 0 3%;
  370. margin: 0;
  371. background-color: #ffffff;
  372. }
  373. .placeholder-class {
  374. color: #9e9e9e;
  375. }
  376. .search-keyword {
  377. width: 100%;
  378. }
  379. .keyword-list-box {
  380. height: calc(100vh - 110upx);
  381. padding-top: 10upx;
  382. /* border-radius: 20upx 20upx 0 0; */
  383. /* background-color: #fff; */
  384. }
  385. .keyword-entry-tap {
  386. background-color: #eee;
  387. }
  388. .keyword-entry {
  389. width: 94%;
  390. height: 80upx;
  391. margin: 0 3%;
  392. font-size: 30upx;
  393. color: #333;
  394. display: flex;
  395. justify-content: space-between;
  396. align-items: center;
  397. border-bottom: solid 1upx #e7e7e7;
  398. }
  399. .keyword-entry image {
  400. width: 60upx;
  401. height: 60upx;
  402. }
  403. .keyword-entry .keyword-text,
  404. .keyword-entry .keyword-img {
  405. height: 80upx;
  406. display: flex;
  407. align-items: center;
  408. }
  409. .keyword-entry .keyword-text {
  410. width: 90%;
  411. }
  412. .keyword-entry .keyword-img {
  413. width: 10%;
  414. justify-content: center;
  415. }
  416. .keyword-box {
  417. height: calc(100vh - 110upx);
  418. /* border-radius: 20upx 20upx 0 0; */
  419. background-color: #F7F7F7;
  420. }
  421. .keyword-box .keyword-block {
  422. padding: 10upx 0;
  423. }
  424. .keyword-box .keyword-block .keyword-list-header {
  425. width: 94%;
  426. padding: 10upx 3%;
  427. font-size: 27upx;
  428. font-weight: 700;
  429. /* color: #FFFFFF; */
  430. display: flex;
  431. justify-content: space-between;
  432. }
  433. .keyword-box .keyword-block .keyword-list-header image {
  434. width: 40upx;
  435. height: 40upx;
  436. }
  437. .keyword-box .keyword-block .keyword {
  438. width: 94%;
  439. padding: 3px 3%;
  440. display: flex;
  441. flex-flow: wrap;
  442. justify-content: flex-start;
  443. }
  444. .keyword-box .keyword-block .hide-hot-tis {
  445. display: flex;
  446. justify-content: center;
  447. font-size: 28upx;
  448. color: #FFFFFF;
  449. }
  450. .keyword-box .keyword-block .keyword>view {
  451. display: flex;
  452. justify-content: center;
  453. align-items: center;
  454. border-radius: 10upx;
  455. padding: 0 20upx;
  456. margin: 10upx 20upx 10upx 0;
  457. height: 60upx;
  458. font-size: 28upx;
  459. background-color: #FFFFFF;
  460. color: #343546;
  461. }
  462. </style>