index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="content">
  3. <view class="rank_header" :style="{ 'background-image': `url(${domain}/static/images/rank_header.png)`}">
  4. <view class="cate_name">
  5. <text class="name line1">
  6. <text class="title_icon icon_left" :style="{ 'background-image': `url(${domain}/static/images/rank-title.png)`}"></text>
  7. {{(active == 0 || !cate_name) ? '热销TOP总榜单' : `${cate_name}热卖榜`}}
  8. <text class="title_icon icon_right" :style="{ 'background-image': `url(${domain}/static/images/rank-title.png)`}"></text>
  9. </text>
  10. </view>
  11. <view class="scroll_box">
  12. <scroll-view scroll-x="true" style="white-space: nowrap; vertical-align: middle;" show-scrollbar="false"
  13. :scroll-left="tabLeft">
  14. <view class="scroll_item"
  15. v-for="(item,index) in categoryList"
  16. :key="item.store_category_id"
  17. :id="`cate${item.store_category_id}`"
  18. :data-index="item.store_category_id"
  19. @click="checkActive(item,index,true)"
  20. :class="active == item.store_category_id ? 'scroll_item_active' : ''">{{item.cate_name}}
  21. </view>
  22. </scroll-view>
  23. </view>
  24. </view>
  25. <view class="rank_list pad30">
  26. <swiper :interval="interval" indicator-color="rgba(255,255,255,0.6)" :current="swiperCurrent" @change="swiperChange" :style="'height:'+swiperHeight+'px;'" >
  27. <block v-for="(item,index) in categoryList" :key="item.store_category_id">
  28. <swiper-item :item-id="`${item.store_category_id}`">
  29. <scroll-view scroll-y="true" :style="'height:'+swiperHeight+'px'" id="goods">
  30. <view class='item acea-row' v-for="(itm,idx) in spuTopList" :key="itm.spu_id" @click="godDetail(itm)">
  31. <view class="rank" :class="'rank'+idx"
  32. :style="{'color': idx<3 ? '#CE8F21' : '#986561'}">
  33. {{idx < 9 ? '0'+(idx+1) : idx+1}}
  34. </view>
  35. <view class='pictrue on'>
  36. <image :src='itm.image' class="on"></image>
  37. </view>
  38. <view class='goods-msg pad16 acea-row row-column row-between'>
  39. <text class="name line2">{{itm.store_name}}</text>
  40. <view v-if="itm.sales>0" class="list"><text class="iconfont icon-goumai"></text>{{itm.sales>10000 ? (itm.sales/10000)+'万' : itm.sales}}人买过</view>
  41. <view class="mt-18 acea-row row-bottom">
  42. <BaseMoney :money="itm.price" symbolSize="26" integerSize="36" decimalSize="28"
  43. incolor="E93323" weight />
  44. <BaseMoney :money="itm.ot_price" symbolSize="22" integerSize="22" decimalSize="22"
  45. incolor="999999" class="ml-16" line />
  46. </view>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. </swiper-item>
  51. </block>
  52. </swiper>
  53. <!-- <view class='item acea-row' v-for="(item,index) in spuTopList" :key="item.spu_id" @click="godDetail(item)">
  54. <view class="rank" :class="'rank'+index"
  55. :style="{'color': index<3 ? '#CE8F21' : '#986561'}">
  56. {{index < 9 ? '0'+(index+1) : index+1}}
  57. </view>
  58. <view class='pictrue on'>
  59. <image :src='item.image' class="on"></image>
  60. </view>
  61. <view class='goods-msg pad16 acea-row row-column row-between'>
  62. <text class="name line2">{{item.store_name}}</text>
  63. <view v-if="item.sales>0" class="list"><text class="iconfont icon-goumai"></text>{{item.sales>10000 ? (item.sales/10000)+'万' : item.sales}}人买过</view>
  64. <view class="mt-18 acea-row row-bottom">
  65. <BaseMoney :money="item.price" symbolSize="26" integerSize="36" decimalSize="28"
  66. incolor="E93323" weight />
  67. <BaseMoney :money="item.ot_price" symbolSize="22" integerSize="22" decimalSize="22"
  68. incolor="999999" class="ml-16" line />
  69. </view>
  70. </view>
  71. </view> -->
  72. </view>
  73. <!-- -->
  74. </view>
  75. </template>
  76. <script>
  77. // +----------------------------------------------------------------------
  78. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  79. // +----------------------------------------------------------------------
  80. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  81. // +----------------------------------------------------------------------
  82. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  83. // +----------------------------------------------------------------------
  84. // | Author: CRMEB Team <admin@crmeb.com>
  85. // +----------------------------------------------------------------------
  86. import { spuTop,spuTopList } from '@/api/activity.js';
  87. import { HTTP_REQUEST_URL } from '@/config/app';
  88. export default {
  89. data() {
  90. return {
  91. categoryList: [{
  92. store_category_id: 0,
  93. cate_name: '总榜'
  94. }],
  95. cate_name: "",
  96. spuTopList: [],
  97. active: 0,
  98. pro_top_banner: 'https://zhongbang-1257983696.cos.ap-beijing.myqcloud.com/uploads/def/20220801/383c0026840f70a9b4e33a43c6bd3341.png',
  99. scrollInto: '',
  100. domain: HTTP_REQUEST_URL,
  101. tabClick: 0,
  102. tabLeft: 0,
  103. isLeft: 0, //导航栏下划线位置
  104. isWidth: 0, //每个导航栏占位
  105. windowHeight: 0,
  106. swiperHeight: 0,
  107. swiperCur: 0,
  108. circular: true,
  109. isScroll: false,
  110. interval: 3000,
  111. currentItemId: 0,
  112. swiperCurrent: 0,
  113. }
  114. },
  115. created() {
  116. var that = this;
  117. // 获取设备宽度
  118. uni.getSystemInfo({
  119. success(e) {
  120. that.isWidth = e.windowWidth / 6;
  121. that.windowHeight = e.windowHeight;
  122. // that.swiperHeight = that.windowHeight - 205
  123. that.$set(that, 'swiperHeight', that.windowHeight-150);
  124. }
  125. });
  126. },
  127. onLoad(option) {
  128. this.spuTop(option.cate_id || 0)
  129. if(option.cate_id){
  130. this.active = option.cate_id
  131. }
  132. },
  133. methods: {
  134. spuTop(cate_id) {
  135. spuTop().then(res => {
  136. this.categoryList = [...this.categoryList, ...res.data]
  137. this.cate_name = this.getCate(cate_id,this.categoryList) || ''
  138. this.$nextTick(() => {
  139. this.getSpuTopList(cate_id)
  140. this.active = cate_id && this.cate_name ? cate_id : 0
  141. this.scrollInto = `cate${cate_id}`;
  142. let tabLeft = (this.swiperCur - 2) * this.isWidth; //设置下划线位置
  143. this.$set(this, 'tabLeft', tabLeft);
  144. });
  145. })
  146. },
  147. getSpuTopList(cate_id) {
  148. cate_id = this.cate_name ? cate_id : 0
  149. spuTopList({
  150. cate_pid: cate_id
  151. }).then(res => {
  152. this.spuTopList = (res.data[0] && res.data[0]['list']) || []
  153. })
  154. },
  155. swiperChange(e) {
  156. let { current, source, currentItemId } = e.detail;
  157. // if(this.active){
  158. // if(current == 1){
  159. // current = this.swiperCur+1
  160. // }else if(current == 0){
  161. // current = this.swiperCur-1
  162. // }
  163. // currentItemId = this.categoryList[current]['store_category_id']
  164. // }
  165. if (source === 'autoplay' || source === 'touch') {
  166. this.active = currentItemId;
  167. this.swiperCur = current
  168. this.checkActive(this.categoryList[this.swiperCur],this.swiperCur,false)
  169. if (this.categoryList.length > 6) {
  170. var tempIndex = this.swiperCur - 2;
  171. tempIndex = tempIndex <= 0 ? 0 : tempIndex;
  172. let tabLeft = (this.swiperCur - 2) * this.isWidth; //设置下划线位置
  173. this.$nextTick(function() {
  174. this.$set(this, 'tabLeft', tabLeft);
  175. });
  176. }
  177. }
  178. },
  179. checkActive(item, index, isScroll) {
  180. this.active = item.store_category_id;
  181. this.cate_name = item.cate_name
  182. this.swiperCurrent = index;
  183. this.swiperCur = index
  184. this.isScroll = isScroll;
  185. this.tabClick = index; //设置导航点击了哪一个
  186. this.isLeft = index * this.isWidth; //设置下划线位置
  187. this.spuTopList = [];
  188. this.getSpuTopList(item.store_category_id)
  189. },
  190. // 去商品详情页
  191. godDetail(item) {
  192. uni.navigateTo({
  193. url: "/pages/goods_details/index?id=" + item.product_id
  194. })
  195. },
  196. // 获取第一次进来的默认分类名称
  197. getCate(id,arr){
  198. for (let i = 0; i < arr.length; i++) {
  199. if (arr[i].store_category_id == id) {
  200. this.swiperCur = i
  201. return arr[i]['cate_name']
  202. }
  203. }
  204. },
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .content{
  210. background: #171717;
  211. min-height: 100vh;
  212. }
  213. .rank_header {
  214. background-size: cover;
  215. height: 270rpx;
  216. position: fixed;
  217. top: 0;
  218. left: 0;
  219. display: block;
  220. z-index: 9999;
  221. background-color: #171717;
  222. .cate_name{
  223. text-align: center;
  224. position: relative;
  225. top: 80rpx;
  226. .name{
  227. color: #FFE9BE;
  228. font-weight: bold;
  229. font-size: 44rpx;
  230. padding: 0 64rpx;
  231. position: relative;
  232. display: inline-block;
  233. .title_icon{
  234. content: "";
  235. display: inline-block;
  236. width: 38rpx;
  237. height: 58rpx;
  238. background-repeat: no-repeat;
  239. background-size: 100% 100%;
  240. position: absolute;
  241. top: 0;
  242. &.icon_left{
  243. left: 0;
  244. }
  245. &.icon_right{
  246. right: 0;
  247. transform: rotateY(180deg);
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .header {
  254. position: relative;
  255. z-index: 6;
  256. display: flex;
  257. align-items: center;
  258. padding-right: 34rpx;
  259. height: 43px;
  260. padding-left: 33rpx;
  261. .head-menu {
  262. display: -webkit-box;
  263. display: -webkit-flex;
  264. display: flex;
  265. -webkit-box-align: center;
  266. -webkit-align-items: center;
  267. align-items: center;
  268. height: 27px;
  269. width: 70px;
  270. border-radius: 13px;
  271. .icon-xiangzuo {
  272. font-size: 32rpx;
  273. color: #FFFFFF;
  274. }
  275. .iconfont {
  276. -webkit-box-flex: 1;
  277. -webkit-flex: 1;
  278. flex: 1;
  279. text-align: center;
  280. color: #fff;
  281. box-sizing: border-box;
  282. &.icon-xiangzuo {
  283. border-right: 1px solid #fff;
  284. }
  285. }
  286. }
  287. }
  288. .head-menu {
  289. display: flex;
  290. align-items: center;
  291. height: 54rpx;
  292. width: 140rpx;
  293. background: transparent;
  294. border: 1px solid rgba(151, 151, 151, 0.2);
  295. border-radius: 27rpx;
  296. position: relative;
  297. z-index: 9999;
  298. &:after {
  299. content: '';
  300. position: absolute;
  301. width: 1px;
  302. height: 26rpx;
  303. background-color: #EAEAEA;
  304. left: 50%;
  305. top: 50%;
  306. transform: translate(-50%, -50%);
  307. }
  308. .iconfont {
  309. flex: 1;
  310. text-align: center;
  311. color: #fff;
  312. box-sizing: border-box;
  313. }
  314. }
  315. .scroll_box {
  316. width: 750rpx;
  317. box-sizing: border-box;
  318. line-height: 50rpx;
  319. padding-left: 32rpx;
  320. margin-top: 140rpx;
  321. }
  322. .scroll_item {
  323. display: inline-block;
  324. font-size: 28rpx;
  325. color: #6D6D6D;
  326. &:last-child {
  327. margin-right: 40rpx;
  328. }
  329. }
  330. .scroll_item_active {
  331. font-weight: 500;
  332. position: relative;
  333. text-align: center;
  334. color: #fff;
  335. &::after{
  336. content: "";
  337. display: block;
  338. margin: 10rpx auto 0;
  339. width: 80%;
  340. height:4rpx;
  341. border-radius: 2rpx;
  342. background: #fff;
  343. }
  344. }
  345. .scroll_item~.scroll_item {
  346. margin-left: 40rpx;
  347. }
  348. .rank_list {
  349. padding-top: 270rpx;
  350. padding-bottom: 32rpx;
  351. .item {
  352. border-radius: 16rpx;
  353. background: #fff;
  354. margin-top: 30rpx;
  355. padding: 28rpx 30rpx 32rpx;
  356. position: relative;
  357. .rank {
  358. position: absolute;
  359. top: 0;
  360. left: 20rpx;
  361. width: 50rpx;
  362. height: 61rpx;
  363. display: flex;
  364. justify-content: center;
  365. line-height: 61rpx;
  366. font-size: 30rpx;
  367. z-index: 10;
  368. background-size: 100% 100%;
  369. background-image: url('@/pages/activity/static/images/rank_num.png');
  370. font-family: '黑体';
  371. font-weight: bold;
  372. &.rank0,&.rank1,&.rank2{
  373. background-image: url('@/pages/activity/static/images/rank.png');
  374. }
  375. }
  376. .name {
  377. width: 382rpx;
  378. height: 76rpx;
  379. line-height: 38rpx;
  380. color: #282828;
  381. font-weight: 500;
  382. font-size: 32rpx;
  383. }
  384. }
  385. .mt-18 {
  386. margin-top: 18rpx;
  387. }
  388. .ot_price {
  389. font-weight: 300;
  390. color: #6D6D6D;
  391. padding-left: 16rpx;
  392. }
  393. .goods-msg {
  394. flex: 1;
  395. margin-left: 20rpx;
  396. .list{
  397. background: #FDF8EE;
  398. border-radius: 6rpx;
  399. line-height: 57rpx;
  400. color: #666666;
  401. font-size: 26rpx;
  402. padding: 0 12rpx;
  403. .iconfont{
  404. color: #FFB31C;
  405. margin-right: 12rpx;
  406. }
  407. }
  408. }
  409. .pictrue {
  410. width: 240rpx;
  411. height: 240rpx;
  412. position: relative;
  413. flex: 1;
  414. image {
  415. width: 100%;
  416. height: 100%;
  417. border-radius: 12rpx 0 0 12rpx;
  418. }
  419. }
  420. }
  421. </style>