mainStatistics.vue 30 KB

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