tuiStoreProduct.vue 6.4 KB

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