index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view>
  3. <view class="w-full bg-top h-470 relative" :style="{backgroundImage:headerBg}">
  4. <view class="fixed-lt w-full z-20" :style="{'padding-top': sysHeight + 'px','background': pageScrollStatus ? '#e93323' : 'transparent'}">
  5. <view class="w-full px-20 pl-20 h-80 flex-between-center">
  6. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-fff" @click="goBack()"></text>
  7. <text class="fs-34 fw-500 text--w111-fff">{{pageScrollStatus ? '商品排行榜' : ''}}</text>
  8. <text></text>
  9. </view>
  10. </view>
  11. <view class="desc flex-between-center">
  12. <view class="h-40 fs-28 lh-40rpx text--w111-fff"
  13. v-for="(item, index) in tabList" :key="index"
  14. :class="item.type == type ? 'active-tab' : ''"
  15. @tap="tabChange(item.type)">{{item.title}}</view>
  16. </view>
  17. </view>
  18. <view class="relative rd-t-40rpx bg--w111-f5f5f5 w-full content">
  19. <view class="">
  20. <view class="pt-32 pl-20 pr-20">
  21. <view class="card w-full bg--w111-fff rd-24rpx p-20 flex" v-for="(item,index) in productList" :key="index"
  22. @click="goDetail(item)">
  23. <view class="picture w-240 h-240 relative">
  24. <easy-loadimage
  25. mode="widthFix"
  26. :image-src="item.image"
  27. width="240rpx"
  28. height="240rpx"
  29. borderRadius="20rpx"></easy-loadimage>
  30. <image class="abs-lt w-72 h-72"
  31. :src="`${imgHost}/statics/images/product/rank_icon${index + 1}.png`" v-if="index < 3"></image>
  32. </view>
  33. <view class="flex-1 pl-20 flex-col justify-between">
  34. <view class="w-full">
  35. <view class="w-full fs-28 lh-40rpx line2">{{item.store_name}}</view>
  36. <view class="flex items-end flex-wrap mt-12 w-full" v-if="item.store_label.length">
  37. <BaseTag
  38. :text="label.label_name"
  39. :color="label.color"
  40. :background="label.bg_color"
  41. :borderColor="label.border_color"
  42. :circle="label.border_color ? true : false"
  43. :imgSrc="label.icon"
  44. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  45. </view>
  46. <view class="font-red lh-30rpx fs-22 fw-500 mt-4">{{item.sales}}人买过 | 评分{{item.star}}</view>
  47. </view>
  48. <view class="w-full flex-between-center">
  49. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" color="#e93323" weight></baseMoney>
  50. <view class="w-144 h-56 rd-30rpx flex-center fs-24 jianbian text--w111-fff">立即抢购</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  61. import { rankCategoryApi, rankListApi } from "@/api/store";
  62. import { goShopDetail } from '@/libs/order.js';
  63. import { HTTP_REQUEST_URL } from '@/config/app';
  64. import {mapGetters} from 'vuex';
  65. export default {
  66. data() {
  67. return {
  68. sysHeight:sysHeight,
  69. imgHost: HTTP_REQUEST_URL,
  70. pageScrollStatus:false,
  71. cateList:[],
  72. form:{
  73. page:1,
  74. limit:10,
  75. selectId:0
  76. },
  77. type:1,
  78. loading:false,
  79. productList:[],
  80. tabList:[
  81. {title:'销量榜',type:1},
  82. {title:'好评榜',type:2},
  83. {title:'收藏榜',type:3},
  84. ],
  85. };
  86. },
  87. computed:{
  88. headerBg(){
  89. return 'url('+this.imgHost+'/statics/images/product/rank_header.png'+')'
  90. },
  91. ...mapGetters(['isLogin', 'uid']),
  92. },
  93. onLoad(e) {
  94. this.type = e.type ? e.type : 1;
  95. this.getList();
  96. },
  97. onPageScroll(object) {
  98. if (object.scrollTop > 130) {
  99. this.pageScrollStatus = true;
  100. } else if (object.scrollTop < 130) {
  101. this.pageScrollStatus = false;
  102. }
  103. uni.$emit('scroll');
  104. },
  105. methods:{
  106. init(){
  107. rankCategoryApi().then(res=>{
  108. this.cateList = res.data;
  109. if(res.data.length){
  110. this.form.selectId = res.data[0].id;
  111. }
  112. })
  113. },
  114. getList(){
  115. if (this.loading) return;
  116. rankListApi(this.type,this.form).then(res=>{
  117. this.productList = this.productList.concat(res.data);
  118. this.loading = res.data.length < this.form.limit;
  119. this.form.page++;
  120. })
  121. },
  122. goBack(){
  123. uni.navigateBack();
  124. },
  125. goDetail(item){
  126. goShopDetail(item, this.uid).catch(res => {
  127. uni.navigateTo({
  128. url: `/pages/goods_details/index?id=${item.id}`
  129. });
  130. });
  131. },
  132. tabChange(type){
  133. this.type = type;
  134. this.loading = false;
  135. this.form.page = 1;
  136. this.productList =[];
  137. this.getList();
  138. }
  139. },
  140. onReachBottom() {
  141. this.getList();
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .h-470{
  147. height: 470rpx;;
  148. }
  149. .w-624{
  150. width: 624rpx;
  151. }
  152. .desc{
  153. width: 402rpx;
  154. height: 52rpx;
  155. position: absolute;
  156. left: 50%;
  157. transform: translateX(-50%);
  158. bottom: 118rpx;
  159. }
  160. .active-tab{
  161. width: 132rpx;
  162. height: 52rpx;
  163. background: #FFF8E4;
  164. color: #F85517;
  165. border-radius: 30rpx;
  166. font-weight: 500;
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. }
  171. .bg-top{
  172. background-size: 100% 100%;
  173. background-repeat: no-repeat;
  174. }
  175. .content{
  176. min-height: 400rpx;
  177. top: -80rpx;
  178. }
  179. ._box{
  180. padding: 40rpx 20rpx 32rpx;
  181. background: #f5f5f5;
  182. position: sticky;
  183. z-index: 99;
  184. }
  185. .font-red{
  186. color: #e93323;
  187. }
  188. .bg-red{
  189. background-color: #e93323;
  190. }
  191. .jianbian{
  192. background: linear-gradient(90deg, #FF7931 0%, #E93323 100%);
  193. }
  194. .card ~ .card{
  195. margin-top: 20rpx;
  196. }
  197. </style>