shortVideo.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view :style="[shortVideoWrapStyle]" v-if="videoList.length">
  3. <view class="shortVideo" :style="[shortVideoStyle]">
  4. <view class="nav acea-row row-between-wrapper" :style="[navStyle]">
  5. <view v-if="dataConfig.titleConfig.tabVal" class="title" :style="[titleStyle]">{{ dataConfig.titleTxtConfig.value }}</view>
  6. <easy-loadimage v-else mode="widthFix" :image-src="dataConfig.imgConfig.url" width="104rpx" height="32rpx"></easy-loadimage>
  7. <view class="more" :style="[buttonStyle]" @click="more(0)">
  8. {{ dataConfig.rightBntConfig.value }}
  9. <text class="iconfont icon-ic_rightarrow" :style="[buttonStyle]"></text>
  10. </view>
  11. </view>
  12. <view v-if="dataConfig.styleConfig.tabVal" class="list" :style="[listStyle]">
  13. <scroll-view scroll-x="true" class="scroll" show-scrollbar="false">
  14. <view class="item" v-for="item in videoList" :key="item.id" @click="more(item.id)" :style="[itemStyle]">
  15. <easy-loadimage mode="widthFix" :image-src="item.image" width="226rpx" height="300rpx" :borderRadius="imageRadius"></easy-loadimage>
  16. </view>
  17. </scroll-view>
  18. </view>
  19. <view v-else class="list-column" :style="[listStyle]">
  20. <view class="item acea-row" v-for="item in videoList" :key="item.id" :style="[itemStyle]" @click="more(item.id)">
  21. <easy-loadimage mode="widthFix" :image-src="item.image" width="226rpx" height="300rpx" :borderRadius="imageRadius"></easy-loadimage>
  22. <view class="text acea-row row-column">
  23. <view class="conter">
  24. <view class="header acea-row row-middle">
  25. <easy-loadimage mode="widthFix" :image-src="item.type_image" width="36rpx" height="36rpx" borderRadius="18rpx"></easy-loadimage>
  26. <view class="name line1">{{ item.type_name }}</view>
  27. </view>
  28. <view class="info line2">{{ item.desc }}</view>
  29. </view>
  30. <view class="goodsList acea-row row-middle">
  31. <template v-for="(goodsItem, index) in item.product_info">
  32. <view v-if="index < 3" :key="goodsItem.id" class="pictrue" @click.stop="goGoods(goodsItem.id)">
  33. <easy-loadimage mode="widthFix" :image-src="goodsItem.image" width="128rpx" height="128rpx" borderRadius="8rpx"></easy-loadimage>
  34. <view v-if="index < 2" class="money acea-row row-center-wrapper">
  35. <text>¥{{ goodsItem.price }}</text>
  36. </view>
  37. <view v-else class="num acea-row row-center-wrapper">
  38. <text>+{{ item.product_num - 2 }}</text>
  39. </view>
  40. </view>
  41. </template>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. diyVideoList
  52. } from '@/api/short-video.js';
  53. export default {
  54. name: 'shortVideo',
  55. props: {
  56. dataConfig: {
  57. type: Object,
  58. default: () => {}
  59. },
  60. isSortType: {
  61. type: String | Number,
  62. default: 0
  63. }
  64. },
  65. data() {
  66. return {
  67. videoList: [],
  68. bgColor: '',
  69. titleColor: '',
  70. infoColor: '',
  71. mbCongfig: 0,
  72. prConfig: 0, //背景边距
  73. // itemStyle: 0,
  74. numConfig: 0
  75. }
  76. },
  77. computed: {
  78. navStyle() {
  79. return {
  80. 'background': `linear-gradient(90deg, ${this.dataConfig.headerBgColor.color[0].item} 0%, ${this.dataConfig.headerBgColor.color[1].item} 100%)`,
  81. };
  82. },
  83. titleStyle() {
  84. let fontStyle = 'normal';
  85. let fontWeight = 'normal';
  86. switch (this.dataConfig.titleText.tabVal) {
  87. case 0:
  88. fontWeight = 'bold'
  89. break;
  90. case 2:
  91. fontStyle = 'italic'
  92. fontWeight = 'bold'
  93. break;
  94. }
  95. return {
  96. 'font-style': fontStyle,
  97. 'font-style': fontWeight,
  98. 'font-size': `${this.dataConfig.titleNumber.val * 2}rpx`,
  99. };
  100. },
  101. buttonStyle() {
  102. return {
  103. 'font-size': `${this.dataConfig.bntNumber.val * 2}rpx`,
  104. 'color': this.dataConfig.headerBntColor.color[0].item,
  105. };
  106. },
  107. itemStyle() {
  108. let marginTop = 0;
  109. let marginLeft = 0;
  110. let marginRight = 0;
  111. if (this.dataConfig.styleConfig.tabVal) {
  112. marginLeft = `${this.dataConfig.videoSpace2.val * 2}rpx`;
  113. marginRight = `${this.dataConfig.videoSpace2.val * 2}rpx`;
  114. } else {
  115. marginTop = `${this.dataConfig.videoSpace.val * 2}rpx`;
  116. }
  117. return {
  118. 'margin-top': marginTop,
  119. 'margin-left': marginRight,
  120. 'margin-right': marginRight,
  121. };
  122. },
  123. itemLastStyle() {
  124. let marginRight = 0;
  125. if (this.dataConfig.styleConfig.tabVal) {
  126. marginRight = `${this.dataConfig.videoSpace2.val * 2}rpx`;
  127. }
  128. return {
  129. 'margin-right': marginRight,
  130. };
  131. },
  132. imageRadius() {
  133. let borderRadius = [`${this.dataConfig.filletImg.val * 2}rpx`];
  134. if (this.dataConfig.filletImg.type) {
  135. borderRadius = [];
  136. for (let i = 0; i < this.dataConfig.filletImg.valList.length; i++) {
  137. borderRadius.push(`${this.dataConfig.filletImg.valList[i].val * 2}rpx`);
  138. }
  139. }
  140. return borderRadius.join(' ');
  141. },
  142. shortVideoWrapStyle() {
  143. return {
  144. 'padding': `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  145. 'margin-top': `${this.dataConfig.mbConfig.val * 2}rpx`,
  146. };
  147. },
  148. shortVideoStyle() {
  149. let borderRadius = [`${this.dataConfig.fillet.val * 2}rpx`];
  150. if (this.dataConfig.fillet.type) {
  151. borderRadius = [];
  152. for (let i = 0; i < this.dataConfig.fillet.valList.length; i++) {
  153. borderRadius.push(`${this.dataConfig.fillet.valList[i].val * 2}rpx`);
  154. }
  155. }
  156. return {
  157. 'border-radius': borderRadius,
  158. };
  159. },
  160. listStyle() {
  161. return {
  162. 'background': `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  163. };
  164. },
  165. },
  166. created() {},
  167. mounted() {
  168. this.getVideoList();
  169. },
  170. methods: {
  171. getVideoList: function() {
  172. let that = this;
  173. let limit = this.$config.LIMIT;
  174. diyVideoList({
  175. page: 1,
  176. limit: this.dataConfig.numberConfig.val >= limit ? limit : this.dataConfig.numberConfig.val
  177. }).then(res => {
  178. that.videoList = res.data;
  179. });
  180. },
  181. more(id) {
  182. uni.navigateTo({
  183. //#ifdef APP
  184. url: '/pages/short_video/appSwiper/index?id=' + id,
  185. //#endif
  186. //#ifndef APP
  187. url: '/pages/short_video/nvueSwiper/index?id=' + id,
  188. //#endif
  189. })
  190. },
  191. goGoods(id) {
  192. uni.navigateTo({
  193. url: `/pages/goods_details/index?id=${id}`
  194. });
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. .shortVideo {
  201. overflow: hidden;
  202. .nav {
  203. width: 100%;
  204. padding: 0 24rpx;
  205. height: 96rpx;
  206. background: linear-gradient(270deg, #FFFFFF 0%, #FFFFFF 100%);
  207. .title {
  208. font-weight: 500;
  209. font-size: 32rpx;
  210. color: #333333;
  211. }
  212. .more {
  213. font-size: 24rpx;
  214. color: #999999;
  215. .iconfont {
  216. font-size: 24rpx;
  217. }
  218. }
  219. }
  220. .list {
  221. padding: 24rpx 0;
  222. border-radius: 0rpx 0rpx 16rpx 16rpx;
  223. background: #FFFFFF;
  224. .scroll {
  225. white-space: nowrap;
  226. }
  227. .item {
  228. display: inline-block;
  229. margin: 0 24rpx;
  230. +.item {
  231. margin-left: 0 !important;
  232. }
  233. .text {
  234. flex: 1;
  235. }
  236. }
  237. }
  238. .list-column {
  239. padding: 32rpx 20rpx;
  240. background: #FFFFFF;
  241. .item {
  242. margin-top: 40rpx;
  243. &:first-child {
  244. margin-top: 0 !important;
  245. }
  246. }
  247. .text {
  248. flex: 1;
  249. padding-left: 20rpx;
  250. }
  251. .conter {
  252. flex: 1;
  253. }
  254. .pictrue {
  255. position: relative;
  256. }
  257. .goodsList {
  258. margin-right: -20rpx;
  259. }
  260. .goodsList .pictrue {
  261. margin-right: 20rpx;
  262. }
  263. .name {
  264. margin-left: 10rpx;
  265. font-weight: 500;
  266. font-size: 28rpx;
  267. color: #333333;
  268. }
  269. .info {
  270. margin-top: 20rpx;
  271. font-size: 24rpx;
  272. line-height: 28rpx;
  273. color: #666666;
  274. }
  275. .money {
  276. position: absolute;
  277. bottom: 0;
  278. left: 0;
  279. width: 100%;
  280. height: 46rpx;
  281. padding: 10rpx 0 6rpx;
  282. border-radius: 0rpx 0rpx 8rpx 8rpx;
  283. background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
  284. font-size: 22rpx;
  285. color: #FFFFFF;
  286. }
  287. .num {
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. width: 100%;
  292. height: 100%;
  293. border-radius: 8rpx 8rpx 8rpx 8rpx;
  294. background: rgba(0, 0, 0, 0.3);
  295. font-size: 30rpx;
  296. color: #FFFFFF;
  297. }
  298. }
  299. }
  300. </style>