userTuiProduct.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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" @confirm="goSearch" :value="form.title" placeholder="输入商品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  8. </view>
  9. </view>
  10. <view class="cate-list">
  11. <!-- 关键字列表 -->
  12. <scroll-view scroll-x="true" >
  13. <view class="inner">
  14. <view v-for="(item,index) in cates" :key="index" :class="cateId == item.dictValue?'item active':'item'" @click="choseCate(item)">
  15. {{ item.dictLabel }}
  16. </view>
  17. </view>
  18. </scroll-view>
  19. </view>
  20. </view>
  21. <mescroll-body top="204rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  22. <!-- 药品列表 -->
  23. <view class="goods-list" >
  24. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  25. <view class="img-box">
  26. <image :src="item.image" mode="aspectFill"></image>
  27. </view>
  28. <view class="info-box">
  29. <view class="title ellipsis2">{{item.productName}}</view>
  30. <view class="sku">{{item.sku}}</view>
  31. <view class="price-box">
  32. <view class="now">
  33. <text class="unit">¥</text>
  34. <text class="num">{{item.price.toFixed(2)}}</text>
  35. </view>
  36. <!-- <view class="old">¥{{item.otPrice.toFixed(2)}}</view> -->
  37. </view>
  38. <view class="tui-money">
  39. 分享赚{{item.brokerage.toFixed(2)}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </mescroll-body>
  45. </view>
  46. </template>
  47. <script>
  48. import {getStoreProductAttrValueList} from '@/api/product.js'
  49. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  50. export default {
  51. mixins: [MescrollMixin],
  52. data() {
  53. return {
  54. cateId:0,
  55. cates:[],
  56. searchKey:"",
  57. mescroll:null,
  58. // 上拉加载的配置
  59. upOption: {
  60. onScroll:true,
  61. use: true, // 是否启用上拉加载; 默认true
  62. page: {
  63. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  64. size: 10 // 每页数据的数量,默认10
  65. },
  66. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  67. empty: {
  68. icon:'/static/images/no_data.png',
  69. tip: '暂无数据'
  70. }
  71. },
  72. // 列表数据
  73. dataList: [],
  74. };
  75. },
  76. onLoad(options) {
  77. var that=this;
  78. this.cates=this.utils.getDict("storeProductTuiCate");
  79. },
  80. methods: {
  81. choseCate(item){
  82. this.cateId = item.dictValue;
  83. this.mescroll.resetUpScroll()
  84. },
  85. goSearch(e) {
  86. this.searchKey=e.detail.value;
  87. this.mescroll.resetUpScroll()
  88. },
  89. mescrollInit(mescroll) {
  90. this.mescroll = mescroll;
  91. },
  92. /*下拉刷新的回调 */
  93. downCallback(mescroll) {
  94. mescroll.resetUpScroll()
  95. },
  96. upCallback(page) {
  97. //联网加载数据
  98. var that = this;
  99. var data = {
  100. tuiCateId:this.cateId,
  101. productName:this.searchKey,
  102. page: page.num,
  103. pageSize: page.size
  104. };
  105. getStoreProductAttrValueList(data).then(res => {
  106. if(res.code==200){
  107. if (page.num == 1) {
  108. that.dataList = res.data.list;
  109. } else {
  110. that.dataList = that.dataList.concat(res.data.list);
  111. }
  112. that.mescroll.endBySize(res.data.list.length, res.data.total);
  113. }else{
  114. uni.showToast({
  115. icon:'none',
  116. title: "请求失败",
  117. });
  118. that.dataList = null;
  119. that.mescroll.endErr();
  120. }
  121. });
  122. },
  123. showDetail(item) {
  124. uni.navigateTo({
  125. url: '/pages/shopping/productDetails?productId=' + item.productId
  126. })
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. .top-fixed{
  133. width: 100%;
  134. position: fixed;
  135. top: 0;
  136. left: 0;
  137. z-index: 10;
  138. .search-cont{
  139. padding: 16upx 30upx;
  140. background-color: #FFFFFF;
  141. display:flex;
  142. align-items: center;
  143. justify-content: space-between;
  144. .inner{
  145. box-sizing: border-box;
  146. width: 100%;
  147. height: 72upx;
  148. background: #F7F7F7;
  149. border-radius: 36upx;
  150. display: flex;
  151. align-items: center;
  152. padding: 0 30upx;
  153. .icon-search{
  154. width: 28upx;
  155. height: 28upx;
  156. margin-right: 20upx;
  157. }
  158. input{
  159. height: 60upx;
  160. line-height: 60upx;
  161. flex: 1;
  162. }
  163. }
  164. }
  165. .cate-list{
  166. box-sizing: border-box;
  167. background: #fff;
  168. padding: 10upx 27upx;
  169. height: 100upx;
  170. .inner{
  171. display: flex;
  172. }
  173. .item{
  174. flex-shrink: 0;
  175. padding: 0 24upx;
  176. height: 64upx;
  177. line-height: 64upx;
  178. font-size: 28upx;
  179. font-family: PingFang SC;
  180. font-weight: 500;
  181. color: #018C39;
  182. background: #F5FFFE;
  183. border: 1px solid #8AD5CE;
  184. border-radius: 32upx;
  185. margin: 0 20upx 20upx 0;
  186. &.active{
  187. color: #FFFFFF;
  188. background: #018C39;
  189. border: 1px solid #018C39;
  190. }
  191. }
  192. }
  193. }
  194. .goods-list{
  195. padding: 20upx;
  196. display: flex;
  197. flex-wrap: wrap;
  198. .item{
  199. margin-right: 20rpx;
  200. margin-bottom: 20rpx;
  201. width: 345rpx;
  202. background: #FFFFFF;
  203. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  204. border-radius: 20rpx;
  205. overflow: hidden;
  206. &:nth-child(2n) {
  207. margin-right: 0;
  208. }
  209. .img-box{
  210. width: 100%;
  211. height: 334upx;
  212. image{
  213. width: 100%;
  214. height: 100%;
  215. }
  216. }
  217. .info-box{
  218. box-sizing: border-box;
  219. padding: 20upx 20upx 30upx;
  220. display: flex;
  221. flex-direction: column;
  222. justify-content: space-between;
  223. position: relative;
  224. .title{
  225. font-size: 26upx;
  226. font-family: PingFang SC;
  227. font-weight: 500;
  228. color: #111111;
  229. line-height: 40upx;
  230. }
  231. .sku{
  232. font-size: 26upx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #BBBBBB;
  236. line-height: 1.1;
  237. }
  238. .price-box{
  239. margin-bottom: 50rpx;
  240. display: flex;
  241. flex-direction: column;
  242. align-items: flex-start;
  243. .now{
  244. display: flex;
  245. align-items: flex-end;
  246. margin-bottom: 5upx;
  247. .unit{
  248. font-size: 24upx;
  249. font-family: PingFang SC;
  250. font-weight: 500;
  251. color: #FF6633;
  252. line-height: 1.2;
  253. margin-right: 4upx;
  254. }
  255. .num{
  256. font-size: 36upx;
  257. font-family: PingFang SC;
  258. font-weight: bold;
  259. color: #FF6633;
  260. line-height: 1;
  261. }
  262. }
  263. .old{
  264. font-size: 26upx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. text-decoration: line-through;
  268. color: #BBBBBB;
  269. line-height: 1.1;
  270. }
  271. }
  272. .tui-money{
  273. position: absolute;
  274. right:0rpx;
  275. bottom: 15rpx;
  276. font-size: 30upx;
  277. font-family: PingFang SC;
  278. font-weight: bold;
  279. color: #FFF;
  280. background:linear-gradient(to right, #FF6633 , #F11118);
  281. padding: 6rpx 12rpx;
  282. border-radius: 30rpx 0rpx 0rpx 30rpx;
  283. }
  284. }
  285. }
  286. }
  287. </style>