index.vue 11 KB

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