share_team_goods.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view class="pageBg">
  3. <view class="top">
  4. <view class="head">
  5. <view class="search">
  6. <image class="search_icon" src="http://139.9.103.171:1888/img/image/search_icon.png"></image>
  7. <input class="search_input" :value="searchValue" @input="inputSearch" placeholder="商品名称" placeholder-style="color:#ccc;" @blur="searchBlur"/>
  8. <image v-if="searchValue" @tap="tapClearInput" class="search-close" src="http://139.9.103.171:1888/img/image/close2.png" mode="widthFix"></image>
  9. <view @tap="tapSearch('')" class="search_text">搜索</view>
  10. </view>
  11. </view>
  12. <view class="condition" v-if="!showHistory">
  13. <view class="item" :class="{'active':curActive==0}" @tap="tapActive(0)">
  14. <view>默认</view>
  15. </view>
  16. <view class="item" :class="{'active':curActive==1}" @tap="tapActive(1)">
  17. <view>销量</view>
  18. <image v-if="curActive!=1" src="http://139.9.103.171:1888/img/image/sort_arrow_icon.png"></image>
  19. <block v-else>
  20. <image v-if="typeList[curActive].v==1" src="http://139.9.103.171:1888/img/image/sort_down_arrow.png"></image>
  21. <image v-else src="http://139.9.103.171:1888/img/image/sort_up_arrow.png"></image>
  22. </block>
  23. </view>
  24. <view class="item" :class="{'active':curActive==2}" @tap="tapActive(2)">
  25. <view>价格</view>
  26. <image v-if="curActive!=2" src="http://139.9.103.171:1888/img/image/sort_arrow_icon.png"></image>
  27. <block v-else>
  28. <image v-if="typeList[curActive].v==1" src="http://139.9.103.171:1888/img/image/sort_down_arrow.png"></image>
  29. <image v-else src="http://139.9.103.171:1888/img/image/sort_up_arrow.png"></image>
  30. </block>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="pre_tip_keyword" v-if="showHistory && history.length>0">
  35. <view class="top_height"></view>
  36. <view class="item_wrap">
  37. <view class="item_type">历史搜索</view>
  38. <view class="item_value_box">
  39. <view v-for="(item,idx) in history" :key="idx"
  40. class="item_value"
  41. @tap="tapSearch(item)">{{item.keyword}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="search_results" v-if="!showHistory">
  46. <view class="top_height"></view>
  47. <view v-if="emptyType==0" class="goods_list_result">
  48. <DtGoodsListH :dataList="dataList" :share="true"/>
  49. </view>
  50. <DtNoMore v-if="isNoMore" />
  51. <DtEmpty :type="emptyType" />
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import DtGoodsListH from '../comps/dt_goods_list_h.vue'
  57. import DtEmpty from '../comps/dt_empty.vue'
  58. import DtNoMore from '../comps/dt_no_more.vue'
  59. export default {
  60. components: {
  61. DtGoodsListH,
  62. DtEmpty,
  63. DtNoMore
  64. },
  65. data() {
  66. return {
  67. hisItem:{},
  68. searchValue: '',
  69. showHistory:true,
  70. memberId:'',
  71. dataList:[],
  72. history:[],
  73. hots:[], // 热门暂时没有接口
  74. curActive:0,
  75. typeList:{
  76. 0:null,
  77. 1:{
  78. k:'sales',
  79. t:3,
  80. v:1
  81. },
  82. 2:{
  83. k:'price',
  84. t:3,
  85. v:1
  86. }
  87. }, // 当 curActive->curType ===> 0->0 1,2->3
  88. }
  89. },
  90. methods: {
  91. tapActive(idx){
  92. this.curActive = idx
  93. if(idx==1 || idx==2){
  94. let typeList = this.typeList
  95. if(typeList[idx].v == 1){
  96. typeList[idx].v = -1
  97. }else{
  98. typeList[idx].v = 1
  99. }
  100. this.typeList = typeList
  101. }
  102. this.pageIndex = 0
  103. this.dataList.length = 0
  104. this.queryDataList()
  105. },
  106. tapClearInput(){
  107. this.searchValue = ''
  108. this.showHistory = true
  109. },
  110. inputSearch(e) {
  111. this.searchValue = e.detail.value;
  112. if(!this.searchValue){
  113. this.showHistory = true
  114. }
  115. },
  116. searchBlur(){
  117. console.log("aaaaaaa");
  118. },
  119. tapSearch(item){
  120. console.log(129,item)
  121. if(item && item.keyword){
  122. this.hisItem = item
  123. this.searchValue = item.keyword
  124. }else{
  125. this.hisItem = {}
  126. }
  127. // if(!this.searchValue || !this.searchValue.trim()){
  128. // this.$dialog.toast('请输入搜索关键字!')
  129. // return
  130. // }
  131. this.showHistory = false
  132. this.isNoMore = false
  133. this.pageIndex = 0
  134. this.dataList.length = 0
  135. this.queryDataList()
  136. },
  137. getParams(){
  138. let history = this.history.slice(0)
  139. let value = this.searchValue.trim()
  140. let baseParam = null
  141. if(value){
  142. let productCategoryId = ''
  143. let isInclude = -1
  144. let hisIdInclude = false
  145. for(let i=0,his;his = history[i]; i++){
  146. if(his.keyword.indexOf(value)!=-1 || value.indexOf(his.keyword)!=-1){
  147. isInclude = i
  148. if(his.id){
  149. productCategoryId = his.id || ''
  150. }else if(this.loadOptions.productCategoryId){
  151. productCategoryId = this.loadOptions.productCategoryId || ''
  152. his.id = this.loadOptions.productCategoryId
  153. }
  154. break;
  155. }else{
  156. if(this.loadOptions.productCategoryId == his.id){
  157. hisIdInclude = true
  158. }
  159. }
  160. }
  161. if(isInclude==-1){
  162. if(hisIdInclude){
  163. productCategoryId = ''
  164. }else{
  165. productCategoryId = this.loadOptions.productCategoryId
  166. }
  167. history.unshift({
  168. id: productCategoryId,
  169. keyword: value
  170. })
  171. if(history.length>10){
  172. history.splice(10,history.length-10)
  173. }
  174. }else{
  175. let aim = history.splice(isInclude,1)
  176. history.unshift(...aim)
  177. }
  178. if(productCategoryId){
  179. console.log(productCategoryId);
  180. baseParam = {
  181. k:'productCategory.id',
  182. t:1,
  183. v:parseInt(productCategoryId)
  184. }
  185. }else{
  186. baseParam = {
  187. k:'name',
  188. t:0,
  189. v:value
  190. }
  191. }
  192. this.history = history
  193. this.$storage.history = history
  194. }
  195. let param = this.typeList[this.curActive]
  196. let resParams = []
  197. if(param){
  198. resParams.unshift(param)
  199. }
  200. if(baseParam){
  201. resParams.unshift(baseParam)
  202. }
  203. return resParams
  204. },
  205. // 搜索
  206. async queryDataList(){
  207. let params = this.getParams()
  208. let resp = await this.$api.searchProduct({
  209. _isShowLoading:true,
  210. pageNo: this.pageIndex,
  211. pageSize: this.pageSize,
  212. memberId: this.memberId,
  213. params: params
  214. })
  215. let list = this.getDataList(resp)
  216. this.dataList = this.dataList.concat(list)
  217. },
  218. onLoadPage(options){
  219. wx.hideShareMenu();
  220. if(this.isLoad){
  221. this.memberId = this.$auth.getMemberId()
  222. this.history = this.$storage.history || []
  223. console.log(159,this.history)
  224. if(options.keyword){
  225. this.searchValue = options.keyword || ''
  226. this.showHistory = false
  227. this.queryDataList()
  228. }
  229. }
  230. if(this.isReach){
  231. this.queryDataList()
  232. }
  233. },
  234. },
  235. onReachBottom(){
  236. this.onReachBottomPage()
  237. },
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .top {
  242. position: fixed;
  243. top: 0;
  244. left: 0;
  245. width: 100%;
  246. z-index: 100;
  247. .head {
  248. padding: 20upx 30upx;
  249. border-bottom: 1upx solid rgb(238, 238, 238);
  250. background: #fff;
  251. .search {
  252. height: 65upx;
  253. border-radius: 6upx;
  254. display: flex;
  255. flex-direction: row;
  256. align-items: center;
  257. background: rgba(242, 242, 242, 1);
  258. font-size: 30upx;
  259. // border: 1upx solid #ccc;
  260. .search_icon {
  261. width: 26upx;
  262. height: 26upx;
  263. padding: 20upx;
  264. }
  265. .search_input {
  266. flex: 1;
  267. height: 65upx;
  268. padding-right: 20upx;
  269. font-size: 30upx;
  270. }
  271. .search-close{
  272. width:30upx;
  273. height:30upx;
  274. }
  275. .search_text {
  276. padding: 0 20upx;
  277. }
  278. }
  279. }
  280. .condition {
  281. display: flex;
  282. flex-direction: row;
  283. align-items: center;
  284. height: 60upx;
  285. justify-content: space-around;
  286. border-bottom: 1upx solid rgb(238, 238, 238);
  287. background: #fff;
  288. .item {
  289. font-size: 28upx;
  290. color: #333333;
  291. display: flex;
  292. flex-direction: row;
  293. align-items: center;
  294. flex: 1;
  295. justify-content: center;
  296. height: 100%;
  297. image {
  298. width: 11upx;
  299. height: 15upx;
  300. margin-left: 10upx;
  301. }
  302. }
  303. .active {
  304. color: $dt-color-primary;
  305. }
  306. }
  307. }
  308. .pre_tip_keyword {
  309. display: flex;
  310. flex-direction: column;
  311. padding: 30upx;
  312. background: #fff;
  313. .top_height {
  314. height: 105upx;
  315. }
  316. .item_wrap {
  317. display: flex;
  318. flex-direction: column;
  319. .item_type {
  320. font-size: 28upx;
  321. color: #333333;
  322. margin-bottom: 20upx;
  323. }
  324. .item_value_box {
  325. display: flex;
  326. flex-direction: row;
  327. flex-wrap: wrap;
  328. .item_value {
  329. margin-right: 20upx;
  330. margin-bottom: 20upx;
  331. padding: 8upx 30upx;
  332. font-size: 24upx;
  333. color: #333333;
  334. border: 1upx solid rgba(204, 204, 204, 1);
  335. border-radius: 6px;
  336. }
  337. }
  338. .item_category_box {
  339. display: flex;
  340. flex-direction: row;
  341. flex-wrap: wrap;
  342. align-items: center;
  343. padding-bottom: 30upx;
  344. .item_category {
  345. width: 25%;
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. padding-top: 30upx;
  350. image {
  351. width: 80upx;
  352. height: 80upx;
  353. border-radius: 50%;
  354. }
  355. .item_text {
  356. margin-top: 10upx;
  357. font-size: 22upx;
  358. color: #353535;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. .search_results {
  365. .top_height {
  366. height: 165upx;
  367. }
  368. .goods_list_result {
  369. background: #fff;
  370. }
  371. .no_data_wrap {
  372. height: 100vh;
  373. display: flex;
  374. align-items: center;
  375. justify-content: center;
  376. }
  377. }
  378. </style>