scrollBox.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view>
  3. <view class='index-wrapper' v-if="isShow && fastList.length">
  4. <view class='title acea-row row-between-wrapper'>
  5. <view class='text'>
  6. <view class='name line1'>快速选择</view>
  7. <view class='line1'>诚意推荐品质商品</view>
  8. </view>
  9. <navigator class='more' url="/pages/goods_cate/goods_cate">更多<text class='iconfont icon-jiantou'></text></navigator>
  10. </view>
  11. <view class='scroll-product'>
  12. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  13. <block v-for="(item,index) in fastList" :key='index'>
  14. <view hover-class="none" class='item' @click="gopage('/pages/goods_list/index?sid='+item.id+'&title='+item.cate_name)">
  15. <view class='img-box'>
  16. <image :src='item.pic'></image>
  17. </view>
  18. <view class='pro-info line1'>{{item.cate_name}}</view>
  19. </view>
  20. </block>
  21. </scroll-view>
  22. </view>
  23. </view>
  24. <view class='index-wrapper' v-if="!isShow && isIframe && fastList.length">
  25. <view class='title acea-row row-between-wrapper'>
  26. <view class='text'>
  27. <view class='name line1'>快速选择</view>
  28. <view class='line1'>诚意推荐品质商品</view>
  29. </view>
  30. <navigator class='more' url="/pages/goods_cate/goods_cate">更多<text class='iconfont icon-jiantou'></text></navigator>
  31. </view>
  32. <view class='scroll-product'>
  33. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  34. <block v-for="(item,index) in fastList" :key='index'>
  35. <view hover-class="none" class='item' @click="gopage('/pages/goods_list/index?sid='+item.id+'&title='+item.cate_name)">
  36. <view class='img-box'>
  37. <image :src='item.pic'></image>
  38. </view>
  39. <view class='pro-info line1'>{{item.cate_name}}</view>
  40. </view>
  41. </block>
  42. </scroll-view>
  43. </view>
  44. </view>
  45. <view class='index-wrapper' v-if="isIframe && !fastList.length">
  46. <view class='title acea-row row-between-wrapper'>
  47. <view class='text'>
  48. <view class='name line1'>快速选择</view>
  49. <view class='line1'>诚意推荐品质商品</view>
  50. </view>
  51. <navigator class='more' url="/pages/goods_cate/goods_cate">更多<text class='iconfont icon-jiantou'></text></navigator>
  52. </view>
  53. <view class='scroll-product'>
  54. <view class="empty-img">快速选择,暂无数据</view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. let app = getApp()
  61. // import {
  62. // mapState
  63. // } from 'vuex'
  64. import {
  65. goPage
  66. } from '@/libs/order.js'
  67. import {
  68. category
  69. } from '@/api/api.js';
  70. export default {
  71. name: 'scrollBox',
  72. props: {
  73. dataConfig: {
  74. type: Object,
  75. default: () => {}
  76. }
  77. },
  78. watch: {
  79. dataConfig: {
  80. immediate: true,
  81. handler(nVal, oVal) {
  82. if(nVal){
  83. this.numConfig = nVal.numConfig.val;
  84. this.isShow = nVal.isShow.val;
  85. this.tabConfig = nVal.tabConfig?nVal.tabConfig.tabVal:0;
  86. this.selectConfig = nVal.selectConfig.activeValue;
  87. if (this.tabConfig) {
  88. this.fastList = nVal.goodsList.list
  89. } else {
  90. this.category();
  91. }
  92. }
  93. }
  94. }
  95. },
  96. created() {
  97. },
  98. mounted() {
  99. },
  100. data() {
  101. return {
  102. fastInfo: '上百种商品分类任您选择',
  103. fastList: [],
  104. name: this.$options.name,
  105. isShow: true,
  106. isIframe: app.globalData.isIframe,
  107. numConfig: 0,
  108. selectConfig: 0,
  109. tabConfig: 0
  110. }
  111. },
  112. methods: {
  113. gopage(url) {
  114. goPage().then(res => {
  115. uni.navigateTo({
  116. url: url,
  117. });
  118. })
  119. },
  120. category() {
  121. category({
  122. pid: this.selectConfig,
  123. limit: this.numConfig
  124. }).then(res => {
  125. this.fastList = res.data;
  126. });
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. .scroll-product {
  133. white-space: nowrap;
  134. margin-top: 38rpx;
  135. padding: 0 30rpx 37rpx 30rpx;
  136. }
  137. .scroll-product .item {
  138. width: 180rpx;
  139. display: inline-block;
  140. margin-right: 19rpx;
  141. border-bottom: 4rpx solid #47b479;
  142. box-shadow: 0 40rpx 30rpx -10rpx #eee;
  143. }
  144. .scroll-product .item:nth-of-type(3n) {
  145. border-bottom: 4rpx solid #ff6960;
  146. }
  147. .scroll-product .item:nth-of-type(3n-1) {
  148. border-bottom: 4rpx solid #579afe;
  149. }
  150. .scroll-product .item:nth-last-child(1) {
  151. margin-right: 0;
  152. }
  153. .scroll-product .item .img-box {
  154. width: 100%;
  155. height: 180rpx;
  156. }
  157. .scroll-product .item .img-box image {
  158. width: 100%;
  159. height: 100%;
  160. border-radius: 6rpx 6rpx 0 0;
  161. }
  162. .scroll-product .item .pro-info {
  163. font-size: 24rpx;
  164. color: #282828;
  165. text-align: center;
  166. height: 60rpx;
  167. line-height: 60rpx;
  168. border: 1rpx solid #f5f5f5;
  169. border-bottom: 0;
  170. border-top: 0;
  171. padding: 0 10rpx;
  172. }
  173. .empty-img {
  174. width: 690rpx;
  175. height: 300rpx;
  176. border-radius: 14rpx;
  177. margin: 26rpx auto 0 auto;
  178. background-color: #ccc;
  179. text-align: center;
  180. line-height: 300rpx;
  181. .iconfont{
  182. font-size: 50rpx;
  183. }
  184. }
  185. </style>