index.js 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683
  1. // index.js
  2. // 获取应用实例
  3. import * as echarts from '../../ec-canvas/echarts' // 这个是自己实际的目录
  4. import {path} from '../../utils/circle';
  5. const app = getApp()
  6. Page({
  7. data: {
  8. showRight:false,
  9. transportStatusData:{},
  10. transportBusinessData:{},
  11. transportBusinessNum:1,
  12. orderWaringStatusData:{},
  13. waringStatus:0,
  14. waringStatusList:["当天","本周","本月",],
  15. transportCityData:[],
  16. transOrderList:[],
  17. transOrderIndex:0,
  18. polyline:[],
  19. tempList:[],
  20. hisLocal:[],
  21. urlLeft:'/group156/default/20211216/16/58/6/bde42061736d8dfcd68bbe33fd9464a0.jpg"',
  22. banner: "/group156/default/20211216/16/58/6/bde42061736d8dfcd68bbe33fd9464a0.jpg",
  23. ossPath: app.globalData.$filePath,
  24. title: '冷链追溯系统',
  25. token: '',
  26. mapCtx: '',
  27. latitude: '', //纬度
  28. longitude: '', //经度
  29. navbarData: {
  30. title: app.globalData.title,
  31. showCapsule: true,
  32. share: false
  33. },
  34. alarmDTO: {
  35. chipNum: 0,
  36. allTimeNum: 0,
  37. realTimeNum: 0
  38. },
  39. temperatureDTO: { //温度监测数量
  40. normal: 0,
  41. warning: 0,
  42. alarm: 0
  43. },
  44. waringDTO: {
  45. chipNum: 0,
  46. allTimeNum: 0,
  47. realTimeNum: 0
  48. },
  49. inTrans: 0, //已出库(个)
  50. inStore: 0, //已入库(个)
  51. inEnd: 0, //已结束(个)
  52. total: 0, //已生产(个)
  53. error11: 0, //一型有源报警数量
  54. error20: 0, //二型报警数量
  55. total10: 0, //一型无源数量
  56. total11: 0, //一型有源数量
  57. total20: 0, //二型数量
  58. warning11: 0, //一型有源预警数量
  59. warning20: 0, //一型无源预警数量
  60. mapTopData: {
  61. name: '暂无',
  62. status: '暂无',
  63. updateTime: '暂无',
  64. lastTemperature: '暂无',
  65. minTemperature: '暂无',
  66. maxTemperature: '暂无'
  67. },
  68. llzsEc: {
  69. lazyLoad: true,
  70. },
  71. chainTempList: [],
  72. tempList:[],
  73. Ec: {
  74. lazyLoad: true,
  75. },
  76. pieEc: {
  77. lazyLoad: true,
  78. },
  79. labelNum: {
  80. lazyLoad: true,
  81. },
  82. latitude: 40,
  83. longitude: 116,
  84. status: {
  85. checkedMap:true,
  86. statisticsInfo:true,
  87. statusLabelTest:true,
  88. statusLabelNum:true,
  89. statusLabelType:true,
  90. expressStatu:true,
  91. transportStatus:true,
  92. tempChart:true,
  93. onlineNum:true,
  94. packageStatu:true,
  95. onlineSituat:true,
  96. newSituat:true
  97. },
  98. CustomBar: app.globalData.CustomBar,
  99. StatusBar: app.globalData.StatusBar,
  100. systemMenu: [{
  101. menuName: '查一查',
  102. icon: '/img/idx_img2.png',
  103. path: 'find',
  104. },
  105. {
  106. menuName: '冷链管理',
  107. icon: '/img/dev_img4.png',
  108. path: 'coldChain'
  109. },
  110. {
  111. menuName: '产品管理',
  112. icon: '/img/idx_img4.png',
  113. path: 'productManager'
  114. },
  115. {
  116. menuName: '员工管理',
  117. icon: '/img/idx_img5.png',
  118. path: 'workerManager'
  119. },
  120. ],
  121. isAuth: false,
  122. showAuthWin: false,
  123. showChaType: false,
  124. isPrem: false,
  125. device: false,
  126. modalHidden: true,
  127. scrollTop:0,//滚动监听
  128. // 沃森新
  129. cardIndex:0,
  130. tabLeftTop:[
  131. {name:'新冠',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'},
  132. {name:'肺炎',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'},
  133. {name:'流感',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'}
  134. ],
  135. tabLeftTop_remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常',
  136. orderCardList:[{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50},{createTime:'2022-07-01',num:50}]
  137. },
  138. // 事件处理函数
  139. onLoad() {
  140. var that = this;
  141. if (!wx.getStorageSync('status')) {
  142. wx.setStorageSync('status', JSON.stringify(that.data.status));
  143. }
  144. },
  145. showRight(){
  146. this.setData({
  147. showRight:true,
  148. })
  149. },
  150. onReady: function () {
  151. var that = this;
  152. // that.canvasRingA = that.selectComponent("#canvasRingA");
  153. // that.canvasRingB = that.selectComponent("#canvasRingB");
  154. // that.canvasRingC = that.selectComponent("#canvasRingC");
  155. // that.canvasRingG = that.selectComponent("#canvasRingG");
  156. // that.canvasRingA.showCanvasRing();
  157. // that.canvasRingB.showCanvasRing();
  158. // that.canvasRingC.showCanvasRing();
  159. // that.canvasRingG.showCanvasRing();
  160. // that.canvasRingD = that.selectComponent("#canvasRingD");
  161. // that.canvasRingE = that.selectComponent("#canvasRingE");
  162. // that.canvasRingF = that.selectComponent("#canvasRingF");
  163. // that.canvasRingL = that.selectComponent("#canvasRingL");
  164. // that.canvasRingD.showCanvasRing();
  165. // that.canvasRingE.showCanvasRing();
  166. // that.canvasRingF.showCanvasRing();
  167. // that.canvasRingL.showCanvasRing();
  168. },
  169. onShow: function (options) {
  170. var that = this;
  171. var status = JSON.parse(wx.getStorageSync('status')) || '';
  172. var title = wx.getStorageSync('title') || ''
  173. var status =status ? status:that.data.status;
  174. title = title ? title : '冷链追溯系统'
  175. this.setData({
  176. status,
  177. title
  178. })
  179. //获取新闻
  180. this.getNewsList();
  181. /**沃森新 */
  182. // this.setPie4Chart({total:8,abnormal:3,normal:8});
  183. // this.setCard_top_right_butChart([{"name":"北京","orderNum":50},{"name":"上海","orderNum":30},{"name":"安徽","orderNum":20},{"name":"成都","orderNum":20},{"name":"广东","orderNum":20},]);
  184. // this.product_two_left_two([
  185. // {name:'标签1',data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]},
  186. // {name:'标签2',data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]},
  187. // {name:'',data:[30.0, 42.2, 43.3, 44.5, 46.3, 80.2, 200.3, 123.4, 223.0, 26.5, 12.0, 6.2]},
  188. // ])
  189. // this.setCardPieTwo();
  190. // this.setCard3dBar();
  191. // this.setKLine();
  192. var diagamList = [
  193. {name: "标签1",value: 0,unNormalTotal:0,symbolSize:40},
  194. {name: "标签2",value: 0,unNormalTotal:0,symbolSize:40},
  195. {name: "标签3",value: 1,unNormalTotal:2,symbolSize:40},
  196. {name: "标签4",value: 3,unNormalTotal:1,symbolSize:40},
  197. {name: "标签5",value: 3,unNormalTotal:1,symbolSize:40},
  198. ]
  199. this.setCardDiagram(diagamList);
  200. // this.setCardFivePie();
  201. this.setCardXuTuOption({normalTotal:15});
  202. // this.setCardFivePie_rght();
  203. // var cardSixBarList = [{"name":"北京","orderNum":50},{"name":"上海","orderNum":30},{"name":"安徽","orderNum":20},{"name":"成都","orderNum":20},{"name":"广东","orderNum":20}];
  204. // var cardSixLineList = [{name:'标签1',data:[10,15,18,25,15]},{name:'标签2',data:[14,16,20,28,17]},{name:'标签3',data:[20,24,28,32,22]}]
  205. // this.setCardSixBar(cardSixBarList,cardSixLineList);
  206. // var sixRightBarList = [{data:[120, 132, 101, 134, 90, 230, 210]},{data:[220, 182, 191, 234, 290, 330, 310]},{data:[150, 232, 201, 154, 190, 330, 410]}]
  207. // this.setCardSixRightBar(sixRightBarList);
  208. // var sevenCardPieList = [
  209. // {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  210. // {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  211. // {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  212. // {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  213. // ]
  214. // this.setSevenCardPie(sevenCardPieList);
  215. // var sevenCardPieList = [
  216. // { name: "标签1", value: 50 },
  217. // { name: "标签2", value: 20 },
  218. // ]
  219. // this.setCardSenvenPie(sevenCardPieList);
  220. // var eightBarLeftList = [
  221. // {name:'标签1',data:[2.0, 4.9, 7.0, 23.2,]},
  222. // {name:'标签2',data:[2.6, 5.9, 9.0, 21.4,]},
  223. // {name:'标签3',data:[3.6, 6.9, 8.0, 18.4,]},
  224. // {name:'标签4',data:[4.6, 7.9, 7.0, 16.4,]},
  225. // ]
  226. // this.setCardEightBar(eightBarLeftList);
  227. // var eightRightBarList = [
  228. // {name:'标签1',data:[10, 20, 30, 40, 50, 60]},
  229. // {name:'标签2',data:[10, 20, 30, 40, 50, 60]},
  230. // {name:'标签3',data:[10, 20, 30, 40, 50, 60]},
  231. // {name:'',data:[15,22,32,45,48,67]}
  232. // ]
  233. // this.setCardEightRightBar(eightRightBarList);
  234. // this.setCardNineBar([{"name":"二价流脑","orderNum":50},{"name":"胶囊","orderNum":30},{"name":"产品1","orderNum":20},{"name":"颗粒","orderNum":20},]);
  235. // var nineRightBarList = [{name:'生产',data:[120, 132, 101, 134, 90, 230, 210]},{name:'销售',data:[220, 182, 191, 234, 290, 330, 310]},{name:'在途',data:[150, 232, 201, 154, 190, 330, 410]},{name:'交付',data:[158, 242, 141, 164, 180, 230, 510]}]
  236. // this.setCardNineRightBar(nineRightBarList);
  237. /**沃森新 */
  238. //获取token,若无则判定用户是游客访问,不进行任何请求
  239. var token = wx.getStorageSync('token');
  240. this.setData({
  241. token,
  242. chainTempList:[],
  243. tempList:[]
  244. })
  245. if (!token) {
  246. setTimeout(function () {
  247. that.noLogin()
  248. }, 500)
  249. return;
  250. }
  251. //地区产品统计
  252. this.setCardLeftFive({
  253. name:['北京', '云南', '广州', '辽宁', '山东', '重庆'],
  254. data:[
  255. {name:'2022',data:[18203, 23489, 29034, 104970, 131744, 630230]},
  256. {name:'2012',data:[19325, 23438, 31000, 121594, 134141, 681807]},
  257. ]
  258. });
  259. // 主产品查询
  260. this.getsignProduct();
  261. //主产品使用、库存、总数统计
  262. this.getSignProductUseAndStackState();
  263. //单一主产品不同地区使用情况
  264. this.getSingleProductUseZoneStat();
  265. // 获取按钮
  266. this.getUserDefaultMenuList();
  267. // 图5 主产品在库、在途、结束统计
  268. this.getSignProductState();
  269. },
  270. getOrderWarnOption(list){
  271. var fontSize = 12
  272. var fontColor = "#999999"
  273. return {
  274. color:["#0079FF","#FF723A","#EA1C43"],
  275. title: {
  276. show:false
  277. },
  278. grid:{
  279. top:"5%",
  280. left:"5%",
  281. right:"5%",
  282. bottom:"5%",
  283. },
  284. tooltip: {
  285. show:true
  286. },
  287. legend: {
  288. data:list.map(item=>item.name),
  289. icon:"rect",
  290. orient:"vertical",
  291. top:"middle",
  292. right:"10%",
  293. itemWidth:fontSize,
  294. itemHeight:fontSize,
  295. textStyle:{
  296. fontSize:fontSize,
  297. color:fontColor,
  298. },
  299. formatter(name){
  300. return name+" " + list.filter(item=>item.name == name)[0].num
  301. },
  302. },
  303. series: [
  304. {
  305. type: 'pie',
  306. silent:0,
  307. radius: ["40%", '90%'],
  308. center: ["30%", '50%'],
  309. label:{
  310. position:'inside',
  311. formatter:"{d}%",
  312. },
  313. itemStyle:{
  314. borderColor:"#ffffff",
  315. borderWidth:2,
  316. },
  317. data: list.filter(item=>{
  318. item.value = item.num
  319. return item
  320. }),
  321. },
  322. ]
  323. }
  324. },
  325. getCysOrderOption(list){
  326. var fontSize=8;
  327. return {
  328. color:["#7190F6","#FF723A","#EA1C43"],
  329. title: {
  330. show:false
  331. },
  332. grid:{
  333. top:"5%",
  334. left:"8%",
  335. right:"5%",
  336. bottom:"14%",
  337. },
  338. xAxis: {
  339. type: 'category',
  340. axisTick:{show:false,},
  341. axisLine:{lineStyle:{color:"#DEE3FF",}},
  342. axisLabel:{color:"#999999", fontSize,interval: 0},
  343. data: list.map(item=>item.name),
  344. },
  345. yAxis: {
  346. type: 'value',
  347. splitLine:{lineStyle:{color:"#DEE3FF",}},
  348. axisLabel:{color:"#999999", fontSize,},
  349. },
  350. series: [
  351. {
  352. type: 'bar',
  353. barMaxWidth:30,
  354. barMinHeight:10,
  355. data: list.map(item=>item.orderNum),
  356. },
  357. ]
  358. }
  359. },
  360. setTemp(temperature) {
  361. var that = this;
  362. that.ecWen = that.selectComponent('#ecDomWen');
  363. that.ecWen.init((canvas, width, height, dpr) => {
  364. const chart = echarts.init(canvas, null, {
  365. width: width,
  366. height: height,
  367. devicePixelRatio: dpr // new
  368. });
  369. var option = that.getTempOption();
  370. option.xAxis.data = temperature.map(v => v.createTime.replace(" ", "\n"));
  371. option.series[0].data = temperature.map(v => v.temp);
  372. chart.setOption(option);
  373. that.wenChart = chart;
  374. return chart;
  375. });
  376. },
  377. showMap(markers) {
  378. var that = this;
  379. var token = wx.getStorageSync('token');
  380. this.mapCtx = wx.createMapContext('home_map');
  381. var points = []
  382. for (var i in markers) {
  383. if(i==0){
  384. points.push({
  385. width:54,
  386. height:54,
  387. latitude:Number(markers[i].lat),
  388. longitude:Number(markers[i].lng),
  389. iconPath:"/img/map_icon1.png",
  390. })
  391. }
  392. else if(i == markers.length-1){
  393. points.push({
  394. width:54,
  395. height:54,
  396. latitude:Number(markers[i].lat),
  397. longitude:Number(markers[i].lng),
  398. iconPath:"/img/index_icon_1000.png",
  399. })
  400. }
  401. markers[i].latitude = Number(markers[i].lat)
  402. markers[i].longitude = Number(markers[i].lng)
  403. delete markers[i].lat
  404. delete markers[i].lng
  405. }
  406. that.setData({
  407. markers:points,
  408. polyline: [{
  409. color: '#2D59E6',
  410. width: 2,
  411. points: markers,
  412. }],
  413. latitude:markers.length != 0 ? markers[0].latitude : '',
  414. longitude:markers.length != 0 ? markers[0].longitude : ''
  415. });
  416. that.mapCtx.includePoints({
  417. points: markers || [],
  418. padding: [50, 50, 50, 50]
  419. })
  420. },
  421. noLogin() {
  422. var temp = [
  423. {temp: '23.3',createTime: "2021-12-03 17:06:40"},
  424. {temp: '23.2', createTime: "2021-12-03 17:08:10"},
  425. {temp: '23.1', createTime: "2021-12-03 17:09:40"},
  426. {temp: '23.1', createTime: "2021-12-03 17:11:10"},
  427. {temp: '23.3', createTime: "2021-12-03 17:12:40"},
  428. {temp:' 23.2', createTime: "2021-12-03 17:14:10"},
  429. {temp: '23.3', createTime: "2021-12-03 17:15:40"},
  430. {temp: '23.3', createTime: "2021-12-03 17:18:40"},
  431. {temp: '23.2', createTime: "2021-12-03 17:26:10"},
  432. {temp: '23.2', createTime: "2021-12-03 17:32:10"}
  433. ]
  434. //设备定位列表
  435. var markerList = [{
  436. id: 1,
  437. lat: "49.828921",
  438. lng: "122.956163",
  439. lastTemp: 29.2,
  440. transportType: '10',
  441. status: '10',
  442. },
  443. {
  444. id: 2,
  445. lat: "39.898959",
  446. lng: "116.188584",
  447. lastTemp: 19.2,
  448. transportType: '40',
  449. status: '00',
  450. },
  451. {
  452. id: 3,
  453. lat: "29.828457",
  454. lng: "120.495225",
  455. lastTemp: 29.3,
  456. transportType: '40',
  457. status: '10',
  458. },
  459. {
  460. id: 4,
  461. lat: "21.358161",
  462. lng: "111.003038",
  463. lastTemp: 29.5,
  464. transportType: '30',
  465. status: '20',
  466. },
  467. {
  468. id: 5,
  469. lat: "38.948484",
  470. lng: "120.846788",
  471. lastTemp: 29.8,
  472. transportType: '20',
  473. status: '10',
  474. },
  475. {
  476. id: 6,
  477. lat: "33.785733",
  478. lng: "104.850694",
  479. lastTemp: 28.2,
  480. transportType: '10',
  481. status: '00',
  482. },
  483. {
  484. id: 7,
  485. lat: "29.225357",
  486. lng: "121.306968",
  487. lastTemp: 27.2,
  488. transportType: '30',
  489. status: '00',
  490. },
  491. ]
  492. this.showMap(markerList);
  493. this.setData({
  494. chainTempList:temp,
  495. tempList:temp,
  496. },()=>{
  497. this.setTemp(temp);
  498. })
  499. //地区产品统计
  500. this.setCardLeftFive({
  501. name:['北京', '云南', '广州', '辽宁', '山东', '重庆'],
  502. data:[
  503. {name:'2022',data:[18203, 23489, 29034, 104970, 131744, 630230]},
  504. {name:'2012',data:[19325, 23438, 31000, 121594, 134141, 681807]},
  505. ]
  506. });
  507. const cardTwo_leftOne = [
  508. {stack: 0, end: 1, productName: "阿莫西林", trans: 0},
  509. {stack: 0, end: 1, productName: "红霉素", trans: 0},
  510. {stack: 0, end: 1, productName: "红霉素", trans: 0},
  511. ]
  512. this.setCard_two_left_one(cardTwo_leftOne);
  513. },
  514. showMap1(markers) {
  515. var that = this;
  516. var token = wx.getStorageSync('token');
  517. this.mapCtx = wx.createMapContext('home_map');
  518. for (var i in markers) {
  519. markers[i].bId = markers[i].id
  520. markers[i].id = Number(i)
  521. markers[i].width = 54
  522. markers[i].height = 54
  523. markers[i].iconPath = "/img/index_icon_" + markers[i].transportType + '' + markers[i].status + ".png"
  524. markers[i].latitude = Number(markers[i].lat)
  525. markers[i].longitude = Number(markers[i].lng)
  526. delete markers[i].lat
  527. delete markers[i].lng
  528. }
  529. that.setData({
  530. markers,
  531. latitude:markers.length != 0 ? markers[0].latitude : '',
  532. longitude:markers.length != 0 ? markers[0].longitude : ''
  533. },()=>{
  534. if(markers.length!=0 && token){
  535. //地图数据加载完成后,获取第一条数据的详情
  536. that.getListInfo(markers[0].bId);
  537. that.getListChainTemperature(markers[0].bId);
  538. }else{
  539. var temp = [
  540. {temp: '23.3',createTime: "2021-12-03 17:06:40"},
  541. {temp: '23.2', createTime: "2021-12-03 17:08:10"},
  542. {temp: '23.1', createTime: "2021-12-03 17:09:40"},
  543. {temp: '23.1', createTime: "2021-12-03 17:11:10"},
  544. {temp: '23.3', createTime: "2021-12-03 17:12:40"},
  545. {temp:' 23.2', createTime: "2021-12-03 17:14:10"},
  546. {temp: '23.3', createTime: "2021-12-03 17:15:40"},
  547. {temp: '23.3', createTime: "2021-12-03 17:18:40"},
  548. {temp: '23.2', createTime: "2021-12-03 17:26:10"},
  549. {temp: '23.2', createTime: "2021-12-03 17:32:10"}
  550. ]
  551. that.setTemp(temp)
  552. }
  553. });
  554. that.mapCtx.includePoints({
  555. points: markers,
  556. padding: [50, 50, 50, 50]
  557. })
  558. },
  559. getMapInfo(e) {
  560. var that = this;
  561. var index = e.detail.markerId;
  562. if (that.data.token) {
  563. for (var i in that.data.markers) {
  564. if (that.data.markers[i].id == index) {
  565. //冷链信息
  566. that.getListInfo(that.data.markers[i].bId);
  567. //冷链温度曲线
  568. that.getListChainTemperature(that.data.markers[i].bId);
  569. return;
  570. }
  571. }
  572. } else {
  573. wx.navigateTo({
  574. url: '/pages/login/login',
  575. })
  576. }
  577. },
  578. onPageScroll:function(e){
  579. this.setData({
  580. scrollTop:e.scrollTop
  581. })
  582. },
  583. getList() {
  584. var that = this;
  585. app.requestP({
  586. url: '/index/listChainLocal',
  587. method: 'post',
  588. contentType: ' application/json'
  589. }).then(res => {
  590. var result = []
  591. res.data.data && res.data.data.map(item=>{
  592. if(item.lng != 0 && item.lat != 0){
  593. result.push(item)
  594. }
  595. })
  596. that.showMap(result);
  597. }).catch(err=>{
  598. app.showToptip(that,'error',err.data.msg)
  599. })
  600. },
  601. getListInfo(id) {
  602. var that = this;
  603. app.requestP({
  604. url: '/index/getChainInfo',
  605. method: 'post',
  606. contentType: 'application/json',
  607. data: {
  608. id
  609. }
  610. }).then(res => {
  611. const {
  612. name,
  613. status,
  614. updateTime,
  615. lastTemperature,
  616. minTemperature,
  617. maxTemperature
  618. } = res.data.data;
  619. that.setData({ //数据处理
  620. mapTopData: {
  621. name: name || '暂无',
  622. status: status == '00' ? '正常' : status == '10' ? '黄色预警' : status == '20' ? '红色预警' : '暂无',
  623. updateTime: updateTime || '暂无',
  624. lastTemperature: lastTemperature ? lastTemperature + '℃' : '暂无',
  625. minTemperature: minTemperature ? minTemperature + '℃' : '暂无',
  626. maxTemperature: maxTemperature || '暂无'
  627. },
  628. })
  629. }).catch(err=>{
  630. app.showToptip(that,'error',err.data.msg)
  631. })
  632. },
  633. getListChainTemperature(id) {
  634. var that = this;
  635. app.requestP({
  636. url: '/index/listChainTemperature',
  637. method: 'post',
  638. contentType: 'application/json',
  639. data: {
  640. id
  641. },
  642. }).then(res => {
  643. that.setData({
  644. chainTempList: res.data.data,
  645. tempList:res.data.data
  646. })
  647. that.setTemp(res.data.data);
  648. }).catch(err => {
  649. app.showToptip(that, 'error', '暂无温度数据');
  650. })
  651. },
  652. setTransOption(temperature) {
  653. var that = this;
  654. that.ecWen = that.selectComponent('#llzsChartDom');
  655. that.ecWen.init((canvas, width, height, dpr) => {
  656. const chart = echarts.init(canvas, null, {
  657. width: width,
  658. height: height,
  659. devicePixelRatio: dpr
  660. });
  661. var option = that.getTransOption();
  662. option.xAxis.data = temperature.map(v => v.productTypeName);
  663. option.series[0].data = temperature.map(v => v.state10);
  664. option.series[1].data = temperature.map(v => v.state11);
  665. option.series[2].data = temperature.map(v => v.state20);
  666. chart.setOption(option);
  667. that.wenChart = chart;
  668. return chart;
  669. });
  670. },
  671. getTransOption() {
  672. return {
  673. title: {
  674. text: '数量',
  675. textStyle: {
  676. color: '#74788D',
  677. fontWeight: 'normal',
  678. fontSize: '16rpx'
  679. }
  680. },
  681. tooltip: {
  682. show: false,
  683. trigger: 'axis'
  684. },
  685. color: ['#7661FF', '#5AC8FA', '#00B972'],
  686. legend: {
  687. data: ['全程温控', '实时追溯', '追溯标签'],
  688. icon: "rect", // 设置形状 类型包括 circle,rect ,roundRect,triangle
  689. itemHeight: 11,
  690. itemWidth: 11,
  691. align: 'left',
  692. itemGap: 5,
  693. right: 10,
  694. top: 0,
  695. textStyle:{
  696. color:'#999',
  697. }
  698. },
  699. grid: {
  700. left: '0%',
  701. right: '0%',
  702. bottom: '3%',
  703. containLabel: true
  704. },
  705. xAxis: {
  706. type: 'category',
  707. nameTextStyle: {
  708. color: "#77869E",
  709. fontSize: 10
  710. },
  711. axisLine: {
  712. onZero: false,
  713. lineStyle: {
  714. color: "#999"
  715. }
  716. },
  717. axisTick: {
  718. show: false
  719. },
  720. splitLine: {
  721. show: false,
  722. },
  723. data: ["产品一", "产品二", "产品三", "产品四"],
  724. },
  725. yAxis: [{
  726. type: 'value'
  727. }],
  728. series: [{
  729. name: '追溯标签',
  730. type: 'bar',
  731. label: {
  732. show: true,
  733. position: 'top'
  734. },
  735. symbolSize: '0',
  736. lineStyle: {
  737. width: 1
  738. },
  739. data: [50, 180, 290, 50]
  740. },
  741. {
  742. name: '全程温控',
  743. type: 'bar',
  744. label: {
  745. show: true,
  746. position: 'top'
  747. },
  748. symbolSize: '0',
  749. lineStyle: {
  750. width: 1
  751. },
  752. data: [200, 200, 292, 200]
  753. }, {
  754. name: '实时追溯',
  755. type: 'bar',
  756. label: {
  757. show: true,
  758. position: 'top'
  759. },
  760. symbolSize: '0',
  761. lineStyle: {
  762. width: 1
  763. },
  764. data: [248, 290, 290, 240]
  765. }
  766. ]
  767. }
  768. },
  769. getTempOption() {
  770. return {
  771. title: {
  772. text: '温度:℃',
  773. textStyle: {
  774. color: '#999',
  775. fontSize: 6,
  776. }
  777. },
  778. grid: {
  779. top: "20%",
  780. left: "4%",
  781. right: "5%",
  782. bottom: "3%",
  783. containLabel: true
  784. },
  785. xAxis: {
  786. type: 'category',
  787. // boundaryGap: false,
  788. nameTextStyle: {
  789. color: "#77869E",
  790. fontSize: 4
  791. },
  792. axisLine: {
  793. onZero: false,
  794. lineStyle: {
  795. color: "#cccccc"
  796. }
  797. },
  798. axisTick: {
  799. show: false
  800. },
  801. splitLine: {
  802. show: false,
  803. },
  804. axisLabel: {
  805. show: true,
  806. textStyle: {
  807. color: '#999', //更改坐标轴文字颜色
  808. fontSize: 5, //更改坐标轴文字大小
  809. }
  810. },
  811. data: ['16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30'],
  812. // show: false
  813. },
  814. yAxis: {
  815. type: 'value',
  816. splitNumber: 10,
  817. max: 40,
  818. axisLine: {
  819. lineStyle: {
  820. color: "#cccccc",
  821. },
  822. show: true
  823. },
  824. axisLabel: {
  825. show: true,
  826. textStyle: {
  827. color: '#999', //更改坐标轴文字颜色
  828. fontSize: 5, //更改坐标轴文字大小
  829. }
  830. },
  831. splitLine: {
  832. show: false
  833. }
  834. },
  835. series: [{
  836. type: 'line',
  837. showSymbol: false,
  838. smooth: true,
  839. lineStyle: {
  840. width: 1,
  841. color: "#328EFD", //#D4D4D4
  842. },
  843. areaStyle: {
  844. origin: "start",
  845. color: {
  846. type: 'linear',
  847. x: 0,
  848. y: 0,
  849. x2: 0,
  850. y2: 1,
  851. colorStops: [{
  852. offset: 0,
  853. color: '#FFFFFF' //
  854. }, {
  855. offset: 1,
  856. color: '#4C96FE' //#D4D4D4
  857. }],
  858. global: false
  859. }
  860. },
  861. data: [18, 36, 25, 30, -20, 40, 33]
  862. }]
  863. }
  864. },
  865. productTypeChipCount(userId) {
  866. var that = this;
  867. app.requestP({
  868. url: '/index/productTypeChipCount',
  869. method: 'post',
  870. data: {
  871. userId
  872. }
  873. }).then(res => {
  874. that.setData({
  875. productTypeChipCount: res.data.data
  876. })
  877. const temperature = res.data.data;
  878. that.setPieChart(temperature.slice(0,6));
  879. }).catch(err => {
  880. that.setData({
  881. productTypeChipCount: []
  882. })
  883. })
  884. },
  885. setPieChart(temperature) {
  886. var that = this;
  887. var num = 0;
  888. var color = ['#45C2E0', '#C1EBDD', '#FFC851','#5A5476','#1869A0','#FF9393'];
  889. temperature.map(v => num += v.num);
  890. that.ecWen = that.selectComponent('#pieDom');
  891. that.ecWen.init((canvas, width, height, dpr) => {
  892. const chart = echarts.init(canvas, null, {
  893. width: width,
  894. height: height,
  895. devicePixelRatio: dpr
  896. });
  897. var option = that.getPieChartOption();
  898. option.color = color;
  899. option.series[0].data = temperature.map(v => {
  900. var per = v.num / num * 100;
  901. return {
  902. value:v.num,
  903. name: v.productTypeName+':'+ v.num + ' 占比' + per.toFixed(2) + '%'
  904. }
  905. });
  906. chart.setOption(option);
  907. that.wenChart = chart;
  908. return chart;
  909. });
  910. },
  911. getPieChartOption() {
  912. return {
  913. legend: {
  914. top: 'bottom',
  915. show: false,
  916. },
  917. grid: {
  918. left: '0%',
  919. right: '0%',
  920. bottom: '3%',
  921. containLabel: true
  922. },
  923. // color:['#45C2E0', '#C1EBDD', '#FFC851','#5A5476','#1869A0','#FF9393'],
  924. series: [{
  925. type: 'pie',
  926. radius: [30, 60],
  927. center: ['50%', '50%'],
  928. itemStyle: {
  929. normal: {
  930. label: {
  931. formatter: function (v) {
  932. //文字中遇到空格就换行
  933. let text = v.name.split(" ").join("\n");
  934. return text;
  935. },
  936. show: true,
  937. },
  938. labelLine: {
  939. show: true,
  940. color:''
  941. }
  942. },
  943. },
  944. emphasis: {
  945. itemStyle: {
  946. shadowBlur: 10,
  947. shadowOffsetX: 0,
  948. shadowColor: 'rgba(0, 0, 0, 0.5)'
  949. },
  950. },
  951. data: [{
  952. value: 40,
  953. itemStyle:{
  954. normal:{
  955. color:'#45C2E0'
  956. }
  957. }
  958. },
  959. {
  960. value: 38,
  961. },
  962. {
  963. value: 32,
  964. },
  965. {
  966. value: 30,
  967. },
  968. ]
  969. }]
  970. }
  971. },
  972. getChainStatus(userId) {
  973. var that = this;
  974. app.requestP({
  975. url: '/index/getChainStatus',
  976. method: 'post',
  977. data: {
  978. userId
  979. }
  980. }).then(res => {
  981. const {
  982. alarmDTO,
  983. temperatureDTO,
  984. waringDTO,
  985. inTrans,
  986. inStore,
  987. inEnd,
  988. total
  989. } = res.data.data;
  990. that.setData({
  991. temperatureDTO,
  992. waringDTO,
  993. inTrans,
  994. inStore,
  995. inEnd,
  996. total
  997. })
  998. }).catch(err=>{
  999. app.showToptip(that,'error',err.data.msg)
  1000. })
  1001. },
  1002. getWarningState(userId) {
  1003. var that = this;
  1004. app.requestP({
  1005. url: '/index/warningState',
  1006. method: 'post',
  1007. data: {
  1008. userId
  1009. }
  1010. }).then(res => {
  1011. const {
  1012. error11,
  1013. error20,
  1014. total10,
  1015. total11,
  1016. total20,
  1017. warning11,
  1018. warning20
  1019. } = res.data.data;
  1020. that.setData({
  1021. error11,
  1022. error20,
  1023. total10,
  1024. total11,
  1025. total20,
  1026. warning11,
  1027. warning20
  1028. }, () => {
  1029. // that.canvasRingA.showCanvasRing();
  1030. // that.canvasRingB.showCanvasRing();
  1031. // that.canvasRingC.showCanvasRing();
  1032. // that.canvasRingD.showCanvasRing();
  1033. // that.canvasRingE.showCanvasRing();
  1034. // that.canvasRingF.showCanvasRing();
  1035. // that.canvasRingG.showCanvasRing();
  1036. // that.canvasRingL.showCanvasRing();
  1037. })
  1038. }).catch(err=>{
  1039. app.showToptip(that,'error',err.data.msg)
  1040. })
  1041. },
  1042. setMapCenter() {
  1043. var that = this;
  1044. var locations = that.data.markers;
  1045. that.mapCtx.includePoints({
  1046. points: locations,
  1047. padding: [50, 50, 50, 50]
  1048. })
  1049. },
  1050. getUserInfo() {
  1051. var that = this;
  1052. app.requestP({
  1053. method: "post",
  1054. url: "/user/getUserInfo",
  1055. }).then(function (res) {
  1056. var userId = res.data.data.userId;
  1057. // that.getProductChipState();
  1058. that.productTypeChipCount(userId);
  1059. that.getChainStatus(userId);
  1060. // that.getWarningState(userId);
  1061. }).catch(err => {
  1062. app.showToptip(that, 'error', '请刷新重试');
  1063. })
  1064. },
  1065. transportationInfo() {
  1066. var token = wx.getStorageSync('token');
  1067. if(!token){
  1068. wx.navigateTo({
  1069. url: '/pages/login/login',
  1070. })
  1071. return;
  1072. }
  1073. var transportationJson = JSON.stringify(this.data.productChipStateList);
  1074. wx.navigateTo({
  1075. url: '/pages/index/transportationInfo/transportationInfo?list=' + transportationJson,
  1076. })
  1077. },
  1078. monitoringNum() {
  1079. var token = wx.getStorageSync('token');
  1080. if(!token){
  1081. wx.navigateTo({
  1082. url: '/pages/login/login',
  1083. })
  1084. return;
  1085. }
  1086. var productTypeChipCountJson = JSON.stringify(this.data.productTypeChipCount);
  1087. wx.navigateTo({
  1088. url: '/pages/index/monitoringNum/monitoringNum?list=' + productTypeChipCountJson,
  1089. })
  1090. },
  1091. packageInfo(){
  1092. var token = wx.getStorageSync('token');
  1093. if(!token){
  1094. wx.navigateTo({
  1095. url: '/pages/login/login',
  1096. })
  1097. return;
  1098. }
  1099. var packageList = JSON.stringify(this.data.packageList);
  1100. wx.navigateTo({
  1101. url: '/pages/index/packageInfo/packageinfo?list=' + packageList,
  1102. })
  1103. },
  1104. expressInfo(){
  1105. var token = wx.getStorageSync('token');
  1106. if(!token){
  1107. wx.navigateTo({
  1108. url: '/pages/login/login',
  1109. })
  1110. return;
  1111. }
  1112. var expressData = JSON.stringify(this.data.expressData);
  1113. var title = JSON.stringify([{name:'出库',type:'o'},{name:'入库',type:'i'}]);
  1114. var titleName = JSON.stringify({titleName:'出入库统计'});
  1115. wx.navigateTo({
  1116. url: '/pages/index/statics/statics?list=' +encodeURIComponent(expressData)+'&title='+title+'&titleName='+titleName,
  1117. })
  1118. },
  1119. goAbnormal(){
  1120. wx.navigateTo({
  1121. url: '/pages/index/abnormal/abnormal',
  1122. })
  1123. },
  1124. ordersInfo(){
  1125. wx.navigateTo({
  1126. url: '/pages/index/ordersList/ordersList',
  1127. })
  1128. },
  1129. transporDetails(){
  1130. var temp = this.data.temp;
  1131. var productName = this.data.productName;
  1132. var {product10,product20,product30,product40,product50} = this.data;
  1133. var token = wx.getStorageSync('token');
  1134. if(!token){
  1135. wx.navigateTo({
  1136. url: '/pages/login/login',
  1137. })
  1138. return;
  1139. }
  1140. wx.navigateTo({
  1141. url: '/pages/index/transporDetails/transporDetails?temp='+encodeURIComponent(JSON.stringify(temp))+'&productName='+encodeURIComponent(JSON.stringify(productName))+'&productNum='+encodeURIComponent(JSON.stringify([product10,product20,product30,product40,product50])),
  1142. })
  1143. },
  1144. onShareAppMessage() {
  1145. return {
  1146. title: 'cover-view',
  1147. }
  1148. },
  1149. monitoringNum() {
  1150. var token = wx.getStorageSync('token');
  1151. if(!token){
  1152. wx.navigateTo({
  1153. url: '/pages/login/login',
  1154. })
  1155. return;
  1156. }
  1157. var transportCityDataJson = JSON.stringify(this.data.transportCityData);
  1158. wx.navigateTo({
  1159. url: '/pages/index/monitoringNum/monitoringNum?list=' + transportCityDataJson,
  1160. })
  1161. },
  1162. getNewsList() {
  1163. var that = this;
  1164. app.requestP({
  1165. url: '/query/news',
  1166. method: 'post',
  1167. needToken: false,
  1168. data: {
  1169. keyword: '',
  1170. pageNum: '1',
  1171. pageSize: '5'
  1172. }
  1173. }).then(res => {
  1174. that.setData({
  1175. newsList: res.data.data.map(item => {
  1176. return {
  1177. ...item,
  1178. createTime: item.createTime.substring(item.createTime.length - 8)
  1179. }
  1180. })
  1181. })
  1182. }).catch(err => {
  1183. app.showToptip(that, 'error', err.data.msg)
  1184. })
  1185. },
  1186. goNewsInfo(e) {
  1187. var id = e.currentTarget.dataset.id;
  1188. wx.navigateTo({
  1189. url: '/pages/index/newsInfo/newsInfo?id=' + id,
  1190. })
  1191. },
  1192. goNewsList() {
  1193. wx.navigateTo({
  1194. url: '/pages/index/newList/newList',
  1195. })
  1196. },
  1197. getUserDefaultMenuList() {
  1198. var that = this;
  1199. app.requestP({
  1200. url: '/userDeaultMenu/list',
  1201. method: 'post',
  1202. }).then(res => {
  1203. that.setData({
  1204. systemMenu: res.data.data
  1205. })
  1206. }).catch(err => {
  1207. app.showToptip(that, 'error', err.data.msg)
  1208. })
  1209. },
  1210. tapMenu(e) {
  1211. let type = e.currentTarget.dataset.type
  1212. let path = e.currentTarget.dataset.path;
  1213. //判断token,若有则假设已经登录
  1214. if (!wx.getStorageSync('token')) {
  1215. wx.redirectTo({
  1216. url: '/pages/login/login',
  1217. })
  1218. return;
  1219. }
  1220. //获取用户信息,判断userInfo是否过期
  1221. let userInfo = wx.getStorageSync('userInfo');
  1222. const {
  1223. loginRole,
  1224. ifOverFlow,
  1225. status
  1226. } = userInfo;
  1227. // this.matchPage(loginRole, ifOverFlow, status, path);
  1228. app.globalData.tabarData = {loginRole, ifOverFlow, status, path};
  1229. wx.switchTab({
  1230. url: '/pages/workbench/workbench',
  1231. })
  1232. },
  1233. goMessage:function(){
  1234. if(this.data.token){
  1235. wx.navigateTo({
  1236. url: '/pages/news/newList',
  1237. })
  1238. }else{
  1239. wx.redirectTo({
  1240. url: '/pages/login/login',
  1241. })
  1242. }
  1243. },
  1244. // 沃森新
  1245. // 主产品查询
  1246. getsignProduct(){
  1247. app.requestP({
  1248. url: '/daping/signProduct',
  1249. method: 'post',
  1250. }).then(res => {
  1251. this.setData({
  1252. tabLeftTop:res.data.data
  1253. })
  1254. }).catch(err => {
  1255. app.showToptip(this,'err',err.data.msg)
  1256. })
  1257. },
  1258. // 主产品使用、库存、总数统计
  1259. getSignProductUseAndStackState(){
  1260. app.requestP({
  1261. url: '/daping/signProductUseAndStackState',
  1262. method: 'post',
  1263. }).then(res => {
  1264. this.setPie4Chart(res.data.data)
  1265. }).catch(err => {
  1266. app.showToptip(this,'err',err.data.msg)
  1267. })
  1268. },
  1269. setCard(e){
  1270. var index = e.currentTarget.dataset.index;
  1271. this.setData({
  1272. cardIndex:index,
  1273. // tabLeftTop_remark:this.data.tabLfeftTop[index].remark
  1274. })
  1275. },
  1276. //单一主产品不同地区使用情况
  1277. getSingleProductUseZoneStat(){
  1278. app.requestP({
  1279. url: '/daping/singleProductUseZoneState',
  1280. method: 'post',
  1281. }).then(res=>{
  1282. this.setCard_top_right_butChart(res.data.data);
  1283. this.setKLine(res.data.data);
  1284. }).catch(err=>{
  1285. app.showToptip(this,'err',err.data.msg)
  1286. })
  1287. },
  1288. setPie4Chart(list){
  1289. var that = this;
  1290. var series = [];
  1291. list.map((item,index)=>{
  1292. series.push(...that.pice4Chart("#23D9E9",index == 0 ? "20%" :index == 1 ? '50%':'80%',item.total,item.use_num,item.stack_num,item.name,'45%',))
  1293. });
  1294. that.pie4ChartConDom = that.selectComponent('#pie4ChartConDom');
  1295. that.pie4ChartConDom.init((canvas, width, height, dpr) => {
  1296. const chart = echarts.init(canvas, null, {
  1297. width: width,
  1298. height: height,
  1299. devicePixelRatio: dpr
  1300. });
  1301. chart.setOption({
  1302. title: {
  1303. show:false
  1304. },
  1305. grid:{
  1306. top:"0%",
  1307. left:"0%",
  1308. right:"0%",
  1309. bottom:"0%",
  1310. },
  1311. color: ["red", "rgb(10,92,170)", "rgb(114,205,255)"],
  1312. legend: {
  1313. icon:"rect",
  1314. top:10,
  1315. right:0,
  1316. itemWidth:20,
  1317. itemHeight:20,
  1318. textStyle:{
  1319. fontSize:16,
  1320. color: "#D1E9F5",
  1321. },
  1322. },
  1323. series:series,
  1324. });
  1325. return chart;
  1326. })
  1327. },
  1328. pice4Chart(color,pos,total,use_num,stack_num,name,top){
  1329. var that = this;
  1330. var placeHolderStyle = {
  1331. normal: {
  1332. label: {
  1333. show: false,
  1334. formatter: function (v) {
  1335. //文字中遇到空格就换行
  1336. let text = v.value;
  1337. return text;
  1338. },
  1339. },
  1340. labelLine: {
  1341. show: true,
  1342. },
  1343. },
  1344. };
  1345. const pieValue1 = {
  1346. value1:(stack_num+use_num) / total,
  1347. value2: 1 - (stack_num+use_num) / total
  1348. };
  1349. const pieValue2 = {
  1350. value1:use_num / total,
  1351. value2:1 - use_num / total
  1352. };
  1353. const pieValue3 = {
  1354. value1: stack_num / total,
  1355. value2: 1 - stack_num / total
  1356. };
  1357. return [{
  1358. type: "pie",
  1359. clockWise: true, //顺时加载
  1360. hoverAnimation: false, //鼠标移入变大
  1361. silent:false,
  1362. radius: [20, 23],
  1363. center: [pos, top],
  1364. itemStyle: placeHolderStyle,
  1365. data: [
  1366. {
  1367. value: pieValue1.value1,
  1368. itemStyle:{
  1369. normal:{
  1370. color:'#0e74ff'
  1371. }
  1372. }
  1373. },
  1374. {
  1375. value: pieValue1.value2,
  1376. itemStyle:{
  1377. normal:{
  1378. color:"rgb(243,243,251)"
  1379. }
  1380. }
  1381. }
  1382. ],
  1383. },{
  1384. type: "pie",
  1385. clockWise: true, //顺时加载
  1386. hoverAnimation: false, //鼠标移入变大
  1387. radius: [15, 18],
  1388. silent:false,
  1389. center: [pos, top],
  1390. itemStyle: placeHolderStyle,
  1391. data: [
  1392. {
  1393. value: pieValue2.value1,
  1394. itemStyle:{
  1395. normal:{
  1396. color:'#64a6ff'
  1397. }
  1398. }
  1399. },
  1400. {
  1401. value: pieValue2.value2,
  1402. itemStyle:{
  1403. normal:{
  1404. color:"rgb(243,243,251)"
  1405. }
  1406. }
  1407. }
  1408. ],
  1409. },
  1410. {
  1411. type: "pie",
  1412. clockWise: true, //顺时加载
  1413. hoverAnimation: false, //鼠标移入变大
  1414. silent:false,
  1415. radius: [10, 13],
  1416. center: [pos, top],
  1417. itemStyle: placeHolderStyle,
  1418. data: [
  1419. {
  1420. value: pieValue3.value1,
  1421. itemStyle:{
  1422. normal:{
  1423. color:'red'
  1424. }
  1425. }
  1426. },
  1427. {
  1428. value: pieValue3.value2,
  1429. itemStyle:{
  1430. normal:{
  1431. color:"rgb(243,243,251)"
  1432. }
  1433. }
  1434. }
  1435. ],
  1436. }]
  1437. },
  1438. setCard_top_right_butChart(list){
  1439. var that = this;
  1440. that.selectComponent('#cardBarChartConDom').init((canvas, width, height, dpr) => {
  1441. const chart = echarts.init(canvas, null, {
  1442. width: width,
  1443. height: height,
  1444. devicePixelRatio: dpr
  1445. });
  1446. list = list.map(item=>{
  1447. return {orderNum:item.total,name:item.city || 'N/A'}
  1448. })
  1449. var option = that.getCysOrderOption(list);
  1450. option.series = [{
  1451. type:'bar',
  1452. barMaxWidth: 15,
  1453. barMinHeight: 10,
  1454. data:list.map(item=>item.orderNum),
  1455. label: {
  1456. show: true,
  1457. position: 'inside'
  1458. },
  1459. itemStyle:{
  1460. normal:{color:'#333FFF'}
  1461. }
  1462. }]
  1463. chart.setOption(option);
  1464. return chart;
  1465. });
  1466. },
  1467. // 图5 主产品在库、在途、结束统计
  1468. getSignProductState(){
  1469. app.requestP({
  1470. url: '/daping/signProductState',
  1471. method: 'post',
  1472. }).then(res=>{
  1473. this.setCard_two_left_one(res.data.data);
  1474. this.setKLine(res.data.data);
  1475. }).catch(err=>{
  1476. app.showToptip(this,'err',err.data.msg)
  1477. })
  1478. },
  1479. setCard_two_left_one(list){
  1480. var that = this;
  1481. that.selectComponent('#product_two_left_one').init((canvas, width, height, dpr) => {
  1482. const chart = echarts.init(canvas, null, {
  1483. width: width,
  1484. height: height,
  1485. devicePixelRatio: dpr
  1486. });
  1487. var option = that.getStaticBarChart();
  1488. option.legend = {
  1489. data:['在库','在途','结束'],
  1490. icon:"circle",
  1491. top:"2%",
  1492. right:"auto",
  1493. itemWidth:8,
  1494. itemHeight:8,
  1495. textStyle:{
  1496. fontSize:8,
  1497. color:'#485465',
  1498. },
  1499. }
  1500. option.color = ['red','rgb(114,205,255)','rgb(10,92,170)']
  1501. option.grid.top='20%';
  1502. option.grid.bottom='13%';
  1503. option.series = [];
  1504. option.xAxis.data = [];
  1505. const echartsData = [
  1506. {
  1507. name:'在库',
  1508. data:list.map(item=>item.stack)
  1509. },
  1510. {
  1511. name:'结束',
  1512. data:list.map(item=>item.end)
  1513. },
  1514. {
  1515. name:'在途',
  1516. data:list.map(item=>item.trans)
  1517. }
  1518. ]
  1519. option.xAxis.data = list.map(item=>item.productName);
  1520. echartsData.map((item,index)=>{
  1521. option.series.push({
  1522. name:item.name,
  1523. type: "bar",
  1524. stack: "Ad",
  1525. emphasis: {
  1526. focus: "series",
  1527. },
  1528. data:item.data
  1529. })
  1530. })
  1531. console.log(option);
  1532. chart.setOption(option);
  1533. return chart;
  1534. })
  1535. },
  1536. product_two_left_two(list){
  1537. var that = this;
  1538. that.selectComponent('#product_two_left_two').init((canvas, width, height, dpr) => {
  1539. const chart = echarts.init(canvas, null, {
  1540. width: width,
  1541. height: height,
  1542. devicePixelRatio: dpr
  1543. });
  1544. var option = this.getStaticBarChart();
  1545. option.series = [];
  1546. option.legend = {
  1547. data:list.map(item=>item.name),
  1548. icon:"circle",
  1549. top:"2%",
  1550. right:"auto",
  1551. itemWidth:8,
  1552. itemHeight:8,
  1553. textStyle:{
  1554. fontSize:8,
  1555. color:'#485465',
  1556. },
  1557. }
  1558. option.grid.top='20%';
  1559. option.grid.bottom='13%';
  1560. list.map((item,index)=>{
  1561. option.series.push({
  1562. name:item.name,
  1563. type: index != list.length -1 ? 'bar' :'line',
  1564. // yAxisIndex: 1,
  1565. data:item.data
  1566. });
  1567. // if(index != list.length-1){
  1568. // delete option.series[index].yAxisIndex;
  1569. // }
  1570. })
  1571. chart.setOption(option);
  1572. return chart;
  1573. })
  1574. },
  1575. getStaticBarChart(){
  1576. return {
  1577. xAxis: {
  1578. type: "category",
  1579. axisTick:{show:false,},
  1580. nameTextStyle: {
  1581. color: "#77869E",
  1582. fontSize: 8,
  1583. },
  1584. axisLabel: {
  1585. color: '#999999',
  1586. fontSize: 8,
  1587. },
  1588. axisLine: {
  1589. onZero: false,
  1590. lineStyle: {
  1591. color: "#cccccc",
  1592. },
  1593. },
  1594. data: ["Mon", "Tue", "Wed", "Thu",],
  1595. },
  1596. yAxis: {
  1597. type: "value",
  1598. minInterval: 1,
  1599. axisLine: {
  1600. lineStyle: {
  1601. color: "#cccccc",
  1602. },
  1603. show: false,
  1604. },
  1605. axisLabel: {
  1606. color: "#999999",
  1607. fontSize: 8,
  1608. },
  1609. },
  1610. color: ["#7661FF", "#5AC8FA", "#00B972"],
  1611. grid: {
  1612. left: "3%",
  1613. top: "8%",
  1614. right: "4%",
  1615. bottom: "3%",
  1616. containLabel: true,
  1617. },
  1618. series: [
  1619. {
  1620. data: [120, 200, 150, 80, 70, 110, 130, 110],
  1621. type: "bar",
  1622. },
  1623. ],
  1624. };
  1625. },
  1626. setCardPieTwo(list){
  1627. var that = this;
  1628. that.selectComponent('#product_three_left_one').init((canvas, width, height, dpr) => {
  1629. const chart = echarts.init(canvas, null, {
  1630. width: width,
  1631. height: height,
  1632. devicePixelRatio: dpr
  1633. });
  1634. var option = this.getStaticPieChart();
  1635. var itemStyle = {
  1636. normal: {
  1637. label: {
  1638. show: true,
  1639. formatter: function (v) {
  1640. //文字中遇到空格
  1641. let text = v.name+'\n'+v.value;
  1642. return text;
  1643. },
  1644. },
  1645. labelLine: {
  1646. show: true,
  1647. length:4,
  1648. length2:4,
  1649. },
  1650. },
  1651. }
  1652. option.series = [
  1653. {
  1654. type: "pie",
  1655. radius: "40%",
  1656. center: ["50%", "25%"],
  1657. itemStyle,
  1658. label: {
  1659. position: "inside",
  1660. formatter: "{d}%",
  1661. fontSize: 8,
  1662. color: '#fff',
  1663. },
  1664. data: [
  1665. { name: "标签1", value: 50 },
  1666. { name: "标签2", value: 20 },
  1667. { name: "标签3", value: 10 },
  1668. ],
  1669. },
  1670. {
  1671. type: "pie",
  1672. radius: "40%",
  1673. center: ["50%", "75%"],
  1674. percentPrecision:0,
  1675. minShowLabelAngle:30,
  1676. itemStyle,
  1677. label: {
  1678. position: "inside",
  1679. formatter: "{d}%",
  1680. fontSize: 8,
  1681. color: '#fff',
  1682. },
  1683. data: [
  1684. { name: "标签1", value: 50 },
  1685. { name: "标签2", value: 20 },
  1686. { name: "标签3", value: 10 },
  1687. ],
  1688. },
  1689. ]
  1690. chart.setOption(option);
  1691. return chart;
  1692. })
  1693. },
  1694. getStaticPieChart(){
  1695. return {
  1696. color: ["#964CC4", "#04A3CC", "#3B6AD5"],
  1697. title: {
  1698. show: false,
  1699. },
  1700. grid: {
  1701. top: "12%",
  1702. left: "5%",
  1703. right: "5%",
  1704. bottom: "12%",
  1705. },
  1706. series: [
  1707. // {
  1708. // type: "pie",
  1709. // radius: "50%",
  1710. // center: ["50%", "25%"],
  1711. // label: {
  1712. // position: "inside",
  1713. // formatter: "{d}%",
  1714. // fontSize: 8,
  1715. // color: '#fff',
  1716. // },
  1717. // data: [
  1718. // { name: "在途", value: 50 },
  1719. // { name: "完成", value: 20 },
  1720. // { name: "待发运", value: 10 },
  1721. // ],
  1722. // },
  1723. // {
  1724. // type: "pie",
  1725. // radius: "50%",
  1726. // center: ["50%", "75%"],
  1727. // percentPrecision:0,
  1728. // minShowLabelAngle:30,
  1729. // label: {
  1730. // position: "inside",
  1731. // formatter: "{d}%",
  1732. // fontSize: 8,
  1733. // color: '#fff',
  1734. // },
  1735. // data: [
  1736. // { name: "在途", value: 50 },
  1737. // { name: "完成", value: 20 },
  1738. // { name: "待发运", value: 10 },
  1739. // ],
  1740. // },
  1741. ]
  1742. }
  1743. },
  1744. setCardFivePie(){
  1745. var that = this;
  1746. that.selectComponent('#product_five_left_one').init((canvas, width, height, dpr) => {
  1747. const chart = echarts.init(canvas, null, {
  1748. width: width,
  1749. height: height,
  1750. devicePixelRatio: dpr
  1751. });
  1752. var option = this.getStaticPieChart();
  1753. option.color = ['rgb(91,132,206)','rgb(127,210,255)','rgb(44,87,226)'];
  1754. var itemStyle = {
  1755. normal: {
  1756. label: {
  1757. show: false,
  1758. formatter: function (v) {
  1759. //文字中遇到空格
  1760. let text = v.name+'\n'+v.value;
  1761. return text;
  1762. },
  1763. },
  1764. labelLine: {
  1765. show: true,
  1766. length:4,
  1767. length2:4,
  1768. },
  1769. },
  1770. }
  1771. option.series = [
  1772. {
  1773. type: "pie",
  1774. radius: "80%",
  1775. center: ["50%", "30%"],
  1776. itemStyle,
  1777. label: {
  1778. position: "inside",
  1779. formatter: "{d}%",
  1780. fontSize: 8,
  1781. color: '#fff',
  1782. },
  1783. data: [
  1784. { name: "标签1", value: 50 },
  1785. { name: "标签2", value: 20 },
  1786. { name: "标签3", value: 10 },
  1787. ],
  1788. },
  1789. {
  1790. type: "pie",
  1791. radius: "80%",
  1792. center: ["50%", "53%"],
  1793. itemStyle,
  1794. data: [
  1795. { name: "标签1", value: 50 },
  1796. { name: "标签2", value: 20 },
  1797. { name: "标签3", value: 10 },
  1798. ],
  1799. },
  1800. {
  1801. type: "pie",
  1802. radius: "80%",
  1803. itemStyle,
  1804. center: ["50%", "77%"],
  1805. data: [
  1806. { name: "标签1", value: 50 },
  1807. { name: "标签2", value: 20 },
  1808. { name: "标签3", value: 10 },
  1809. ],
  1810. },
  1811. ]
  1812. option.grid = {
  1813. top: "12%",
  1814. left: "10%",
  1815. right: "0%",
  1816. bottom: "12%",
  1817. },
  1818. chart.setOption(option);
  1819. return chart;
  1820. })
  1821. },
  1822. setCard3dBar(){
  1823. var that = this;
  1824. that.selectComponent('#product_three_left_two').init((canvas, width, height, dpr) => {
  1825. const chart = echarts.init(canvas, null, {
  1826. width: width,
  1827. height: height,
  1828. devicePixelRatio: dpr
  1829. });
  1830. var data = [[0, 0, 5], [0, 1, 1], [0, 2, 0], [0, 3, 0], [0, 4, 0], [0, 5, 0], [0, 6, 0], [0, 7, 0], [0, 8, 0], [0, 9, 0], [0, 10, 0], [0, 11, 2], [0, 12, 4], [0, 13, 1], [0, 14, 1], [0, 15, 3], [0, 16, 4], [0, 17, 6], [0, 18, 4], [0, 19, 4], [0, 20, 3], [0, 21, 3], [0, 22, 2], [0, 23, 5], [1, 0, 7], [1, 1, 0], [1, 2, 0], [1, 3, 0], [1, 4, 0], [1, 5, 0], [1, 6, 0], [1, 7, 0], [1, 8, 0], [1, 9, 0], [1, 10, 5], [1, 11, 2], [1, 12, 2], [1, 13, 6], [1, 14, 9], [1, 15, 11], [1, 16, 6], [1, 17, 7], [1, 18, 8], [1, 19, 12], [1, 20, 5], [1, 21, 5], [1, 22, 7], [1, 23, 2], [2, 0, 1], [2, 1, 1], [2, 2, 0], [2, 3, 0], [2, 4, 0], [2, 5, 0], [2, 6, 0], [2, 7, 0], [2, 8, 0], [2, 9, 0], [2, 10, 3], [2, 11, 2], [2, 12, 1], [2, 13, 9], [2, 14, 8], [2, 15, 10], [2, 16, 6], [2, 17, 5], [2, 18, 5], [2, 19, 5], [2, 20, 7], [2, 21, 4], [2, 22, 2], [2, 23, 4], [3, 0, 7], [3, 1, 3], [3, 2, 0], [3, 3, 0], [3, 4, 0], [3, 5, 0], [3, 6, 0], [3, 7, 0], [3, 8, 1], [3, 9, 0], [3, 10, 5], [3, 11, 4], [3, 12, 7], [3, 13, 14], [3, 14, 13], [3, 15, 12], [3, 16, 9], [3, 17, 5], [3, 18, 5], [3, 19, 10], [3, 20, 6], [3, 21, 4], [3, 22, 4], [3, 23, 1], [4, 0, 1], [4, 1, 3], [4, 2, 0], [4, 3, 0], [4, 4, 0], [4, 5, 1], [4, 6, 0], [4, 7, 0], [4, 8, 0], [4, 9, 2], [4, 10, 4], [4, 11, 4], [4, 12, 2], [4, 13, 4], [4, 14, 4], [4, 15, 14], [4, 16, 12], [4, 17, 1], [4, 18, 8], [4, 19, 5], [4, 20, 3], [4, 21, 7], [4, 22, 3], [4, 23, 0], [5, 0, 2], [5, 1, 1], [5, 2, 0], [5, 3, 3], [5, 4, 0], [5, 5, 0], [5, 6, 0], [5, 7, 0], [5, 8, 2], [5, 9, 0], [5, 10, 4], [5, 11, 1], [5, 12, 5], [5, 13, 10], [5, 14, 5], [5, 15, 7], [5, 16, 11], [5, 17, 6], [5, 18, 0], [5, 19, 5], [5, 20, 3], [5, 21, 4], [5, 22, 2], [5, 23, 0], [6, 0, 1], [6, 1, 0], [6, 2, 0], [6, 3, 0], [6, 4, 0], [6, 5, 0], [6, 6, 0], [6, 7, 0], [6, 8, 0], [6, 9, 0], [6, 10, 1], [6, 11, 0], [6, 12, 2], [6, 13, 1], [6, 14, 3], [6, 15, 4], [6, 16, 0], [6, 17, 0], [6, 18, 0], [6, 19, 0], [6, 20, 1], [6, 21, 2], [6, 22, 2], [6, 23, 6]]
  1831. chart.setOption({
  1832. tooltip: {},
  1833. xAxis3D: {
  1834. type: 'category',
  1835. data: ['12a', '1a', '2a', '3a', '4a', '5a', '6a','7a', '8a', '9a', '10a', '11a','12p', '1p', '2p', '3p', '4p', '5p','6p', '7p', '8p', '9p', '10p', '11p']
  1836. },
  1837. yAxis3D: {
  1838. type: 'category',
  1839. data: ['Saturday', 'Friday', 'Thursday','Wednesday', 'Tuesday', 'Monday', 'Sunday']
  1840. },
  1841. zAxis3D: {
  1842. type: 'value'
  1843. },
  1844. grid3D: {
  1845. boxWidth: 200,
  1846. boxDepth: 80,
  1847. viewControl: {
  1848. // projection: 'orthographic'
  1849. },
  1850. light: {
  1851. main: {
  1852. intensity: 1.2,
  1853. shadow: true
  1854. },
  1855. ambient: {
  1856. intensity: 0.3
  1857. }
  1858. }
  1859. },
  1860. series: [
  1861. {
  1862. type: 'bar3D',
  1863. data: data.map(function (item) {
  1864. return {
  1865. value: [item[1], item[0], item[2]]
  1866. };
  1867. }),
  1868. shading: 'lambert',
  1869. label: {
  1870. fontSize: 16,
  1871. borderWidth: 1
  1872. },
  1873. emphasis: {
  1874. label: {
  1875. fontSize: 20,
  1876. color: '#900'
  1877. },
  1878. itemStyle: {
  1879. color: '#900'
  1880. }
  1881. }
  1882. }
  1883. ]
  1884. });
  1885. return chart;
  1886. })
  1887. },
  1888. setKLine(list){
  1889. var that = this;
  1890. that.selectComponent('#product_four').init((canvas, width, height, dpr) => {
  1891. const chart = echarts.init(canvas, null, {
  1892. width: width,
  1893. height: height,
  1894. devicePixelRatio: dpr
  1895. });
  1896. list = list.map(item=>{
  1897. return {orderNum:item.total,name:item.city || 'N/A'}
  1898. })
  1899. var option = that.getCysOrderOption(list);
  1900. // lenged
  1901. option.series = [{
  1902. type:'bar',
  1903. barMaxWidth: 15,
  1904. barMinHeight: 10,
  1905. data:list.map(item=>item.orderNum),
  1906. label: {
  1907. show: true,
  1908. position: 'inside'
  1909. },
  1910. itemStyle:{
  1911. normal:{color:'#333FFF'}
  1912. }
  1913. }]
  1914. chart.setOption(option);
  1915. return chart;
  1916. })
  1917. },
  1918. calculateMA(dayCount, data) {
  1919. var result = [];
  1920. for (var i = 0, len = data.length; i < len; i++) {
  1921. if (i < dayCount) {
  1922. result.push('-');
  1923. continue;
  1924. }
  1925. var sum = 0;
  1926. for (var j = 0; j < dayCount; j++) {
  1927. sum += +data[i - j][1];
  1928. }
  1929. result.push(sum / dayCount);
  1930. }
  1931. return result;
  1932. },
  1933. setCardDiagram(list){
  1934. var that = this;
  1935. that.selectComponent('#product_four_left_two').init((canvas, width, height, dpr) => {
  1936. const chart = echarts.init(canvas, null, {
  1937. width: width,
  1938. height: height,
  1939. devicePixelRatio: dpr
  1940. });
  1941. chart.setOption({
  1942. backgroundColor: "transparent",
  1943. tooltip: {
  1944. formatter:function(params){
  1945. const {data:{name,value,unNormalTotal}} = params;
  1946. return `${name}\n正常: ${value}\n预警: ${unNormalTotal}`
  1947. }
  1948. },
  1949. grid: {},
  1950. animationDurationUpdate: function (idx) {
  1951. // 越往后的数据延迟越大
  1952. return idx * 100;
  1953. },
  1954. color: ["red", "rgb(10,92,170)", "rgb(114,205,255)"],
  1955. animationEasingUpdate: "bounceIn",
  1956. series: [
  1957. {
  1958. type: "graph",
  1959. layout: "force",
  1960. force: {
  1961. repulsion: 100, //越大斥力越大
  1962. gravity: 0.05, //越大节点越往中心靠拢
  1963. edgeLength: 20, //值越小则长度越长
  1964. },
  1965. roam: true,
  1966. draggable: true,
  1967. symbolSize: 1,
  1968. itemStyle: {
  1969. // opacity: 0.9,
  1970. color: () => {
  1971. return (
  1972. 'red',
  1973. 'rgb(114,205,255)',
  1974. 'rgb(10,92,170)'
  1975. );
  1976. },
  1977. },
  1978. label: {
  1979. normal: {
  1980. show: true,
  1981. fontSize: 10,
  1982. },
  1983. },
  1984. data: list
  1985. },
  1986. ],
  1987. })
  1988. return chart;
  1989. })
  1990. },
  1991. setCardXuTuOption(testNum){
  1992. var that = this;
  1993. let icon =
  1994. "path://M512.584639,219.893708c40.41173,0.258019,73.19961-32.274913,73.199609-72.557634,0-40.025725-32.78788-72.559681-73.199609-72.559681-40.473163,0-73.196538,32.533956-73.196538,72.559681,0,40.089206,32.723375,72.557634,73.196538,72.557634z,m73.330666,16.396499H439.129058c-55.266258,0-91.39098,48.28336-91.390981,94.203594v220.945238c0,42.847553,60.780905,42.847553,60.780905,0V347.144224h11.782872v555.564273c0,59.179548,82.417649,57.316077,84.337434,0V582.569248h15.696162V902.96754c3.391108,60.650871,84.340506,54.817796,84.340506-0.258019V347.144224h9.800631v204.234406c0,42.837314,62.696594,42.837314,62.696594,0V330.433391c0.126962-45.72979-36.116531-94.143184-91.257876-94.143184z";
  1995. for (var index = 0; index < 4; index++) {
  1996. that.selectComponent('#product_five_right_one'+index).init((canvas, width, height, dpr) => {
  1997. const chart = echarts.init(canvas, null, {
  1998. width: width,
  1999. height: height,
  2000. devicePixelRatio: dpr
  2001. });
  2002. chart.setOption({
  2003. backgroundColor: "transparent",
  2004. tooltip: {
  2005. trigger: "axis",
  2006. axisPointer: {
  2007. type: "shadow",
  2008. },
  2009. formatter: "{b0}: {c0}%",
  2010. },
  2011. grid: {
  2012. containLabel: true,
  2013. height: "200px",
  2014. width: "auto",
  2015. left: "0",
  2016. top: "center",
  2017. },
  2018. xAxis: {
  2019. max: 100,
  2020. splitLine: {
  2021. show: false,
  2022. },
  2023. axisLine: {
  2024. show: false,
  2025. },
  2026. axisLabel: {
  2027. show: false,
  2028. },
  2029. axisTick: {
  2030. show: false,
  2031. },
  2032. },
  2033. yAxis: {
  2034. type: "category",
  2035. inverse: true,
  2036. axisLine: {
  2037. show: false,
  2038. },
  2039. axisTick: {
  2040. show: false,
  2041. },
  2042. axisLabel: {
  2043. // margin: 10,
  2044. fontSize: 20,
  2045. color: "white",
  2046. },
  2047. axisPointer: {
  2048. label: {
  2049. show: true,
  2050. margin: 100,
  2051. },
  2052. },
  2053. },
  2054. series: [
  2055. {
  2056. type: "pictorialBar",
  2057. symbolRepeat: "fixed",
  2058. symbolMargin: "6!",
  2059. label: {
  2060. normal: {
  2061. show: false,
  2062. position: "right",
  2063. offset: [3, 0],
  2064. formatter: (param) => {
  2065. return param.value.toFixed(0) + "%";
  2066. },
  2067. textStyle: {
  2068. fontSize: 20,
  2069. color: "white",
  2070. },
  2071. },
  2072. },
  2073. symbolClip: true,
  2074. symbolSize: [22, 30],
  2075. symbolPosition: "start",
  2076. symbolBoundingData: 100,
  2077. data: [
  2078. {
  2079. value: testNum.normalTotal,
  2080. symbol: icon,
  2081. itemStyle: {
  2082. color: "#1DDBF9",
  2083. },
  2084. },
  2085. ],
  2086. z: 10,
  2087. },
  2088. {
  2089. type: "pictorialBar",
  2090. itemStyle: {
  2091. normal: {
  2092. opacity: 0.2,
  2093. },
  2094. },
  2095. animationDuration: 0,
  2096. symbolRepeat: "fixed",
  2097. symbolMargin: "6!",
  2098. symbolSize: [22, 30],
  2099. symbolBoundingData: 100,
  2100. symbolPosition: "start",
  2101. // symbolOffset: [
  2102. // 10,
  2103. // 0
  2104. // ],
  2105. data: [
  2106. {
  2107. value: 100,
  2108. symbol: icon,
  2109. itemStyle: {
  2110. color: "#1DDBF9",
  2111. },
  2112. },
  2113. ],
  2114. z: 5,
  2115. },
  2116. ],
  2117. })
  2118. return chart
  2119. })
  2120. }
  2121. },
  2122. setCardFivePie_rght(list){
  2123. var that = this;
  2124. var placeHolderStyle = {
  2125. normal: {
  2126. label: {
  2127. show: false,
  2128. formatter: function (v) {
  2129. //文字中遇到空格就换行
  2130. let text = v.value;
  2131. return text;
  2132. },
  2133. },
  2134. labelLine: {
  2135. show: true,
  2136. },
  2137. },
  2138. };
  2139. that.selectComponent('#product_five_right').init((canvas, width, height, dpr) => {
  2140. const chart = echarts.init(canvas, null, {
  2141. width: width,
  2142. height: height,
  2143. devicePixelRatio: dpr
  2144. });
  2145. var option = this.getStaticPieChart();
  2146. var position = [['20%','20%'],['20%','50%'],['20%','80%'],['50%','20%'],['50%','50%'],['50%','80%'],['80%','20%'],['80%','50%'],['80%','80%']]
  2147. position.map(item=>{
  2148. option.series.push({
  2149. type: "pie",
  2150. clockWise: true, //顺时加载
  2151. hoverAnimation: false, //鼠标移入变大
  2152. silent:false,
  2153. radius: [20, 23],
  2154. center: item,
  2155. itemStyle: placeHolderStyle,
  2156. label:{
  2157. normal:{
  2158. show:true,
  2159. position:'center',
  2160. color:'#485465',
  2161. formatter:'{d}',
  2162. emphasis:{
  2163. show:true
  2164. }
  2165. }
  2166. },
  2167. data: [
  2168. {
  2169. value: 0.6,
  2170. itemStyle:{
  2171. normal:{
  2172. color:'#0e74ff'
  2173. }
  2174. }
  2175. },
  2176. {
  2177. value: 0.4,
  2178. itemStyle:{
  2179. normal:{
  2180. color:"rgb(243,243,251)"
  2181. }
  2182. }
  2183. }
  2184. ]
  2185. })
  2186. })
  2187. chart.setOption(option)
  2188. return chart;
  2189. })
  2190. },
  2191. setCardSixBar(list,lineList){
  2192. var that = this;
  2193. that.selectComponent('#product_six_left').init((canvas, width, height, dpr) => {
  2194. const chart = echarts.init(canvas, null, {
  2195. width: width,
  2196. height: height,
  2197. devicePixelRatio: dpr
  2198. });
  2199. var colors = ['#F71404','#2D59E6','#71CCFF']
  2200. var option = that.getCysOrderOption(list);
  2201. option.color = ['rgb(243,243,251)'];
  2202. option.grid.top = '20%'
  2203. option.yAxis.axisLabel.color = '#000';
  2204. option.legend = {
  2205. data:lineList.map(item=>item.name),
  2206. icon:"circle",
  2207. top:"2%",
  2208. right:"auto",
  2209. itemWidth:8,
  2210. itemHeight:8,
  2211. textStyle:{
  2212. fontSize:8,
  2213. color:'#485465',
  2214. },
  2215. }
  2216. lineList.map((item,index)=>{
  2217. option.series.push({
  2218. name:item.name,
  2219. type:'line',
  2220. data:item.data,
  2221. lineStyle:{
  2222. normal:{
  2223. color:colors[index]
  2224. }
  2225. },
  2226. itemStyle:{
  2227. normal:{
  2228. color:colors[index]
  2229. }
  2230. }
  2231. })
  2232. })
  2233. chart.setOption(option);
  2234. return chart
  2235. })
  2236. },
  2237. setCardSixRightBar(list){
  2238. var that = this;
  2239. that.selectComponent('#product_six_right').init((canvas, width, height, dpr) => {
  2240. const chart = echarts.init(canvas, null, {
  2241. width: width,
  2242. height: height,
  2243. devicePixelRatio: dpr
  2244. });
  2245. var option = this.setCardLineTotal();
  2246. option.series = [];
  2247. list.map(item=>{
  2248. option.series.push({
  2249. type: 'line',
  2250. stack: 'Total',
  2251. areaStyle: {},
  2252. showSymbol:false,
  2253. emphasis: {
  2254. focus: 'series'
  2255. },
  2256. data: item.data,
  2257. })
  2258. })
  2259. chart.setOption(option)
  2260. return chart;
  2261. })
  2262. },
  2263. setCardLineTotal(){
  2264. return {
  2265. xAxis: {
  2266. type: "category",
  2267. axisTick:{show:false,},
  2268. nameTextStyle: {
  2269. color: "#77869E",
  2270. fontSize: 8,
  2271. },
  2272. axisLabel: {
  2273. color: '#999999',
  2274. fontSize: 8,
  2275. },
  2276. axisLine: {
  2277. onZero: false,
  2278. lineStyle: {
  2279. color: "#cccccc",
  2280. },
  2281. },
  2282. data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  2283. },
  2284. yAxis: {
  2285. type: "value",
  2286. minInterval: 1,
  2287. axisLabel:{color:"#000", fontSize:8,},
  2288. axisLine: {
  2289. lineStyle: {
  2290. color: "#cccccc",
  2291. },
  2292. show: true,
  2293. },
  2294. },
  2295. color: ["#7661FF", "#5AC8FA", "#00B972"],
  2296. grid: {
  2297. left: "3%",
  2298. top: "5%",
  2299. right: "4%",
  2300. bottom: "3%",
  2301. containLabel: true,
  2302. },
  2303. series: [
  2304. {
  2305. data: [120, 200, 150, 80, 70, 110, 130, 110],
  2306. type: "line",
  2307. },
  2308. ]
  2309. }
  2310. },
  2311. setSevenCardPie(list){
  2312. var that = this;
  2313. that.selectComponent('#product_seven_left').init((canvas, width, height, dpr) => {
  2314. const chart = echarts.init(canvas, null, {
  2315. width: width,
  2316. height: height,
  2317. devicePixelRatio: dpr
  2318. });
  2319. var itemStyle = {
  2320. normal: {
  2321. label: {
  2322. show: false,
  2323. formatter: function (v) {
  2324. //文字中遇到空格
  2325. let text = v.name+'\n'+v.value;
  2326. return text;
  2327. },
  2328. },
  2329. labelLine: {
  2330. show: true,
  2331. length:4,
  2332. length2:4,
  2333. },
  2334. },
  2335. }
  2336. var option = this.getStaticPieChart();
  2337. option.color = ['rgb(247,20,4)','rgb(127,210,255)','rgb(44,88,288)'];
  2338. var center = [["50%", "10%"],["50%", "35%"],["50%", "60%"],["50%", "85%"]];
  2339. option.series = [];
  2340. list.map((item,index)=>{
  2341. option.series.push({
  2342. type: "pie",
  2343. radius: ['40%','70%'],
  2344. center: center[index],
  2345. itemStyle,
  2346. label: {
  2347. position: "inside",
  2348. formatter: "{d}%",
  2349. fontSize: 8,
  2350. color: '#fff',
  2351. },
  2352. data: item.data,
  2353. })
  2354. })
  2355. chart.setOption(option)
  2356. return chart
  2357. })
  2358. },
  2359. setCardSenvenPie(list){
  2360. var that = this;
  2361. that.selectComponent('#product_seven_right').init((canvas, width, height, dpr) => {
  2362. const chart = echarts.init(canvas, null, {
  2363. width: width,
  2364. height: height,
  2365. devicePixelRatio: dpr
  2366. });
  2367. var option = this.getStaticPieChart();
  2368. option.series = [];
  2369. option.color = ['#FFAF36','#7A4AFE']
  2370. option.legend = {
  2371. data:list.map(item=>item.name),
  2372. icon:"circle",
  2373. top:"2%",
  2374. right:"auto",
  2375. itemWidth:8,
  2376. itemHeight:8,
  2377. textStyle:{
  2378. fontSize:8,
  2379. color:'#485465',
  2380. },
  2381. }
  2382. option.series = [{
  2383. type: "pie",
  2384. radius: "80%",
  2385. center: ["50%", "50%"],
  2386. label: {
  2387. show:false,
  2388. position: "inside",
  2389. formatter: "{d}%",
  2390. fontSize: 8,
  2391. color: '#fff',
  2392. },
  2393. data:list,
  2394. }]
  2395. chart.setOption(option);
  2396. return chart;
  2397. })
  2398. },
  2399. setCardEightBar(list){
  2400. var that = this;
  2401. that.selectComponent('#product_eight_left').init((canvas, width, height, dpr) => {
  2402. const chart = echarts.init(canvas, null, {
  2403. width: width,
  2404. height: height,
  2405. devicePixelRatio: dpr
  2406. });
  2407. var option = that.getStaticBarChart();
  2408. option.series = [];
  2409. option.legend = {
  2410. data:list.map(item=>item.name),
  2411. icon:"circle",
  2412. top:"2%",
  2413. right:"auto",
  2414. itemWidth:8,
  2415. itemHeight:8,
  2416. textStyle:{
  2417. fontSize:8,
  2418. color:'#485465',
  2419. },
  2420. }
  2421. option.grid.top='20%';
  2422. option.grid.bottom='13%';
  2423. list.map((item,index)=>{
  2424. option.series.push({
  2425. name:item.name,
  2426. type: 'bar',
  2427. data:item.data
  2428. });
  2429. })
  2430. chart.setOption(option);
  2431. return chart;
  2432. });
  2433. },
  2434. setCardEightRightBar(list){
  2435. var that = this;
  2436. that.selectComponent('#product_eight_right').init((canvas, width, height, dpr) => {
  2437. const chart = echarts.init(canvas, null, {
  2438. width: width,
  2439. height: height,
  2440. devicePixelRatio: dpr
  2441. });
  2442. var option = that.getStaticBarChart();
  2443. option.title = {
  2444. text: '历来所有疫苗的数据',
  2445. top:'10%',
  2446. textStyle: {
  2447. color: '#999',
  2448. fontSize: 6,
  2449. }
  2450. }
  2451. option.legend = {
  2452. data:list.map(item=>item.name),
  2453. icon:"circle",
  2454. top:"2%",
  2455. right:"auto",
  2456. itemWidth:8,
  2457. itemHeight:8,
  2458. textStyle:{
  2459. fontSize:8,
  2460. color:'#485465',
  2461. },
  2462. }
  2463. option.grid = {
  2464. top:'20%',
  2465. bottom:'15%',
  2466. right:'15%',
  2467. left:'15%'
  2468. }
  2469. option.color = ['#26E657','#FFAF36','#F71404'];
  2470. option.yAxis = [
  2471. {
  2472. type: 'value',
  2473. // min: 0,
  2474. // max: 250,
  2475. interval: 50,
  2476. minInterval: 1,
  2477. axisLine: {
  2478. lineStyle: {
  2479. color: "#cccccc",
  2480. },
  2481. show: false,
  2482. },
  2483. axisLabel: {
  2484. color: "#999999",
  2485. fontSize: 8,
  2486. },
  2487. },
  2488. {
  2489. type: 'value',
  2490. min: 0,
  2491. max:25,
  2492. interval: 5,
  2493. // minInterval: 1,
  2494. axisLine: {
  2495. lineStyle: {
  2496. // color: "",
  2497. },
  2498. show: false,
  2499. },
  2500. axisLabel: {
  2501. color: "#999999",
  2502. fontSize: 8,
  2503. },
  2504. }
  2505. ];
  2506. option.series = [];
  2507. list.map((item,index)=>{
  2508. option.series.push({
  2509. name: item.name,
  2510. type: index != list.length -1 ? 'bar' :'line',
  2511. stack: "Ad",
  2512. emphasis: {
  2513. focus: "series",
  2514. },
  2515. data:item.data,
  2516. })
  2517. })
  2518. chart.setOption(option);
  2519. return chart;
  2520. })
  2521. },
  2522. setCardNineBar(list){
  2523. var that = this;
  2524. that.selectComponent('#product_nine_left').init((canvas, width, height, dpr) => {
  2525. const chart = echarts.init(canvas, null, {
  2526. width: width,
  2527. height: height,
  2528. devicePixelRatio: dpr
  2529. });
  2530. var option = that.getCysOrderOption(list);
  2531. option.title = {
  2532. text: '产品分类信息',
  2533. top:'10%',
  2534. textStyle: {
  2535. color: '#999',
  2536. fontSize: 6,
  2537. }
  2538. }
  2539. option.grid = {
  2540. top:"25%",
  2541. left:"13%",
  2542. right:"15%",
  2543. bottom:"14%",
  2544. }
  2545. option.yAxis = [
  2546. {
  2547. type: 'value',
  2548. // min: 0,
  2549. // max: 250,
  2550. // interval: 50,
  2551. minInterval: 1,
  2552. axisLine: {
  2553. lineStyle: {
  2554. color: "#cccccc",
  2555. },
  2556. show: false,
  2557. },
  2558. axisLabel: {
  2559. color: "#999999",
  2560. fontSize: 8,
  2561. },
  2562. },
  2563. {
  2564. type: 'value',
  2565. min: 0,
  2566. max:25,
  2567. interval: 5,
  2568. // minInterval: 1,
  2569. axisLine: {
  2570. lineStyle: {
  2571. // color: "",
  2572. },
  2573. show: false,
  2574. },
  2575. axisLabel: {
  2576. color: "#999999",
  2577. fontSize: 8,
  2578. },
  2579. }
  2580. ];
  2581. chart.setOption(option);
  2582. return chart;
  2583. })
  2584. },
  2585. setCardNineRightBar(list){
  2586. var that = this;
  2587. that.selectComponent('#product_nine_right').init((canvas, width, height, dpr) => {
  2588. const chart = echarts.init(canvas, null, {
  2589. width: width,
  2590. height: height,
  2591. devicePixelRatio: dpr
  2592. });
  2593. var option = that.setCardLineTotal();
  2594. option.series = [];
  2595. option.legend = {
  2596. data:list.map(item=>item.name),
  2597. icon:"circle",
  2598. top:"5%",
  2599. right:"auto",
  2600. itemWidth:8,
  2601. itemHeight:8,
  2602. textStyle:{
  2603. fontSize:8,
  2604. color:'#485465',
  2605. },
  2606. }
  2607. option.yAxis = {
  2608. type: "value",
  2609. // minInterval: 1,
  2610. axisLine: {
  2611. lineStyle: {
  2612. color: "#cccccc",
  2613. },
  2614. },
  2615. axisLabel: {
  2616. color: "#999999",
  2617. fontSize: 8,
  2618. },
  2619. },
  2620. option.grid.top = '20%';
  2621. option.grid.right = '10%';
  2622. list.map(item=>{
  2623. option.series.push({
  2624. name:item.name,
  2625. type: 'line',
  2626. stack: 'Total',
  2627. areaStyle: {},
  2628. showSymbol:false,
  2629. emphasis: {
  2630. focus: 'series'
  2631. },
  2632. data: item.data,
  2633. })
  2634. })
  2635. chart.setOption(option)
  2636. return chart;
  2637. })
  2638. },
  2639. // 地区产品统计
  2640. setCardLeftFive(list){
  2641. var that = this;
  2642. that.selectComponent('#product_five').init((canvas, width, height, dpr) => {
  2643. const chart = echarts.init(canvas, null, {
  2644. width: width,
  2645. height: height,
  2646. devicePixelRatio: dpr
  2647. });
  2648. var option = {
  2649. xAxis: {
  2650. type: 'value',
  2651. axisLabel: {
  2652. show: false
  2653. }
  2654. },
  2655. grid:{
  2656. top:0,
  2657. left: '3%',
  2658. right: '4%',
  2659. bottom: '3%',
  2660. containLabel: true
  2661. },
  2662. yAxis: {
  2663. type: 'category',
  2664. data: list.name.map(item=>item),
  2665. axisTick: { show: false },
  2666. axisLabel:{color:"#999999", fontSize:9,},
  2667. axisLine: { lineStyle: { color: '#DEE3FF' } },
  2668. },
  2669. series:list.data.map(item=>{
  2670. return{ name:item.name,type:'bar',data:item.data }
  2671. })
  2672. }
  2673. chart.setOption(option);
  2674. return chart;
  2675. })
  2676. },
  2677. })