ranking.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view :style="[boxStyle]">
  3. <view class="pt-24 pb-24 pl-24" :style="[boxContentStyle]" @tap="goRank">
  4. <view class="flex-between-center pr-24">
  5. <text class="fs-32 fw-500" :style="[titleStyle]" v-if="titleConfig">{{titleTxtConfig}}</text>
  6. <image :src="titleImg" class="w-102 h-32" v-else></image>
  7. <text class="fs-24 text--w111-999" :style="[headerBntColor]">
  8. {{headerBtnText}} <text class="iconfont icon-ic_rightarrow fs-24" :style="[headerBntColor]"></text>
  9. </text>
  10. </view>
  11. <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-full mt-32"
  12. show-scrollbar="false" v-if="styleConfig == 0">
  13. <view class="inline-block mr-20">
  14. <view class="rank-card" :style="[rankCardStyle]">
  15. <view class="fs-28 lh-40rpx fw-600 flex-y-center" :style="[rankItemTitleStyle]">
  16. <text class="iconfont icon-ic_fire fs-32"></text>
  17. <text class="pl-8 font-color" :style="[rankItemTitleStyle]">{{ $t(`销量榜`) }}</text>
  18. </view>
  19. <view class="rd-12rpx bg--w111-fff mt-18 p-14 h-400" v-if="sales.length">
  20. <view class="rank-pro-item flex-y-center" v-for="(item,index) in sales" :key="index">
  21. <view class="w-108 h-108 relative">
  22. <easy-loadimage
  23. :image-src="item.image"
  24. width="108rpx"
  25. height="108rpx"
  26. :borderRadius="imgStyle"></easy-loadimage>
  27. <view class="rank_count fs-24 text--w111-fff flex-center" :class="'rank-count' + (index + 1)">{{index + 1}}</view>
  28. </view>
  29. <view class="pl-16">
  30. <view class="w-130 line1 fs-26 lh-36rpx mb-8">{{item.store_name}}</view>
  31. <baseMoney :money="item.price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="inline-block mr-20">
  38. <view class="rank-card" :style="[rankCardStyle]">
  39. <view class="fs-28 lh-40rpx fw-600 flex-y-center" :style="[rankItemTitleStyle]">
  40. <text class="iconfont icon-ic_fire fs-32"></text>
  41. <text class="pl-8 font-color" :style="[rankItemTitleStyle]">{{ $t(`收藏榜`) }}</text>
  42. </view>
  43. <view class="rd-12rpx bg--w111-fff mt-18 p-14 h-400" v-if="collect.length">
  44. <view class="rank-pro-item flex-y-center" v-for="(item,index) in collect" :key="index">
  45. <view class="w-108 h-108 relative">
  46. <easy-loadimage
  47. :image-src="item.image"
  48. width="108rpx"
  49. height="108rpx"
  50. :borderRadius="imgStyle"></easy-loadimage>
  51. <view class="rank_count fs-24 text--w111-fff flex-center" :class="'rank-count' + (index + 1)">{{index + 1}}</view>
  52. </view>
  53. <view class="pl-16">
  54. <view class="w-130 line1 fs-26 lh-36rpx mb-8">{{item.store_name}}</view>
  55. <baseMoney :money="item.price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="inline-block mr-20">
  62. <view class="rank-card" :style="[rankCardStyle]">
  63. <view class="fs-28 lh-40rpx fw-600 flex-y-center" :style="[rankItemTitleStyle]">
  64. <text class="iconfont icon-ic_fire fs-32"></text>
  65. <text class="pl-8 font-color" :style="[rankItemTitleStyle]">{{ $t(`好评榜`) }}</text>
  66. </view>
  67. <view class="rd-12rpx bg--w111-fff mt-18 p-14 h-400" v-if="star.length">
  68. <view class="rank-pro-item flex-y-center" v-for="(item,index) in star" :key="index">
  69. <view class="w-108 h-108 relative">
  70. <easy-loadimage
  71. :image-src="item.image"
  72. width="108rpx"
  73. height="108rpx"
  74. :borderRadius="imgStyle"></easy-loadimage>
  75. <view class="rank_count fs-24 text--w111-fff flex-center" :class="'rank-count' + (index + 1)">{{index + 1}}</view>
  76. </view>
  77. <view class="pl-16">
  78. <view class="w-130 line1 fs-26 lh-36rpx mb-8">{{item.store_name}}</view>
  79. <baseMoney :money="item.price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </scroll-view>
  86. <view class="mt-26" v-else>
  87. <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-full mt-20"
  88. show-scrollbar="false" >
  89. <view class="inline-block type-3 rd-16rpx mr-24" :style="[rankCardStyle]" v-if="sales.length">
  90. <view class="fs-26 fw-500" :style="[rankItemTitleStyle]">{{ $t(`销量榜`) }}</view>
  91. <view class="flex mt-20">
  92. <view class="w-296 h-296 relative mr-12">
  93. <image :src="sales[0].image" class="w-full h-full" :style="{borderRadius:imgStyle}"></image>
  94. <image class="abs-lt w-72 h-72" :src="`${imgHost}/statics/images/rank_icon1.png`"></image>
  95. </view>
  96. <view>
  97. <view class="relative">
  98. <easy-loadimage
  99. :image-src="sales[1].image"
  100. width="142rpx"
  101. height="142rpx"
  102. :borderRadius="imgStyle"></easy-loadimage>
  103. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon2.png`"></image>
  104. </view>
  105. <view class="w-142 h-142 relative mt-12">
  106. <easy-loadimage
  107. :image-src="sales[2].image"
  108. width="142rpx"
  109. height="142rpx"
  110. :borderRadius="imgStyle"></easy-loadimage>
  111. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon3.png`"></image>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="mt-20 fs-26 w-280 line1">{{sales[0].store_name}}</view>
  116. <view class="flex items-baseline mt-10">
  117. <baseMoney :money="sales[0].price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  118. <text class="fs-20 text--w111-999 text-line pl-8">{{ $t(`¥`) }}{{sales[0].ot_price}}</text>
  119. </view>
  120. </view>
  121. <view class="inline-block type-3 rd-16rpx mr-24" :style="[rankCardStyle]" v-if="star.length">
  122. <view class="fs-26 fw-500" :style="[rankItemTitleStyle]">{{ $t(`好评榜`) }}</view>
  123. <view class="flex mt-20">
  124. <view class="w-296 h-296 relative mr-12">
  125. <image :src="star[0].image" class="w-full h-full" :style="{borderRadius:imgStyle}"></image>
  126. <image class="abs-lt w-72 h-72" :src="`${imgHost}/statics/images/rank_icon1.png`"></image>
  127. </view>
  128. <view>
  129. <view class="w-142 h-142 relative">
  130. <easy-loadimage
  131. :image-src="star[1].image"
  132. width="142rpx"
  133. height="142rpx"
  134. :borderRadius="imgStyle"></easy-loadimage>
  135. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon2.png`"></image>
  136. </view>
  137. <view class="w-142 h-142 relative mt-12">
  138. <easy-loadimage
  139. :image-src="star[2].image"
  140. width="142rpx"
  141. height="142rpx"
  142. :borderRadius="imgStyle"></easy-loadimage>
  143. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon3.png`"></image>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="mt-20 fs-26 w-280 line1">{{star[0].store_name}}</view>
  148. <view class="flex items-baseline mt-10">
  149. <baseMoney :money="star[0].price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  150. <text class="fs-20 text--w111-999 text-line pl-8">{{ $t(`¥`) }}{{star[0].ot_price}}</text>
  151. </view>
  152. </view>
  153. <view class="inline-block type-3 rd-16rpx mr-24" :style="[rankCardStyle]" v-if="collect.length">
  154. <view class="fs-26 fw-500" :style="[rankItemTitleStyle]">{{ $t(`收藏榜`) }}</view>
  155. <view class="flex mt-20">
  156. <view class="w-296 h-296 relative mr-12">
  157. <image :src="collect[0].image" class="w-full h-full" :style="{borderRadius:imgStyle}"></image>
  158. <image class="abs-lt w-72 h-72" :src="`${imgHost}/statics/images/rank_icon1.png`"></image>
  159. </view>
  160. <view>
  161. <view class="w-142 h-142 relative">
  162. <easy-loadimage
  163. :image-src="collect[1].image"
  164. width="142rpx"
  165. height="142rpx"
  166. :borderRadius="imgStyle"></easy-loadimage>
  167. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon2.png`"></image>
  168. </view>
  169. <view class="w-142 h-142 relative mt-12">
  170. <easy-loadimage
  171. :image-src="collect[2].image"
  172. width="142rpx"
  173. height="142rpx"
  174. :borderRadius="imgStyle"></easy-loadimage>
  175. <image class="abs-lt w-48 h-48" :src="`${imgHost}/statics/images/rank_icon3.png`"></image>
  176. </view>
  177. </view>
  178. </view>
  179. <view class="mt-20 fs-26 w-280 line1">{{collect[0].store_name}}</view>
  180. <view class="flex items-baseline mt-10">
  181. <baseMoney :money="collect[0].price" symbolSize="20" integerSize="28" decimalSize="28" :color="priceColor" weight></baseMoney>
  182. <text class="fs-20 text--w111-999 text-line pl-8">{{ $t(`¥`) }}{{collect[0].ot_price}}</text>
  183. </view>
  184. </view>
  185. </scroll-view>
  186. </view>
  187. </view>
  188. </view>
  189. </template>
  190. <script>
  191. import { HTTP_REQUEST_URL } from '@/config/app';
  192. import { diyRankApi } from "@/api/activity.js"
  193. export default {
  194. name:'ranking',
  195. props:{
  196. dataConfig: {
  197. type: Object,
  198. default: () => {}
  199. },
  200. },
  201. data(){
  202. return {
  203. imgHost: HTTP_REQUEST_URL,
  204. collect:[],
  205. sales:[],
  206. star:[]
  207. }
  208. },
  209. computed:{
  210. titleStyle(){
  211. let titleText = this.dataConfig.titleText
  212. return {
  213. fontStyle: !titleText.tabVal?'normal':titleText.tabList[titleText.tabVal].style,
  214. fontWeight: !titleText.tabVal?'bold':'normal',
  215. color: this.dataConfig.titleColor.color[0].item,
  216. fontSize: this.dataConfig.titleNumber.val*2+'rpx'
  217. }
  218. },
  219. boxStyle(){
  220. return {
  221. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  222. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  223. background: this.dataConfig.bottomBgColor.color[0].item,
  224. }
  225. },
  226. boxContentStyle() {
  227. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  228. if (this.dataConfig.fillet.type) {
  229. borderRadius =
  230. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx`;
  231. }
  232. return {
  233. borderRadius,
  234. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  235. };
  236. },
  237. styleConfig(){
  238. return this.dataConfig.styleConfig.tabVal
  239. },
  240. /*标题是文本还是图片*/
  241. titleConfig(){
  242. return this.dataConfig.titleConfig.tabVal
  243. },
  244. /*标题文本*/
  245. titleTxtConfig(){
  246. return this.dataConfig.titleTxtConfig.value
  247. },
  248. /*标题图片*/
  249. titleImg(){
  250. return this.dataConfig.imgConfig.url
  251. },
  252. /*卡片颜色和圆角*/
  253. rankCardStyle(){
  254. let filletBg = this.dataConfig.filletBg.type;
  255. let valListBg = this.dataConfig.filletBg.valList;
  256. let filletValBg = this.dataConfig.filletBg.val;
  257. return {
  258. borderRadius: filletBg ? valListBg[0].val+ 'px ' +valListBg[1].val+ 'px ' + valListBg[3].val + 'px ' + valListBg[2].val +'px': filletValBg +'px',
  259. background: `linear-gradient(172deg, ${this.dataConfig.listBgColor.color[0].item} 0%, ${this.dataConfig.listBgColor.color[1].item} 100%)`
  260. }
  261. },
  262. /*商品图片圆角样式*/
  263. imgStyle(){
  264. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  265. if (this.dataConfig.filletImg.type) {
  266. borderRadius =
  267. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx`;
  268. }
  269. return borderRadius
  270. },
  271. rankItemTitleStyle(){
  272. return {
  273. color: this.dataConfig.toneConfig.tabVal ? `${this.dataConfig.classColor.color[0].item} !important` : 'var(--view-theme) !important'
  274. }
  275. },
  276. /* 价格颜色 */
  277. priceColor(){
  278. return this.dataConfig.toneConfig.tabVal ? this.dataConfig.goodsPriceColor.color[0].item : 'var(--view-theme)'
  279. },
  280. /*头部按钮样式*/
  281. headerBntColor(){
  282. return {
  283. color: this.dataConfig.headerBntColor.color[0].item,
  284. fontSize: `${this.dataConfig.bntNumber.val * 2}rpx`
  285. }
  286. },
  287. headerBtnText(){
  288. return this.dataConfig.rightBntConfig.value
  289. }
  290. },
  291. mounted() {
  292. this.getList();
  293. },
  294. methods:{
  295. getList(){
  296. diyRankApi().then(res=>{
  297. this.collect = res.data.collect;
  298. this.sales = res.data.sales;
  299. this.star = res.data.star;
  300. })
  301. },
  302. goRank(){
  303. uni.navigateTo({
  304. url:'/pages/columnGoods/rank/index'
  305. })
  306. }
  307. }
  308. }
  309. </script>
  310. <style>
  311. .rank-card {
  312. width: 372rpx;
  313. padding: 22rpx 16rpx 18rpx;
  314. }
  315. .rank_count{
  316. width:30rpx;
  317. height:32rpx;
  318. position: absolute;
  319. top:0;
  320. left:0;
  321. background-size: cover;
  322. }
  323. .rank-count1{
  324. background-image:url('@/static/images/rank1_icon.png');
  325. }
  326. .rank-count2{
  327. background-image:url('@/static/images/rank2_icon.png');
  328. }
  329. .rank-count3{
  330. background-image:url('@/static/images/rank3_icon.png');
  331. }
  332. .type-3{
  333. padding: 20rpx 36rpx 20rpx 18rpx;
  334. }
  335. .rank-pro-item ~ .rank-pro-item{
  336. margin-top: 16rpx;
  337. }
  338. </style>