search.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view>
  3. <view class="search-pop">
  4. <view class="main-title" style="background: #05C25C;">
  5. <view class="search-tab">
  6. <view class="close-src" @tap="navigateBack"><text class="iconfont icon-zuojiantou"></text></view>
  7. <view class="search">
  8. <input type="text" :value="keywords" :placeholder="placeholder" class="search_area" @input="searchInput" @confirm="submitSearch" />
  9. <text v-if="keywords !== ''" class="cuIcon-close clear" @tap="clearInput"></text>
  10. <view class="search_submit" @tap="submitSearch">搜 索</view>
  11. </view>
  12. <image class="image-src" src="/static/image/icon_fenlei.png" style="width: 40upx;height: 40upx;margin-top: -50upx;"
  13. @tap='openPopus'></image>
  14. </view>
  15. </view>
  16. <view class="tui-tabs">
  17. <scroll-view id="tab-bar" scroll-with-animation class="tui-scroll-h" :scroll-x="true" :show-scrollbar="false" style="border-bottom: 2upx solid #F8F8F8;">
  18. <view style="display: flex;">
  19. <view v-for="(tab, index) in tabBars" :id="tab.id" :data-current="index" @tap='tabSlect(tab)'>
  20. <view class="tui-tab-item-title" style="margin-left: 130upx;" :class="{ 'tui-tab-item-title-active': tabIndex == tab.id }">{{ tab.name }}</view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </view>
  26. <uni-popup ref="popus" type="top">
  27. <view style="width: 100%;height: max-content;background: #FFFFFF;padding: 20upx 20upx 100upx 20upx;margin-top: 120upx;">
  28. <view class="">品牌</view>
  29. <view style="display: flex;flex-wrap: wrap;flex-wrap: wrap;">
  30. <view style="display: flex;flex-wrap: wrap;margin-left: 10upx;" v-for="(item,ind) in brandList" @tap='checkState(item)'>
  31. <view :style="item.brandId == brandIndex?
  32. 'width: 150rpx; height: 50rpx;background: #F2F2F2;text-align: center;border-radius: 50rpx;line-height: 50rpx;margin: 20rpx 0rpx 0rpx 10rpx;border: 1rpx solid #e10a07;'
  33. : 'width: 150rpx; height: 50rpx;background: #F2F2F2;text-align: center;border-radius: 50rpx;line-height: 50rpx;margin: 20rpx 0rpx 0rpx 10rpx;'">{{item.brandName}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </uni-popup>
  38. <view style="display: flex;flex-wrap: wrap;padding-top: 70upx;">
  39. <view style="width: 345upx;height: 550upx;background-color: #FFFFFF; border-radius: 20upx;margin-left: 20upx; margin-top: 20upx;box-shadow: rgba(183, 183, 183, 0.3) 1px 1px 10px 1px;"
  40. @tap='goDetail(item.id)' v-for="(item,index) in list" :key='index'>
  41. <image :src="item.coverImg" style="width: 345upx;height: 340upx;border-top-left-radius:20upx;border-top-right-radius:20upx;"></image>
  42. <view style="padding: 16upx 2upx 16upx 16upx;">
  43. <view style="width: 100%;height: 60upx;">
  44. <text class="limapboxqing2"><text class="indexr" style=""><text>自营</text></text>{{ item.title }}</text>
  45. </view>
  46. </view>
  47. <view>
  48. <view style="padding: 0rpx 15rpx;display: flex;margin:60rpx 0">
  49. <view style="width: 40%;font-size: 38upx;color: #05C25C;font-weight: 700;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">¥{{item.memberPrice}}</view>
  50. <view style="width: 60%;font-size: 24upx;color: #999999;margin-top: 10upx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;text-align: right;">{{item.sales}}人已购买</view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 悬浮上拉 -->
  55. <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '','']" style="bottom: 56px;">
  56. <text class="iconfont icon-shangla"></text>
  57. </view>
  58. <!-- 加载更多提示 -->
  59. <view class="s-col is-col-24" v-if="list.length > 0">
  60. <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
  61. </view>
  62. <!-- 加载更多提示 -->
  63. <empty style="width: 100%;" v-if="list.length === 0" des="暂无数据" show="false"></empty>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. onShareAppMessage(res) {
  70. return {};
  71. },
  72. data() {
  73. return {
  74. placeholder: '输入关键字或粘贴宝贝标题',
  75. keywords: '',
  76. keywordlist: [],
  77. recentKeyword: [],
  78. copyTklStatus: '',
  79. localKeyword: 'orange-tyh-keyword',
  80. current: 0,
  81. tabIndex: '0',
  82. tabStatus: 'createAt',
  83. list: [],
  84. relation: false,
  85. isEnable: '否',
  86. //综合createAt 销量sales 佣金比例commissionPrice 超低价price
  87. tabBars: [{
  88. name: '综合',
  89. id: '0',
  90. status: 'createAt'
  91. },
  92. {
  93. name: '销量',
  94. id: '1',
  95. status: 'sales'
  96. },
  97. {
  98. name: '超低价',
  99. id: '2',
  100. status: 'price'
  101. }
  102. ],
  103. page: 0,
  104. size: 10,
  105. brandId: '',
  106. brandIndex: 0,
  107. brandList: [],
  108. loadingType: 0,
  109. type: '',
  110. title: '',
  111. scrollTop: false,
  112. contentText: {
  113. contentdown: '上拉显示更多',
  114. contentrefresh: '正在加载...',
  115. contentnomore: '没有更多数据了'
  116. }
  117. };
  118. },
  119. onShow() {
  120. let a = this.$queue.getData("isEnable")
  121. if (a === '是') {
  122. let b = this.$queue.getData('isLieBiaoEnable');
  123. if (b) {
  124. this.isEnable = b;
  125. } else {
  126. this.isEnable = a;
  127. }
  128. } else {
  129. this.isEnable = a;
  130. }
  131. },
  132. onLoad(e) {
  133. let relation_id = this.$queue.getData('relation_id');
  134. if (relation_id && relation_id !== 'undefined') {
  135. this.relation = true;
  136. } else {
  137. this.relation = false;
  138. }
  139. if (e.keyword) {
  140. this.keywords = e.keyword;
  141. }
  142. this.getList('', this.tabStatus);
  143. this.getBrandList();
  144. },
  145. methods: {
  146. checkState(item) {
  147. if (item.brandId === this.brandIndex) {
  148. this.brandIndex = 0;
  149. this.brandId = '';
  150. } else {
  151. this.brandIndex = item.brandId;
  152. this.brandId = item.brandId;
  153. }
  154. this.getList('', this.tabStatus);
  155. this.$refs.popus.close();
  156. },
  157. getBrandList() {
  158. this.$Request.getT('/goods/brandList?title=' + this.keywords).then(res => {
  159. if (res.status === 0) {
  160. res.data.forEach(d => {
  161. this.brandList.push(d);
  162. });
  163. }
  164. });
  165. },
  166. openPopus() {
  167. this.filter = true;
  168. this.$refs.popus.open();
  169. },
  170. hindPopus() {
  171. this.$refs.popus.close();
  172. },
  173. goDetail(id) {
  174. uni.navigateTo({
  175. url: './commoditydetail?ordersId=' + id
  176. });
  177. },
  178. getList(type, sort) {
  179. this.loadingType = 1;
  180. uni.showLoading({
  181. title: '加载中...',
  182. });
  183. this.$Request.getT('/app/goods/userList?page=' + this.page + '&size=' + this.size + '&type=' + this.type + '&title=' +
  184. this.keywords + '&sort=' + sort + '&brandId=' + this.brandId).then(res => {
  185. if (res.status === 0) {
  186. if (this.page === 0 || res.status) {
  187. this.list = [];
  188. }
  189. let grade = this.$queue.getData('grade');
  190. res.data.content.forEach(d => {
  191. d.descrition = '';
  192. // if (d.commissionPrice != 0) {
  193. // if (grade) {
  194. // if (this.relation) {
  195. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d.commissionPrice)) * parseFloat(grade)).toFixed(
  196. // 2);
  197. // } else {
  198. // d.descrition = ((parseFloat(d.price) * parseFloat(d.commissionPrice)) * parseFloat(grade)).toFixed(2);
  199. // }
  200. // } else {
  201. // if (this.relation) {
  202. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d.commissionPrice)) * parseFloat(this.$queue.minMoney()))
  203. // .toFixed(2);
  204. // } else {
  205. // d.descrition = ((parseFloat(d.price) * parseFloat(d.commissionPrice)) * parseFloat(this.$queue.minMoney()))
  206. // .toFixed(2);
  207. // }
  208. // }
  209. // }
  210. d.sales = d.sales > 10000 ? (d.sales / 10000).toFixed(1) + '万' : d.sales;
  211. this.list.push(d);
  212. });
  213. if (res.data.content.length === this.size) {
  214. this.loadingType = 0;
  215. } else {
  216. this.loadingType = 3;
  217. }
  218. } else {
  219. this.loadingType = 2;
  220. }
  221. uni.hideLoading();
  222. if (type === 'Refresh') {
  223. uni.stopPullDownRefresh(); // 停止刷新
  224. }
  225. });
  226. },
  227. searchInput: function(e) {
  228. this.keywords = e.detail.value;
  229. },
  230. submitSearch: function() {
  231. this.getList('', this.tabStatus)
  232. // if (this.$queue.getSearchKeys(this.keywords) != -1) {
  233. // uni.showToast({
  234. // title: "输入内容带有非法关键字请重新输入",
  235. // mask: false,
  236. // duration: 1500,
  237. // icon: "none"
  238. // });
  239. // this.keywords = '';
  240. // } else {
  241. // this.getList('', this.tabStatus)
  242. // }
  243. },
  244. clearInput() {
  245. this.keywords = '';
  246. this.getList('', this.tabStatus);
  247. },
  248. navigateBack() {
  249. uni.navigateBack();
  250. },
  251. tabSlect(item) {
  252. this.switchTab(item.id);
  253. },
  254. switchTab(index) {
  255. this.page = 0;
  256. this.tabIndex = index;
  257. this.tabStatus = this.tabBars[index].status;
  258. this.list = [];
  259. this.getList('', this.tabStatus);
  260. },
  261. topScrollTap: function() {
  262. uni.pageScrollTo({
  263. scrollTop: 0,
  264. duration: 300
  265. });
  266. }
  267. },
  268. onPageScroll: function(e) {
  269. this.scrollTop = e.scrollTop > 200;
  270. },
  271. onReachBottom: function() {
  272. this.page = this.page + 1;
  273. this.getList('', this.tabStatus);
  274. },
  275. onPullDownRefresh: function() {
  276. this.page = 0;
  277. this.getList('Refresh', this.tabStatus);
  278. }
  279. };
  280. </script>
  281. <style lang="less">
  282. @import '../../../../static/less/index.less';
  283. @import '../../../../static/css/index.css';
  284. page {
  285. background: #F8F8F8;
  286. }
  287. .limapboxqing2 {
  288. font-size: 28upx;
  289. color: #333333;
  290. overflow: hidden;
  291. text-overflow: ellipsis;
  292. display: -webkit-box;
  293. -webkit-line-clamp: 2;
  294. -webkit-box-orient: vertical;
  295. }
  296. .indexr {
  297. color: #FFFFFF;
  298. font-size: 22upx;
  299. padding-left: 12upx;
  300. display: inline-block;
  301. padding-right: 13upx;
  302. border-radius: 8upx;
  303. margin-right: 8upx;
  304. padding-top: 4upx;
  305. line-height: 38upx;
  306. background: #05C25C
  307. }
  308. .main-title {
  309. background: -webkit-linear-gradient(left, #e10a07 0, #f15b6c 100%);
  310. background: -o-linear-gradient(left, #e10a07 0, #f15b6c 100%);
  311. background: -ms-linear-gradient(left, #e10a07 0, #f15b6c 100%);
  312. background: -webkit-gradient(linear, right top, left top, color-stop(0, #e10a07), to(#f15b6c));
  313. background: -o-linear-gradient(right, #e10a07 0, #f15b6c 100%);
  314. background: linear-gradient(to left, #e10a07 0, #f15b6c 100%);
  315. border-bottom-color: transparent;
  316. padding: 16upx 20upx;
  317. position: fixed;
  318. top: 0;
  319. left: 0;
  320. width: 100%;
  321. z-index: 120;
  322. display: block;
  323. box-sizing: border-box;
  324. }
  325. .search-pop .search-tab {
  326. /* #ifdef APP-PLUS */
  327. margin: 50upx 0 20upx;
  328. /* #endif */
  329. /* #ifndef APP-PLUS */
  330. margin: 10upx 0 20upx;
  331. /* #endif */
  332. color: #fff;
  333. font-size: 32upx;
  334. text-align: center;
  335. }
  336. .search-pop .search-tab .my-sub-src {
  337. margin: 0 auto 0 40upx;
  338. display: inline-block;
  339. color: #fff;
  340. line-height: 60upx;
  341. margin-bottom: 20upx !important;
  342. }
  343. .search-pop .search-tab .my-sub-src:nth-child(1) {
  344. margin-left: 0px !important;
  345. }
  346. .main-title .search-tab .cur {
  347. opacity: 1;
  348. border-bottom: 2upx solid #fff;
  349. }
  350. .main-title .search-tab .close-src {
  351. position: absolute;
  352. left: 20upx;
  353. display: block;
  354. float: left;
  355. color: #ffffff;
  356. margin-top: 10upx;
  357. }
  358. .main-title .search-tab .image-src {
  359. position: fixed;
  360. left: 680upx;
  361. display: block;
  362. float: right;
  363. color: #ffffff;
  364. }
  365. .main-title .search-tab .close-src .iconfont {
  366. font-size: 40upx;
  367. }
  368. .main-title .search {
  369. background-color: #fff;
  370. border-radius: 40upx;
  371. width: 76%;
  372. margin-left: 10%;
  373. position: relative;
  374. padding: 0 18upx;
  375. height: 64upx;
  376. line-height: 64upx;
  377. font-size: 26upx;
  378. margin-top: 20upx;
  379. /* #ifdef APP-PLUS */
  380. margin-top: 50upx;
  381. /* #endif */
  382. }
  383. .search_submit {
  384. width: 25%;
  385. height: 64upx;
  386. background: #ffb925;
  387. color: #fff;
  388. float: right;
  389. margin-top: -64upx;
  390. position: relative;
  391. border-radius: 32upx;
  392. margin-right: -32upx;
  393. z-index: 30;
  394. }
  395. .clear {
  396. width: 70upx;
  397. background: white;
  398. color: crimson;
  399. position: absolute;
  400. z-index: 999;
  401. font-size: 32upx;
  402. /* height: 56upx; */
  403. margin-left: 86upx;
  404. margin-top: -64upx;
  405. }
  406. .main-title .search input {
  407. border: none;
  408. outline: 0;
  409. height: 64upx;
  410. font-size: 26upx;
  411. line-height: 60upx;
  412. background: #fff;
  413. color: #666;
  414. border-radius: 10upx;
  415. padding: 0 0 0 10upx;
  416. text-align: left;
  417. }
  418. .main-title .search input.search_area {
  419. background-color: transparent;
  420. position: relative;
  421. z-index: 99;
  422. width: 80%;
  423. color: #333;
  424. font-size: 28upx;
  425. }
  426. .tui-tabs {
  427. flex: 1;
  428. flex-direction: column;
  429. overflow: hidden;
  430. background-color: #fafafa;
  431. /* #ifdef MP-ALIPAY || MP-BAIDU */
  432. height: 100vh;
  433. /* #endif */
  434. padding-top: 130upx;
  435. /* #ifdef APP-PLUS */
  436. padding-top: 160upx;
  437. /* #endif */
  438. }
  439. .tui-scroll-h {
  440. width: 750rpx;
  441. height: 80rpx;
  442. background-color: #ffffff;
  443. flex-direction: row;
  444. /* #ifndef APP-PLUS */
  445. white-space: nowrap;
  446. /* #endif */
  447. /* #ifdef APP-PLUS */
  448. position: fixed;
  449. top: 44px;
  450. left: 0;
  451. margin-top: 60upx;
  452. z-index: 999;
  453. /* #endif */
  454. /* #ifdef H5 */
  455. position: fixed;
  456. top: 44px;
  457. left: 0;
  458. margin-top: 40upx;
  459. z-index: 999;
  460. /* #endif */
  461. /* #ifdef MP-WEIXIN */
  462. position: fixed;
  463. top: 44px;
  464. left: 0;
  465. margin-top: 40upx;
  466. z-index: 999;
  467. /* #endif */
  468. }
  469. .tui-line-h {
  470. /* #ifdef APP-PLUS */
  471. height: 1rpx;
  472. background-color: #cccccc;
  473. /* #endif */
  474. position: relative;
  475. }
  476. /* #ifndef APP-PLUS*/
  477. .tui-line-h::after {
  478. content: '';
  479. position: absolute;
  480. border-bottom: 1rpx solid #cccccc;
  481. -webkit-transform: scaleY(0.5);
  482. transform: scaleY(0.5);
  483. bottom: 0;
  484. right: 0;
  485. left: 0;
  486. }
  487. /* #endif */
  488. .tui-tab-item {
  489. /* #ifndef APP-PLUS */
  490. display: flex;
  491. /* #endif */
  492. }
  493. .tui-tab-item-title {
  494. color: #555;
  495. font-size: 30rpx;
  496. height: 80rpx;
  497. line-height: 80rpx;
  498. flex-wrap: nowrap;
  499. /* #ifndef APP-PLUS */
  500. white-space: nowrap;
  501. /* #endif */
  502. }
  503. .tui-tab-item-title-active {
  504. color: #05C25C;
  505. font-size: 32upx;
  506. font-weight: bold;
  507. border-bottom-width: 6upx;
  508. text-align: center;
  509. }
  510. </style>