index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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. <view class="search-keyword">
  19. <scroll-view class="keyword-list-box" v-show="isShowKeywordList" scroll-y>
  20. <view class="margin-lr-sm padding-bottom">
  21. <view class="flex justify-between margin-bottom padding-sm radius"
  22. v-for="(item, index) in keywordList" :key="index" @click="goOrder(item)">
  23. <!-- <image :src="item.headImg?item.headImg: '../../../static/logo.png'"
  24. style="width: 220rpx;height: 200rpx;border-radius: 10rpx;"></image> -->
  25. <view style="width: 300upx;height: 260upx;border-radius: 10rpx;">
  26. <image :src="item.headImg?item.headImg: '../../static/logo.png'"
  27. style="width: 300upx;height: 260upx;" mode="aspectFit"></image>
  28. </view>
  29. <view class=" margin-left-sm text-white flex flex-direction justify-between" style="width: 50%;">
  30. <view class="flex">
  31. <view v-if="item.authentication == 2">
  32. <image src="../../../static/images/qi.png" style="width: 35rpx;height: 35rpx;"></image>
  33. </view>
  34. <view class="" v-if="item.authentication == 1">
  35. <image src="../../../static/images/geren.png" style="width: 35rpx;height: 35rpx;"></image>
  36. </view>
  37. <view class="margin-right-xs text-df margin-left-xs"
  38. style="margin-top: -2px;display: inline-block;width: 320upx; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  39. {{item.myLevel}}
  40. </view>
  41. </view>
  42. <view style="color: #999999;" v-if="item.authentication == 1">
  43. <text v-if="item.sex == 1">女</text>
  44. <text v-if="item.sex == 0">男</text>
  45. /<text>{{age}}岁</text>
  46. /<text>{{item.orderLevel}}</text>
  47. /<text >{{item.region}}</text>
  48. </view>
  49. <view style="color: #999999;" v-if="item.authentication == 2">
  50. <text>{{item.name}}</text>
  51. </view>
  52. <view class="flex flex-wrap">
  53. <text class=" box" v-for="(item,index) in item.gameName"
  54. :key="index" style="margin-right: 5rpx;">{{item}}</text>
  55. </view>
  56. <!-- <view class="flex" style="align-items: center;font-size: 24rpx;" v-if="item.salesNum">
  57. <view style="color: #999999;background: #F2F2F2; padding: 5rpx 10rpx;">已售{{item.salesNum}}
  58. </view>
  59. </view> -->
  60. <view style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
  61. <view style="color:#FF1200;font-size: 31rpx;">
  62. ¥{{item.oldMoney}}/月
  63. </view>
  64. <!-- <view style="background: #005DFF;color: #ffffff;padding: 15rpx 25rpx;border-radius: 8rpx;">
  65. 预约服务
  66. </view> -->
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- <view v-if="keywordList.length == 0">
  72. 暂无数据
  73. </view> -->
  74. <empty v-if="keywordList.length == 0"></empty>
  75. </scroll-view>
  76. <scroll-view class="keyword-box" v-show="!isShowKeywordList" scroll-y>
  77. <view class="keyword-block">
  78. <view class="keyword-list-header">
  79. <view>热门搜索</view>
  80. <view>
  81. <image @tap="hotToggle" :src="'/static/images/index/attention'+forbid+'.png'"></image>
  82. </view>
  83. </view>
  84. <view class="keyword" v-if="forbid==''">
  85. <view v-for="(keyword,index) in hotKeywordList" @tap="doSearch(keyword)" :key="index">
  86. {{keyword}}
  87. </view>
  88. </view>
  89. <view class="hide-hot-tis" v-else>
  90. <view>当前搜热已隐藏</view>
  91. </view>
  92. </view>
  93. <view class="keyword-block" v-if="oldKeywordList.length>0">
  94. <view class="keyword-list-header">
  95. <view>历史记录</view>
  96. <view>
  97. <image @tap="oldDelete" src="/static/images/index/delete.png"></image>
  98. </view>
  99. </view>
  100. <view class="keyword">
  101. <view v-for="(keyword,index) in oldKeywordList" @tap="doSearch(keyword)" :key="index">
  102. {{keyword}}
  103. </view>
  104. </view>
  105. </view>
  106. </scroll-view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import empty from '@/components/empty.vue'
  112. export default {
  113. components: {
  114. empty
  115. },
  116. data() {
  117. return {
  118. defaultKeyword: "",
  119. keyword: "",
  120. oldKeywordList: [], //历史记录
  121. hotKeywordList: [], //热搜
  122. keywordList: [], //搜索列表
  123. forbid: '',
  124. isShowKeywordList: false,
  125. limit: 10,
  126. page: 1,
  127. userId: '',
  128. isVip: false,
  129. age: 0,
  130. birthDate: ''
  131. }
  132. },
  133. onLoad() {
  134. this.userId = uni.getStorageSync('userId')
  135. if (this.userId) {
  136. this.getSearchList()
  137. }
  138. this.isVip = uni.getStorageSync('isVIP')
  139. },
  140. methods: {
  141. //换算年龄
  142. getAge(e) {
  143. console.log('出生日期:' + e)
  144. this.birthDate = e
  145. //创建系统日期
  146. var today = new Date();
  147. //把出生日期转换成日期
  148. this.birthDate = new Date(this.birthDate);
  149. //分别获取到年份后相减
  150. this.age = today.getFullYear() - this.birthDate.getFullYear();
  151. // console.log(this.age+'当前年龄')
  152. },
  153. // 获取搜索历史
  154. getSearchList() {
  155. this.$Request.get("/app/Search/selectAppSearchNum").then(res => {
  156. console.log(res)
  157. if (res.code == 0) {
  158. this.oldKeywordList = res.data.userSearchName
  159. // for (let i = 0; i < this.oldKeywordList.length; i++) {
  160. // this.oldKeywordList[i].gameName = this.oldKeywordList[i].gameName.split(",");
  161. // }
  162. this.hotKeywordList = res.data.allSerchName
  163. }
  164. });
  165. },
  166. //清除历史搜索
  167. oldDelete() {
  168. uni.showModal({
  169. content: '确定清除历史搜索记录?',
  170. success: (res) => {
  171. if (res.confirm) {
  172. console.log('用户点击确定');
  173. this.$Request.get("/app/Search/deleteAppSearch").then(res => {
  174. if (res.code == 0) {
  175. this.getSearchList()
  176. }
  177. })
  178. } else if (res.cancel) {
  179. console.log('用户点击取消');
  180. }
  181. }
  182. });
  183. },
  184. //执行搜索
  185. doSearch(keyword) {
  186. this.keyword = keyword === false ? this.keyword : keyword;
  187. this.isShowKeywordList = true;
  188. if (!this.keyword) {
  189. uni.showToast({
  190. title: '请输入内容',
  191. icon: 'none',
  192. duration: 1000
  193. })
  194. return
  195. }
  196. let data = {
  197. like: this.keyword,
  198. limit: this.limit,
  199. page: this.page,
  200. }
  201. if (this.userId) {
  202. this.$Request.get("/app/orderTaking/queryTaking", data).then(res => {
  203. if (res.code == 0) {
  204. if (this.page == 1) this.keywordList = [];
  205. this.keywordList = [...this.keywordList, ...res.data.list]
  206. for (let i = 0; i < this.keywordList.length; i++) {
  207. this.keywordList[i].gameName = this.keywordList[i].gameName.split(",");
  208. this.getAge(this.keywordList[i].birthdate)
  209. // this.keywordList[i].region = this.keywordList[i].region.split(",");
  210. if(this.keywordList[i].region){
  211. let region=this.keywordList[i].region.split(",");
  212. this.keywordList[i].region = region[1]
  213. }else{
  214. this.keywordList[i].region='不限地区'
  215. }
  216. }
  217. }
  218. });
  219. } else {
  220. this.$Request.get("/app/orderTaking/queryTakings", data).then(res => {
  221. if (res.code == 0) {
  222. if (this.page == 1) this.keywordList = [];
  223. this.keywordList = [...this.keywordList, ...res.data.list]
  224. for (let i = 0; i < this.keywordList.length; i++) {
  225. this.keywordList[i].gameName = this.keywordList[i].gameName.split(",");
  226. this.getAge(this.keywordList[i].birthdate)
  227. // this.keywordList[i].region = this.keywordList[i].region.split(",");
  228. if(this.keywordList[i].region){
  229. let region=this.keywordList[i].region.split(",");
  230. this.keywordList[i].region = region[1]
  231. }else{
  232. this.keywordList[i].region='不限地区'
  233. }
  234. }
  235. }
  236. });
  237. }
  238. },
  239. // 点击取消返回首页
  240. goBack() {
  241. uni.navigateBack()
  242. },
  243. //热门搜索开关
  244. hotToggle() {
  245. this.forbid = this.forbid ? '' : '_forbid';
  246. },
  247. // 跳转订单
  248. goOrder(e) {
  249. if (this.userId) {
  250. uni.navigateTo({
  251. url: '/pages/index/game/order?id=' + e.id
  252. });
  253. } else {
  254. uni.navigateTo({
  255. url: '/pages/public/login'
  256. });
  257. }
  258. },
  259. },
  260. onReachBottom: function() {
  261. this.page = this.page + 1;
  262. this.doSearch(false);
  263. },
  264. onPullDownRefresh: function() {
  265. this.page = 1;
  266. this.doSearch(false);
  267. },
  268. }
  269. </script>
  270. <style>
  271. page {
  272. background-color: #F7F7F7;
  273. }
  274. .bg {
  275. background-color: #FFFFFF;
  276. }
  277. .search-box {
  278. width: 100%;
  279. /* background-color: rgb(242, 242, 242); */
  280. padding: 15upx 2.5%;
  281. display: flex;
  282. justify-content: space-between;
  283. position: sticky;
  284. top: 0;
  285. background-color: #FFFFFF;
  286. }
  287. .search-box .mSearch-input-box {
  288. width: 100%;
  289. }
  290. .search-box .input-box {
  291. width: 85%;
  292. flex-shrink: 1;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. }
  297. .search-box .search-btn {
  298. width: 15%;
  299. margin: 0 0 0 2%;
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. flex-shrink: 0;
  304. font-size: 28upx;
  305. color: #fff;
  306. background: linear-gradient(to right, #ff9801, #ff570a);
  307. border-radius: 60upx;
  308. }
  309. .search-box .input-box>input {
  310. width: 100%;
  311. height: 60upx;
  312. font-size: 32upx;
  313. border: 0;
  314. border-radius: 60upx;
  315. -webkit-appearance: none;
  316. -moz-appearance: none;
  317. appearance: none;
  318. padding: 0 3%;
  319. margin: 0;
  320. background-color: #ffffff;
  321. }
  322. .placeholder-class {
  323. color: #9e9e9e;
  324. }
  325. .search-keyword {
  326. width: 100%;
  327. background-color: #FFFFFF;
  328. }
  329. .keyword-list-box {
  330. height: calc(100vh - 110upx);
  331. padding-top: 10upx;
  332. /* border-radius: 20upx 20upx 0 0; */
  333. /* background-color: #fff; */
  334. }
  335. .keyword-entry-tap {
  336. background-color: #eee;
  337. }
  338. .keyword-entry {
  339. width: 94%;
  340. height: 80upx;
  341. margin: 0 3%;
  342. font-size: 30upx;
  343. color: #333;
  344. display: flex;
  345. justify-content: space-between;
  346. align-items: center;
  347. border-bottom: solid 1upx #e7e7e7;
  348. }
  349. .keyword-entry image {
  350. width: 60upx;
  351. height: 60upx;
  352. }
  353. .keyword-entry .keyword-text,
  354. .keyword-entry .keyword-img {
  355. height: 80upx;
  356. display: flex;
  357. align-items: center;
  358. }
  359. .keyword-entry .keyword-text {
  360. width: 90%;
  361. }
  362. .keyword-entry .keyword-img {
  363. width: 10%;
  364. justify-content: center;
  365. }
  366. .keyword-box {
  367. height: calc(100vh - 110upx);
  368. /* border-radius: 20upx 20upx 0 0; */
  369. background-color: #F7F7F7;
  370. }
  371. .keyword-box .keyword-block {
  372. padding: 10upx 0;
  373. }
  374. .keyword-box .keyword-block .keyword-list-header {
  375. width: 94%;
  376. padding: 10upx 3%;
  377. font-size: 27upx;
  378. font-weight: 700;
  379. /* color: #FFFFFF; */
  380. display: flex;
  381. justify-content: space-between;
  382. }
  383. .keyword-box .keyword-block .keyword-list-header image {
  384. width: 40upx;
  385. height: 40upx;
  386. }
  387. .keyword-box .keyword-block .keyword {
  388. width: 94%;
  389. padding: 3px 3%;
  390. display: flex;
  391. flex-flow: wrap;
  392. justify-content: flex-start;
  393. }
  394. .keyword-box .keyword-block .hide-hot-tis {
  395. display: flex;
  396. justify-content: center;
  397. font-size: 28upx;
  398. color: #FFFFFF;
  399. }
  400. .keyword-box .keyword-block .keyword>view {
  401. display: flex;
  402. justify-content: center;
  403. align-items: center;
  404. border-radius: 10upx;
  405. padding: 0 20upx;
  406. margin: 10upx 20upx 10upx 0;
  407. height: 60upx;
  408. font-size: 28upx;
  409. background-color: #FFFFFF;
  410. color: #343546;
  411. }
  412. .box {
  413. border: 1rpx solid #005dff;
  414. color: #005DFF;
  415. padding: 5rpx 15rpx;
  416. font-size: 22rpx;
  417. letter-spacing: 2rpx;
  418. border-radius: 8rpx;
  419. margin-bottom: 2rpx;
  420. }
  421. </style>