index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. uni.navigateTo({
  297. url: '/pages/public/login'
  298. });
  299. }
  300. },
  301. },
  302. onReachBottom: function() {
  303. this.page = this.page + 1;
  304. this.doSearch(false);
  305. },
  306. onPullDownRefresh: function() {
  307. this.page = 1;
  308. this.doSearch(false);
  309. },
  310. }
  311. </script>
  312. <style>
  313. page {
  314. background-color: #F7F7F7;
  315. }
  316. .bg {
  317. background-color: #FFFFFF;
  318. }
  319. .search-box {
  320. width: 100%;
  321. /* background-color: rgb(242, 242, 242); */
  322. padding: 15upx 2.5%;
  323. display: flex;
  324. justify-content: space-between;
  325. position: sticky;
  326. top: 0;
  327. background-color: #FFFFFF;
  328. position: fixed;
  329. top: 0;
  330. left: 0;
  331. right: 0;
  332. z-index: 9;
  333. /* #ifdef H5 */
  334. position: fixed;
  335. top: 45px;
  336. left: 0;
  337. right: 0;
  338. /* #endif */
  339. }
  340. .search-box .mSearch-input-box {
  341. width: 100%;
  342. }
  343. .search-box .input-box {
  344. width: 85%;
  345. flex-shrink: 1;
  346. display: flex;
  347. justify-content: center;
  348. align-items: center;
  349. }
  350. .search-box .search-btn {
  351. width: 15%;
  352. margin: 0 0 0 2%;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. flex-shrink: 0;
  357. font-size: 28upx;
  358. color: #fff;
  359. background: linear-gradient(to right, #ff9801, #ff570a);
  360. border-radius: 60upx;
  361. }
  362. .search-box .input-box>input {
  363. width: 100%;
  364. height: 60upx;
  365. font-size: 32upx;
  366. border: 0;
  367. border-radius: 60upx;
  368. -webkit-appearance: none;
  369. -moz-appearance: none;
  370. appearance: none;
  371. padding: 0 3%;
  372. margin: 0;
  373. background-color: #ffffff;
  374. }
  375. .placeholder-class {
  376. color: #9e9e9e;
  377. }
  378. .search-keyword {
  379. width: 100%;
  380. }
  381. .keyword-list-box {
  382. height: calc(100vh - 110upx);
  383. padding-top: 10upx;
  384. /* border-radius: 20upx 20upx 0 0; */
  385. /* background-color: #fff; */
  386. }
  387. .keyword-entry-tap {
  388. background-color: #eee;
  389. }
  390. .keyword-entry {
  391. width: 94%;
  392. height: 80upx;
  393. margin: 0 3%;
  394. font-size: 30upx;
  395. color: #333;
  396. display: flex;
  397. justify-content: space-between;
  398. align-items: center;
  399. border-bottom: solid 1upx #e7e7e7;
  400. }
  401. .keyword-entry image {
  402. width: 60upx;
  403. height: 60upx;
  404. }
  405. .keyword-entry .keyword-text,
  406. .keyword-entry .keyword-img {
  407. height: 80upx;
  408. display: flex;
  409. align-items: center;
  410. }
  411. .keyword-entry .keyword-text {
  412. width: 90%;
  413. }
  414. .keyword-entry .keyword-img {
  415. width: 10%;
  416. justify-content: center;
  417. }
  418. .keyword-box {
  419. height: calc(100vh - 110upx);
  420. /* border-radius: 20upx 20upx 0 0; */
  421. background-color: #F7F7F7;
  422. }
  423. .keyword-box .keyword-block {
  424. padding: 10upx 0;
  425. }
  426. .keyword-box .keyword-block .keyword-list-header {
  427. width: 94%;
  428. padding: 10upx 3%;
  429. font-size: 27upx;
  430. font-weight: 700;
  431. /* color: #FFFFFF; */
  432. display: flex;
  433. justify-content: space-between;
  434. }
  435. .keyword-box .keyword-block .keyword-list-header image {
  436. width: 40upx;
  437. height: 40upx;
  438. }
  439. .keyword-box .keyword-block .keyword {
  440. width: 94%;
  441. padding: 3px 3%;
  442. display: flex;
  443. flex-flow: wrap;
  444. justify-content: flex-start;
  445. }
  446. .keyword-box .keyword-block .hide-hot-tis {
  447. display: flex;
  448. justify-content: center;
  449. font-size: 28upx;
  450. color: #FFFFFF;
  451. }
  452. .keyword-box .keyword-block .keyword>view {
  453. display: flex;
  454. justify-content: center;
  455. align-items: center;
  456. border-radius: 10upx;
  457. padding: 0 20upx;
  458. margin: 10upx 20upx 10upx 0;
  459. height: 60upx;
  460. font-size: 28upx;
  461. background-color: #FFFFFF;
  462. color: #343546;
  463. }
  464. </style>