productList.vue 12 KB

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