scrollBox.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view>
  3. <view class='index-wrapper skeleton-rect' v-if="isShow && fastList.length">
  4. <view class='title acea-row row-between-wrapper'>
  5. <view class='text'>
  6. <view class='name line1'>{{$t(titleInfo[0].val)}}</view>
  7. <view class='line1 txt-btn'>{{$t(titleInfo[1].val)}}</view>
  8. </view>
  9. <navigator class='more' open-type="switchTab" :url="titleInfo[2].val">{{$t(`更多`)}}<text
  10. class='iconfont icon-jiantou'></text></navigator>
  11. </view>
  12. <view class='scroll-product'>
  13. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  14. <block v-for="(item,index) in fastList" :key='index'>
  15. <view hover-class="none" class='item'
  16. @click="gopage('/pages/goods/goods_list/index?sid='+item.id+'&title='+item.cate_name)">
  17. <view class='img-box'>
  18. <easy-loadimage mode="widthFix" :image-src="item.pic"></easy-loadimage>
  19. </view>
  20. <view class='pro-info line1'>{{$t(item.cate_name)}}</view>
  21. </view>
  22. </block>
  23. </scroll-view>
  24. </view>
  25. </view>
  26. <view class='index-wrapper' v-if="!isShow && isIframe && fastList.length">
  27. <view class='title acea-row row-between-wrapper'>
  28. <view class='text'>
  29. <view class='name line1'>{{titleInfo[0].val}}</view>
  30. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  31. </view>
  32. <navigator class='more' open-type="switchTab" :url="titleInfo[2].val">{{$t(`更多`)}}<text
  33. class='iconfont icon-jiantou'></text></navigator>
  34. </view>
  35. <view class='scroll-product'>
  36. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  37. <block v-for="(item,index) in fastList" :key='index'>
  38. <view hover-class="none" class='item'
  39. @click="gopage('/pages/goods/goods_list/index?sid='+item.id+'&title='+item.cate_name)">
  40. <view class='img-box'>
  41. <image :src='item.pic'></image>
  42. </view>
  43. <view class='pro-info line1'>{{item.cate_name}}</view>
  44. </view>
  45. </block>
  46. </scroll-view>
  47. </view>
  48. </view>
  49. <view class='index-wrapper' v-if="isIframe && !fastList.length">
  50. <view class='title acea-row row-between-wrapper'>
  51. <view class='text'>
  52. <view class='name line1'>{{titleInfo[0].val}}</view>
  53. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  54. </view>
  55. <navigator class='more' open-type="switchTab" :url="titleInfo[2].val">{{$t(`更多`)}}<text
  56. class='iconfont icon-jiantou'></text></navigator>
  57. </view>
  58. <view class='scroll-product'>
  59. <view class="empty-img">{{$t(`快速选择,暂无数据`)}}</view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. let app = getApp()
  66. // import {
  67. // mapState
  68. // } from 'vuex'
  69. import {
  70. goPage
  71. } from '@/libs/order.js'
  72. import {
  73. category
  74. } from '@/api/api.js';
  75. export default {
  76. name: 'scrollBox',
  77. props: {
  78. dataConfig: {
  79. type: Object,
  80. default: () => {}
  81. }
  82. },
  83. watch: {
  84. dataConfig: {
  85. immediate: true,
  86. handler(nVal, oVal) {
  87. if (nVal) {
  88. this.numConfig = nVal.numConfig.val;
  89. this.isShow = nVal.isShow.val;
  90. this.tabConfig = nVal.tabConfig ? nVal.tabConfig.tabVal : 0;
  91. this.selectConfig = nVal.selectConfig.activeValue || '';
  92. this.titleInfo = nVal.titleInfo.list;
  93. if (this.tabConfig) {
  94. this.fastList = nVal.goodsList.list
  95. } else {
  96. this.category();
  97. }
  98. }
  99. }
  100. }
  101. },
  102. created() {},
  103. mounted() {},
  104. data() {
  105. return {
  106. fastInfo: this.$t(`上百种商品分类任您选择`),
  107. fastList: [],
  108. name: this.$options.name,
  109. isShow: true,
  110. isIframe: app.globalData.isIframe,
  111. numConfig: 0,
  112. selectConfig: 0,
  113. tabConfig: 0,
  114. titleInfo: []
  115. }
  116. },
  117. methods: {
  118. gopage(url) {
  119. goPage().then(res => {
  120. uni.navigateTo({
  121. url: url,
  122. });
  123. })
  124. },
  125. category() {
  126. category({
  127. pid: this.selectConfig,
  128. limit: this.numConfig
  129. }).then(res => {
  130. this.fastList = res.data;
  131. });
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss">
  137. .index-wrapper {
  138. background-color: $uni-bg-color;
  139. margin: $uni-index-margin-row $uni-index-margin-col;
  140. border-radius: $uni-border-radius-index;
  141. // box-shadow: $uni-index-box-shadow;
  142. }
  143. .text {
  144. display: flex;
  145. .name {
  146. font-size: $uni-index-title-font-size;
  147. font-weight: bold;
  148. }
  149. .txt-btn {
  150. display: flex;
  151. align-items: flex-end;
  152. margin-bottom: 8rpx;
  153. margin-left: 12rpx;
  154. }
  155. }
  156. .scroll-product {
  157. white-space: nowrap;
  158. margin-top: 30rpx;
  159. padding: 0 20rpx 20rpx 20rpx;
  160. }
  161. .scroll-product .item {
  162. display: inline-block;
  163. margin-right: 24rpx;
  164. border-radius: 0 0 10rpx 10rpx;
  165. // box-shadow: 0 40rpx 30rpx -10rpx #eee;
  166. // background: linear-gradient(180deg, #fff 0%, #fff 30%, rgba(255, 96, 16, 0.2) 100%);
  167. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 207, 183, 0.65) 100%);
  168. color: #FF7E00;
  169. }
  170. .scroll-product .item:nth-of-type(3n) {
  171. color: #1DB0FC;
  172. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(187, 221, 255, 0.65) 100%);
  173. }
  174. .scroll-product .item:nth-of-type(3n-1) {
  175. color: #FF448F;
  176. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(253, 199, 255, 0.65) 100%);
  177. }
  178. .scroll-product .item:nth-last-child(1) {
  179. margin-right: 0;
  180. }
  181. .scroll-product .item .img-box {
  182. width: 160rpx;
  183. height: 160rpx;
  184. margin: 0 10rpx;
  185. border-radius: 10px;
  186. }
  187. .scroll-product .item .img-box image {
  188. width: 100%;
  189. height: 100%;
  190. border-radius: 10rpx;
  191. }
  192. .scroll-product .item .img-box {
  193. /deep/,
  194. /deep/image,
  195. /deep/.easy-loadimage,
  196. /deep/uni-image {
  197. width: 160rpx;
  198. height: 160rpx;
  199. border-radius: 10rpx;
  200. }
  201. }
  202. .scroll-product .item .pro-info {
  203. max-width: 180rpx;
  204. font-size: 24rpx;
  205. text-align: center;
  206. height: 60rpx;
  207. line-height: 60rpx;
  208. border-bottom: 0;
  209. border-top: 0;
  210. padding: 0 10rpx;
  211. font-weight: bold;
  212. }
  213. .empty-img {
  214. height: 300rpx;
  215. border-radius: 14rpx;
  216. margin: 26rpx auto 0 auto;
  217. background-color: #ccc;
  218. text-align: center;
  219. line-height: 300rpx;
  220. .iconfont {
  221. font-size: 50rpx;
  222. }
  223. }
  224. .more {
  225. color: #999;
  226. font-size: 24rpx;
  227. }
  228. </style>