index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="content">
  3. <view class="home-top">
  4. <image :src="$getimg+'home-top-bg.png'" class="home-top-bg" mode="widthFix"></image>
  5. <view class="home-top-til">“碳汇+”生态产品价值实现</view>
  6. <view class="home-top-subtil">The value of ecological environment is realized</view>
  7. </view>
  8. <view class="swiper-wrap">
  9. <swiper class="swiper"
  10. :indicator-dots="swiper.indicatorDots"
  11. :indicator-color="swiper.indicatorColor"
  12. :indicator-active-color="swiper.indicatorActiveColor"
  13. :autoplay="swiper.autoplay"
  14. @change="swiperChange"
  15. :interval="swiper.interval" :duration="swiper.duration">
  16. <!-- <swiper-item>
  17. <view class="adv-item"><image :src="$getimg +'banner01.png'" class="pic" mode="scaleToFill"></image></view>
  18. </swiper-item>
  19. <swiper-item>
  20. <view class="adv-item" @click="goIndex"><image :src="$getimg +'guide02.png'" class="pic" mode="scaleToFill"></image></view>
  21. </swiper-item> -->
  22. <swiper-item v-for="(item, index) in swiperList" :key="index">
  23. <view class="adv-item" @click="swiperClick"><image :src="$getimg +item.src" class="pic" mode="scaleToFill"></image></view>
  24. </swiper-item>
  25. </swiper>
  26. <view class="dots-container">
  27. <view v-for="(item, index) in swiperList" :key="index">
  28. <view :class="['dot', index === swiperCurrent ? 'active' : '']"></view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="wrap40">
  33. <view class="title">推荐生态产品</view>
  34. <view class="buy-now" @click="randomPop">
  35. <view class="buy-now-imgwrap">
  36. <image :src="$getimg+'home-buy-now-img.png'" class="buy-now-img" mode="aspectFit"></image>
  37. </view>
  38. <view class="buy-now-text">
  39. <view class="buy-now-text-big">立即购碳</view>
  40. <view class="buy-now-text-small">点击去购碳哟</view>
  41. </view>
  42. <view class="buy-now-icon">
  43. <text class="iconfont icon-down-s"></text>
  44. </view>
  45. </view>
  46. <!-- buy-now end -->
  47. <view class="type-nav">
  48. <view class="type-nav-item active">
  49. <view class="type-nav-item-til">林业碳汇</view>
  50. <view class="type-nav-item-subtil">为您推荐</view>
  51. <image :src="$getimg+'type-nav-active.png'" class="active-bg" mode="aspectFit"></image>
  52. </view>
  53. <view class="type-nav-item">
  54. <!-- <view class="type-nav-item-til">新能源汽车</view>
  55. <view class="type-nav-item-subtil">绿色出行</view> -->
  56. </view>
  57. <view class="type-nav-item">
  58. <!-- <view class="type-nav-item-til">分布式光伏</view>
  59. <view class="type-nav-item-subtil">新能源</view> -->
  60. </view>
  61. </view>
  62. <view class="common-content">
  63. <view class="common-content-title">
  64. <view class="common-content-icon">
  65. <image :src="$getimg+'icon-tanpuhui.png'" class="icon" mode="aspectFit"></image>
  66. </view>
  67. <view class="common-content-til">
  68. 碳汇产品展示
  69. </view>
  70. <view class="common-content-right" @click="refreshProductList">
  71. <image :src="$getimg+'icon-refresh.png'" class="icon" mode="aspectFit"></image>
  72. 换一批
  73. </view>
  74. </view>
  75. <view class="product-list">
  76. <view class="product-list-item" v-for="(item, index) in productList" :key="index" @click="productClick(item)">
  77. <image :src="$onlineImg + item.goodsImages | firstImg" class="product-img" mode="heightFix"></image>
  78. <view class="product-text">{{item.goodsName}}</view>
  79. </view>
  80. </view>
  81. <!-- <view class="common-content-blink">查看更多 ></view> -->
  82. </view>
  83. <!-- 碳汇产品展示 结束 -->
  84. <view class="title">购买排行榜</view>
  85. <view class="rank-wrap">
  86. <view class="rank-tab">
  87. <view class="rank-tab-item" :class="{active: rankType == 1 }" @click="rankTab(1)">
  88. 企业排行榜
  89. </view>
  90. <view class="rank-tab-item" :class="{active: rankType == 2 }" @click="rankTab(2)">
  91. 个人排行榜
  92. </view>
  93. </view>
  94. <view class="rank-top">
  95. <view class="rank-top-item" v-for="(item, index) in rankTop" :key="index">
  96. <view class="rank-top-imgwrap">
  97. <image :src="$getimg+'rank-top01.png'" class="rank-top-bg" mode="aspectFit"></image>
  98. <image :src="item.img" class="rank-top-photo" mode="scaleToFill"></image>
  99. </view>
  100. <view class="rank-top-name f-ellipsis">{{item.name}}</view>
  101. <view class="rank-top-carbon f-ellipsis">共购买{{item.carbon}}kg碳汇</view>
  102. </view>
  103. <view class="my-rank-wrap">
  104. <view class="my-rank-photo">
  105. <image :src="myRank.img" class="photo" mode="scaleToFill"></image>
  106. </view>
  107. <view class="my-rank-text">
  108. <view class="my-rank">第{{myRank.rank}}名</view>
  109. <view class="my-rank-num">共购买{{myRank.carbon}}kg碳汇</view>
  110. </view>
  111. </view>
  112. </view>
  113. <!-- rank-top end -->
  114. <view class="rank-list-header">
  115. <view class="rank-list-header-rank">排名</view>
  116. <view class="rank-list-header-user">用户</view>
  117. <view class="rank-list-header-carbon">购买碳汇</view>
  118. </view>
  119. <view class="rank-list">
  120. <view class="rank-list-item" v-for="(item, index) in rankList" :key="index">
  121. <view class="rank-list-rank">{{item.rank}}</view>
  122. <view class="rank-list-user">
  123. <image :src="item.img" class="photo" mode="scaleToFill"></image>
  124. <view class="name f-ellipsis">{{item.name}}</view>
  125. </view>
  126. <view class="rank-list-carbon">共购买{{item.carbon}}kg<br />碳汇</view>
  127. </view>
  128. </view>
  129. </view>
  130. <!-- 购买排行榜 结束 -->
  131. </view>
  132. <!-- wrap end -->
  133. <quick-buy class="quickbuy" ref="quickBuy" @closeModal="closeModal" :visible="modal.visibleModal" v-if="modal.visibleModal"></quick-buy>
  134. </view>
  135. </template>
  136. <script>
  137. import quickBuy from './modal/quickBuy';
  138. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  139. export default {
  140. components:{
  141. uniPopup,
  142. quickBuy,
  143. },
  144. data() {
  145. return {
  146. $getimg:this.$getimg,
  147. thetoken:'',
  148. modal: {
  149. visibleModal: false
  150. },
  151. swiper: {
  152. indicatorDots: false,
  153. autoplay: true,
  154. interval: 9000,
  155. duration: 500,
  156. indicatorColor:"rgba(255, 255, 255, 0.7)",
  157. indicatorActiveColor:"rgba(255, 255, 255, 1)",
  158. },
  159. swiperList:[
  160. {src:'banner01.png'},
  161. {src:'banner01.png'}
  162. ],
  163. current: 0,
  164. swiperCurrent: 0,
  165. productList:[],
  166. rankType:1,
  167. rankTop:[
  168. {name:'酉阳土家族苗',carbon:1000,img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  169. {name:'酉阳土家族苗',carbon:1000,img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  170. {name:'酉阳土家族苗',carbon:1000,img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  171. ],
  172. myRank:{name:'家族苗',carbon:1000,rank:11,img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  173. rankList:[
  174. {name:'家族苗',carbon:1000,rank:'04',img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  175. {name:'家族苗',carbon:1000,rank:'05',img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  176. {name:'家族苗',carbon:1000,rank:'06',img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  177. {name:'家族苗',carbon:1000,rank:'07',img:'http://qny.gzsdtfp.com/gzth005/imgupload/39b6b37e61e240c98e4c8ca392c5f3a5.jpg'},
  178. ],
  179. }
  180. },
  181. onLoad() {
  182. this.thetoken = 'Bearer' + ' ' + this.$store.state.token;
  183. this.getProductList();
  184. },
  185. methods: {
  186. swiperChange (e) {
  187. this.swiperCurrent = e.detail.current
  188. },
  189. swiperClick(){
  190. console.log(this.swiperCurrent);
  191. },
  192. getProductList(){
  193. this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/goodsManage/pushGoods',{"pageNo":1,"pageSize":6},{
  194. header: {
  195. Accept:'application/json',
  196. Authorization: 'Bearer '+ this.thetoken, //注意Bearer后面有一空格
  197. },
  198. }).then(res => {
  199. this.productList = res.data.retBody;
  200. // console.log('res',JSON.parse(JSON.stringify(res.data.retBody)))
  201. }).catch(err =>{
  202. console.log('err',err)
  203. });
  204. },
  205. refreshProductList(){
  206. this.getProductList();
  207. },
  208. productClick(item){
  209. let id = item.guid;
  210. this.$api.href('/pages/product/product?guid='+id);
  211. },
  212. rankTab(type){
  213. this.rankType = type;
  214. this.getRank(type);
  215. },
  216. getRank(type){
  217. this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/goodsManage/pushGoods',{"pageNo":1,"pageSize":6},{
  218. header: {
  219. Accept:'application/json',
  220. Authorization: 'Bearer '+ this.thetoken, //注意Bearer后面有一空格
  221. },
  222. }).then(res => {
  223. // this.productList = res.data.retBody;
  224. console.log('res',JSON.parse(JSON.stringify(res.data.retBody)))
  225. }).catch(err =>{
  226. console.log('err',err)
  227. });
  228. },
  229. //开启多株购碳
  230. randomPop() {
  231. this.modal.visibleModal = true;
  232. this.$nextTick(res => {
  233. // console.log('this.$refs',this.$refs.quickBuy)
  234. this.$refs.quickBuy.openPop();
  235. });
  236. },
  237. closeModal() {
  238. this.modal.visibleModal = false;
  239. },
  240. }
  241. }
  242. </script>
  243. <style>
  244. @import url("./index.css");
  245. </style>