productList.vue 12 KB

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