com.kailaimei.carbon/pages/count/count.vue

954 lines
28 KiB
Vue
Raw Normal View History

2023-02-03 10:05:19 +08:00
<template>
<view class="main">
<!-- 头部 -->
2023-02-03 14:19:23 +08:00
<status-nav></status-nav>
2023-02-03 10:05:19 +08:00
<!-- 计算碳足迹 -->
<view class="calculator-bg">
<view class="bg-img">
<image src="/static/count-bg.png" mode="widthFix"></image>
</view>
<view class="calculator">
2023-02-22 09:01:38 +08:00
<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>
2023-02-03 10:05:19 +08:00
</view>
2023-02-22 09:01:38 +08:00
</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>
2023-02-03 10:05:19 +08:00
</view>
</view>
</view>
2023-02-22 09:01:38 +08:00
<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>
2023-02-03 10:05:19 +08:00
</view>
</view>
</view>
2023-02-22 09:01:38 +08:00
<!-- 饼图 -->
<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>
2023-02-03 10:05:19 +08:00
</view>
2023-02-22 09:01:38 +08:00
</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">
2023-02-03 10:05:19 +08:00
<view class="item">
2023-02-22 09:01:38 +08:00
<image src="/static/footprint.png" mode="heightFix" :style="{height:averageHeight>=230?'230px':averageHeight+'px'}"></image>
<view>您的碳足迹为</view>
<view><text>{{average}}</text>kg</view>
2023-02-03 10:05:19 +08:00
</view>
<view class="item">
2023-02-22 09:01:38 +08:00
<image src="/static/footprint.png" mode="heightFix" style="height: 92px;"></image>
<view>中国人均碳足迹为</view>
<view><text>7100</text>kg</view>
2023-02-03 10:05:19 +08:00
</view>
<view class="item">
2023-02-22 09:01:38 +08:00
<image src="/static/footprint.png" mode="heightFix" style="height: 207px;"></image>
<view>美国人均碳足迹为</view>
<view><text>16100</text>kg</view>
2023-02-03 10:05:19 +08:00
</view>
<view class="item">
2023-02-22 09:01:38 +08:00
<image src="/static/footprint.png" mode="heightFix" style="height: 60px;"></image>
<view>全球人均碳足迹为</view>
<view><text>4700</text>kg</view>
2023-02-03 10:05:19 +08:00
</view>
<view class="item">
2023-02-22 09:01:38 +08:00
<image src="/static/footprint.png" mode="heightFix" style="height: 30px;"></image>
<view>应对气候变化全球人均目标碳足迹为</view>
<view><text>2330</text>kg</view>
2023-02-03 10:05:19 +08:00
</view>
</view>
2023-02-22 09:01:38 +08:00
</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
2023-02-03 10:05:19 +08:00
</view>
2023-02-22 09:01:38 +08:00
<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>
2023-02-03 10:05:19 +08:00
</view>
</view>
</view>
2023-02-22 09:01:38 +08:00
<!-- 在线捐款 -->
<view class="iframe-box" style="padding-top: 0;" v-if="current==3">
<web-view :src="webViewUrl" allow></web-view>
</view>
2023-02-03 14:19:23 +08:00
<!-- 导航 -->
2023-02-22 09:01:38 +08:00
<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> -->
2023-02-03 14:19:23 +08:00
<!-- 操作说明 -->
2023-02-16 10:18:20 +08:00
<view class="explain">友情提醒计算前请先按AC键消除上一用户数据</view>
2023-02-03 10:05:19 +08:00
</view>
</view>
<!-- 轮播 -->
<view class="banner">
<swiper-pull></swiper-pull>
</view>
<!-- 底部 -->
<view class="footer">
2023-02-20 14:53:06 +08:00
<text>中国绿色碳汇基金会低碳旅游专项基金监制北京凯来美气候科技有限公司开发</text>
2023-02-03 10:05:19 +08:00
</view>
2023-02-22 09:01:38 +08:00
<!-- 证书 -->
<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>
2023-02-03 10:05:19 +08:00
</view>
</template>
<script>
2023-02-03 14:19:23 +08:00
import statusNav from '@/components/status-nav/status-nav.vue';
2023-02-03 10:05:19 +08:00
import swiperPull from '@/components/swiper/swiper-pull.vue';
2023-02-22 09:01:38 +08:00
import * as echarts from '@/uni_modules/lime-echart/static/echarts.min.js';
2023-02-22 14:45:40 +08:00
// 初始化
2023-02-27 15:48:10 +08:00
var LySDKModule = uni.requireNativePlugin('LY028-NativeSdk');
2023-02-03 10:05:19 +08:00
export default {
components: {
2023-02-03 14:19:23 +08:00
statusNav,
2023-02-03 10:05:19 +08:00
swiperPull
},
data() {
return {
statusHeight: uni.getSystemInfoSync().statusBarHeight, //状态栏高度
2023-02-22 09:01:38 +08:00
navList:['/pages/count/count','/pages/assess/assess','/pages/eliminate/eliminate'],
current:0, //当前选择
2023-02-03 10:05:19 +08:00
cateList: {
'衣': [{
'title': '购买衣服数量',
'company': '件',
2023-02-06 16:56:58 +08:00
'carbon': 7.01,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'a1'
},
{
'title': '洗衣粉使用量',
2023-02-03 10:05:19 +08:00
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 1.46,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'a2'
}
],
'食': [{
'title': '吸烟数量',
'company': '包',
2023-02-16 10:18:20 +08:00
'carbon': 0.1182,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'b1'
},
{
'title': '喝白酒数量',
2023-02-06 16:56:58 +08:00
'company': '升',
'carbon': 4.5,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'b2'
},
2023-02-06 16:56:58 +08:00
{
'title': '喝红酒数量',
'company': '升',
'carbon': 1.75,
'num': '',
'tag': 'b3'
},
2023-02-03 10:05:19 +08:00
{
'title': '喝啤酒数量',
'company': '瓶',
2023-02-06 16:56:58 +08:00
'carbon': 0.43,
2023-02-03 10:05:19 +08:00
'num': '',
2023-02-06 16:58:27 +08:00
'tag': 'b4'
2023-02-03 10:05:19 +08:00
},
{
'title': '肉类消费',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 8.823,
2023-02-03 10:05:19 +08:00
'num': '',
2023-02-06 16:58:27 +08:00
'tag': 'b5'
2023-02-03 10:05:19 +08:00
},
{
'title': '粮食消费',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 0.918,
2023-02-03 10:05:19 +08:00
'num': '',
2023-02-06 16:58:27 +08:00
'tag': 'b6'
2023-02-03 10:05:19 +08:00
}
],
'住': [{
'title': '用电',
'company': '度',
2023-02-06 16:56:58 +08:00
'carbon': 0.581,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c1'
},
{
'title': '煤气',
'company': '立方米',
2023-02-06 16:56:58 +08:00
'carbon': 2.826,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c2'
},
{
'title': '天然气',
'company': '立方米',
2023-02-06 16:56:58 +08:00
'carbon': 2.826,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c3'
},
{
'title': '燃煤',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 3.0978,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c4'
},
{
'title': '集中取暖',
'company': '立方米',
2023-02-06 16:56:58 +08:00
'carbon': 46.57,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c5'
},
{
'title': '装修用木材',
2023-02-06 16:56:58 +08:00
'company': '千克',
'carbon': 0.31,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c6'
},
{
'title': '装修用陶瓷',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 0.74,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c7'
},
{
'title': '装修用钢材',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 2.3,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c8'
},
{
'title': '装修用铝材',
2023-02-06 16:56:58 +08:00
'company': '千克',
'carbon': 15.8,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'c9'
}
],
'行': [{
'title': '飞机',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.088,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd1'
},
{
'title': '火车',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.0262,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd2'
},
{
'title': '轮船',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.128,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd3'
},
{
'title': '地铁',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.0153,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd4'
},
{
'title': '公共汽车',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.03344,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd5'
},
{
'title': '低油耗小轿车',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.16,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd6'
},
{
'title': '中油耗小轿车',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.24,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd7'
},
{
'title': '高油耗小轿车',
2023-02-06 16:56:58 +08:00
'company': '千米',
'carbon': 0.33,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'd8'
},
],
'用': [{
'title': '塑料袋使用量',
'company': '个',
2023-02-06 16:56:58 +08:00
'carbon': 0.0821,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'e1'
},
{
'title': '纸制品',
'company': '千克',
2023-02-06 16:56:58 +08:00
'carbon': 1.4,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'e2'
},
{
'title': '一次性筷子',
'company': '双',
2023-02-06 16:56:58 +08:00
'carbon': 0.023,
2023-02-03 10:05:19 +08:00
'num': '',
'tag': 'e3'
}
]
},
numlist: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '00', '.'],
2023-02-16 10:18:20 +08:00
operateList: ['DEL','AC', '计算'],
2023-02-03 10:05:19 +08:00
cateTagList: [], //分类标题
subTotal: [0, 0, 0, 0, 0], //小计
total: 0, //总计
focusIndex: '', //选中一级分类
focusIndex1: 0, //选中二级分类
2023-02-22 09:01:38 +08:00
// 评估碳足迹
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,
2023-02-03 10:05:19 +08:00
}
},
onLoad() {
2023-02-16 10:18:20 +08:00
if(uni.getStorageSync('cateTagList')){
this.cateTagList = uni.getStorageSync('cateTagList');
2023-02-03 10:05:19 +08:00
}
2023-02-16 10:18:20 +08:00
if(uni.getStorageSync('cacheTotal')){
this.total = uni.getStorageSync('cacheTotal');
2023-02-03 14:19:23 +08:00
}
2023-02-16 10:18:20 +08:00
if(uni.getStorageSync('cacheSubTotal')){
this.subTotal = uni.getStorageSync('cacheSubTotal');
}
if(uni.getStorageSync('cateList')){
this.cateList = uni.getStorageSync('cateList');
2023-02-13 15:08:16 +08:00
}
2023-02-22 09:01:38 +08:00
setTimeout(()=>{
const query = wx.createSelectorQuery().in(this);
query.select('.message-scroll').boundingClientRect((rect) => {
this.scrollTop = rect.height;
}).exec()
},200)
2023-02-03 10:05:19 +08:00
},
methods: {
2023-02-22 09:01:38 +08:00
//切换页面
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;
}
},
2023-02-03 10:05:19 +08:00
// 选择分类
changeEv(index, index1) {
2023-02-22 09:01:38 +08:00
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;
}
2023-02-03 10:05:19 +08:00
},
// 获取光标
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 = '';
2023-02-16 10:18:20 +08:00
}else if(index == 1){
// 清除所有数据
this.clearEv();
2023-02-03 10:05:19 +08:00
} else {
// 计算
this.calculationEv();
}
}
},
2023-02-16 10:18:20 +08:00
// 清除所有数据
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);
}
})
},
2023-02-03 10:05:19 +08:00
// 计算
calculationEv() {
2023-02-22 09:01:38 +08:00
this.focusIndex = '';
2023-02-03 10:05:19 +08:00
// 小计
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);
2023-02-16 10:18:20 +08:00
uni.setStorageSync('cacheSubTotal', this.subTotal);
2023-02-03 10:05:19 +08:00
// 总计
let totalArr = this.subTotal.filter(item => {
return item !== 0
});
let totalNum = 0;
totalArr.forEach(item => {
totalNum += item * 1;
})
this.total = parseFloat(totalNum);
2023-02-16 10:18:20 +08:00
uni.setStorageSync('cacheTotal', this.total);
2023-02-03 10:05:19 +08:00
// 缓存小计数据
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);
2023-02-03 14:19:23 +08:00
// 缓存总计数据
uni.setStorageSync('allTotal', this.total.toFixed(2));
2023-02-16 10:18:20 +08:00
// 缓存分类数组
uni.setStorageSync('cateList', this.cateList);
2023-02-22 09:01:38 +08:00
// 滚动到底部
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);
2023-02-03 10:05:19 +08:00
},
2023-02-22 14:45:40 +08:00
},
onReady() {
2023-02-24 18:10:48 +08:00
LySDKModule.openSecondScreen({
2023-02-27 15:48:10 +08:00
url: plus.io.convertLocalFileSystemURL("/static/index.html"),//副屏url
2023-02-24 18:10:48 +08:00
},ret => {
uni.showToast({
icon: 'none',
title: ret
2023-02-22 14:45:40 +08:00
});
}
2023-02-24 18:10:48 +08:00
);
2023-02-03 10:05:19 +08:00
}
}
</script>
<style>
</style>