| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- const app = getApp();
- import * as echarts from '../../../../ec-canvas/echarts' // 这个是自己实际的目录
- Component({
- data:{
- Ec: { lazyLoad: true, },
- },
- lifetimes: {
- attached: function () {
- var token = wx.getStorageSync('token');
- if(!token){
- var list = [{name:"追溯产品",value:999,},{name:"非追溯产品",value:666,},]
- this.initChart(list);
- }
- },
- moved: function () { },
- detached: function () { },
- },
- properties:{
- prductIndex:{
- type:String,
- value:'',
- }
- },
- observers:{
- 'prductIndex':function(nv,ol){
- var token = wx.getStorageSync('token');
- if(token && nv){
- this.getRetransProductState(nv);
- }
- }
- },
- methods:{
- getRetransProductState(productName){
- app.requestP({
- url: '/daping/retransProductState?productName='+productName,
- method: 'post',
- }).then(res=>{
- var data = res.data.data[0];
- var list = [{name:"追溯产品",value:data.zs,},{name:"非追溯产品",value:data.normal,},]
- this.initChart(list);
- })
- },
- initChart(list){
- var that = this;
- that.selectComponent('#chartConDom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- var option = that.getOrderWarnOption(list);
- chart.setOption(option);
- return chart;
- });
- },
- getOrderWarnOption(list){
-
- var fontSize = 10
- var fontColor = "#999999"
- return {
- color:["#7A4AFF","#FFAE36"],
- legend:{
- icon:"circle",
- itemWidth:fontSize*0.8,
- itemHeight:fontSize*0.8,
- textStyle:{
- fontSize:fontSize*0.9,
- color:fontColor,
- },
- data:list.map(item=>item.name)
- },
- series:[
- {
- type: 'pie',
- silent:1,
- radius:'75%',
- center: ["50%", '55%'],
- label:{
- show:true,
- formatter:"{c}",
- fontSize:10,
- position:"inside",
- color:'#ffffff',
- },
- data: list,
- },
- ]
- }
- },
- },
- })
|