index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view class="adminIndex">
  3. <navigation-bar-view ref="nav"></navigation-bar-view>
  4. <view class="group">
  5. <view class="label" @click="toSetting">
  6. <view class="line"></view>
  7. <text>当前设备</text>
  8. <view class="more">
  9. <text>设置</text>
  10. <image class="arrow" src="../../static/images/icon-arrow-right-grey.png"></image>
  11. </view>
  12. <!-- <view class="more" style="color: #007AFF;" @click="uploadVersion" v-if="!version">
  13. <text>有新版本</text>
  14. </view> -->
  15. </view>
  16. <view class="value">
  17. <text>{{body.stationName}}(</text>
  18. <text v-if="body.status == 1">在线</text>
  19. <text v-if="body.status == 2">下线</text>
  20. <text>)</text>
  21. </view>
  22. </view>
  23. <view class="group">
  24. <view class="label" @click="toOrderList">
  25. <view class="line"></view>
  26. <text>订单统计</text>
  27. <view class="more">
  28. <text>查看</text>
  29. <image class="arrow" src="../../static/images/icon-arrow-right-grey.png"></image>
  30. </view>
  31. </view>
  32. <view class="value order">
  33. <view class="item">
  34. <view class="title">今日订单数</view>
  35. <view class="amount">{{data.todayNum}}</view>
  36. </view>
  37. <view class="item">
  38. <view class="title">今日订单金额</view>
  39. <view class="amount">¥{{data.todayAmount}}</view>
  40. </view>
  41. <view class="item">
  42. <view class="title">今日使用人数</view>
  43. <view class="amount">{{data.personNum}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="group">
  48. <view class="label" @click="toPortList">
  49. <view class="line"></view>
  50. <text>设备统计</text>
  51. <view class="more">
  52. <text>查看</text>
  53. <image class="arrow" src="../../static/images/icon-arrow-right-grey.png"></image>
  54. </view>
  55. </view>
  56. <view class="value order">
  57. <view class="item">
  58. <view class="title">使用中</view>
  59. <view class="amount">{{data.useCount}}</view>
  60. </view>
  61. <view class="item">
  62. <view class="title">空闲中</view>
  63. <view class="amount">{{data.freeCount}}</view>
  64. </view>
  65. <view class="item">
  66. <view class="title">冻结中</view>
  67. <view class="amount">{{data.frozenCount}}</view>
  68. </view>
  69. <view class="item">
  70. <view class="title">禁用中</view>
  71. <view class="amount">{{data.disableCount}}</view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="btns">
  76. <view class="btn full" @click="knockOut">一键清箱</view>
  77. </view>
  78. <view class="btns">
  79. <view class="btn" @click="openDoor">一键开门</view>
  80. <view style="width: 4vw;"></view>
  81. <view class="btn" @click="closeDoor">一键关门</view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import navigationBarView from '../../components/navigationBarView.vue';
  87. export default {
  88. components: {
  89. navigationBarView
  90. },
  91. data() {
  92. return {
  93. body: {},
  94. data: {},
  95. version: '',
  96. }
  97. },
  98. onLoad() {
  99. this.getData();
  100. },
  101. onShow() {
  102. this.getVersion();
  103. },
  104. methods: {
  105. getVersion() {
  106. let sn = uni.getStorageSync('sn');
  107. this.$api.getCurrentVersion({
  108. deviceSn: sn
  109. }).then(res => {
  110. if (this.$config.version != res.version) {
  111. this.version = res.url;
  112. } else {
  113. this.version = ''
  114. }
  115. })
  116. },
  117. uploadVersion() {
  118. uni.showLoading({
  119. title: '更新中……'
  120. })
  121. console.log('ssaaa', this.version);
  122. const downloadTask = uni.downloadFile({ //执行下载
  123. url: this.version, //下载地址
  124. success: downloadResult => { //下载成功
  125. uni.hideLoading();
  126. if (downloadResult.statusCode == 200) {
  127. uni.showModal({
  128. title: '',
  129. content: '更新成功,确定现在重启吗?',
  130. confirmText: '重启',
  131. confirmColor: '#EE8F57',
  132. success: function(res) {
  133. if (res.confirm == true) {
  134. plus.runtime.install( //安装
  135. downloadResult.tempFilePath, {
  136. force: true
  137. },
  138. function(res) {
  139. utils.showToast('更新成功,重启中');
  140. plus.runtime.restart();
  141. }
  142. );
  143. }
  144. }
  145. });
  146. }
  147. },
  148. fail: err => {
  149. console.log('下载错误', err);
  150. }
  151. });
  152. downloadTask.onProgressUpdate((res) => {
  153. console.log('下载进度' + res.progress);
  154. console.log('已经下载的数据长度' + res.totalBytesWritten);
  155. console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
  156. // 测试条件,取消下载任务。
  157. // if (res.progress == 100) {
  158. // downloadTask.abort();
  159. // }
  160. });
  161. },
  162. getData() {
  163. let sn = uni.getStorageSync('sn');
  164. this.$api.managerStatistics({
  165. deviceSn: sn
  166. }).then(res => {
  167. this.body = res.device;
  168. res.todayAmount = res.todayAmount.toFixed(2)
  169. this.data = res;
  170. })
  171. },
  172. // 一键清箱
  173. knockOut() {
  174. const _ = this;
  175. uni.showModal({
  176. title: '提示',
  177. content: '请确认是否一键清箱?',
  178. success: r => {
  179. if (r.confirm) {
  180. let sn = uni.getStorageSync('sn');
  181. _.$api.managerTranslateSys({
  182. deviceSn: sn,
  183. port: 0
  184. }).then(res => {
  185. uni.showToast({
  186. title: '一键清箱成功'
  187. })
  188. _.getData()
  189. })
  190. }
  191. }
  192. })
  193. },
  194. // 一键开箱
  195. openDoor() {
  196. const _ = this;
  197. uni.showModal({
  198. title: '提示',
  199. content: '请确认是否一键开箱?',
  200. success: r => {
  201. if (r.confirm) {
  202. let sn = uni.getStorageSync('sn');
  203. _.$api.managerOperationSys({
  204. deviceSn: sn,
  205. witch: 1,
  206. port: 0
  207. }).then(res => {
  208. uni.showToast({
  209. title: '一键开箱成功'
  210. })
  211. _.getData()
  212. })
  213. }
  214. }
  215. })
  216. },
  217. // 一键开箱
  218. closeDoor() {
  219. const _ = this;
  220. uni.showModal({
  221. title: '提示',
  222. content: '请确认是否一键关箱?',
  223. success: r => {
  224. if (r.confirm) {
  225. let sn = uni.getStorageSync('sn');
  226. _.$api.managerOperationSys({
  227. deviceSn: sn,
  228. witch: 0,
  229. port: 0
  230. }).then(res => {
  231. uni.showToast({
  232. title: '一键关箱成功'
  233. })
  234. _.getData()
  235. })
  236. }
  237. }
  238. })
  239. },
  240. toOrderList() {
  241. uni.navigateTo({
  242. url: '/pages/order/list'
  243. })
  244. },
  245. toPortList() {
  246. uni.navigateTo({
  247. url: '/pages/admin/port'
  248. })
  249. },
  250. toSetting() {
  251. uni.navigateTo({
  252. url: '/pages/admin/setting'
  253. })
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .adminIndex {
  260. min-height: 100vh;
  261. background-color: #f8f8f8;
  262. .group {
  263. border-radius: 2.7vw;
  264. margin: 2.7vw 4vw 0;
  265. background: #FFFFFF;
  266. padding: 0 4.1vw 4.9vw;
  267. .label {
  268. display: flex;
  269. align-items: center;
  270. height: 13.2vw;
  271. font-size: 4vw;
  272. font-weight: bold;
  273. border-bottom: 2rpx solid #F8F8F8;
  274. .line {
  275. width: 1.1vw;
  276. height: 4vw;
  277. border-radius: 1.1vw;
  278. background-color: #FDD302;
  279. margin-right: 2.1vw;
  280. }
  281. text {
  282. flex: 1;
  283. }
  284. .more {
  285. display: flex;
  286. align-items: center;
  287. font-weight: 300;
  288. font-size: 3.7vw;
  289. color: #333333;
  290. .arrow {
  291. width: 2vw;
  292. height: 3.6vw;
  293. margin-left: 2vw;
  294. }
  295. }
  296. }
  297. .value {
  298. color: #222222;
  299. font-size: 4.5vw;
  300. margin-top: 4.9vw;
  301. font-weight: 600;
  302. &.order {
  303. display: flex;
  304. align-items: center;
  305. .item {
  306. flex: 1;
  307. text-align: center;
  308. .title {
  309. margin-bottom: 3.2vw;
  310. font-weight: 300;
  311. color: #999999;
  312. font-size: 3.2vw;
  313. line-height: 3.2vw;
  314. }
  315. .amount {
  316. font-family: DIN Alternate;
  317. font-weight: bold;
  318. color: #444444;
  319. font-size: 4.8vw;
  320. line-height: 4.8vw;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .btns {
  327. display: flex;
  328. margin: 5.3vw 4vw 0;
  329. .btn {
  330. flex: 1;
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. font-weight: 500;
  335. font-size: 4vw;
  336. height: 11.5vw;
  337. border-radius: 11.5vw;
  338. background: linear-gradient(to right, #FEE704, #FDD001);
  339. &.full {
  340. background: linear-gradient(to right, #44F62C, #00CB75);
  341. // color: #FFFFFF;
  342. }
  343. }
  344. }
  345. }
  346. </style>