index.js 72 KB

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