海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
4.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <view class="head" v-if="tab_list.length">
  4. <u-tabs :list="tab_list" :is-scroll="false" :current="current" @change="tabChange"></u-tabs>
  5. </view>
  6. <view v-if="current != 2">
  7. <view class="lf-row-between lf-bg-white" style="align-items: center;">
  8. <view class="lf-p-t-30 lf-p-r-30 lf-flex lf-bg-white">
  9. <u-icon name="search" class="search-icon"></u-icon>
  10. <input class="rom-search" type="text" v-model="searchContent" @confirm="setSearch()" placeholder="请输入商品名称"/>
  11. </view>
  12. <view class="lf-bg-white lf-font-28 lf-color-222 lf-p-t-30 lf-p-r-30">取消</view>
  13. </view>
  14. <view class="history-card" v-if="historySearch != ''">
  15. <view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
  16. 历史搜索
  17. </view>
  18. <view class="lf-flex lf-flex-wrap lf-p-l-20 lf-p-r-20">
  19. <view class="search-tag" v-for="(i,index) of historySearch" :key="index" @click="gosearch(i)">{{i}}</view>
  20. </view>
  21. </view>
  22. <view class="history-card" v-else>
  23. <view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
  24. 历史搜索
  25. </view>
  26. <view class="lf-flex lf-flex-wrap lf-p-l-30 lf-p-r-20">
  27. 暂无历史搜索记录
  28. </view>
  29. </view>
  30. </view>
  31. <view class="lf-row-center" v-if="current == 2" >
  32. <view class="taget-form lf-m-t-40 lf-p-30">
  33. <view class="lf-flex-column">
  34. <view class="lf-color-gray lf-font-28 lf-m-b-34">出发地和目的地</view>
  35. <view class="lf-flex lf-m-b-40">
  36. <text style="color: #1998FE;" class="lf-font-22 lf-m-r-32"></text>
  37. <input v-model="start_place" type="text" class="lf-font-28 lf-color-222" placeholder="请输入出发地" />
  38. </view>
  39. <view class="lf-flex lf-m-b-40">
  40. <text style="color: #1998FE;" class="lf-font-22 lf-m-r-32"></text>
  41. <input v-model="target_place" type="text" class="lf-font-28 lf-color-222" placeholder="请输入目的地" />
  42. </view>
  43. <button class="choose_btn" @click="searchTarget()">立即购买</button>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. let list = []
  51. export default {
  52. data() {
  53. return {
  54. historySearch: [],
  55. searchContent: '',
  56. value1: 1,
  57. options1: [{
  58. label: '商品',
  59. value: 1,
  60. },
  61. {
  62. label: '地图',
  63. value: 2,
  64. },
  65. {
  66. label: '出发地和目的地',
  67. value: 3,
  68. }
  69. ],
  70. tab_list: [
  71. {id: 1,name: '商品'},
  72. {id: 2,name: '地图'},
  73. {id: 3,name: '地址'}
  74. ],
  75. current: 0,
  76. windowHeight: 0,
  77. start_place: '',
  78. target_place: ''
  79. }
  80. },
  81. onLoad() {
  82. this.windowHeight = getApp().globalData.windowHeight;
  83. },
  84. methods: {
  85. searchTarget() {
  86. if(!this.start_place) {
  87. this.$msg('请输入出发地!')
  88. return
  89. }
  90. if(!this.target_place) {
  91. this.$msg('请输入目的地!')
  92. return
  93. }
  94. uni.navigateTo({
  95. url: '/pages/search/searchList?start_place=' + this.start_place+'&target_place='+this.target_place
  96. })
  97. this.start_place = '';
  98. this.target_place = '';
  99. },
  100. tabChange(index){
  101. this.current = index;
  102. if(this.current == 1) {
  103. uni.navigateTo({
  104. url: '/pages/shopmap/index'
  105. })
  106. }
  107. },
  108. getCategory(e) {
  109. console.log(e)
  110. },
  111. gosearch(i) {
  112. uni.navigateTo({
  113. url: '/pages/search/searchList?serach_content=' + i
  114. })
  115. },
  116. setSearch() {
  117. list.push(this.searchContent);
  118. list = [...new Set(list)];
  119. uni.navigateTo({
  120. url: '/pages/search/searchList?serach_content=' + this.searchContent
  121. })
  122. setTimeout(() => {
  123. this.historySearch = list
  124. uni.setStorageSync('historySearch',this.historySearch)
  125. },1000)
  126. }
  127. },
  128. onShow() {
  129. this.historySearch = uni.getStorageSync('historySearch') || [];
  130. console.log('初始',this.historySearch)
  131. }
  132. }
  133. </script>
  134. <style>
  135. page {
  136. background-color: #F8F8F8;
  137. }
  138. </style>
  139. <style lang="scss" scoped>
  140. .choose_btn {
  141. width: 626rpx;
  142. height: 82rpx;
  143. background: #1998FE;
  144. border-radius: 10rpx;
  145. font-size: 32rpx;
  146. color: white;
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. }
  151. .taget-form {
  152. width: 686rpx;
  153. height: 410rpx;
  154. border-radius: 10rpx;
  155. border: 1rpx solid #D9D9D9;
  156. }
  157. .history-card {
  158. background-color: white;
  159. width: 100%;
  160. height: 100%;
  161. padding: 30rpx 0;
  162. }
  163. .search-tag {
  164. padding: 10rpx 20rpx;
  165. border-radius: 30rpx;
  166. background: #f5f5f5;
  167. color: #222;
  168. display: flex;
  169. align-items: center;
  170. text-align: center;
  171. width: max-content;
  172. height: max-content;
  173. font-size: 28rpx;
  174. margin-right: 20rpx;
  175. &:nth-child(5n) {
  176. margin-right: 0;
  177. }
  178. &:nth-child(n + 6) {
  179. margin-top: 20rpx;
  180. }
  181. }
  182. .search-icon {
  183. position: relative;
  184. bottom: 0;
  185. left: 54rpx;
  186. }
  187. /deep/.input-placeholder{
  188. color: #777;
  189. font-size: 28rpx;
  190. }
  191. .rom-search {
  192. width: 605rpx;
  193. height: 60rpx;
  194. background: #f5f5f5;
  195. border-radius: 30rpx;
  196. padding-left: 74rpx;
  197. font-size: 28rpx;
  198. }
  199. </style>