productList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/search.png" mode=""></image>
  8. <input type="text" @confirm="goSearch" :value="form.productName" placeholder="输入产品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  9. </view>
  10. <view class="icon-search">
  11. <image @click="showChange(2)" v-if="showType==1" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/search1.png" mode=""></image>
  12. <image @click="showChange(1)" v-if="showType==2" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/search2.png" mode=""></image>
  13. <image @click="openCart()" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/carts.png" mode=""></image>
  14. </view>
  15. </view>
  16. <!-- 排序框 -->
  17. <view class="sort-box">
  18. <view class="item" :class="form.defaultOrder=='desc'?'active':''" @click="searchChange('1')">
  19. <text class="label">默认</text>
  20. </view>
  21. <view class="item" @click="searchChange('2')">
  22. <text class="label">价格</text>
  23. <view class="sort-img">
  24. <image v-if="form.priceOrder==null||form.priceOrder=='desc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_up.png" mode="" @click="priceUp(true)"></image>
  25. <image v-if="form.priceOrder=='asc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_up2.png" mode="" @click="priceUp(false)"></image>
  26. <image v-if="form.priceOrder==null||form.priceOrder=='asc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_down.png" mode="" @click="priceDown(true)"></image>
  27. <image v-if="form.priceOrder=='desc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_down2.png" mode="" @click="priceDown(false)"></image>
  28. </view>
  29. </view>
  30. <view class="item" @click="searchChange('3')">
  31. <text class="label">销量</text>
  32. <view class="sort-img">
  33. <image v-if="form.salesOrder==null||form.salesOrder=='desc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_up.png" mode="" @click="saleUp(true)"></image>
  34. <image v-if="form.salesOrder=='asc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_up2.png" mode="" @click="saleUp(false)"></image>
  35. <image v-if="form.salesOrder==null||form.salesOrder=='asc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_down.png" mode="" @click="saleDown(true)"></image>
  36. <image v-if="form.salesOrder=='desc'" src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/price_arrow_down2.png" mode="" @click="saleDown(false)"></image>
  37. </view>
  38. </view>
  39. <view class="item" :class="form.newOrder=='desc'?'active':''" @click="searchChange('4')">
  40. <text class="label">新品</text>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 数据列表 -->
  45. <mescroll-body top="190rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  46. <view class="medic-list" v-if="showType==1">
  47. <view v-for="(item,index) in dataList" :key="index" class="item" @click="showDetail(item)">
  48. <view class="img-box">
  49. <image :src="item.image" mode="aspectFit"></image>
  50. </view>
  51. <view class="info-box">
  52. <view class="title ellipsis2">{{item.productName}}</view>
  53. <!-- <view class="intro ellipsis">{{item.productInfo}}</view> -->
  54. <view class="prce-num">
  55. <view class="price">
  56. <text class="unit">¥</text>
  57. <text class="num">{{item.price.toFixed(2)}} </text>
  58. </view>
  59. <view class="cart-img" @click="navgetTo('../shopping/cart')">
  60. <view class="sale">已售 {{item.sales||'0'}} {{item.unitName||''}}</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="goods-list" v-if="showType==2">
  67. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  68. <view class="img-box">
  69. <image :src="item.image" mode="aspectFill"></image>
  70. </view>
  71. <view class="info-box">
  72. <view class="title ellipsis2">{{item.productName}}</view>
  73. <view class="price-box">
  74. <view class="now">
  75. <text class="unit">¥</text>
  76. <text class="num">{{item.price.toFixed(2)}}</text>
  77. </view>
  78. <view class="old">¥{{item.otPrice.toFixed(2)}}</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </mescroll-body>
  84. </view>
  85. </template>
  86. <script>
  87. import {getSalesProducts} from '@/api/companyOrder'
  88. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  89. export default {
  90. mixins: [MescrollMixin],
  91. data() {
  92. return {
  93. showType:1,
  94. form:{
  95. defaultOrder:'desc',
  96. newOrder:null,
  97. priceOrder:null,
  98. salesOrder:null,
  99. productName:"",
  100. token:''
  101. },
  102. mescroll:null,
  103. // 上拉加载的配置
  104. upOption: {
  105. onScroll:true,
  106. use: true, // 是否启用上拉加载; 默认true
  107. page: {
  108. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  109. size: 10 // 每页数据的数量,默认10
  110. },
  111. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  112. empty: {
  113. icon:'https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/no_data.png',
  114. tip: '暂无数据'
  115. },
  116. textNoMore:"已经到底了",
  117. },
  118. // 列表数据
  119. dataList: [],
  120. };
  121. },
  122. onLoad(option) {
  123. if(option.key!=undefined){
  124. this.form.productName = option.key
  125. }
  126. },
  127. methods:{
  128. goSearch(e) {
  129. this.form.productName=e.detail.value;
  130. this.mescroll.resetUpScroll();
  131. },
  132. searchChange(type){
  133. if(type==1){
  134. this.form.defaultOrder="desc";
  135. this.form.priceOrder=null;
  136. this.form.salesOrder=null;
  137. this.form.newOrder=null;
  138. }
  139. else if(type==2){
  140. this.form.defaultOrder=null;
  141. if(this.form.priceOrder==null){
  142. this.form.priceOrder="asc"
  143. }
  144. else if(this.form.priceOrder=="asc"){
  145. this.form.priceOrder="desc"
  146. }
  147. else if(this.form.priceOrder=="desc"){
  148. this.form.priceOrder=null;
  149. }
  150. this.form.salesOrder=null;
  151. this.form.newOrder=null;
  152. }
  153. else if(type==3){
  154. this.form.defaultOrder=null;
  155. this.form.priceOrder=null;
  156. if(this.form.salesOrder==null){
  157. this.form.salesOrder="asc"
  158. }
  159. else if(this.form.salesOrder=="asc"){
  160. this.form.salesOrder="desc"
  161. }
  162. else if(this.form.salesOrder=="desc"){
  163. this.form.salesOrder=null;
  164. }
  165. this.form.newOrder=null;
  166. }
  167. else if(type==4){
  168. this.form.newOrder="desc";
  169. this.form.defaultOrder=null;
  170. this.form.priceOrder=null;
  171. this.form.salesOrder=null;
  172. }
  173. this.mescroll.resetUpScroll();
  174. },
  175. showChange(type){
  176. this.showType=type;
  177. },
  178. mescrollInit(mescroll) {
  179. this.mescroll = mescroll;
  180. },
  181. /*下拉刷新的回调 */
  182. downCallback(mescroll) {
  183. mescroll.resetUpScroll()
  184. },
  185. upCallback(page) {
  186. //联网加载数据
  187. var that = this;
  188. this.form.page=page.num;
  189. this.form.pageSize=page.size;
  190. this.form.token=uni.getStorageSync('CompanyUserToken');
  191. getSalesProducts(this.form).then(res => {
  192. if(res.code==200){
  193. //设置列表数据
  194. if (page.num == 1) {
  195. that.dataList = res.data.list;
  196. } else {
  197. that.dataList = that.dataList.concat(res.data.list);
  198. }
  199. that.mescroll.endBySize(res.data.list.length, res.data.total);
  200. }else{
  201. uni.showToast({
  202. icon:'none',
  203. title: "请求失败",
  204. });
  205. that.dataList = null;
  206. that.mescroll.endErr();
  207. }
  208. });
  209. },
  210. // 价格升序是否选中
  211. priceUp(value) {
  212. this.priceIsUp = value
  213. this.priceIsDown = false
  214. },
  215. // 价格降序是否选中
  216. priceDown(value) {
  217. this.priceIsDown = value
  218. this.priceIsUp = false
  219. },
  220. // 销量升序是否选中
  221. saleUp(value) {
  222. this.saleIsUp = value
  223. this.saleIsDown = false
  224. },
  225. // 销量降序是否选中
  226. saleDown(value) {
  227. this.saleIsDown = value
  228. this.saleIsUp = false
  229. },
  230. // 查看详情
  231. showDetail(item) {
  232. console.log("在这里",item)
  233. uni.navigateTo({
  234. url: 'productDetails?productId='+item.productId+"&companyId="+item.companyId+"&companyUserId="+item.companyUserId
  235. })
  236. },
  237. openCart() {
  238. uni.navigateTo({
  239. url: './cart'
  240. })
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .top-fixed{
  247. width: 100%;
  248. position: fixed;
  249. top: 0;
  250. left: 0;
  251. z-index: 10;
  252. }
  253. .search-cont{
  254. padding: 16upx 30upx;
  255. background-color: #FFFFFF;
  256. display:flex;
  257. align-items: center;
  258. justify-content: space-between;
  259. .inner{
  260. box-sizing: border-box;
  261. width: 100%;
  262. height: 72upx;
  263. background: #F7F7F7;
  264. border-radius: 36upx;
  265. display: flex;
  266. align-items: center;
  267. padding: 0 30upx;
  268. .icon-search{
  269. width: 28upx;
  270. height: 28upx;
  271. margin-right: 20upx;
  272. }
  273. input{
  274. height: 60upx;
  275. line-height: 60upx;
  276. flex: 1;
  277. }
  278. }
  279. .icon-search{
  280. height: 40upx;
  281. display: flex;
  282. align-items: center;
  283. image{
  284. margin-left: 10upx;
  285. width: 40upx;
  286. height: 40upx;
  287. }
  288. }
  289. }
  290. .sort-box{
  291. height: 88upx;
  292. background: #FFFFFF;
  293. padding: 0 100upx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: space-between;
  297. .item{
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. &.active .label{
  302. color: #2BC7B9;
  303. }
  304. .label{
  305. font-size: 26upx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #666666;
  309. line-height: 1;
  310. }
  311. .sort-img{
  312. height: 20upx;
  313. display: flex;
  314. flex-direction: column;
  315. justify-content: space-between;
  316. margin: 3upx 0 0 10upx;
  317. image{
  318. width: 12upx;
  319. height: 8upx;
  320. }
  321. }
  322. }
  323. }
  324. .medic-list{
  325. padding: 20upx;
  326. .item{
  327. box-sizing: border-box;
  328. min-height: 285upx;
  329. background: #FFFFFF;
  330. border: 4upx solid #FFFFFF;
  331. border-radius: 16upx;
  332. margin-bottom: 20upx;
  333. padding: 40upx 30upx;
  334. display: flex;
  335. .img-box{
  336. width: 200upx;
  337. height: 200upx;
  338. margin-right: 30upx;
  339. image{
  340. width: 100%;
  341. height: 100%;
  342. }
  343. }
  344. .info-box{
  345. width: calc(100% - 210upx);
  346. .title{
  347. font-size: 32upx;
  348. font-family: PingFang SC;
  349. font-weight: 500;
  350. color: #111111;
  351. line-height: 40rpx;
  352. height: 80rpx;
  353. }
  354. .intro{
  355. font-size: 26upx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #999999;
  359. line-height: 1;
  360. margin-top: 26upx;
  361. }
  362. .prce-num{
  363. display: flex;
  364. align-items: center;
  365. justify-content: space-between;
  366. margin-top: 30upx;
  367. .price{
  368. display: flex;
  369. align-items: flex-end;
  370. .unit{
  371. font-size: 24upx;
  372. font-family: PingFang SC;
  373. font-weight: 500;
  374. color: #FF6633;
  375. line-height: 1.2;
  376. margin-right: 4upx;
  377. }
  378. .num{
  379. font-size: 36upx;
  380. font-family: PingFang SC;
  381. font-weight: bold;
  382. color: #FF6633;
  383. line-height: 1;
  384. }
  385. }
  386. .cart-img{
  387. .sale{
  388. font-size: 20upx;
  389. font-family: PingFang SC;
  390. color: #999999;
  391. }
  392. }
  393. }
  394. }
  395. }
  396. }
  397. .goods-list{
  398. padding: 20upx;
  399. display: flex;
  400. flex-wrap: wrap;
  401. .item{
  402. margin-right: 20rpx;
  403. margin-bottom: 20rpx;
  404. width: 345rpx;
  405. background: #FFFFFF;
  406. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  407. border-radius: 20rpx;
  408. overflow: hidden;
  409. &:nth-child(2n) {
  410. margin-right: 0;
  411. }
  412. .img-box{
  413. width: 100%;
  414. height: 334upx;
  415. image{
  416. width: 100%;
  417. height: 100%;
  418. }
  419. }
  420. .info-box{
  421. box-sizing: border-box;
  422. height: 182upx;
  423. padding: 20upx 20upx 30upx;
  424. display: flex;
  425. flex-direction: column;
  426. justify-content: space-between;
  427. .title{
  428. font-size: 26upx;
  429. font-family: PingFang SC;
  430. font-weight: 500;
  431. color: #111111;
  432. line-height: 40upx;
  433. }
  434. .price-box{
  435. display: flex;
  436. align-items: flex-end;
  437. .now{
  438. display: flex;
  439. align-items: flex-end;
  440. margin-right: 20upx;
  441. .unit{
  442. font-size: 24upx;
  443. font-family: PingFang SC;
  444. font-weight: 500;
  445. color: #FF6633;
  446. line-height: 1.2;
  447. margin-right: 4upx;
  448. }
  449. .num{
  450. font-size: 36upx;
  451. font-family: PingFang SC;
  452. font-weight: bold;
  453. color: #FF6633;
  454. line-height: 1;
  455. }
  456. }
  457. .old{
  458. font-size: 26upx;
  459. font-family: PingFang SC;
  460. font-weight: 500;
  461. text-decoration: line-through;
  462. color: #BBBBBB;
  463. line-height: 1.1;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. </style>