954 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			Vue
		
	
	
			
		
		
	
	
			954 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			Vue
		
	
	
| <template>
 | ||
| 	<view class="main">
 | ||
| 		<!-- 头部 -->
 | ||
| 		<status-nav></status-nav>
 | ||
| 		<!-- 计算碳足迹 -->
 | ||
| 		<view class="calculator-bg">
 | ||
| 			<view class="bg-img">
 | ||
| 				<image src="/static/count-bg.png" mode="widthFix"></image>
 | ||
| 			</view>
 | ||
| 			<view class="calculator">
 | ||
| 				<view class="count" style="padding-top: 47px;" v-if="current==0">
 | ||
| 					<view class="cate">
 | ||
| 						<view class="list" v-for="(item,index) in cateList" :key="index">
 | ||
| 							<view class="title">
 | ||
| 								<text>{{index}}</text>
 | ||
| 							</view>
 | ||
| 							<view class="item" v-for="(item1,index1) in item" :key="index1" @tap="changeEv(index,index1)">
 | ||
| 								{{item1.title}}
 | ||
| 							</view>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 					<view class="interface">
 | ||
| 						<scroll-view class="result" scroll-y="true" id="" :scroll-top="scrollTop">
 | ||
| 							<view class="message-scroll">
 | ||
| 								<view class="individual" v-if="cateTagList.length>0">
 | ||
| 									<view class="list" v-for="(item,index) in cateList" :key="index">
 | ||
| 										<view class="item" v-for="(item1,index1) in item" :key="index1"
 | ||
| 											v-if="cateTagList.indexOf(item1.tag)!==-1">
 | ||
| 											<view>{{item1.title}}</view>
 | ||
| 											<view>
 | ||
| 												<text class="input" :class="focusIndex==index&&focusIndex1==index1?'blur':''" @tap="changeFocus(index,index1)">{{item1.num!==''?item1.num:0}}</text>
 | ||
| 											</view>
 | ||
| 											<view>{{item1.company}}</view>
 | ||
| 										</view>
 | ||
| 									</view>
 | ||
| 								</view>
 | ||
| 								<view class="subtotal">
 | ||
| 									<view class="item">
 | ||
| 										<view>衣<text>排碳</text></view>
 | ||
