tuiStoreProduct.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <!-- 数据列表 -->
  4. <mescroll-body top="0" :height="scrollHeight+'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  5. <view class="medic-itemlist">
  6. <medicineItem :type="'store'" v-for="(item, index) in dataList" :key="index" :item="item"></medicineItem>
  7. <view class="morebtn" v-if="dataList&&dataList.length>0" @click="navTo('/pages_shopping/home/productList?storeId='+storeId)">查看更多</view>
  8. </view>
  9. <!-- <view class="goods-list">
  10. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  11. <view class="img-box">
  12. <image :src="item.image" mode="aspectFill"></image>
  13. <view class="otctxt" :style="{background:_background(item.productType)}" v-show="item.productType">{{$getDictLabelName("storeProductType",item.productType)}}</view>
  14. </view>
  15. <view class="info-box">
  16. <view class="title ellipsis2">{{item.productName}}</view>
  17. <view class="price-box">
  18. <view class="now">
  19. <text class="unit">¥</text>
  20. <text class="num">{{item.price.toFixed(2)}}</text>
  21. </view>
  22. <view class="old" v-show="item.price!=item.otPrice&&item.otPrice!==null&&item.otPrice!==undefined">¥{{item.otPrice.toFixed(2)}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view> -->
  27. </mescroll-body>
  28. </view>
  29. </template>
  30. <script>
  31. import medicineItem from '@/components/medicineItem.vue'
  32. import {getProducts} from '@/pages_shopping/api/product.js'
  33. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  34. export default {
  35. mixins: [MescrollMixin],
  36. components:{
  37. medicineItem
  38. },
  39. props: {
  40. storeId:'',
  41. scrollHeight: 0
  42. },
  43. data() {
  44. return {
  45. form:{
  46. defaultOrder:'desc',
  47. newOrder:null,
  48. priceOrder:null,
  49. salesOrder:null,
  50. productName:"",
  51. storeId: ""
  52. },
  53. mescroll:null,
  54. // 上拉加载的配置
  55. upOption: {
  56. onScroll:true,
  57. use: true, // 是否启用上拉加载; 默认true
  58. page: {
  59. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  60. size: 10 // 每页数据的数量,默认10
  61. },
  62. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  63. empty: {
  64. icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
  65. tip: '暂无数据'
  66. },
  67. textNoMore:"已经到底了",
  68. },
  69. // 列表数据
  70. dataList: [],
  71. };
  72. },
  73. computed: {
  74. _background() {
  75. //productType: 1:OTC,2:Rx,3:非药品,4:器械
  76. return (productType)=> {
  77. switch (productType) {
  78. case 1: return '#37E2EA' // OTC
  79. case 2: return 'red' // Rx
  80. case 3: return '#2583EB' // 非药品
  81. case 4: return '#999' // 器械
  82. default: return '#ccc'
  83. }
  84. }
  85. }
  86. },
  87. watch: {
  88. storeId: {
  89. immediate: true, // 第一次也触发
  90. handler (newVal, oldVal) {
  91. console.log('msg 变了:', newVal)
  92. if(newVal) {
  93. console.log(this.mescroll)
  94. this.mescroll.resetUpScroll()
  95. }
  96. }
  97. }
  98. },
  99. methods:{
  100. navTo(url) {
  101. uni.navigateTo({
  102. url: url
  103. })
  104. },
  105. mescrollInit(mescroll) {
  106. this.mescroll = mescroll;
  107. },
  108. /*下拉刷新的回调 */
  109. downCallback(mescroll) {
  110. mescroll.resetUpScroll()
  111. },
  112. upCallback(page) {
  113. //联网加载数据
  114. var that = this;
  115. const param = {
  116. page: page.num,
  117. pageSize: page.size,
  118. storeId: this.storeId
  119. }
  120. getProducts(param).then(res => {
  121. if(res.code==200){
  122. //设置列表数据
  123. if (page.num == 1) {
  124. that.dataList = res.data.list;
  125. } else {
  126. that.dataList = that.dataList.concat(res.data.list);
  127. }
  128. that.mescroll.endBySize(res.data.list.length, res.data.total);
  129. }else{
  130. uni.showToast({
  131. icon:'none',
  132. title: "请求失败",
  133. });
  134. that.dataList = null;
  135. that.mescroll.endErr();
  136. }
  137. });
  138. },
  139. // 查看详情
  140. showDetail(item) {
  141. uni.navigateTo({
  142. url: '/pages_shopping/productDetails?productId='+item.productId + `${this.storeId ? '&storeId='+this.storeId : ''}`
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .morebtn{
  150. padding: 20rpx;
  151. box-sizing: border-box;
  152. text-align: center;
  153. font-weight: 500;
  154. font-size: 32rpx;
  155. color: #999;
  156. }
  157. .medic-itemlist {
  158. padding: 20upx;
  159. box-sizing: border-box;
  160. }
  161. .desc {
  162. margin-top: 12rpx;
  163. font-family: PingFang SC, PingFang SC;
  164. font-weight: 400;
  165. font-size: 24rpx;
  166. color: #939599;
  167. }
  168. .otctxt {
  169. position: absolute;
  170. top: 0;
  171. left: 0;
  172. background-color: #37E2EA;
  173. font-family: PingFang SC, PingFang SC;
  174. font-weight: 500;
  175. font-size: 20rpx;
  176. color: #FFFFFF;
  177. padding: 4rpx 14rpx;
  178. border-radius: 16rpx 0 16rpx 0;
  179. }
  180. .goods-list{
  181. padding: 20upx;
  182. display: flex;
  183. flex-wrap: wrap;
  184. .item{
  185. margin-right: 20rpx;
  186. margin-bottom: 20rpx;
  187. width: 345rpx;
  188. background: #FFFFFF;
  189. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  190. border-radius: 20rpx;
  191. overflow: hidden;
  192. &:nth-child(2n) {
  193. margin-right: 0;
  194. }
  195. .img-box{
  196. width: 100%;
  197. height: 334upx;
  198. position: relative;
  199. image{
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. .info-box{
  205. box-sizing: border-box;
  206. height: 182upx;
  207. padding: 20upx 20upx 30upx;
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: space-between;
  211. .title{
  212. font-size: 32upx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #111111;
  216. line-height: 40upx;
  217. }
  218. .price-box{
  219. display: flex;
  220. align-items: flex-end;
  221. .now{
  222. display: flex;
  223. align-items: flex-end;
  224. margin-right: 20upx;
  225. .unit{
  226. font-size: 24upx;
  227. font-family: PingFang SC;
  228. font-weight: 500;
  229. color: #FF6633;
  230. line-height: 1.2;
  231. margin-right: 4upx;
  232. }
  233. .num{
  234. font-size: 36upx;
  235. font-family: PingFang SC;
  236. font-weight: bold;
  237. color: #FF6633;
  238. line-height: 1;
  239. }
  240. }
  241. .old{
  242. font-size: 26upx;
  243. font-family: PingFang SC;
  244. font-weight: 500;
  245. text-decoration: line-through;
  246. color: #BBBBBB;
  247. line-height: 1.1;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>