OrderSearch.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view class="div search-wrapper">
  3. <view class="common-header">
  4. <view class="div slot" >
  5. <view class="div" style="text-align: left"><text class="span iconfont" @click="goBack()">&#xe67f;</text></view>
  6. </view>
  7. <view class="common-search">
  8. <input type="text" v-model="orderkeyword" placeholder="请输入您要搜索的订单商品名称">
  9. </view>
  10. <view class="search_btn" @click="goOrderSearch(orderkeyword)">搜索</view>
  11. </view>
  12. <view class="div search-body">
  13. <view class="div list current-search" v-if='currenKeywords.length > 0'>
  14. <view class="div list-header">
  15. <text class="span">最近搜索</text>
  16. <image mode="aspectFit" class="img" src="../../../static/image/home/home-search-delete1.png" v-on:click='deleteCurrent()'>
  17. </view>
  18. <view class="ul">
  19. <view class="li item" v-for="(item, index) in currenKeywords" v-on:click='getKey(item)' :key="index">{{item}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view></member-base>
  24. </template>
  25. <script>
  26. import {getFontSize} from '@/util/common'
  27. import MemberBase from '../MemberBase'
  28. import { urlencode } from '@/util/common'
  29. import { mapState, mapMutations } from 'vuex'
  30. import { searchKeywordList } from '../../../api/homesearch'
  31. export default {
  32. data () {
  33. return {
  34. orderkeyword: ''
  35. }
  36. },
  37. components:{
  38. MemberBase
  39. },
  40. computed:{
  41. fontSize(){
  42. return getFontSize()
  43. },
  44. ...mapState({
  45. currenKeywords: state => state.homesearch.currenKeywords
  46. })
  47. },
  48. created () {
  49. },
  50. methods: {
  51. ...mapMutations({
  52. 'changeKey': 'changeKey',
  53. 'saveKeywords': 'saveKeywords'
  54. }),
  55. goBack(){
  56. uni.navigateBack({delta:1})
  57. },
  58. goOrderSearch (value) {
  59. if (value.replace(/\s+/g, '').length <= 0) {
  60. uni.showToast({icon:'none',title: '请输入您要搜索的关键字'})
  61. return false
  62. } else {
  63. this.orderkeyword = value
  64. }
  65. if (value) {
  66. let data = this.utils.arrayFilter(this.currenKeywords.concat(value))
  67. this.saveKeywords(data)
  68. }
  69. uni.navigateTo({url: '/pages/member/order/OrderList'+'?'+urlencode( { keyword: this.orderkeyword })})
  70. },
  71. getKey (item) {
  72. if (item.content) {
  73. this.orderkeyword = item.content
  74. } else {
  75. this.orderkeyword = item
  76. }
  77. this.changeKey(this.orderkeyword)
  78. this.goOrderSearch(this.orderkeyword)
  79. },
  80. deleteCurrent () {
  81. this.saveKeywords([])
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang='scss' scoped>
  87. .search-wrapper{
  88. height: auto;
  89. width: auto;
  90. background-color: #fff;
  91. .common-header{
  92. display: flex;
  93. height: 2rem;
  94. padding: 0.25rem .6rem;
  95. justify-content: space-between;
  96. align-items: center;
  97. box-shadow: 0px 4px 4px #f7f7f7;
  98. box-sizing: border-box;
  99. .slot{width:2.5rem;height: 1.6rem;text-align:center;line-height:1.6rem;font-size: .8rem;}
  100. .common-search{
  101. padding:0;
  102. padding-left: $pageSpace;
  103. padding-right: $pageSpace;
  104. flex:1;
  105. input {
  106. box-sizing: border-box;
  107. width: 100%;
  108. height: 1.6rem;
  109. border-radius: 1.6rem;
  110. background: #F4F4F4 url(../../../static/image/home/icon_search.png) no-repeat 0.6rem center;
  111. background-size:0.55rem;
  112. font-size:$fontSize;
  113. color: #999;
  114. padding-left:1.6rem;
  115. border: 0;
  116. }
  117. }
  118. .search_btn{background-color: $primaryColor;padding: .3rem .7rem;color:#fff;border-radius: 1.2rem;font-size: .7rem;margin-right: .6rem;}
  119. }
  120. .search-body {
  121. .div.list {
  122. padding-top: 0.75rem;
  123. padding-bottom: 0.75rem;
  124. padding-left: $pageSpace;
  125. padding-right: $pageSpace;
  126. background-color: #fff;
  127. .list-header {
  128. display: flex;
  129. justify-content: space-between;
  130. align-content: center;
  131. align-items: center;
  132. .span {
  133. color: #333;
  134. font-size: $h3;
  135. background: url('../../../static/image/home/home-search-history.png') no-repeat left center;
  136. background-size: 0.8rem;
  137. padding-left: 1.25rem;
  138. align-self: flex-end;
  139. }
  140. .img {
  141. width: 1rem;
  142. height:1rem;
  143. cursor: pointer;
  144. }
  145. }
  146. .ul {
  147. display: flex;
  148. padding-top: 0.65rem;
  149. flex-wrap: wrap;
  150. .li {
  151. padding: 0.4rem;
  152. background-color: #F4F4F4;
  153. color: $descTextColor;
  154. font-size: $fontSize;
  155. margin-right: 0.8rem;
  156. margin-bottom: 0.8rem;
  157. border-radius:.2rem;
  158. }
  159. }
  160. }
  161. .div.hot-wrapper {
  162. .list-header{
  163. .span{
  164. background: url('../../../static/image/home/home-search-hot.png') no-repeat left center;
  165. background-size: 0.8rem;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>