tuiStoreProduct.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view>
  3. <!-- 数据列表 -->
  4. <!-- <mescroll-body :top="top+'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. top: 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: 20, // 配置列表的总数量要大于等于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. getProducts(storeId) {
  113. this.storeId = storeId
  114. //联网加载数据
  115. var that = this;
  116. const param = {
  117. page: 1,
  118. pageSize: 10,
  119. storeId: this.storeId,
  120. isGood: 1
  121. }
  122. getProducts(param).then(res => {
  123. if(res.code==200){
  124. //设置列表数据
  125. that.dataList = res.data.list;
  126. // that.mescroll.endBySize(res.data.list.length, 10);
  127. }else{
  128. uni.showToast({
  129. icon:'none',
  130. title: "请求失败",
  131. });
  132. // that.dataList = null;
  133. // that.mescroll.endErr();
  134. }
  135. that.$emit('refreshElementTop')
  136. });
  137. },
  138. // 查看详情
  139. showDetail(item) {
  140. uni.navigateTo({
  141. url: '/pages_shopping/productDetails?productId='+item.productId + `${this.storeId ? '&storeId='+this.storeId : ''}`
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .morebtn{
  149. padding: 20rpx;
  150. box-sizing: border-box;
  151. text-align: center;
  152. font-weight: 500;
  153. font-size: 32rpx;
  154. color: #999;
  155. }
  156. .medic-itemlist {
  157. padding: 20upx;
  158. box-sizing: border-box;
  159. }
  160. .desc {
  161. margin-top: 12rpx;
  162. font-family: PingFang SC, PingFang SC;
  163. font-weight: 400;
  164. font-size: 24rpx;
  165. color: #939599;
  166. }
  167. .otctxt {
  168. position: absolute;
  169. top: 0;
  170. left: 0;
  171. background-color: #37E2EA;
  172. font-family: PingFang SC, PingFang SC;
  173. font-weight: 500;
  174. font-size: 20rpx;
  175. color: #FFFFFF;
  176. padding: 4rpx 14rpx;
  177. border-radius: 16rpx 0 16rpx 0;
  178. }
  179. .goods-list{
  180. padding: 20upx;
  181. display: flex;
  182. flex-wrap: wrap;
  183. .item{
  184. margin-right: 20rpx;
  185. margin-bottom: 20rpx;
  186. width: 345rpx;
  187. background: #FFFFFF;
  188. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  189. border-radius: 20rpx;
  190. overflow: hidden;
  191. &:nth-child(2n) {
  192. margin-right: 0;
  193. }
  194. .img-box{
  195. width: 100%;
  196. height: 334upx;
  197. position: relative;
  198. image{
  199. width: 100%;
  200. height: 100%;
  201. }
  202. }
  203. .info-box{
  204. box-sizing: border-box;
  205. height: 182upx;
  206. padding: 20upx 20upx 30upx;
  207. display: flex;
  208. flex-direction: column;
  209. justify-content: space-between;
  210. .title{
  211. font-size: 32upx;
  212. font-family: PingFang SC;
  213. font-weight: 500;
  214. color: #111111;
  215. line-height: 40upx;
  216. }
  217. .price-box{
  218. display: flex;
  219. align-items: flex-end;
  220. .now{
  221. display: flex;
  222. align-items: flex-end;
  223. margin-right: 20upx;
  224. .unit{
  225. font-size: 24upx;
  226. font-family: PingFang SC;
  227. font-weight: 500;
  228. color: #FF6633;
  229. line-height: 1.2;
  230. margin-right: 4upx;
  231. }
  232. .num{
  233. font-size: 36upx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #FF6633;
  237. line-height: 1;
  238. }
  239. }
  240. .old{
  241. font-size: 26upx;
  242. font-family: PingFang SC;
  243. font-weight: 500;
  244. text-decoration: line-through;
  245. color: #BBBBBB;
  246. line-height: 1.1;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. </style>