productList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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://zkzh-2025.oss-cn-beijing.aliyuncs.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://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/search1.png" mode=""></image>
  12. <image @click="showChange(1)" v-if="showType==2" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/search2.png" mode=""></image>
  13. <image @click="openCart()" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.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://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_up.png" mode="" @click="priceUp(true)"></image>
  25. <image v-if="form.priceOrder=='asc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_up2.png" mode="" @click="priceUp(false)"></image>
  26. <image v-if="form.priceOrder==null||form.priceOrder=='asc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_down.png" mode="" @click="priceDown(true)"></image>
  27. <image v-if="form.priceOrder=='desc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.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://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_up.png" mode="" @click="saleUp(true)"></image>
  34. <image v-if="form.salesOrder=='asc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_up2.png" mode="" @click="saleUp(false)"></image>
  35. <image v-if="form.salesOrder==null||form.salesOrder=='asc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/price_arrow_down.png" mode="" @click="saleDown(true)"></image>
  36. <image v-if="form.salesOrder=='desc'" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.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}} {{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://zkzh-2025.oss-cn-beijing.aliyuncs.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. uni.navigateTo({
  233. url: 'productDetails?productId='+item.productId
  234. })
  235. },
  236. openCart() {
  237. uni.navigateTo({
  238. url: './cart'
  239. })
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .top-fixed{
  246. width: 100%;
  247. position: fixed;
  248. top: 0;
  249. left: 0;
  250. z-index: 10;
  251. }
  252. .search-cont{
  253. padding: 16upx 30upx;
  254. background-color: #FFFFFF;
  255. display:flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. .inner{
  259. box-sizing: border-box;
  260. width: 100%;
  261. height: 72upx;
  262. background: #F7F7F7;
  263. border-radius: 36upx;
  264. display: flex;
  265. align-items: center;
  266. padding: 0 30upx;
  267. .icon-search{
  268. width: 28upx;
  269. height: 28upx;
  270. margin-right: 20upx;
  271. }
  272. input{
  273. height: 60upx;
  274. line-height: 60upx;
  275. flex: 1;
  276. }
  277. }
  278. .icon-search{
  279. height: 40upx;
  280. display: flex;
  281. align-items: center;
  282. image{
  283. margin-left: 10upx;
  284. width: 40upx;
  285. height: 40upx;
  286. }
  287. }
  288. }
  289. .sort-box{
  290. height: 88upx;
  291. background: #FFFFFF;
  292. padding: 0 100upx;
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. .item{
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. &.active .label{
  301. color: #2BC7B9;
  302. }
  303. .label{
  304. font-size: 26upx;
  305. font-family: PingFang SC;
  306. font-weight: 500;
  307. color: #666666;
  308. line-height: 1;
  309. }
  310. .sort-img{
  311. height: 20upx;
  312. display: flex;
  313. flex-direction: column;
  314. justify-content: space-between;
  315. margin: 3upx 0 0 10upx;
  316. image{
  317. width: 12upx;
  318. height: 8upx;
  319. }
  320. }
  321. }
  322. }
  323. .medic-list{
  324. padding: 20upx;
  325. .item{
  326. box-sizing: border-box;
  327. min-height: 285upx;
  328. background: #FFFFFF;
  329. border: 4upx solid #FFFFFF;
  330. border-radius: 16upx;
  331. margin-bottom: 20upx;
  332. padding: 40upx 30upx;
  333. display: flex;
  334. .img-box{
  335. width: 200upx;
  336. height: 200upx;
  337. margin-right: 30upx;
  338. image{
  339. width: 100%;
  340. height: 100%;
  341. }
  342. }
  343. .info-box{
  344. width: calc(100% - 210upx);
  345. .title{
  346. font-size: 32upx;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. color: #111111;
  350. line-height: 40rpx;
  351. height: 80rpx;
  352. }
  353. .intro{
  354. font-size: 26upx;
  355. font-family: PingFang SC;
  356. font-weight: 500;
  357. color: #999999;
  358. line-height: 1;
  359. margin-top: 26upx;
  360. }
  361. .prce-num{
  362. display: flex;
  363. align-items: center;
  364. justify-content: space-between;
  365. margin-top: 30upx;
  366. .price{
  367. display: flex;
  368. align-items: flex-end;
  369. .unit{
  370. font-size: 24upx;
  371. font-family: PingFang SC;
  372. font-weight: 500;
  373. color: #FF6633;
  374. line-height: 1.2;
  375. margin-right: 4upx;
  376. }
  377. .num{
  378. font-size: 36upx;
  379. font-family: PingFang SC;
  380. font-weight: bold;
  381. color: #FF6633;
  382. line-height: 1;
  383. }
  384. }
  385. .cart-img{
  386. .sale{
  387. font-size: 20upx;
  388. font-family: PingFang SC;
  389. color: #999999;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. }
  396. .goods-list{
  397. padding: 20upx;
  398. display: flex;
  399. flex-wrap: wrap;
  400. .item{
  401. margin-right: 20rpx;
  402. margin-bottom: 20rpx;
  403. width: 345rpx;
  404. background: #FFFFFF;
  405. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  406. border-radius: 20rpx;
  407. overflow: hidden;
  408. &:nth-child(2n) {
  409. margin-right: 0;
  410. }
  411. .img-box{
  412. width: 100%;
  413. height: 334upx;
  414. image{
  415. width: 100%;
  416. height: 100%;
  417. }
  418. }
  419. .info-box{
  420. box-sizing: border-box;
  421. height: 182upx;
  422. padding: 20upx 20upx 30upx;
  423. display: flex;
  424. flex-direction: column;
  425. justify-content: space-between;
  426. .title{
  427. font-size: 26upx;
  428. font-family: PingFang SC;
  429. font-weight: 500;
  430. color: #111111;
  431. line-height: 40upx;
  432. }
  433. .price-box{
  434. display: flex;
  435. align-items: flex-end;
  436. .now{
  437. display: flex;
  438. align-items: flex-end;
  439. margin-right: 20upx;
  440. .unit{
  441. font-size: 24upx;
  442. font-family: PingFang SC;
  443. font-weight: 500;
  444. color: #FF6633;
  445. line-height: 1.2;
  446. margin-right: 4upx;
  447. }
  448. .num{
  449. font-size: 36upx;
  450. font-family: PingFang SC;
  451. font-weight: bold;
  452. color: #FF6633;
  453. line-height: 1;
  454. }
  455. }
  456. .old{
  457. font-size: 26upx;
  458. font-family: PingFang SC;
  459. font-weight: 500;
  460. text-decoration: line-through;
  461. color: #BBBBBB;
  462. line-height: 1.1;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. </style>