index.js 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670
  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. list.map((item,index)=>{
  1506. const {stack,end,trans,} = item;
  1507. option.xAxis.data.push(item.productName);
  1508. option.series.push({
  1509. name:item.productName,
  1510. type: "bar",
  1511. stack: "Ad",
  1512. emphasis: {
  1513. focus: "series",
  1514. },
  1515. data:[stack,trans,end]
  1516. })
  1517. })
  1518. console.log(option);
  1519. chart.setOption(option);
  1520. return chart;
  1521. })
  1522. },
  1523. product_two_left_two(list){
  1524. var that = this;
  1525. that.selectComponent('#product_two_left_two').init((canvas, width, height, dpr) => {
  1526. const chart = echarts.init(canvas, null, {
  1527. width: width,
  1528. height: height,
  1529. devicePixelRatio: dpr
  1530. });
  1531. var option = this.getStaticBarChart();
  1532. option.series = [];
  1533. option.legend = {
  1534. data:list.map(item=>item.name),
  1535. icon:"circle",
  1536. top:"2%",
  1537. right:"auto",
  1538. itemWidth:8,
  1539. itemHeight:8,
  1540. textStyle:{
  1541. fontSize:8,
  1542. color:'#485465',
  1543. },
  1544. }
  1545. option.grid.top='20%';
  1546. option.grid.bottom='13%';
  1547. list.map((item,index)=>{
  1548. option.series.push({
  1549. name:item.name,
  1550. type: index != list.length -1 ? 'bar' :'line',
  1551. // yAxisIndex: 1,
  1552. data:item.data
  1553. });
  1554. // if(index != list.length-1){
  1555. // delete option.series[index].yAxisIndex;
  1556. // }
  1557. })
  1558. chart.setOption(option);
  1559. return chart;
  1560. })
  1561. },
  1562. getStaticBarChart(){
  1563. return {
  1564. xAxis: {
  1565. type: "category",
  1566. axisTick:{show:false,},
  1567. nameTextStyle: {
  1568. color: "#77869E",
  1569. fontSize: 8,
  1570. },
  1571. axisLabel: {
  1572. color: '#999999',
  1573. fontSize: 8,
  1574. },
  1575. axisLine: {
  1576. onZero: false,
  1577. lineStyle: {
  1578. color: "#cccccc",
  1579. },
  1580. },
  1581. data: ["Mon", "Tue", "Wed", "Thu",],
  1582. },
  1583. yAxis: {
  1584. type: "value",
  1585. minInterval: 1,
  1586. axisLine: {
  1587. lineStyle: {
  1588. color: "#cccccc",
  1589. },
  1590. show: false,
  1591. },
  1592. axisLabel: {
  1593. color: "#999999",
  1594. fontSize: 8,
  1595. },
  1596. },
  1597. color: ["#7661FF", "#5AC8FA", "#00B972"],
  1598. grid: {
  1599. left: "3%",
  1600. top: "8%",
  1601. right: "4%",
  1602. bottom: "3%",
  1603. containLabel: true,
  1604. },
  1605. series: [
  1606. {
  1607. data: [120, 200, 150, 80, 70, 110, 130, 110],
  1608. type: "bar",
  1609. },
  1610. ],
  1611. };
  1612. },
  1613. setCardPieTwo(list){
  1614. var that = this;
  1615. that.selectComponent('#product_three_left_one').init((canvas, width, height, dpr) => {
  1616. const chart = echarts.init(canvas, null, {
  1617. width: width,
  1618. height: height,
  1619. devicePixelRatio: dpr
  1620. });
  1621. var option = this.getStaticPieChart();
  1622. var itemStyle = {
  1623. normal: {
  1624. label: {
  1625. show: true,
  1626. formatter: function (v) {
  1627. //文字中遇到空格
  1628. let text = v.name+'\n'+v.value;
  1629. return text;
  1630. },
  1631. },
  1632. labelLine: {
  1633. show: true,
  1634. length:4,
  1635. length2:4,
  1636. },
  1637. },
  1638. }
  1639. option.series = [
  1640. {
  1641. type: "pie",
  1642. radius: "40%",
  1643. center: ["50%", "25%"],
  1644. itemStyle,
  1645. label: {
  1646. position: "inside",
  1647. formatter: "{d}%",
  1648. fontSize: 8,
  1649. color: '#fff',
  1650. },
  1651. data: [
  1652. { name: "标签1", value: 50 },
  1653. { name: "标签2", value: 20 },
  1654. { name: "标签3", value: 10 },
  1655. ],
  1656. },
  1657. {
  1658. type: "pie",
  1659. radius: "40%",
  1660. center: ["50%", "75%"],
  1661. percentPrecision:0,
  1662. minShowLabelAngle:30,
  1663. itemStyle,
  1664. label: {
  1665. position: "inside",
  1666. formatter: "{d}%",
  1667. fontSize: 8,
  1668. color: '#fff',
  1669. },
  1670. data: [
  1671. { name: "标签1", value: 50 },
  1672. { name: "标签2", value: 20 },
  1673. { name: "标签3", value: 10 },
  1674. ],
  1675. },
  1676. ]
  1677. chart.setOption(option);
  1678. return chart;
  1679. })
  1680. },
  1681. getStaticPieChart(){
  1682. return {
  1683. color: ["#964CC4", "#04A3CC", "#3B6AD5"],
  1684. title: {
  1685. show: false,
  1686. },
  1687. grid: {
  1688. top: "12%",
  1689. left: "5%",
  1690. right: "5%",
  1691. bottom: "12%",
  1692. },
  1693. series: [
  1694. // {
  1695. // type: "pie",
  1696. // radius: "50%",
  1697. // center: ["50%", "25%"],
  1698. // label: {
  1699. // position: "inside",
  1700. // formatter: "{d}%",
  1701. // fontSize: 8,
  1702. // color: '#fff',
  1703. // },
  1704. // data: [
  1705. // { name: "在途", value: 50 },
  1706. // { name: "完成", value: 20 },
  1707. // { name: "待发运", value: 10 },
  1708. // ],
  1709. // },
  1710. // {
  1711. // type: "pie",
  1712. // radius: "50%",
  1713. // center: ["50%", "75%"],
  1714. // percentPrecision:0,
  1715. // minShowLabelAngle:30,
  1716. // label: {
  1717. // position: "inside",
  1718. // formatter: "{d}%",
  1719. // fontSize: 8,
  1720. // color: '#fff',
  1721. // },
  1722. // data: [
  1723. // { name: "在途", value: 50 },
  1724. // { name: "完成", value: 20 },
  1725. // { name: "待发运", value: 10 },
  1726. // ],
  1727. // },
  1728. ]
  1729. }
  1730. },
  1731. setCardFivePie(){
  1732. var that = this;
  1733. that.selectComponent('#product_five_left_one').init((canvas, width, height, dpr) => {
  1734. const chart = echarts.init(canvas, null, {
  1735. width: width,
  1736. height: height,
  1737. devicePixelRatio: dpr
  1738. });
  1739. var option = this.getStaticPieChart();
  1740. option.color = ['rgb(91,132,206)','rgb(127,210,255)','rgb(44,87,226)'];
  1741. var itemStyle = {
  1742. normal: {
  1743. label: {
  1744. show: false,
  1745. formatter: function (v) {
  1746. //文字中遇到空格
  1747. let text = v.name+'\n'+v.value;
  1748. return text;
  1749. },
  1750. },
  1751. labelLine: {
  1752. show: true,
  1753. length:4,
  1754. length2:4,
  1755. },
  1756. },
  1757. }
  1758. option.series = [
  1759. {
  1760. type: "pie",
  1761. radius: "80%",
  1762. center: ["50%", "30%"],
  1763. itemStyle,
  1764. label: {
  1765. position: "inside",
  1766. formatter: "{d}%",
  1767. fontSize: 8,
  1768. color: '#fff',
  1769. },
  1770. data: [
  1771. { name: "标签1", value: 50 },
  1772. { name: "标签2", value: 20 },
  1773. { name: "标签3", value: 10 },
  1774. ],
  1775. },
  1776. {
  1777. type: "pie",
  1778. radius: "80%",
  1779. center: ["50%", "53%"],
  1780. itemStyle,
  1781. data: [
  1782. { name: "标签1", value: 50 },
  1783. { name: "标签2", value: 20 },
  1784. { name: "标签3", value: 10 },
  1785. ],
  1786. },
  1787. {
  1788. type: "pie",
  1789. radius: "80%",
  1790. itemStyle,
  1791. center: ["50%", "77%"],
  1792. data: [
  1793. { name: "标签1", value: 50 },
  1794. { name: "标签2", value: 20 },
  1795. { name: "标签3", value: 10 },
  1796. ],
  1797. },
  1798. ]
  1799. option.grid = {
  1800. top: "12%",
  1801. left: "10%",
  1802. right: "0%",
  1803. bottom: "12%",
  1804. },
  1805. chart.setOption(option);
  1806. return chart;
  1807. })
  1808. },
  1809. setCard3dBar(){
  1810. var that = this;
  1811. that.selectComponent('#product_three_left_two').init((canvas, width, height, dpr) => {
  1812. const chart = echarts.init(canvas, null, {
  1813. width: width,
  1814. height: height,
  1815. devicePixelRatio: dpr
  1816. });
  1817. 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]]
  1818. chart.setOption({
  1819. tooltip: {},
  1820. xAxis3D: {
  1821. type: 'category',
  1822. 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']
  1823. },
  1824. yAxis3D: {
  1825. type: 'category',
  1826. data: ['Saturday', 'Friday', 'Thursday','Wednesday', 'Tuesday', 'Monday', 'Sunday']
  1827. },
  1828. zAxis3D: {
  1829. type: 'value'
  1830. },
  1831. grid3D: {
  1832. boxWidth: 200,
  1833. boxDepth: 80,
  1834. viewControl: {
  1835. // projection: 'orthographic'
  1836. },
  1837. light: {
  1838. main: {
  1839. intensity: 1.2,
  1840. shadow: true
  1841. },
  1842. ambient: {
  1843. intensity: 0.3
  1844. }
  1845. }
  1846. },
  1847. series: [
  1848. {
  1849. type: 'bar3D',
  1850. data: data.map(function (item) {
  1851. return {
  1852. value: [item[1], item[0], item[2]]
  1853. };
  1854. }),
  1855. shading: 'lambert',
  1856. label: {
  1857. fontSize: 16,
  1858. borderWidth: 1
  1859. },
  1860. emphasis: {
  1861. label: {
  1862. fontSize: 20,
  1863. color: '#900'
  1864. },
  1865. itemStyle: {
  1866. color: '#900'
  1867. }
  1868. }
  1869. }
  1870. ]
  1871. });
  1872. return chart;
  1873. })
  1874. },
  1875. setKLine(list){
  1876. var that = this;
  1877. that.selectComponent('#product_four').init((canvas, width, height, dpr) => {
  1878. const chart = echarts.init(canvas, null, {
  1879. width: width,
  1880. height: height,
  1881. devicePixelRatio: dpr
  1882. });
  1883. list = list.map(item=>{
  1884. return {orderNum:item.total,name:item.city || 'N/A'}
  1885. })
  1886. var option = that.getCysOrderOption(list);
  1887. // lenged
  1888. option.series = [{
  1889. type:'bar',
  1890. barMaxWidth: 15,
  1891. barMinHeight: 10,
  1892. data:list.map(item=>item.orderNum),
  1893. label: {
  1894. show: true,
  1895. position: 'inside'
  1896. },
  1897. itemStyle:{
  1898. normal:{color:'#333FFF'}
  1899. }
  1900. }]
  1901. chart.setOption(option);
  1902. return chart;
  1903. })
  1904. },
  1905. calculateMA(dayCount, data) {
  1906. var result = [];
  1907. for (var i = 0, len = data.length; i < len; i++) {
  1908. if (i < dayCount) {
  1909. result.push('-');
  1910. continue;
  1911. }
  1912. var sum = 0;
  1913. for (var j = 0; j < dayCount; j++) {
  1914. sum += +data[i - j][1];
  1915. }
  1916. result.push(sum / dayCount);
  1917. }
  1918. return result;
  1919. },
  1920. setCardDiagram(list){
  1921. var that = this;
  1922. that.selectComponent('#product_four_left_two').init((canvas, width, height, dpr) => {
  1923. const chart = echarts.init(canvas, null, {
  1924. width: width,
  1925. height: height,
  1926. devicePixelRatio: dpr
  1927. });
  1928. chart.setOption({
  1929. backgroundColor: "transparent",
  1930. tooltip: {
  1931. formatter:function(params){
  1932. const {data:{name,value,unNormalTotal}} = params;
  1933. return `${name}\n正常: ${value}\n预警: ${unNormalTotal}`
  1934. }
  1935. },
  1936. grid: {},
  1937. animationDurationUpdate: function (idx) {
  1938. // 越往后的数据延迟越大
  1939. return idx * 100;
  1940. },
  1941. color: ["red", "rgb(10,92,170)", "rgb(114,205,255)"],
  1942. animationEasingUpdate: "bounceIn",
  1943. series: [
  1944. {
  1945. type: "graph",
  1946. layout: "force",
  1947. force: {
  1948. repulsion: 100, //越大斥力越大
  1949. gravity: 0.05, //越大节点越往中心靠拢
  1950. edgeLength: 20, //值越小则长度越长
  1951. },
  1952. roam: true,
  1953. draggable: true,
  1954. symbolSize: 1,
  1955. itemStyle: {
  1956. // opacity: 0.9,
  1957. color: () => {
  1958. return (
  1959. 'red',
  1960. 'rgb(114,205,255)',
  1961. 'rgb(10,92,170)'
  1962. );
  1963. },
  1964. },
  1965. label: {
  1966. normal: {
  1967. show: true,
  1968. fontSize: 10,
  1969. },
  1970. },
  1971. data: list
  1972. },
  1973. ],
  1974. })
  1975. return chart;
  1976. })
  1977. },
  1978. setCardXuTuOption(testNum){
  1979. var that = this;
  1980. let icon =
  1981. "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";
  1982. for (var index = 0; index < 4; index++) {
  1983. that.selectComponent('#product_five_right_one'+index).init((canvas, width, height, dpr) => {
  1984. const chart = echarts.init(canvas, null, {
  1985. width: width,
  1986. height: height,
  1987. devicePixelRatio: dpr
  1988. });
  1989. chart.setOption({
  1990. backgroundColor: "transparent",
  1991. tooltip: {
  1992. trigger: "axis",
  1993. axisPointer: {
  1994. type: "shadow",
  1995. },
  1996. formatter: "{b0}: {c0}%",
  1997. },
  1998. grid: {
  1999. containLabel: true,
  2000. height: "200px",
  2001. width: "auto",
  2002. left: "0",
  2003. top: "center",
  2004. },
  2005. xAxis: {
  2006. max: 100,
  2007. splitLine: {
  2008. show: false,
  2009. },
  2010. axisLine: {
  2011. show: false,
  2012. },
  2013. axisLabel: {
  2014. show: false,
  2015. },
  2016. axisTick: {
  2017. show: false,
  2018. },
  2019. },
  2020. yAxis: {
  2021. type: "category",
  2022. inverse: true,
  2023. axisLine: {
  2024. show: false,
  2025. },
  2026. axisTick: {
  2027. show: false,
  2028. },
  2029. axisLabel: {
  2030. // margin: 10,
  2031. fontSize: 20,
  2032. color: "white",
  2033. },
  2034. axisPointer: {
  2035. label: {
  2036. show: true,
  2037. margin: 100,
  2038. },
  2039. },
  2040. },
  2041. series: [
  2042. {
  2043. type: "pictorialBar",
  2044. symbolRepeat: "fixed",
  2045. symbolMargin: "6!",
  2046. label: {
  2047. normal: {
  2048. show: false,
  2049. position: "right",
  2050. offset: [3, 0],
  2051. formatter: (param) => {
  2052. return param.value.toFixed(0) + "%";
  2053. },
  2054. textStyle: {
  2055. fontSize: 20,
  2056. color: "white",
  2057. },
  2058. },
  2059. },
  2060. symbolClip: true,
  2061. symbolSize: [22, 30],
  2062. symbolPosition: "start",
  2063. symbolBoundingData: 100,
  2064. data: [
  2065. {
  2066. value: testNum.normalTotal,
  2067. symbol: icon,
  2068. itemStyle: {
  2069. color: "#1DDBF9",
  2070. },
  2071. },
  2072. ],
  2073. z: 10,
  2074. },
  2075. {
  2076. type: "pictorialBar",
  2077. itemStyle: {
  2078. normal: {
  2079. opacity: 0.2,
  2080. },
  2081. },
  2082. animationDuration: 0,
  2083. symbolRepeat: "fixed",
  2084. symbolMargin: "6!",
  2085. symbolSize: [22, 30],
  2086. symbolBoundingData: 100,
  2087. symbolPosition: "start",
  2088. // symbolOffset: [
  2089. // 10,
  2090. // 0
  2091. // ],
  2092. data: [
  2093. {
  2094. value: 100,
  2095. symbol: icon,
  2096. itemStyle: {
  2097. color: "#1DDBF9",
  2098. },
  2099. },
  2100. ],
  2101. z: 5,
  2102. },
  2103. ],
  2104. })
  2105. return chart
  2106. })
  2107. }
  2108. },
  2109. setCardFivePie_rght(list){
  2110. var that = this;
  2111. var placeHolderStyle = {
  2112. normal: {
  2113. label: {
  2114. show: false,
  2115. formatter: function (v) {
  2116. //文字中遇到空格就换行
  2117. let text = v.value;
  2118. return text;
  2119. },
  2120. },
  2121. labelLine: {
  2122. show: true,
  2123. },
  2124. },
  2125. };
  2126. that.selectComponent('#product_five_right').init((canvas, width, height, dpr) => {
  2127. const chart = echarts.init(canvas, null, {
  2128. width: width,
  2129. height: height,
  2130. devicePixelRatio: dpr
  2131. });
  2132. var option = this.getStaticPieChart();
  2133. var position = [['20%','20%'],['20%','50%'],['20%','80%'],['50%','20%'],['50%','50%'],['50%','80%'],['80%','20%'],['80%','50%'],['80%','80%']]
  2134. position.map(item=>{
  2135. option.series.push({
  2136. type: "pie",
  2137. clockWise: true, //顺时加载
  2138. hoverAnimation: false, //鼠标移入变大
  2139. silent:false,
  2140. radius: [20, 23],
  2141. center: item,
  2142. itemStyle: placeHolderStyle,
  2143. label:{
  2144. normal:{
  2145. show:true,
  2146. position:'center',
  2147. color:'#485465',
  2148. formatter:'{d}',
  2149. emphasis:{
  2150. show:true
  2151. }
  2152. }
  2153. },
  2154. data: [
  2155. {
  2156. value: 0.6,
  2157. itemStyle:{
  2158. normal:{
  2159. color:'#0e74ff'
  2160. }
  2161. }
  2162. },
  2163. {
  2164. value: 0.4,
  2165. itemStyle:{
  2166. normal:{
  2167. color:"rgb(243,243,251)"
  2168. }
  2169. }
  2170. }
  2171. ]
  2172. })
  2173. })
  2174. chart.setOption(option)
  2175. return chart;
  2176. })
  2177. },
  2178. setCardSixBar(list,lineList){
  2179. var that = this;
  2180. that.selectComponent('#product_six_left').init((canvas, width, height, dpr) => {
  2181. const chart = echarts.init(canvas, null, {
  2182. width: width,
  2183. height: height,
  2184. devicePixelRatio: dpr
  2185. });
  2186. var colors = ['#F71404','#2D59E6','#71CCFF']
  2187. var option = that.getCysOrderOption(list);
  2188. option.color = ['rgb(243,243,251)'];
  2189. option.grid.top = '20%'
  2190. option.yAxis.axisLabel.color = '#000';
  2191. option.legend = {
  2192. data:lineList.map(item=>item.name),
  2193. icon:"circle",
  2194. top:"2%",
  2195. right:"auto",
  2196. itemWidth:8,
  2197. itemHeight:8,
  2198. textStyle:{
  2199. fontSize:8,
  2200. color:'#485465',
  2201. },
  2202. }
  2203. lineList.map((item,index)=>{
  2204. option.series.push({
  2205. name:item.name,
  2206. type:'line',
  2207. data:item.data,
  2208. lineStyle:{
  2209. normal:{
  2210. color:colors[index]
  2211. }
  2212. },
  2213. itemStyle:{
  2214. normal:{
  2215. color:colors[index]
  2216. }
  2217. }
  2218. })
  2219. })
  2220. chart.setOption(option);
  2221. return chart
  2222. })
  2223. },
  2224. setCardSixRightBar(list){
  2225. var that = this;
  2226. that.selectComponent('#product_six_right').init((canvas, width, height, dpr) => {
  2227. const chart = echarts.init(canvas, null, {
  2228. width: width,
  2229. height: height,
  2230. devicePixelRatio: dpr
  2231. });
  2232. var option = this.setCardLineTotal();
  2233. option.series = [];
  2234. list.map(item=>{
  2235. option.series.push({
  2236. type: 'line',
  2237. stack: 'Total',
  2238. areaStyle: {},
  2239. showSymbol:false,
  2240. emphasis: {
  2241. focus: 'series'
  2242. },
  2243. data: item.data,
  2244. })
  2245. })
  2246. chart.setOption(option)
  2247. return chart;
  2248. })
  2249. },
  2250. setCardLineTotal(){
  2251. return {
  2252. xAxis: {
  2253. type: "category",
  2254. axisTick:{show:false,},
  2255. nameTextStyle: {
  2256. color: "#77869E",
  2257. fontSize: 8,
  2258. },
  2259. axisLabel: {
  2260. color: '#999999',
  2261. fontSize: 8,
  2262. },
  2263. axisLine: {
  2264. onZero: false,
  2265. lineStyle: {
  2266. color: "#cccccc",
  2267. },
  2268. },
  2269. data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  2270. },
  2271. yAxis: {
  2272. type: "value",
  2273. minInterval: 1,
  2274. axisLabel:{color:"#000", fontSize:8,},
  2275. axisLine: {
  2276. lineStyle: {
  2277. color: "#cccccc",
  2278. },
  2279. show: true,
  2280. },
  2281. },
  2282. color: ["#7661FF", "#5AC8FA", "#00B972"],
  2283. grid: {
  2284. left: "3%",
  2285. top: "5%",
  2286. right: "4%",
  2287. bottom: "3%",
  2288. containLabel: true,
  2289. },
  2290. series: [
  2291. {
  2292. data: [120, 200, 150, 80, 70, 110, 130, 110],
  2293. type: "line",
  2294. },
  2295. ]
  2296. }
  2297. },
  2298. setSevenCardPie(list){
  2299. var that = this;
  2300. that.selectComponent('#product_seven_left').init((canvas, width, height, dpr) => {
  2301. const chart = echarts.init(canvas, null, {
  2302. width: width,
  2303. height: height,
  2304. devicePixelRatio: dpr
  2305. });
  2306. var itemStyle = {
  2307. normal: {
  2308. label: {
  2309. show: false,
  2310. formatter: function (v) {
  2311. //文字中遇到空格
  2312. let text = v.name+'\n'+v.value;
  2313. return text;
  2314. },
  2315. },
  2316. labelLine: {
  2317. show: true,
  2318. length:4,
  2319. length2:4,
  2320. },
  2321. },
  2322. }
  2323. var option = this.getStaticPieChart();
  2324. option.color = ['rgb(247,20,4)','rgb(127,210,255)','rgb(44,88,288)'];
  2325. var center = [["50%", "10%"],["50%", "35%"],["50%", "60%"],["50%", "85%"]];
  2326. option.series = [];
  2327. list.map((item,index)=>{
  2328. option.series.push({
  2329. type: "pie",
  2330. radius: ['40%','70%'],
  2331. center: center[index],
  2332. itemStyle,
  2333. label: {
  2334. position: "inside",
  2335. formatter: "{d}%",
  2336. fontSize: 8,
  2337. color: '#fff',
  2338. },
  2339. data: item.data,
  2340. })
  2341. })
  2342. chart.setOption(option)
  2343. return chart
  2344. })
  2345. },
  2346. setCardSenvenPie(list){
  2347. var that = this;
  2348. that.selectComponent('#product_seven_right').init((canvas, width, height, dpr) => {
  2349. const chart = echarts.init(canvas, null, {
  2350. width: width,
  2351. height: height,
  2352. devicePixelRatio: dpr
  2353. });
  2354. var option = this.getStaticPieChart();
  2355. option.series = [];
  2356. option.color = ['#FFAF36','#7A4AFE']
  2357. option.legend = {
  2358. data:list.map(item=>item.name),
  2359. icon:"circle",
  2360. top:"2%",
  2361. right:"auto",
  2362. itemWidth:8,
  2363. itemHeight:8,
  2364. textStyle:{
  2365. fontSize:8,
  2366. color:'#485465',
  2367. },
  2368. }
  2369. option.series = [{
  2370. type: "pie",
  2371. radius: "80%",
  2372. center: ["50%", "50%"],
  2373. label: {
  2374. show:false,
  2375. position: "inside",
  2376. formatter: "{d}%",
  2377. fontSize: 8,
  2378. color: '#fff',
  2379. },
  2380. data:list,
  2381. }]
  2382. chart.setOption(option);
  2383. return chart;
  2384. })
  2385. },
  2386. setCardEightBar(list){
  2387. var that = this;
  2388. that.selectComponent('#product_eight_left').init((canvas, width, height, dpr) => {
  2389. const chart = echarts.init(canvas, null, {
  2390. width: width,
  2391. height: height,
  2392. devicePixelRatio: dpr
  2393. });
  2394. var option = that.getStaticBarChart();
  2395. option.series = [];
  2396. option.legend = {
  2397. data:list.map(item=>item.name),
  2398. icon:"circle",
  2399. top:"2%",
  2400. right:"auto",
  2401. itemWidth:8,
  2402. itemHeight:8,
  2403. textStyle:{
  2404. fontSize:8,
  2405. color:'#485465',
  2406. },
  2407. }
  2408. option.grid.top='20%';
  2409. option.grid.bottom='13%';
  2410. list.map((item,index)=>{
  2411. option.series.push({
  2412. name:item.name,
  2413. type: 'bar',
  2414. data:item.data
  2415. });
  2416. })
  2417. chart.setOption(option);
  2418. return chart;
  2419. });
  2420. },
  2421. setCardEightRightBar(list){
  2422. var that = this;
  2423. that.selectComponent('#product_eight_right').init((canvas, width, height, dpr) => {
  2424. const chart = echarts.init(canvas, null, {
  2425. width: width,
  2426. height: height,
  2427. devicePixelRatio: dpr
  2428. });
  2429. var option = that.getStaticBarChart();
  2430. option.title = {
  2431. text: '历来所有疫苗的数据',
  2432. top:'10%',
  2433. textStyle: {
  2434. color: '#999',
  2435. fontSize: 6,
  2436. }
  2437. }
  2438. option.legend = {
  2439. data:list.map(item=>item.name),
  2440. icon:"circle",
  2441. top:"2%",
  2442. right:"auto",
  2443. itemWidth:8,
  2444. itemHeight:8,
  2445. textStyle:{
  2446. fontSize:8,
  2447. color:'#485465',
  2448. },
  2449. }
  2450. option.grid = {
  2451. top:'20%',
  2452. bottom:'15%',
  2453. right:'15%',
  2454. left:'15%'
  2455. }
  2456. option.color = ['#26E657','#FFAF36','#F71404'];
  2457. option.yAxis = [
  2458. {
  2459. type: 'value',
  2460. // min: 0,
  2461. // max: 250,
  2462. interval: 50,
  2463. minInterval: 1,
  2464. axisLine: {
  2465. lineStyle: {
  2466. color: "#cccccc",
  2467. },
  2468. show: false,
  2469. },
  2470. axisLabel: {
  2471. color: "#999999",
  2472. fontSize: 8,
  2473. },
  2474. },
  2475. {
  2476. type: 'value',
  2477. min: 0,
  2478. max:25,
  2479. interval: 5,
  2480. // minInterval: 1,
  2481. axisLine: {
  2482. lineStyle: {
  2483. // color: "",
  2484. },
  2485. show: false,
  2486. },
  2487. axisLabel: {
  2488. color: "#999999",
  2489. fontSize: 8,
  2490. },
  2491. }
  2492. ];
  2493. option.series = [];
  2494. list.map((item,index)=>{
  2495. option.series.push({
  2496. name: item.name,
  2497. type: index != list.length -1 ? 'bar' :'line',
  2498. stack: "Ad",
  2499. emphasis: {
  2500. focus: "series",
  2501. },
  2502. data:item.data,
  2503. })
  2504. })
  2505. chart.setOption(option);
  2506. return chart;
  2507. })
  2508. },
  2509. setCardNineBar(list){
  2510. var that = this;
  2511. that.selectComponent('#product_nine_left').init((canvas, width, height, dpr) => {
  2512. const chart = echarts.init(canvas, null, {
  2513. width: width,
  2514. height: height,
  2515. devicePixelRatio: dpr
  2516. });
  2517. var option = that.getCysOrderOption(list);
  2518. option.title = {
  2519. text: '产品分类信息',
  2520. top:'10%',
  2521. textStyle: {
  2522. color: '#999',
  2523. fontSize: 6,
  2524. }
  2525. }
  2526. option.grid = {
  2527. top:"25%",
  2528. left:"13%",
  2529. right:"15%",
  2530. bottom:"14%",
  2531. }
  2532. option.yAxis = [
  2533. {
  2534. type: 'value',
  2535. // min: 0,
  2536. // max: 250,
  2537. // interval: 50,
  2538. minInterval: 1,
  2539. axisLine: {
  2540. lineStyle: {
  2541. color: "#cccccc",
  2542. },
  2543. show: false,
  2544. },
  2545. axisLabel: {
  2546. color: "#999999",
  2547. fontSize: 8,
  2548. },
  2549. },
  2550. {
  2551. type: 'value',
  2552. min: 0,
  2553. max:25,
  2554. interval: 5,
  2555. // minInterval: 1,
  2556. axisLine: {
  2557. lineStyle: {
  2558. // color: "",
  2559. },
  2560. show: false,
  2561. },
  2562. axisLabel: {
  2563. color: "#999999",
  2564. fontSize: 8,
  2565. },
  2566. }
  2567. ];
  2568. chart.setOption(option);
  2569. return chart;
  2570. })
  2571. },
  2572. setCardNineRightBar(list){
  2573. var that = this;
  2574. that.selectComponent('#product_nine_right').init((canvas, width, height, dpr) => {
  2575. const chart = echarts.init(canvas, null, {
  2576. width: width,
  2577. height: height,
  2578. devicePixelRatio: dpr
  2579. });
  2580. var option = that.setCardLineTotal();
  2581. option.series = [];
  2582. option.legend = {
  2583. data:list.map(item=>item.name),
  2584. icon:"circle",
  2585. top:"5%",
  2586. right:"auto",
  2587. itemWidth:8,
  2588. itemHeight:8,
  2589. textStyle:{
  2590. fontSize:8,
  2591. color:'#485465',
  2592. },
  2593. }
  2594. option.yAxis = {
  2595. type: "value",
  2596. // minInterval: 1,
  2597. axisLine: {
  2598. lineStyle: {
  2599. color: "#cccccc",
  2600. },
  2601. },
  2602. axisLabel: {
  2603. color: "#999999",
  2604. fontSize: 8,
  2605. },
  2606. },
  2607. option.grid.top = '20%';
  2608. option.grid.right = '10%';
  2609. list.map(item=>{
  2610. option.series.push({
  2611. name:item.name,
  2612. type: 'line',
  2613. stack: 'Total',
  2614. areaStyle: {},
  2615. showSymbol:false,
  2616. emphasis: {
  2617. focus: 'series'
  2618. },
  2619. data: item.data,
  2620. })
  2621. })
  2622. chart.setOption(option)
  2623. return chart;
  2624. })
  2625. },
  2626. // 地区产品统计
  2627. setCardLeftFive(list){
  2628. var that = this;
  2629. that.selectComponent('#product_five').init((canvas, width, height, dpr) => {
  2630. const chart = echarts.init(canvas, null, {
  2631. width: width,
  2632. height: height,
  2633. devicePixelRatio: dpr
  2634. });
  2635. var option = {
  2636. xAxis: {
  2637. type: 'value',
  2638. axisLabel: {
  2639. show: false
  2640. }
  2641. },
  2642. grid:{
  2643. top:0,
  2644. left: '3%',
  2645. right: '4%',
  2646. bottom: '3%',
  2647. containLabel: true
  2648. },
  2649. yAxis: {
  2650. type: 'category',
  2651. data: list.name.map(item=>item),
  2652. axisTick: { show: false },
  2653. axisLabel:{color:"#999999", fontSize:9,},
  2654. axisLine: { lineStyle: { color: '#DEE3FF' } },
  2655. },
  2656. series:list.data.map(item=>{
  2657. return{ name:item.name,type:'bar',data:item.data }
  2658. })
  2659. }
  2660. chart.setOption(option);
  2661. return chart;
  2662. })
  2663. },
  2664. })