index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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">{{buyNowText}}</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="rankTop.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">
  146. <custom-nodata notice='暂无更多数据' v-if="rankTop.length > 0&&rankList.length<=0"></custom-nodata>
  147. <view class="rank-list-item" v-for="(item, index) in rankList" :key="index">
  148. <view class="rank-list-rank">{{item.rank}}</view>
  149. <view class="rank-list-user">
  150. <image :src="item.headImage" class="photo" mode="scaleToFill"></image>
  151. <view class="name f-ellipsis">{{item.customerName}}</view>
  152. </view>
  153. <view class="rank-list-carbon">共购买{{item.carbonVal}}kg<br />碳汇</view>
  154. </view>
  155. </view>
  156. </view>
  157. <!-- 购买排行榜 结束 -->
  158. </view>
  159. <!-- wrap end -->
  160. <quick-buy
  161. class="quickbuy"
  162. ref="quickBuy"
  163. @closeModal="closeModal"
  164. :visible="modal.visibleModal"
  165. v-if="modal.visibleModal"></quick-buy>
  166. </view>
  167. </template>
  168. <script>
  169. import quickBuy from './modal/quickBuy';
  170. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  171. import customNodata from '@/components/custom-nodata/custom-nodata.vue';
  172. export default {
  173. components:{
  174. uniPopup,
  175. quickBuy,
  176. customNodata
  177. },
  178. data() {
  179. return {
  180. $getimg:this.$getimg,
  181. thetoken:'',
  182. modal: {
  183. visibleModal: false
  184. },
  185. swiper: {
  186. indicatorDots: false,
  187. autoplay: true,
  188. interval: 9000,
  189. duration: 500,
  190. indicatorColor:"rgba(255, 255, 255, 0.7)",
  191. indicatorActiveColor:"rgba(255, 255, 255, 1)",
  192. },
  193. swiperList:[
  194. {src:'banner01.png'},
  195. {src:'banner01.png'}
  196. ],
  197. current: 0,
  198. swiperCurrent: 0,
  199. productList:[],
  200. rankType:1,
  201. rankTop:[],
  202. myRank:{},
  203. rankList:[],
  204. rankResult:{},
  205. buyNowText:'立即认购'
  206. }
  207. },
  208. onShow() {
  209. let self = this;
  210. //判断用户类别
  211. uni.getStorage({
  212. key : 'userInfo',
  213. success:function(res){
  214. console.log('userInfo customerType',res.data.customerType);
  215. if(res.data.customerType =='1'){
  216. // console.log('个人用户');
  217. // uni.setTabBarItem({
  218. // index: 1,
  219. // text: '普惠商城',
  220. // iconPath: '/static/img/icon_mall.png',
  221. // selectedIconPath: '/static/img/icon_mall_active.png',
  222. // pagePath: '/pages/mall/mall'
  223. // });
  224. self.buyNowText = '立即购碳'
  225. }else{
  226. self.buyNowText = '立即认购'
  227. self.rankTab(2);
  228. };
  229. }
  230. });
  231. //页面跳转
  232. uni.getStorage({
  233. key:'beforeLoginPage',
  234. success: (res) => {
  235. console.log('beforeLoginPage',res.data);
  236. let switchTabList = ['/pages/use/use'];
  237. // switchTabList.some(res.data);
  238. // console.log('switchTabList.some(res.data)',switchTabList.includes(res.data));
  239. if(switchTabList.includes(res.data)){
  240. uni.switchTab({
  241. url: res.data,
  242. success: () => {
  243. uni.removeStorage({
  244. key:'beforeLoginPage'
  245. })
  246. }
  247. });
  248. }else{
  249. uni.navigateTo({
  250. url: res.data,
  251. success: () => {
  252. uni.removeStorage({
  253. key:'beforeLoginPage'
  254. })
  255. }
  256. });
  257. }
  258. }
  259. });
  260. //产品跳转
  261. uni.getStorage({
  262. key:'productID',
  263. success: (res) => {
  264. // console.log('productID',res.data)
  265. let item=new Object();
  266. item.guid = res.data;
  267. this.productClick(item);
  268. }
  269. });
  270. },
  271. onLoad() {
  272. this.thetoken = 'Bearer' + ' ' + this.$store.state.token;
  273. this.getProductList();
  274. this.getRank();
  275. },
  276. methods: {
  277. swiperChange (e) {
  278. this.swiperCurrent = e.detail.current
  279. },
  280. swiperClick(){
  281. console.log(this.swiperCurrent);
  282. },
  283. getProductList(){
  284. uni.showLoading({title: '加载中'});
  285. this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/goodsManage/pushGoods',{"pageNo":1,"pageSize":6},{
  286. header: {
  287. Accept:'application/json',
  288. Authorization: this.thetoken, //注意Bearer后面有一空格
  289. },
  290. }).then(res => {
  291. this.productList = res.data.retBody;
  292. uni.hideLoading();
  293. // console.log('res',JSON.parse(JSON.stringify(res.data.retBody)))
  294. }).catch(err =>{
  295. uni.hideLoading();
  296. console.log('err',err)
  297. });
  298. },
  299. refreshProductList(){
  300. this.getProductList();
  301. },
  302. productClick(item){
  303. let id = item.guid;
  304. this.$api.href('/pages/product/product?guid='+id);
  305. },
  306. rankTab(type){
  307. this.rankType = type;
  308. this.getRank(type);
  309. },
  310. getRank(){
  311. uni.showLoading({title: '加载中'});
  312. let params = {"type":this.rankType};
  313. // console.log('this.thetoken',this.thetoken);
  314. this.$api.http.get(this.config.apiBaseurl+'/carbon-h5/wap/carbonVal/getCustomerCarbonValRank',{params:params,header: {Authorization:this.thetoken}}).then(res => {
  315. if(!res.data.retBody){
  316. this.rankResult.currCustomerRankForm='';
  317. this.rankResult.list='';
  318. }else{
  319. this.rankResult = res.data.retBody
  320. };
  321. console.log('this.rankResult',this.rankResult);
  322. this.myRank = this.rankResult.currCustomerRankForm;
  323. this.rankTop = this.rankResult.list.slice(0,3);
  324. console.log('this.rankTop',JSON.parse(JSON.stringify(this.rankTop)))
  325. this.rankList =this.rankResult.list.slice(3,this.rankResult.list.length);
  326. console.log('res',JSON.parse(JSON.stringify(res.data.retBody)))
  327. uni.hideLoading();
  328. }).catch(err =>{
  329. uni.hideLoading();
  330. console.log('err',err)
  331. });
  332. },
  333. //开启多株购碳
  334. randomPop() {
  335. //登录判断
  336. if(!this.$store.state.hasLogin){
  337. this.$api.msg('请先登录');
  338. setTimeout(i=>{
  339. uni.navigateTo({
  340. url: '/pages/login/loginType',
  341. fail:function(err){
  342. console.log(err)
  343. }
  344. });
  345. },2000);
  346. return;
  347. };
  348. this.modal.visibleModal = true;
  349. this.$nextTick(res => {
  350. // console.log('this.$refs',this.$refs.quickBuy)
  351. this.$refs.quickBuy.openPop();
  352. });
  353. },
  354. closeModal() {
  355. this.modal.visibleModal = false;
  356. },
  357. }
  358. }
  359. </script>
  360. <style>
  361. @import url("./index.css");
  362. </style>