| 										<view>{{subTotal[0]?subTotal[0].toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 									<view class="item">
 | ||
| 										<view>食<text>排碳</text></view>
 | ||
| 										<view>{{subTotal[1]?subTotal[1].toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 									<view class="item">
 | ||
| 										<view>住<text>排碳</text></view>
 | ||
| 										<view>{{subTotal[2]?subTotal[2].toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 									<view class="item">
 | ||
| 										<view>行<text>排碳</text></view>
 | ||
| 										<view>{{subTotal[3]?subTotal[3].toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 									<view class="item">
 | ||
| 										<view>用<text>排碳</text></view>
 | ||
| 										<view>{{subTotal[4]?subTotal[4].toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 								</view>
 | ||
| 								<view class="total">
 | ||
| 									<view class="item">
 | ||
| 										<view>合计排碳</view>
 | ||
| 										<view>{{total>0?total.toFixed(2):0}}</view>
 | ||
| 										<view>kg</view>
 | ||
| 									</view>
 | ||
| 								</view>
 | ||
| 							</view>
 | ||
| 						</scroll-view>
 | ||
| 						<view class="interface-btns">
 | ||
| 							<view class="num">
 | ||
| 								<view class="btn" v-for="(item,index) in numlist" :key="index" @tap="chengeNum(item)">
 | ||
| 									{{item}}
 | ||
| 								</view>
 | ||
| 							</view>
 | ||
| 							<view class="operate">
 | ||
| 								<view class="btn" v-for="(item,index) in operateList" :key="index" @tap="choseEv(index)">
 | ||
| 									{{item}}
 | ||
| 								</view>
 | ||
| 							</view>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 				</view>
 | ||
| 				<view class="assess" style="padding-top: 26px;" v-if="current==1">
 | ||
| 					<view class="assess-title">
 | ||
| 						<image src="/static/icon-title-01.png" mode="heightFix"></image>
 | ||
| 						<view class="total-num">
 | ||
| 							<view class="num" v-for="(item,index) in showTotal" :key="index">{{item}}</view>
 | ||
| 							<image src="/static/kg.png" mode="heightFix"></image>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 					<view class="assess-form">
 | ||
| 						<!-- 柱状图 -->
 | ||
| 						<view class="histogram">
 | ||
| 							<view class="form-list">
 | ||
| 								<view class="form-item">
 | ||
| 									<text>{{cacheSubTotal[0]}}kg</text>
 | ||
| 									<view :style="{'height':heightList[0]}"></view>
 | ||
| 								</view>
 | ||
| 								<view class="form-item">
 | ||
| 									<text>{{cacheSubTotal[1]}}kg</text>
 | ||
| 									<view :style="{'height':heightList[1]}"></view>
 | ||
| 								</view>
 | ||
| 								<view class="form-item">
 | ||
| 									<text>{{cacheSubTotal[2]}}kg</text>
 | ||
| 									<view :style="{'height':heightList[2]}"></view>
 | ||
| 								</view>
 | ||
| 								<view class="form-item">
 | ||
| 									<text>{{cacheSubTotal[3]}}kg</text>
 | ||
| 									<view :style="{'height':heightList[3]}"></view>
 | ||
| 								</view>
 | ||
| 								<view class="form-item">
 | ||
| 									<text>{{cacheSubTotal[4]}}kg</text>
 | ||
| 									<view :style="{'height':heightList[4]}"></view>
 | ||
| 								</view>
 | ||
| 							</view>
 | ||
| 							<view class="form-title">
 | ||
| 								<view>
 | ||
| 									<image src="/static/icon-font-01.png" mode="heightFix"></image>
 | ||
| 								</view>
 | ||
| 								<view>
 | ||
| 									<image src="/static/icon-font-02.png" mode="heightFix"></image>
 | ||
| 								</view>
 | ||
| 								<view>
 | ||
| 									<image src="/static/icon-font-03.png" mode="heightFix"></image>
 | ||
| 								</view>
 | ||
| 								<view>
 | ||
| 									<image src="/static/icon-font-04.png" mode="heightFix"></image>
 | ||
| 								</view>
 | ||
| 								<view>
 | ||
| 									<image src="/static/icon-font-05.png" mode="heightFix"></image>
 | ||
| 								</view>
 | ||
| 							</view>
 | ||
| 						</view>
 | ||
| 						<!-- 饼图 -->
 | ||
| 						<view class="pie-chart">
 | ||
| 							<l-echart ref="chart" @finished="init"></l-echart>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 					<view class="assess-title assess-title-other">
 | ||
| 						<image src="/static/icon-title-02.png" mode="heightFix"></image>
 | ||
| 					</view>
 | ||
| 					<view class="assess-txt">
 | ||
| 						<view class="">您全家一年的碳足迹(碳排放)为<text>{{cacheTotal}}</text>kg,家庭人数</view>
 | ||
| 						<view class="assess-btns">
 | ||
| 							<view class="btn" @tap="changeNum('reduce')">
 | ||
| 								<image src="/static/icon-reduce.png" mode="widthFix"></image>
 | ||
| 							</view>
 | ||
| 							<input type="number" @blur="averageEv" v-model="member">
 | ||
| 							<view class="btn" @tap="changeNum('add')">
 | ||
| 								<image src="/static/icon-add.png" mode="widthFix"></image>
 | ||
| 							</view>
 | ||
| 						</view>
 | ||
| 						<view class="">,人均碳足迹为<text>{{average}}</text>kg。</view>
 | ||
| 					</view>
 | ||
| 					<view class="assess-contrast">
 | ||
| 						<!-- <image src="/static/assess.png" mode="widthFix"></image> -->
 | ||
| 						<view class="assess-contrast-bg"></view>
 | ||
| 						<view class="line"></view>
 | ||
| 						<view class="list">
 | ||
| 							<view class="item">
 | ||
| 								<image src="/static/footprint.png" mode="heightFix" :style="{height:averageHeight>=230?'230px':averageHeight+'px'}"></image>
 | ||
| 								<view>您的碳足迹为</view>
 | ||
| 								<view><text>{{average}}</text>kg</view>
 | ||
| 							</view>
 | ||
| 							<view class="item">
 | ||
| 								<image src="/static/footprint.png" mode="heightFix" style="height: 92px;"></image>
 | ||
| 								<view>中国人均碳足迹为</view>
 | ||
| 								<view><text>7100</text>kg</view>
 | ||
| 							</view>
 | ||
| 							<view class="item">
 | ||
| 								<image src="/static/footprint.png" mode="heightFix" style="height: 207px;"></image>
 | ||
| 								<view>美国人均碳足迹为</view>
 | ||
| 								<view><text>16100</text>kg</view>
 | ||
| 							</view>
 | ||
| 							<view class="item">
 | ||
| 								<image src="/static/footprint.png" mode="heightFix" style="height: 60px;"></image>
 | ||
| 								<view>全球人均碳足迹为</view>
 | ||
| 								<view><text>4700</text>kg</view>
 | ||
| 							</view>
 | ||
| 							<view class="item">
 | ||
| 								<image src="/static/footprint.png" mode="heightFix" style="height: 30px;"></image>
 | ||
| 								<view>应对气候变化全球人均目标碳足迹为</view>
 | ||
| 								<view><text>2330</text>kg</view>
 | ||
| 							</view>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 				</view>
 | ||
| 				<view class="eliminate" style="padding-top: 26px;" v-if="current==2">
 | ||
| 					<view class="eliminate-title">
 | ||
| 						<image src="/static/icon-title-03.png" mode="heightFix"></image>
 | ||
| 					</view>
 | ||
| 					<view class="tips">
 | ||
| 						<view class="item">
 | ||
| 							您全家一年的碳足迹(碳排放)为<text>{{cacheTotal}}</text>kg,人均碳足迹为<text>{{average}}</text>kg。
 | ||
| 						</view>
 | ||
| 						<view class="item">
 | ||
| 							消除掉您的家庭碳足迹需要指数<text>{{treeNum.toFixed(2)}}</text>棵,您需要捐款<text>{{money.toFixed(2)}}</text>元人民币用于中国绿色碳汇基金会低碳旅游专项基金。
 | ||
| 						</view>
 | ||
| 						<view class="item">
 | ||
| 							谢谢您在应对气候变化方面所做的贡献,您是一位有责任的的人。
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 					<view class="eliminate-img">
 | ||
| 						<image src="/static/eliminate.png" mode="heightFix"></image>
 | ||
| 						<view class="payment-btn" @tap="changeNav(3)">
 | ||
| 							<image src="/static/icon-tabbar-04.png" mode="heightFix"></image>
 | ||
| 						</view>
 | ||
| 						<view class="payment-btn payment-btn-other" @tap="ifShow=true">
 | ||
| 							<image src="/static/icon-tabbar-05.png" mode="heightFix"></image>
 | ||
| 						</view>
 | ||
| 					</view>
 | ||
| 				</view>
 | ||
| 				<!-- 在线捐款 -->
 | ||
| 				<view class="iframe-box" style="padding-top: 0;" v-if="current==3">
 | ||
| 					<web-view :src="webViewUrl" allow></web-view>
 | ||
| 				</view>
 | ||
| 				<!-- 导航 -->
 | ||
| 				<view class="nav-btns">
 | ||
| 					<view class="btn" :class="current==index?'active':''" @tap="changeNav(index)" v-for="(item,index) in navList" :key="index">
 | ||
| 						<image :src="`/static/icon-tabbar-0${index+1}.png`" mode="heightFix"></image>
 | ||
| 					</view>
 | ||
| 				</view>
 | ||
| 				<!-- <tabbar :current='0'></tabbar> -->
 | ||
| 				<!-- 操作说明 -->
 | ||
| 				<view class="explain">友情提醒:计算前请先按AC键,消除上一用户数据</view>
 | ||
| 			</view>
 | ||
| 		</view>
 | ||
| 		<!-- 轮播 -->
 | ||
| 		<view class="banner">
 | ||
| 			<swiper-pull></swiper-pull>
 | ||
| 		</view>
 | ||
| 		<!-- 底部 -->
 | ||
| 		<view class="footer">
 | ||
| 			<text>中国绿色碳汇基金会低碳旅游专项基金监制,北京凯来美气候科技有限公司开发。</text>
 | ||
| 		</view>
 | ||
| 		<!-- 证书 -->
 | ||
| 		<view class="certificate-bg" v-show="ifShow" @tap.stop="ifShow=false">
 | ||
| 			<view class="certificate" @tap.stop="">
 | ||
| 				<image src="/static/certificate-bg.jpg" mode="widthFix"></image>
 | ||
| 				<view class="content">
 | ||
| 					<view class="logo">
 | ||
| 						<image src="/static/logo-01.png" mode="heightFix"></image>
 | ||
| 					</view>
 | ||
| 					<view class="txt">
 | ||
| 						<image src="/static/code-title.png" mode="heightFix"></image>
 | ||
| 						<view class="code">NO.{{code}}</view>
 | ||
| 					</view>
 | ||
| 					<view class="msg">
 | ||
| 						<view class="item">
 | ||
| 							您是第
 | ||
| 							<view class="number">
 | ||
| 								<text v-for="(item,index) in difference">0</text>
 | ||
| 								<text>{{experients}}</text>
 | ||
| 							</view>
 | ||
| 							位体验者: 
 | ||
| 						</view>
 | ||
| 						<view class="item">感谢您参与“爱绿行碳普惠”平台互动,计算碳排放量,学习节能降碳等知识,践行低碳旅游和生活新风尚,用行动守护景区美丽环境。</view>
 | ||
| 						<view class="time">{{date}}</view>
 | ||
| 					</view>
 | ||
| 					<view class="foot">
 | ||
| 						<view class="qr">
 | ||
| 							<image src="/static/qr-alx.png" mode="widthFix"></image>
 | ||
| 							<view class="tips">扫码关注<text>爱绿行</text></view>
 | ||
| 						</view>
 | ||
| 						<view class="foot-logo">
 | ||
| 							<!-- <image src="/static/logo-02.png" mode="widthFix"></image> -->
 | ||
| 							<image src="/static/logo-03.png" mode="widthFix"></image>
 | ||
| 						</view>
 | ||
| 						<view class="support">技术支持:北京零碳创意科技有限公司</view>
 | ||
| 					</view>
 | ||
| 				</view>
 | ||
| 			</view>
 | ||
| 		</view>
 | ||
| 	</view>
 | ||
| </template>
 | ||
| 
 | ||
| <script>
 | ||
| 	import statusNav from '@/components/status-nav/status-nav.vue';
 | ||
| 	import swiperPull from '@/components/swiper/swiper-pull.vue';
 | ||
| 	import * as echarts from '@/uni_modules/lime-echart/static/echarts.min.js';
 | ||
| 	// 初始化
 | ||
| 	var LySDKModule = uni.requireNativePlugin('LY028-NativeSdk');
 | ||
| 	export default {
 | ||
| 		components: {
 | ||
| 			statusNav,
 | ||
| 			swiperPull
 | ||
| 		},
 | ||
| 		data() {
 | ||
| 			return {
 | ||
| 				statusHeight: uni.getSystemInfoSync().statusBarHeight, //状态栏高度
 | ||
| 				navList:['/pages/count/count','/pages/assess/assess','/pages/eliminate/eliminate'],
 | ||
| 				current:0, //当前选择
 | ||
| 				cateList: {
 | ||
| 					'衣': [{
 | ||
| 							'title': '购买衣服数量',
 | ||
| 							'company': '件',
 | ||
| 							'carbon': 7.01,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'a1'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '洗衣粉使用量',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 1.46,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'a2'
 | ||
| 						}
 | ||
| 					],
 | ||
| 					'食': [{
 | ||
| 							'title': '吸烟数量',
 | ||
| 							'company': '包',
 | ||
| 							'carbon': 0.1182,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b1'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '喝白酒数量',
 | ||
| 							'company': '升',
 | ||
| 							'carbon': 4.5,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b2'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '喝红酒数量',
 | ||
| 							'company': '升',
 | ||
| 							'carbon': 1.75,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b3'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '喝啤酒数量',
 | ||
| 							'company': '瓶',
 | ||
| 							'carbon': 0.43,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b4'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '肉类消费',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 8.823,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b5'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '粮食消费',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 0.918,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'b6'
 | ||
| 						}
 | ||
| 					],
 | ||
| 					'住': [{
 | ||
| 							'title': '用电',
 | ||
| 							'company': '度',
 | ||
| 							'carbon': 0.581,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c1'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '煤气',
 | ||
| 							'company': '立方米',
 | ||
| 							'carbon': 2.826,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c2'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '天然气',
 | ||
| 							'company': '立方米',
 | ||
| 							'carbon': 2.826,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c3'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '燃煤',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 3.0978,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c4'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '集中取暖',
 | ||
| 							'company': '立方米',
 | ||
| 							'carbon': 46.57,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c5'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '装修用木材',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 0.31,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c6'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '装修用陶瓷',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 0.74,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c7'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '装修用钢材',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 2.3,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c8'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '装修用铝材',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 15.8,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'c9'
 | ||
| 						}
 | ||
| 					],
 | ||
| 					'行': [{
 | ||
| 							'title': '飞机',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.088,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd1'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '火车',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.0262,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd2'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '轮船',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.128,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd3'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '地铁',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.0153,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd4'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '公共汽车',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.03344,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd5'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '低油耗小轿车',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.16,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd6'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '中油耗小轿车',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.24,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd7'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '高油耗小轿车',
 | ||
| 							'company': '千米',
 | ||
| 							'carbon': 0.33,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'd8'
 | ||
| 						},
 | ||
| 					],
 | ||
| 					'用': [{
 | ||
| 							'title': '塑料袋使用量',
 | ||
| 							'company': '个',
 | ||
| 							'carbon': 0.0821,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'e1'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '纸制品',
 | ||
| 							'company': '千克',
 | ||
| 							'carbon': 1.4,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'e2'
 | ||
| 						},
 | ||
| 						{
 | ||
| 							'title': '一次性筷子',
 | ||
| 							'company': '双',
 | ||
| 							'carbon': 0.023,
 | ||
| 							'num': '',
 | ||
| 							'tag': 'e3'
 | ||
| 						}
 | ||
| 					]
 | ||
| 				},
 | ||
| 				numlist: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '00', '.'],
 | ||
| 				operateList: ['DEL','AC', '计算'],
 | ||
| 				cateTagList: [], //分类标题
 | ||
| 				subTotal: [0, 0, 0, 0, 0], //小计
 | ||
| 				total: 0, //总计
 | ||
| 
 | ||
| 				focusIndex: '', //选中一级分类
 | ||
| 				focusIndex1: 0, //选中二级分类
 | ||
| 				
 | ||
| 				// 评估碳足迹
 | ||
| 				member: 1, //家庭成员
 | ||
| 				average: 0, //平均值
 | ||
| 				cacheTotal:0, //缓存总计
 | ||
| 				cacheSubTotal:[], //缓存小计
 | ||
| 				showTotal: [], //显示总计
 | ||
| 				histogram: {}, //柱状图数据
 | ||
| 				pie: {}, //饼图数据
 | ||
| 				heightList: [], //柱状高度
 | ||
| 				averageHeight:0, //足迹icon图片
 | ||
| 				
 | ||
| 				// 消除碳足迹
 | ||
| 				treeNum: 0, //树数量
 | ||
| 				money: 0, //捐款额
 | ||
| 				ifShow:false, //是否显示证书
 | ||
| 				code:'', //证书编码
 | ||
| 				experients:0, //体验者编号
 | ||
| 				difference:0, //补齐位数
 | ||
| 				date:'', //报告时间
 | ||
| 				webViewUrl:'', //web-view地址
 | ||
| 				
 | ||
| 				// 双击控制
 | ||
| 				index: 0,  
 | ||
| 				start_time: 0,  
 | ||
| 				end_time: 0,
 | ||
| 				scrollTop:0,
 | ||
| 			}
 | ||
| 		},
 | ||
| 		onLoad() {
 | ||
| 			if(uni.getStorageSync('cateTagList')){
 | ||
| 				this.cateTagList = uni.getStorageSync('cateTagList');
 | ||
| 			}
 | ||
| 			if(uni.getStorageSync('cacheTotal')){
 | ||
| 				this.total = uni.getStorageSync('cacheTotal');
 | ||
| 			}
 | ||
| 			if(uni.getStorageSync('cacheSubTotal')){
 | ||
| 				this.subTotal = uni.getStorageSync('cacheSubTotal');
 | ||
| 			}
 | ||
| 			if(uni.getStorageSync('cateList')){
 | ||
| 				this.cateList = uni.getStorageSync('cateList');
 | ||
| 			}
 | ||
| 			setTimeout(()=>{
 | ||
| 				const query = wx.createSelectorQuery().in(this);
 | ||
| 				query.select('.message-scroll').boundingClientRect((rect) => {
 | ||
| 					this.scrollTop = rect.height;
 | ||
| 				}).exec()
 | ||
| 			},200)
 | ||
| 		},
 | ||
| 		methods: {
 | ||
| 			//切换页面
 | ||
| 			changeNav(index) {
 | ||
| 				switch (index){
 | ||
| 					case 0:
 | ||
| 						if(index!==this.current){
 | ||
| 							this.current = index;
 | ||
| 							if(uni.getStorageSync('cateTagList')){
 | ||
| 								this.cateTagList = uni.getStorageSync('cateTagList');
 | ||
| 							}
 | ||
| 							if(uni.getStorageSync('cacheTotal')){
 | ||
| 								this.total = uni.getStorageSync('cacheTotal');
 | ||
| 							}
 | ||
| 							if(uni.getStorageSync('cacheSubTotal')){
 | ||
| 								this.subTotal = uni.getStorageSync('cacheSubTotal');
 | ||
| 							}
 | ||
| 							if(uni.getStorageSync('cateList')){
 | ||
| 								this.cateList = uni.getStorageSync('cateList');
 | ||
| 							}
 | ||
| 						}
 | ||
| 						break;
 | ||
| 					case 1:
 | ||
| 						if (uni.getStorageSync('subTotal')) {
 | ||
| 							if(index!==this.current){
 | ||
| 								this.current = index;
 | ||
| 								if (uni.getStorageSync('allTotal')) {
 | ||
| 									this.cacheTotal = uni.getStorageSync('allTotal');
 | ||
| 									this.showTotal = this.cacheTotal.toString().split('');
 | ||
| 									// 计算平均值
 | ||
| 									this.averageEv();
 | ||
| 								}
 | ||
| 								if (uni.getStorageSync('subTotal')) {
 | ||
| 									this.cacheSubTotal = uni.getStorageSync('subTotal');
 | ||
| 								}
 | ||
| 								// 计算柱状高度
 | ||
| 								let height01 = `${(this.subTotal[0]/this.total*280).toFixed(2)}%`;
 | ||
| 								let height02 = `${(this.subTotal[1]/this.total*280).toFixed(2)}%`;
 | ||
| 								let height03 = `${(this.subTotal[2]/this.total*280).toFixed(2)}%`;
 | ||
| 								let height04 = `${(this.subTotal[3]/this.total*280).toFixed(2)}%`;
 | ||
| 								let height05 = `${(this.subTotal[4]/this.total*280).toFixed(2)}%`;
 | ||
| 								this.heightList = [height01, height02, height03, height04, height05];
 | ||
| 								// 绘制饼图
 | ||
| 								this.pieEv();
 | ||
| 							}
 | ||
| 						} else {
 | ||
| 							uni.showToast({
 | ||
| 								title: '请先计算碳足迹',
 | ||
| 								icon: 'none',
 | ||
| 								duration: 2000
 | ||
| 							})
 | ||
| 						}
 | ||
| 						break;
 | ||
| 					case 2:
 | ||
| 						if (uni.getStorageSync('average')) {
 | ||
| 							if(index!==this.current){
 | ||
| 								this.current = index;
 | ||
| 								if(uni.getStorageSync('newUser')!=='newUser'){
 | ||
| 									if(uni.getStorageSync('experients')){
 | ||
| 										this.experients = uni.getStorageSync('experients')+1;
 | ||
| 									}else{
 | ||
| 										this.experients = 1;
 | ||
| 									}
 | ||
| 									uni.setStorageSync('experients',this.experients);
 | ||
| 									uni.setStorageSync('newUser','newUser');
 | ||
| 								}else{
 | ||
| 									this.experients = uni.getStorageSync('experients');
 | ||
| 								}
 | ||
| 								this.difference = 6-this.experients.toString().length;
 | ||
| 								if (uni.getStorageSync('allTotal') && uni.getStorageSync('average')) {
 | ||
| 									this.total = uni.getStorageSync('allTotal');
 | ||
| 									this.average = uni.getStorageSync('average');
 | ||
| 									this.treeNum = this.average/440.00*1;
 | ||
| 									this.money = this.treeNum*67.6*1;
 | ||
| 									this.webViewUrl = `http://e-file.thjj.org/tools/thjj-c.htm?cid=122104&y=0&mn=${this.money}`;
 | ||
| 								}
 | ||
| 								const date = new Date();
 | ||
| 								let year = date.getFullYear();
 | ||
| 								let month = date.getMonth() + 1;
 | ||
| 								let day = date.getDate();
 | ||
| 								let hour = date.getHours();
 | ||
| 								let minute = date.getMinutes();
 | ||
| 								let second = date.getSeconds();
 | ||
| 								let random = Math.ceil(Math.random() * 99 + 1);
 | ||
| 								this.date = `${year}年${month<10?'0'+month:month}月${day<10?'0'+day:day}日`;
 | ||
| 								this.code = `${year.toString().substr(2)}${month<10?'0'+month:month}${day<10?'0'+day:day}${hour<10?'0'+hour:hour}${minute<10?'0'+minute:minute}${second<10?'0'+second:second}${random<10?'0'+random:random}`
 | ||
| 							}
 | ||
| 						} else {
 | ||
| 							uni.showToast({
 | ||
| 								title: '请先评估碳足迹',
 | ||
| 								icon: 'none',
 | ||
| 								duration: 2000
 | ||
| 							})
 | ||
| 						}
 | ||
| 						break;
 | ||
| 					case 3:
 | ||
| 						if(index!==this.current){
 | ||
| 							this.current = index;
 | ||
| 							setTimeout(()=>{
 | ||
| 								// webView信息
 | ||
| 								let iframeInfo = {};
 | ||
| 								const query = wx.createSelectorQuery().in(this)
 | ||
| 								query.select('.iframe-box').boundingClientRect((rect) => {
 | ||
| 									iframeInfo.top = rect.top;
 | ||
| 									iframeInfo.left = rect.left;
 | ||
| 									iframeInfo.width = rect.width;
 | ||
| 									iframeInfo.height = rect.height;
 | ||
| 								}).exec()
 | ||
| 								
 | ||
| 								let currentWebview = this.$scope.$getAppWebview();
 | ||
| 								setTimeout(()=> {
 | ||
| 									let wv = currentWebview.children()[0];
 | ||
| 									wv.setStyle({top:iframeInfo.top,left:iframeInfo.left,width:iframeInfo.width,height:iframeInfo.height});
 | ||
| 									wv.overrideUrlLoading({mode:"reject",match:'.*www\.thjj\.org/list.html#key.*'}, (e)=>{
 | ||
| 										let wxCode = e.url.substr(e.url.indexOf('=')+1);
 | ||
| 										console.log(wxCode+'微信证书编号')
 | ||
| 										this.webViewUrl = `http://e-file.thjj.org/ajaxserv/webform/zfb/show.aspx?no=${wxCode}`;
 | ||
| 									}); 
 | ||
| 									wv.addEventListener('titleUpdate',({title}) => {
 | ||
| 										console.log(title+'标题url')
 | ||
| 										if(title.indexOf('show.aspx?no=')!==-1){
 | ||
| 											let zfbCode = title.substr(title.indexOf('show.aspx?no=')+1);
 | ||
| 											console.log(zfbCode+'支付宝编号');
 | ||
| 										}
 | ||
| 									})
 | ||
| 								}, 100);
 | ||
| 							},100)
 | ||
| 						}
 | ||
| 						break;
 | ||
| 				}
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 选择分类
 | ||
| 			changeEv(index, index1) {
 | ||
| 				let delIndex = this.cateTagList.indexOf(this.cateList[index][index1].tag);
 | ||
| 				this.index = this.index == 0 ? 1 : this.index + 1;  
 | ||
| 				if (this.index == 1) {  
 | ||
| 					this.start_time = new Date().getTime();  
 | ||
| 					setTimeout(()=>{  
 | ||
| 						this.index = this.start_time = this.end_time = 0;
 | ||
| 						if(delIndex==-1){
 | ||
| 							this.cateTagList.push(this.cateList[index][index1].tag);
 | ||
| 							this.focusIndex = index;
 | ||
| 							this.focusIndex1 = index1;
 | ||
| 							// 缓存已选分类
 | ||
| 							uni.setStorageSync('cateTagList',this.cateTagList);
 | ||
| 						}
 | ||
| 					},200)
 | ||
| 				} else if (this.index == 2) {  
 | ||
| 					this.end_time = new Date().getTime();  
 | ||
| 					if (this.end_time - this.start_time < 300) {
 | ||
| 						if(delIndex!==-1){
 | ||
| 							this.cateTagList.splice(delIndex,1);
 | ||
| 							this.cateList[index][index1].num = '';
 | ||
| 							this.focusIndex = '';
 | ||
| 							// 缓存已选分类
 | ||
| 							uni.setStorageSync('cateTagList',this.cateTagList);
 | ||
| 						}
 | ||
| 					} 
 | ||
| 					this.index = this.start_time = this.end_time = 0;  
 | ||
| 				}
 | ||
| 			},
 | ||
| 
 | ||
| 			// 获取光标
 | ||
| 			changeFocus(index, index1) {
 | ||
| 				this.focusIndex = index;
 | ||
| 				this.focusIndex1 = index1;
 | ||
| 			},
 | ||
| 
 | ||
| 			// 计算器按钮
 | ||
| 			chengeNum(num) {
 | ||
| 				if (this.cateTagList.length > 0) {
 | ||
| 					let curNum = this.cateList[this.focusIndex][this.focusIndex1].num;
 | ||
| 					if (curNum.indexOf('.') == -1 && curNum !== '') {
 | ||
| 						this.cateList[this.focusIndex][this.focusIndex1].num = curNum + num;
 | ||
| 					} else {
 | ||
| 						if (num !== '.') {
 | ||
| 							this.cateList[this.focusIndex][this.focusIndex1].num = curNum + num;
 | ||
| 						}
 | ||
| 					}
 | ||
| 				}
 | ||
| 			},
 | ||
| 
 | ||
| 			// 计算 || 清除
 | ||
| 			choseEv(index) {
 | ||
| 				if (this.cateTagList.length > 0) {
 | ||
| 					if (index == 0) {
 | ||
| 						this.cateList[this.focusIndex][this.focusIndex1].num = '';
 | ||
| 					}else if(index == 1){
 | ||
| 						// 清除所有数据
 | ||
| 						this.clearEv();
 | ||
| 					} else {
 | ||
| 						// 计算
 | ||
| 						this.calculationEv();
 | ||
| 					}
 | ||
| 				}
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 清除所有数据
 | ||
| 			clearEv(){
 | ||
| 				this.cateList['衣'].forEach(item=>item.num = '');
 | ||
| 				this.cateList['食'].forEach(item=>item.num = '');
 | ||
| 				this.cateList['住'].forEach(item=>item.num = '');
 | ||
| 				this.cateList['行'].forEach(item=>item.num = '');
 | ||
| 				this.cateList['用'].forEach(item=>item.num = '');
 | ||
| 				this.cateTagList = [];
 | ||
| 				this.subTotal = [0, 0, 0, 0, 0];
 | ||
| 				this.total = 0; //总计
 | ||
| 				// 清除缓存
 | ||
| 				const res = uni.getStorageInfoSync();
 | ||
| 				res.keys.map((item) => {
 | ||
| 					if (item !== 'experients') {
 | ||
| 						uni.removeStorageSync(item);
 | ||
| 					}
 | ||
| 				})
 | ||
| 			},
 | ||
| 
 | ||
| 			// 计算
 | ||
| 			calculationEv() {
 | ||
| 				this.focusIndex = '';
 | ||
| 				// 小计
 | ||
| 				let subTotalArr1 = this.cateList['衣'].filter(item => {
 | ||
| 					return item.num !== ''
 | ||
| 				});
 | ||
| 				let subTotalNum1 = 0;
 | ||
| 				subTotalArr1.forEach(item => {
 | ||
| 					subTotalNum1 += item.num * item.carbon * 1;
 | ||
| 				})
 | ||
| 				this.subTotal[0] = parseFloat(subTotalNum1);
 | ||
| 
 | ||
| 				let subTotalArr2 = this.cateList['食'].filter(item => {
 | ||
| 					return item.num !== ''
 | ||
| 				});
 | ||
| 				let subTotalNum2 = 0;
 | ||
| 				subTotalArr2.forEach(item => {
 | ||
| 					subTotalNum2 += item.num * item.carbon * 1;
 | ||
| 				})
 | ||
| 				this.subTotal[1] = parseFloat(subTotalNum2);
 | ||
| 
 | ||
| 				let subTotalArr3 = this.cateList['住'].filter(item => {
 | ||
| 					return item.num !== ''
 | ||
| 				});
 | ||
| 				let subTotalNum3 = 0;
 | ||
| 				subTotalArr3.forEach(item => {
 | ||
| 					subTotalNum3 += item.num * item.carbon * 1;
 | ||
| 				})
 | ||
| 				this.subTotal[2] = parseFloat(subTotalNum3);
 | ||
| 
 | ||
| 				let subTotalArr4 = this.cateList['行'].filter(item => {
 | ||
| 					return item.num !== ''
 | ||
| 				});
 | ||
| 				let subTotalNum4 = 0;
 | ||
| 				subTotalArr4.forEach(item => {
 | ||
| 					subTotalNum4 += item.num * item.carbon * 1;
 | ||
| 				})
 | ||
| 				this.subTotal[3] = parseFloat(subTotalNum4);
 | ||
| 
 | ||
| 				let subTotalArr5 = this.cateList['用'].filter(item => {
 | ||
| 					return item.num !== ''
 | ||
| 				});
 | ||
| 				let subTotalNum5 = 0;
 | ||
| 				subTotalArr5.forEach(item => {
 | ||
| 					subTotalNum5 += item.num * item.carbon * 1;
 | ||
| 				})
 | ||
| 				this.subTotal[4] = parseFloat(subTotalNum5);
 | ||
| 				
 | ||
| 				uni.setStorageSync('cacheSubTotal', this.subTotal);
 | ||
| 
 | ||
| 				// 总计
 | ||
| 				let totalArr = this.subTotal.filter(item => {
 | ||
| 					return item !== 0
 | ||
| 				});
 | ||
| 				let totalNum = 0;
 | ||
| 				totalArr.forEach(item => {
 | ||
| 					totalNum += item * 1;
 | ||
| 				})
 | ||
| 				this.total = parseFloat(totalNum);
 | ||
| 				uni.setStorageSync('cacheTotal', this.total);
 | ||
| 
 | ||
| 				// 缓存小计数据
 | ||
| 				let cacheTotal = [];
 | ||
| 				cacheTotal[0] = this.subTotal[0].toFixed(2);
 | ||
| 				cacheTotal[1] = this.subTotal[1].toFixed(2);
 | ||
| 				cacheTotal[2] = this.subTotal[2].toFixed(2);
 | ||
| 				cacheTotal[3] = this.subTotal[3].toFixed(2);
 | ||
| 				cacheTotal[4] = this.subTotal[4].toFixed(2);
 | ||
| 				uni.setStorageSync('subTotal', cacheTotal);
 | ||
| 				
 | ||
| 				// 缓存总计数据
 | ||
| 				uni.setStorageSync('allTotal', this.total.toFixed(2));
 | ||
| 				
 | ||
| 				// 缓存分类数组
 | ||
| 				uni.setStorageSync('cateList', this.cateList);
 | ||
| 				
 | ||
| 				// 滚动到底部
 | ||
| 				this.scrollToButtom();
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 滚动到底部
 | ||
| 			scrollToButtom() {
 | ||
| 				const query = wx.createSelectorQuery().in(this);
 | ||
| 				query.select('.message-scroll').boundingClientRect((rect) => {
 | ||
| 					this.scrollTop = rect.height;
 | ||
| 				}).exec()
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 获取饼图数据
 | ||
| 			pieEv() {
 | ||
| 				this.pie = {
 | ||
| 					tooltip: {
 | ||
| 						trigger: 'item'
 | ||
| 					},
 | ||
| 					series: [{
 | ||
| 						type: 'pie',
 | ||
| 						color: [
 | ||
| 							'#a6fea5',
 | ||
| 							'#ffb0ae',
 | ||
| 							'#92dede',
 | ||
| 							'#ffdaad',
 | ||
| 							'#8888ac'
 | ||
| 						],
 | ||
| 						radius: '50%',
 | ||
| 						label: {
 | ||
| 							fontSize: 15,
 | ||
| 							color: '#000',
 | ||
| 							fontWeight: 'bold'
 | ||
| 						},
 | ||
| 						data: [{
 | ||
| 								value: this.subTotal[0],
 | ||
| 								name: `${(this.subTotal[0]/this.total*100).toFixed(2)}%`
 | ||
| 							},
 | ||
| 							{
 | ||
| 								value: this.subTotal[1],
 | ||
| 								name: `${(this.subTotal[1]/this.total*100).toFixed(2)}%`
 | ||
| 							},
 | ||
| 							{
 | ||
| 								value: this.subTotal[2],
 | ||
| 								name: `${(this.subTotal[2]/this.total*100).toFixed(2)}%`
 | ||
| 							},
 | ||
| 							{
 | ||
| 								value: this.subTotal[3],
 | ||
| 								name: `${(this.subTotal[3]/this.total*100).toFixed(2)}%`
 | ||
| 							},
 | ||
| 							{
 | ||
| 								value: this.subTotal[4],
 | ||
| 								name: `${(this.subTotal[4]/this.total*100).toFixed(2)}%`
 | ||
| 							}
 | ||
| 						],
 | ||
| 					}]
 | ||
| 				}
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 绘制饼图
 | ||
| 			init() {
 | ||
| 				this.$refs.chart.init(echarts, chart => {
 | ||
| 					chart.setOption(this.pie);
 | ||
| 				});
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 改变数量
 | ||
| 			changeNum(type) {
 | ||
| 				if (type == 'reduce') {
 | ||
| 					if (this.member > 1) {
 | ||
| 						this.member--
 | ||
| 					}
 | ||
| 				}
 | ||
| 				if (type == 'add') {
 | ||
| 					this.member++
 | ||
| 				}
 | ||
| 				// 计算平均值
 | ||
| 				this.averageEv();
 | ||
| 			},
 | ||
| 			
 | ||
| 			// 计算平均值
 | ||
| 			averageEv() {
 | ||
| 				let averageNum = this.total / this.member * 1;
 | ||
| 				this.average = averageNum.toFixed(2);
 | ||
| 				this.averageHeight = Math.ceil((this.average*30)/2330*1);
 | ||
| 				uni.setStorageSync('average', this.average);
 | ||
| 			},
 | ||
| 		},
 | ||
| 		onReady() {
 | ||
| 			LySDKModule.openSecondScreen({
 | ||
| 					url: plus.io.convertLocalFileSystemURL("/static/index.html"),//副屏url
 | ||
| 				},ret => {
 | ||
| 					uni.showToast({
 | ||
| 						icon: 'none',
 | ||
| 						title: ret
 | ||
| 					});
 | ||
| 				}
 | ||
| 			);
 | ||
| 		}
 | ||
| 	}
 | ||
| </script>
 | ||
| 
 | ||
| <style>
 | ||
| 
 | ||
| </style>
 |