mainStatistics.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="">
  5. <image class="userFlagimg" src="../../static/img/userFlag.png" mode=""></image>
  6. </view>
  7. <view class="pname">
  8. <font class="wenzi" style="color: #BDD6F3;font-size:28upx"> {{$t('mainStatistics.name')}}: {{pnameData}}</font>
  9. </view>
  10. <view class="company">
  11. <font style="color: #BDD6F3;font-size:28upx">{{$t('mainStatistics.company')}}</font>
  12. </view>
  13. </view>
  14. <view class="ri">
  15. <view class="riShell">
  16. <view class="riImg">
  17. <image style="width: 64upx;height: 64upx;padding-top: 20upx;" :src="$t('mainStatistics.dayImg')"></image>
  18. </view>
  19. <view class="riTitle">
  20. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  21. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalMoney')}}:</font>
  22. <font style="color: #ED341F;">{{dayRandomTimes}}</font>
  23. </view>
  24. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  25. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalNum')}}:</font>
  26. <font style="color: #ED341F;">{{dayRegularTimes}}</font>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="riqi">
  31. <view style="text-align:right" class="tody">
  32. <font style="color: #596D83;">{{today}}</font>
  33. </view>
  34. <view style="text-align:right" class="xingqi">
  35. <font style="color: #596D83;">{{week}}</font>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="fourTitle">
  40. <view class="four">
  41. <view class="fourImg">
  42. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.weekImg')" mode=""></image>
  43. </view>
  44. <view class="fourShell">
  45. <view class="one">
  46. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalMoney')}}:</font>
  47. <font style="color: #ED341F;">{{weekRandomTimes}}</font>
  48. </view>
  49. <view class="two">
  50. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalNum')}}:</font>
  51. <font style="color: #ED341F;">{{weekRegularTimes}}</font>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="four">
  56. <view class="fourImg">
  57. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.monthImg')" mode=""></image>
  58. </view>
  59. <view class="fourShell">
  60. <view class="one">
  61. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalMoney')}}:</font>
  62. <font style="color: #ED341F;">{{monthRandomTimes}}</font>
  63. </view>
  64. <view class="two">
  65. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalNum')}}:</font>
  66. <font style="color: #ED341F;">{{monthRegularTimes}}</font>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="four">
  71. <view class="fourImg">
  72. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.yearImg')" mode=""></image>
  73. </view>
  74. <view class="fourShell">
  75. <view class="one">
  76. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalMoney')}}:</font>
  77. <font style="color: #ED341F;">{{yearRandomTimes}}</font>
  78. </view>
  79. <view class="two">
  80. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalNum')}}:</font>
  81. <font style="color: #ED341F;">{{yearRegularTimes}}</font>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="four">
  86. <view class="fourImg">
  87. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.allImg')" mode=""></image>
  88. </view>
  89. <view class="fourShell">
  90. <view class="one">
  91. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineTotalNum')}}:</font>
  92. <font style="color: #ED341F;">{{machineTotalNum}}</font>
  93. </view>
  94. <view class="two">
  95. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineUseNum')}}:</font>
  96. <font style="color: #ED341F;">{{machineUseNum}}</font>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 厕所实时使用情况 -->
  102. <view class="">
  103. <view class="titleFlag">
  104. <image class="img" src="../../static/img/red.png"></image>
  105. <font class="wenziT">红色正在使用</font>
  106. <image class="img" src="../../static/img/green.png"></image>
  107. <font class="wenziT">绿色空闲</font>
  108. <image class="img" src="../../static/img/yellow.png"></image>
  109. <font class="wenziT">黄色清洗中</font>
  110. </view>
  111. <view class="td-right">
  112. <view class="uni-list">
  113. <view class="uni-list-cell">
  114. <view class="uni-list-cell-left">
  115. 当前选择
  116. </view>
  117. <view class="uni-list-cell-db">
  118. <picker @change="changeEquipment" :value="index" :range="equipmentNameList">
  119. <view class="uni-input">{{equipmentNameList[index]}}</view>
  120. </picker>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="single-poster" v-for="(box,num) in boxs" :key="num">
  126. <view class="poster-wapper">
  127. <image v-show="box.status==0" src="../../static/img/green.png" mode="" class="image"></image>
  128. <image v-show="box.status==1" src="../../static/img/red.png" mode="" class="image"></image>
  129. <image v-show="box.status==2" src="../../static/img/yellow.png" mode="" class="image"></image>
  130. </view>
  131. <view class="box-name">
  132. {{box.sn}}
  133. </view>
  134. </view>
  135. </view>
  136. <!-- 机器详表 -->
  137. <view class="">
  138. <view v-if="merchantList.length>1">
  139. <uni-collapse :accordion="true">
  140. <view class="titleFlag">
  141. <image class="img" src="../../static/img/red.png"></image>
  142. <font class="wenziT">红色代表机器报警</font>
  143. <image class="img" src="../../static/img/green.png"></image>
  144. <font class="wenziT">绿色代表机器正常</font>
  145. </view>
  146. <view class="titlelist" v-for="(merchant,index) in merchantList" :key="merchant.id">
  147. <uni-collapse-item :title="getMerchantTitle(merchant)" :open="index===0">
  148. <view style="padding: 20upx;background-color: aliceblue;">
  149. <view v-if="merchant.equipmentList.length==0" style="text-align: center;">暂无数据</view>
  150. <view v-if="merchant.equipmentList.length>0">
  151. <uni-collapse :show-animation="true">
  152. <view style="position: relative;" v-for="equipment in merchant.equipmentList" :key="equipment.id">
  153. <span class="status-css" :class="equipment.hasTodayAlarm===true?statusError : statusNormal"></span>
  154. <uni-collapse-item :title="getEquipmentTitle(equipment)">
  155. <view style="padding: 20upx;background-color: #F8F8F8;">
  156. <view class="swithBox" v-if="equipment.isSleep">
  157. <view class="swichFont">睡眠状态:机器已睡眠</view>
  158. <view class="switch">
  159. <switch style="transform:scale(0.65)" checked @change="change(equipment.id,0)" />
  160. </view>
  161. </view>
  162. <view class="swithBox" v-else>
  163. <view class="swichFont">睡眠状态:未睡眠</view>
  164. <view class="switch">
  165. <switch style="transform:scale(0.65)" :checked="sleepChecked" @change="change(equipment.id,1)" />
  166. </view>
  167. </view>
  168. <view class="line1"></view>
  169. <!-- <view class="swithBox" v-if="equipment.eqeStatus==0">
  170. <view class="swichFont">关机:已关机</view>
  171. <view class="switch">
  172. <switch style="transform:scale(0.65)" checked @change="OnOff(equipment.id,1)" />
  173. </view>
  174. </view>
  175. <view class="swithBox" v-else>
  176. <view class="swichFont">关机:未关机</view>
  177. <view class="switch">
  178. <switch style="transform:scale(0.65)" :checked="onffChecked" @change="OnOff(equipment.id,0)" />
  179. </view>
  180. </view> -->
  181. <!-- 远程开机 -->
  182. <view class="opendoor"><span>远程开机:</span>
  183. <view class="">
  184. <button type="primary" @click="openEquipment(equipment.id)" class="button">
  185. <p class="p">开机</p>
  186. </button>
  187. </view>
  188. </view>
  189. <view class="line1"></view>
  190. <view><span>机器唯一码:</span><span>{{equipment.clientId}}</span></view>
  191. <!-- <view><span>所在地:</span><span>{{equipment.fullName?equipment.fullName:''}}</span></view> -->
  192. <view><span>清洁剂余量:</span><span>{{equipment.cleaner?equipment.cleaner:''}}</span></view>
  193. <view><span>消毒水余量:</span><span>{{equipment.disinfectant?equipment.disinfectant:''}}</span></view>
  194. <view><span>机器到期时间:</span><span>{{equipment.overdueDate?equipment.overdueDate:''}}</span></view>
  195. <view><span>机器剩余使用次数:</span><span>{{equipment.remaining?equipment.remaining:''}}</span></view>
  196. <!-- <view><span>机器温度:</span><span>{{equipment.furnaceTm?equipment.furnaceTm:''}}</span></view> -->
  197. <view><span>气味浓度:</span><span>{{equipment.odorConcentration?equipment.odorConcentration:''}}</span></view>
  198. <view><span>室内湿度:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span></view>
  199. <view><span>室内温度:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span></view>
  200. <view v-if="equipment.hasTodayAlarm">
  201. <view><span>报警内容:</span></view>
  202. <view v-for="(alarm,index) in equipment.alarmList" :key="index">
  203. <view><span class="baojing">{{alarm.occurrenceTime?alarm.occurrenceTime:''}} {{alarm.alarmContent}}</span></view>
  204. </view>
  205. </view>
  206. <view v-else>
  207. <view><span>报警内容:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}
  208. {{equipment.alarmContent}}</span></view>
  209. </view>
  210. </view>
  211. </uni-collapse-item>
  212. </view>
  213. </uni-collapse>
  214. </view>
  215. </view>
  216. </uni-collapse-item>
  217. </view>
  218. </uni-collapse>
  219. </view>
  220. <view v-else>
  221. <uni-collapse :show-animation="true">
  222. <view class="titleFlag">
  223. <image class="img" src="../../static/img/red.png"></image>
  224. <font class="wenziT">{{$t('equipmentStatusList.red')}}</font>
  225. <image class="img" src="../../static/img/green.png"></image>
  226. <font class="wenziT">{{$t('equipmentStatusList.green')}}</font>
  227. </view>
  228. <view class="titlelist" style="position: relative;" v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
  229. <span class="status-css" :class="equipment.hasTodayAlarm===true?statusError : statusNormal"></span>
  230. <uni-collapse-item :title="getEquipmentTitle(equipment)">
  231. <view class="" v-show="level<=2">
  232. <!-- 睡眠 -->
  233. <view style="padding: 20upx;background-color:#F8F8F8;">
  234. <view class="swithBox" v-if="equipment.isSleep">
  235. <view class="swichFont">{{$t('equipmentStatusList.sleep')}}</view>
  236. <view class="switch">
  237. <switch style="transform:scale(0.65)" checked @change="change(equipment.id,0)" />
  238. </view>
  239. </view>
  240. <view class="swithBox" v-else>
  241. <view class="swichFont">{{$t('equipmentStatusList.unsleep')}}</view>
  242. <view class="switch">
  243. <switch style="transform:scale(0.65)" :checked="sleepChecked" @change="change(equipment.id,1)" />
  244. </view>
  245. </view>
  246. <view class="line1"></view>
  247. <!-- 关机 -->
  248. <!-- <view class="" v-if="globalUser.open==0">
  249. <view class="swithBox" v-if="equipment.eqeStatus==0">
  250. <view class="swichFont">{{$t('equipmentStatusList.off')}}</view>
  251. <view class="switch">
  252. <switch style="transform:scale(0.65)" checked @change="OnOff(equipment.id,1)" />
  253. </view>
  254. </view>
  255. <view class="swithBox" v-else>
  256. <view class="swichFont">{{$t('equipmentStatusList.on')}}</view>
  257. <view class="switch">
  258. <switch style="transform:scale(0.65)" :checked="onffChecked" @change="OnOff(equipment.id,0)" />
  259. </view>
  260. </view>
  261. </view>
  262. <view class="line1"></view> -->
  263. <!-- 远程开机 -->
  264. <view class="opendoor"><span>远程开机:</span>
  265. <view class="">
  266. <button type="primary" @click="openEquipment(equipment.id)" class="button">
  267. <p class="p">开机</p>
  268. </button>
  269. </view>
  270. </view>
  271. <view class="line1"></view>
  272. <!-- 远程开门 -->
  273. <view class="opendoor"><span>{{$t('equipmentStatusList.door')}}:</span>
  274. <view class="">
  275. <button type="primary" @click="openDoor(equipment.id)" class="button">
  276. <p class="p">{{$t('equipmentStatusList.open')}}</p>
  277. </button>
  278. </view>
  279. </view>
  280. </view>
  281. <view><span>{{$t('equipmentStatusList.equipmentNo')}}:</span><span>{{equipment.clientId}}</span></view>
  282. <!-- <view><span>{{$t('equipmentStatusList.area')}}:</span><span>{{equipment.fullName?equipment.fullName:''}}</span></view>
  283. -->
  284. <view><span>清洁剂余量:</span><span>{{equipment.cleaner?equipment.cleaner:''}}</span></view>
  285. <view><span>消毒水余量:</span><span>{{equipment.disinfectant?equipment.disinfectant:''}}</span></view>
  286. <view><span>机器到期时间:</span><span>{{equipment.overdueDate?equipment.overdueDate:''}}</span></view>
  287. <view><span>机器剩余使用次数:</span><span>{{equipment.remaining?equipment.remaining:''}}</span></view>
  288. <!-- <view><span>{{$t('equipmentStatusList.temperature')}}:</span><span>{{equipment.furnaceTm?equipment.furnaceTm:''}}</span></view> -->
  289. <view><span>气味浓度:</span><span>{{equipment.odorConcentration?equipment.odorConcentration:''}}</span></view>
  290. <view><span>{{$t('equipmentStatusList.humidity')}}:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span></view>
  291. <view><span>{{$t('equipmentStatusList.equipmentTemperature')}}:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span></view>
  292. <view class="" v-if="equipment.hasTodayAlarm">
  293. <view><span>{{$t('equipmentStatusList.alarm')}}:</span></view>
  294. <view v-for="(alarm,index) in equipment.alarmList" :key="index">
  295. <view><span class="baojing">{{alarm.occurrenceTime?alarm.occurrenceTime:''}} {{alarm.alarmContent}}</span></view>
  296. </view>
  297. </view>
  298. <view class="" v-else>
  299. <view><span>{{$t('equipmentStatusList.alarm')}}:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}
  300. {{equipment.alarmContent}}</span></view>
  301. </view>
  302. </view>
  303. </uni-collapse-item>
  304. </view>
  305. </uni-collapse>
  306. </view>
  307. </view>
  308. </view>
  309. </template>
  310. <script>
  311. import {
  312. mapState,
  313. mapActions,
  314. mapMutations
  315. } from 'vuex';
  316. // import uCharts from '@/components/u-charts/u-charts.js';
  317. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  318. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  319. import uniList from '@/components/uni-list/uni-list.vue'
  320. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  321. import {
  322. dateUtils
  323. } from '@/common/util.js';
  324. var _self;
  325. export default {
  326. name: 'mainStatistics',
  327. props: {
  328. equipmentId: '',
  329. adminId: '',
  330. pname: '',
  331. },
  332. components: {
  333. uniCollapse,
  334. uniCollapseItem,
  335. uniList,
  336. uniListItem
  337. },
  338. data() {
  339. return {
  340. machineTotalNum: 0,
  341. machineUseNum: 0,
  342. dayRandomTimes: 0,
  343. dayRegularTimes: 0,
  344. weekRandomTimes: 0,
  345. weekRegularTimes: 0,
  346. monthRandomTimes: 0,
  347. monthRegularTimes: 0,
  348. yearRandomTimes: 0,
  349. yearRegularTimes: 0,
  350. today: '',
  351. week: '',
  352. globalUser: {},
  353. merchantList: [{
  354. equipmentList: []
  355. }],
  356. level:3,
  357. index: 0,
  358. equipmentName: null,
  359. equipmentNameList: [],
  360. boxs: [],
  361. num:null,
  362. extraIcon: {
  363. color: '#4cd964',
  364. size: '22',
  365. type: 'spinner'
  366. },
  367. statusNormal: 'status-normal',
  368. statusError: 'status-error',
  369. sleepChecked: null,
  370. onffChecked: null,
  371. time: null,
  372. timeAll: {
  373. },
  374. // input: 0
  375. }
  376. },
  377. computed: {
  378. ...mapState(['loginUser']),
  379. pnameData: {
  380. get() {
  381. return this.pname;
  382. }
  383. },
  384. },
  385. onShow() {
  386. uni.setNavigationBarTitle({
  387. title: this.$t('mainStatistics.title')
  388. });
  389. uni.setTabBarItem({
  390. index: 0,
  391. text: this.$t('tabs.tab1')
  392. });
  393. var token = uni.getStorageSync("token");
  394. this.level = uni.getStorageSync("level");
  395. if (token.toString().length > 1) {
  396. this.init();
  397. } else {
  398. uni.reLaunch({
  399. url: '../Login/Login',
  400. });
  401. }
  402. // this.input = this.input + 1;
  403. var test = uni.getStorageSync('test');
  404. var globalUser = uni.getStorageSync("globalUser");
  405. this.globalUser = globalUser;
  406. if (globalUser.toString().length > 1) {
  407. //判断是不是初次登陆
  408. if (test == 2) {
  409. this.init();
  410. }
  411. }
  412. var id = this.adminId;
  413. this.day();
  414. // this.equipmentStatus();
  415. },
  416. mounted() {
  417. var token = uni.getStorageSync("token");
  418. if (token.toString().length > 1) {
  419. this.init();
  420. } else {
  421. uni.reLaunch({
  422. url: '../Login/Login',
  423. });
  424. }
  425. // this.day();
  426. this.equipmentStatus();
  427. },
  428. methods: {
  429. ...mapActions('chart', ['getStatistics', 'getMainStatistics', 'getMachineNum', 'getEquipmentListByUser']),
  430. async init() {
  431. if (!this.pname) {
  432. this.pname = this.loginUser.name;
  433. }
  434. _self = this;
  435. await this.getMainStatisticsData();
  436. await this.getEquipmentListData();
  437. //初次登陆跳转后,把test变成2
  438. uni.setStorageSync('test', '2');
  439. },
  440. day() {
  441. var date = new Date();
  442. // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
  443. var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
  444. this.today = daystr;
  445. // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
  446. this.week = this.$t('mainStatistics.week' + date.getDay());
  447. },
  448. //改变机器
  449. changeEquipment: function(e) {
  450. this.index = e.target.value;
  451. var list = uni.getStorageSync("listName");
  452. this.getBoxs(list[e.target.value].id);
  453. },
  454. equipmentStatus() {
  455. var id = uni.getStorageSync("globalUser").id;
  456. var token = uni.getStorageSync("token");
  457. uni.request({
  458. url: this.serverurl + '/TEquipment/equipmentStatus',
  459. data: {
  460. "adminId": id
  461. },
  462. header: {
  463. 'token': token
  464. },
  465. method: "POST",
  466. success: (res) => {
  467. },
  468. });
  469. },
  470. getBoxs(equipmentId) {
  471. var token = uni.getStorageSync("token");
  472. uni.request({
  473. url: this.serverurl + '/TEquipment/getBoxs',
  474. data: {
  475. "equipmentId": equipmentId
  476. },
  477. header: {
  478. 'token': token
  479. },
  480. method: "POST",
  481. success: (res) => {
  482. this.boxs = res.data.data;
  483. },
  484. });
  485. },
  486. getMainStatisticsData() {
  487. const param = {};
  488. if (this.adminId) { // 子组件,则拿传过来的参
  489. param['adminId'] = this.adminId;
  490. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  491. param['adminId'] = this.loginUser['id'];
  492. }
  493. var globalUser = uni.getStorageSync("globalUser");
  494. if (globalUser.id != 1) {
  495. if (param.adminId == null || param.adminId == undefined) {
  496. param['adminId'] = globalUser.id;
  497. }
  498. }
  499. if (this.equipmentId) {
  500. param['equipmentId'] = this.equipmentId;
  501. }
  502. // console.log('getMainStatisticsData:{}', param);
  503. var adminId = param.adminId;
  504. var equipmentId = this.equipmentId;
  505. var serverurl = this.serverurl;
  506. var token = uni.getStorageSync("token");
  507. uni.request({
  508. url: serverurl + '/TEquipment/getMachineNum',
  509. data: {
  510. "adminId": adminId,
  511. "equipmentId": equipmentId
  512. },
  513. method: "POST",
  514. header: {
  515. 'token': token
  516. },
  517. success: (res) => {
  518. var list = res.data.data;
  519. this.machineTotalNum = list[0];
  520. this.machineUseNum = list[1];
  521. }
  522. });
  523. return this.getMainStatistics(param)
  524. .then(data => {
  525. for (let bean of data) {
  526. if (bean['categorie'] === 'day') {
  527. if (bean['randomTimes'] != null) {
  528. this.dayRandomTimes = bean['randomTimes'];
  529. }
  530. if (bean['regularTimes'] != null) {
  531. this.dayRegularTimes = bean['regularTimes'];
  532. }
  533. }
  534. if (bean['categorie'] === 'week') {
  535. if (bean['randomTimes'] != null) {
  536. this.weekRandomTimes = bean['randomTimes'];
  537. }
  538. if (bean['regularTimes'] != null) {
  539. this.weekRegularTimes = bean['regularTimes'];
  540. }
  541. }
  542. if (bean['categorie'] === 'month') {
  543. if (bean['randomTimes'] != null) {
  544. this.monthRandomTimes = bean['randomTimes'];
  545. }
  546. if (bean['regularTimes'] != null) {
  547. this.monthRegularTimes = bean['regularTimes'];
  548. }
  549. }
  550. if (bean['categorie'] === 'year') {
  551. if (bean['randomTimes'] != null) {
  552. this.yearRandomTimes = bean['randomTimes'];
  553. }
  554. if (bean['regularTimes'] != null) {
  555. this.yearRegularTimes = bean['regularTimes'];
  556. }
  557. }
  558. }
  559. uni.stopPullDownRefresh();
  560. }, _ => void uni.stopPullDownRefresh());
  561. },
  562. // 属性方法
  563. getMerchantTitle(merchant) {
  564. return merchant.name ? merchant.name : merchant.username;
  565. },
  566. getEquipmentTitle(equipment) {
  567. return equipment.name ? equipment.name : '暂无名称';
  568. },
  569. getEquipmentListData() {
  570. this.getEquipmentListByUser(this.globalUser)
  571. .then(data => {
  572. this.merchantList = data;
  573. var listName = data[0].equipmentList;
  574. var equipmentNameList = [];
  575. for (var i = 0; i < listName.length; i++) {
  576. equipmentNameList.push(listName[i].name);
  577. if (i == 0) {
  578. this.getBoxs(listName[i].id);
  579. }
  580. }
  581. this.equipmentNameList = equipmentNameList;
  582. var times = new Map;
  583. var listId = data[0].id;
  584. if (listId != null && listId != '1') {
  585. uni.setStorageSync("listName", listName);
  586. }
  587. uni.stopPullDownRefresh();
  588. }, _ => void uni.stopPullDownRefresh());
  589. },
  590. OnOff(id, code) {
  591. var that = this;
  592. var ddd = this.timeAll.get(id);
  593. if (that.timeAll.get(id) != null) {
  594. var stamp = Date.parse(new Date());
  595. var t = (stamp - that.timeAll.get(id)) / 1000;
  596. if (t < 30) {
  597. var s = 30 - t;
  598. uni.showModal({
  599. title: that.$t('equipmentStatusList.onoff'),
  600. content: that.$t('equipmentStatusList.remainingtime') + s + "s",
  601. success: function(res) {
  602. that.getEquipmentListData();
  603. }
  604. });
  605. return;
  606. }
  607. }
  608. var code1 = code;
  609. if (code1 == 0) {
  610. uni.showModal({
  611. title: that.$t('equipmentStatusList.tip'),
  612. content: that.$t('equipmentStatusList.onoffTip'),
  613. success: function(res) {
  614. if (res.confirm) {
  615. var serverurl = that.serverurl;
  616. var code2 = code1;
  617. var equipmentId = id;
  618. var token = uni.getStorageSync("token");
  619. uni.request({
  620. url: serverurl + '/TEquipment/onOff',
  621. data: {
  622. "adminId": code2,
  623. "equipmentId": equipmentId
  624. },
  625. method: "POST",
  626. header: {
  627. 'token': token
  628. },
  629. success: (res) => {
  630. var list = res.data.data;
  631. // that.input = 2;
  632. var timestamp = Date.parse(new Date());
  633. that.timeAll.set(id, timestamp);
  634. var oo = that.timeAll;
  635. // that.time = timestamp;
  636. that.getEquipmentListData();
  637. if (list == 'SUCCESS') {
  638. uni.showModal({
  639. title: that.$t('equipmentStatusList.guanji'),
  640. content: that.$t('equipmentStatusList.tishi'),
  641. success: function(res) {
  642. that.getEquipmentListData();
  643. setTimeout(function() {
  644. that.network(id);
  645. }, 7000);
  646. }
  647. })
  648. } else {
  649. uni.showModal({
  650. title: that.$t('equipmentStatusList.error'),
  651. content: that.$t('equipmentStatusList.guanjierror'),
  652. success: function(res) {
  653. that.onffChecked = true;
  654. that.getEquipmentListData();
  655. }
  656. })
  657. }
  658. }
  659. });
  660. } else if (res.cancel) {
  661. that.onffChecked = false;
  662. that.getEquipmentListData();
  663. }
  664. }
  665. });
  666. } else {
  667. var serverurl = that.serverurl;
  668. var code = code;
  669. var equipmentId = id;
  670. var token = uni.getStorageSync("token");
  671. uni.request({
  672. url: serverurl + '/TEquipment/onOff',
  673. data: {
  674. "adminId": code,
  675. "equipmentId": equipmentId
  676. },
  677. method: "POST",
  678. header: {
  679. 'token': token
  680. },
  681. success: (res) => {
  682. // that.input = 2;
  683. var list = res.data.data;
  684. that.getEquipmentListData();
  685. var timestamp = Date.parse(new Date());
  686. that.timeAll.set(id, timestamp);
  687. var oo = that.timeAll;
  688. // that.time = timestamp;
  689. if (list == "SUCCESS") {
  690. uni.showModal({
  691. title: that.$t('equipmentStatusList.kaiji'),
  692. content: that.$t('equipmentStatusList.tishi'),
  693. success: function(res) {
  694. that.getEquipmentListData();
  695. setTimeout(function() {
  696. that.network(id);
  697. }, 7000);
  698. }
  699. })
  700. } else {
  701. uni.showModal({
  702. title: that.$t('equipmentStatusList.error'),
  703. content: that.$t('equipmentStatusList.kaijierror'),
  704. success: function(res) {
  705. that.onffChecked = false;
  706. that.getEquipmentListData();
  707. }
  708. })
  709. }
  710. }
  711. });
  712. }
  713. },
  714. network(id) {
  715. var token = uni.getStorageSync("token");
  716. var equipmentId = id;
  717. uni.request({
  718. url: this.serverurl + '/TEquipment/checkStatus',
  719. data: {
  720. "equipmentId": id
  721. },
  722. method: "POST",
  723. header: {
  724. 'token': token
  725. },
  726. success: (res) => {
  727. var data = res.data.data;
  728. if (data == 'fail') {
  729. uni.showToast({
  730. title: this.$t('equipmentStatusList.network'),
  731. icon: 'none',
  732. duration: 3000
  733. });
  734. this.getEquipmentListData();
  735. }
  736. }
  737. });
  738. },
  739. openDoor(id) {
  740. var token = uni.getStorageSync("token");
  741. uni.request({
  742. url: this.serverurl + '/TEquipment/clean',
  743. data: {
  744. "equipmentId": id
  745. },
  746. method: "POST",
  747. header: {
  748. 'token': token
  749. },
  750. success: (res) => {
  751. uni.showModal({
  752. title: this.$t('equipmentStatusList.open'),
  753. content: this.$t('equipmentStatusList.opensuccess'),
  754. success: function(res) {
  755. }
  756. })
  757. }
  758. });
  759. },
  760. openEquipment(id) {
  761. var token = uni.getStorageSync("token");
  762. uni.request({
  763. url: this.serverurl + '/TEquipment/openEquipment',
  764. data: {
  765. "equipmentId": id
  766. },
  767. method: "POST",
  768. header: {
  769. 'token': token
  770. },
  771. success: (res) => {
  772. uni.showModal({
  773. title: "提示",
  774. content: "发送成功",
  775. success: function(res) {
  776. }
  777. })
  778. }
  779. });
  780. },
  781. change(id, code) {
  782. var that = this;
  783. var code1 = code;
  784. if (code1 == 1) {
  785. uni.showModal({
  786. title: that.$t('equipmentStatusList.tip'),
  787. content: that.$t('equipmentStatusList.sleepTip'),
  788. success: function(res) {
  789. if (res.confirm) {
  790. var serverurl = that.serverurl;
  791. var code2 = code1;
  792. var equipmentId = id;
  793. var token = uni.getStorageSync("token");
  794. uni.request({
  795. url: serverurl + '/TEquipment/sleep',
  796. data: {
  797. "adminId": code2,
  798. "equipmentId": equipmentId
  799. },
  800. method: "POST",
  801. header: {
  802. 'token': token
  803. },
  804. success: (res) => {
  805. var list = res.data.data;
  806. that.getEquipmentListData();
  807. }
  808. });
  809. } else if (res.cancel) {
  810. that.sleepChecked = false;
  811. that.getEquipmentListData();
  812. }
  813. }
  814. });
  815. } else {
  816. var serverurl = that.serverurl;
  817. var code = code;
  818. var equipmentId = id;
  819. var token = uni.getStorageSync("token");
  820. uni.request({
  821. url: serverurl + '/TEquipment/sleep',
  822. data: {
  823. "adminId": code,
  824. "equipmentId": equipmentId
  825. },
  826. method: "POST",
  827. header: {
  828. 'token': token
  829. },
  830. success: (res) => {
  831. var list = res.data.data;
  832. that.getEquipmentListData();
  833. }
  834. });
  835. }
  836. },
  837. }
  838. }
  839. </script>
  840. <style>
  841. page {
  842. /* background: #F2F2F2; */
  843. background: #FFFFFF;
  844. width: 750upx;
  845. overflow-x: hidden;
  846. }
  847. .head {
  848. display: flex;
  849. flex-direction: row;
  850. background: #206DC3;
  851. width: 750upx;
  852. height: 180upx;
  853. }
  854. .company {
  855. width: 48%;
  856. text-align: right;
  857. }
  858. .pname {
  859. display: flex;
  860. flex-direction: row;
  861. width: 40%;
  862. }
  863. .userFlagimg {
  864. padding-left: 30upx;
  865. padding-top: 10upx;
  866. width: 26upx;
  867. height: 28upx;
  868. }
  869. .wenzi {
  870. padding-left: 5upx;
  871. /* text-align:right; */
  872. white-space: nowrap;
  873. overflow: hidden;
  874. /* text-overflow: ellipsis; */
  875. }
  876. .ri {
  877. width: 690upx;
  878. height: 180upx;
  879. background: #FFFFFF;
  880. border-radius: 15upx;
  881. /* 上移 */
  882. transform: translateY(-90upx);
  883. text-align: center;
  884. margin: auto;
  885. display: flex;
  886. flex-direction: row;
  887. /* 阴影 */
  888. box-shadow: 0upx -1upx 20upx #D3D3D3;
  889. /* box-shadow:0px 0px 10px 5px #aaa; */
  890. }
  891. .riShell {
  892. display: flex;
  893. flex-direction: row;
  894. margin: auto;
  895. }
  896. .riTitle {
  897. display: flex;
  898. flex-direction: column;
  899. margin: auto;
  900. }
  901. .riqi {
  902. display: flex;
  903. flex-direction: column;
  904. margin: auto;
  905. }
  906. .fourTitle {
  907. width: 690upx;
  908. height: 294upx;
  909. display: flex;
  910. flex-direction: row;
  911. flex-wrap: wrap;
  912. background: #FFFFFF;
  913. box-shadow: 0upx 0upx 20upx #D3D3D3;
  914. margin: auto;
  915. border-radius: 15upx;
  916. transform: translateY(-60upx);
  917. }
  918. .four {
  919. display: flex;
  920. flex-direction: row;
  921. margin: auto;
  922. width: 48%;
  923. }
  924. .fourImg {
  925. width: 54upx;
  926. height: 54upx;
  927. }
  928. .qiun-padding {
  929. padding: 2%;
  930. width: 96%;
  931. }
  932. .qiun-wrap {
  933. display: flex;
  934. flex-wrap: wrap;
  935. }
  936. .qiun-rows {
  937. display: flex;
  938. flex-direction: row !important;
  939. }
  940. .fontLeft {
  941. margin-right: 6upx;
  942. }
  943. /* 参数表 */
  944. .status-css {
  945. position: absolute;
  946. width: 30upx;
  947. height: 30upx;
  948. right: 86upx;
  949. top: 30upx;
  950. border-radius: 30upx;
  951. color: "#596D83";
  952. font-size: 12upx;
  953. }
  954. .status-error {
  955. background-color: #dd524d
  956. }
  957. .status-normal {
  958. background-color: #4cd964
  959. }
  960. .baojing {
  961. padding-left: 120upx;
  962. }
  963. .titleFlag {
  964. height: 56upx;
  965. background-color: #F8F8F8;
  966. color: #8C959F;
  967. font-size: 22upx;
  968. display: flex;
  969. flex-direction: row;
  970. }
  971. .opendoor {
  972. /* #ifdef H5 */
  973. /* #endif */
  974. padding-top: 10upx;
  975. padding-bottom: 10upx;
  976. /* text-align: center; */
  977. display: flex;
  978. flex-direction: row;
  979. }
  980. .button {
  981. /* #ifdef H5 */
  982. text-align: center;
  983. height: 50upx;
  984. weight: 20upx;
  985. /* #endif */
  986. padding-left: 15upx;
  987. /* padding-top: 2upx; */
  988. }
  989. .p {
  990. /* #ifdef H5 */
  991. font-size: 28upx;
  992. height: 50upx;
  993. weight: 20upx;
  994. transform: translateY(-14upx);
  995. /* text-align: center; */
  996. /* #endif */
  997. /* padding-bottom: 50upx; */
  998. text-align: center;
  999. padding-left: 13upx;
  1000. }
  1001. .img {
  1002. padding-top: 20upx;
  1003. padding-left: 30upx;
  1004. width: 15upx;
  1005. height: 15upx;
  1006. }
  1007. .wenziT {
  1008. padding-top: 10upx;
  1009. padding-left: 10upx;
  1010. }
  1011. .titlelist {
  1012. color: #363D44;
  1013. font-size: 16upx;
  1014. font-family: "PingFang-SC-Medium";
  1015. }
  1016. .swithBox {
  1017. display: flex;
  1018. flex-direction: row;
  1019. padding-bottom: 15upx;
  1020. padding-top: 5upx;
  1021. }
  1022. .switch {
  1023. width: 44upx;
  1024. height: 22upx;
  1025. }
  1026. .swichFont {
  1027. width: 85%;
  1028. padding-top: 12upx;
  1029. }
  1030. .line1 {
  1031. width: 100%;
  1032. height: 3upx;
  1033. background: #000000;
  1034. }
  1035. .single-poster {
  1036. display: inline-block;
  1037. margin-left: 20upx;
  1038. padding-top: 10upx;
  1039. text-align: center;
  1040. /* height: 30upx; */
  1041. }
  1042. .poster-wapper {
  1043. text-align: center;
  1044. display: flex;
  1045. flex-direction: column;
  1046. }
  1047. .image{
  1048. height: 30upx;
  1049. width: 30upx;
  1050. }
  1051. .box-name{
  1052. /* width: 200upx; */
  1053. /* margin-top: 10upx; */
  1054. font-size: 22upx;
  1055. font-weight: bold;
  1056. white-space: nowrap;
  1057. overflow: hidden;
  1058. text-overflow: ellipsis;
  1059. }
  1060. </style>