index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <view class="work-pages">
  3. <!-- 工作控制按钮及进度 -->
  4. <view class="work-cons flex-center" style="flex-direction: column;">
  5. <!-- 操作按钮组件 -->
  6. <view class="work-button-wrap">
  7. <!-- 按钮 -->
  8. <view class="work-button flex-center">
  9. <!-- 扇形进度条 -->
  10. <view class="circle_process">
  11. <view class="wrapper right"><view class="circle rightcircle" :style="{ transform: `rotate(${rdeg}deg)` }"></view></view>
  12. <view class="wrapper left"><view class="circle leftcircle" :style="{ transform: `rotate(${ldeg}deg)` }"></view></view>
  13. </view>
  14. <view class="cirle-one"></view>
  15. <!-- 指针 -->
  16. <view class="cirle-two flex-center" v-for="item in 60" :key="item">
  17. <view class="sector" :style="{ transform: `rotate(${item * 6}deg)` }"></view>
  18. </view>
  19. <view class="cirle-three flex-center"></view>
  20. <view class="cirle-free" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  21. <view class="cirle-free-1" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  22. <view class="cirle-free-2" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  23. <view class="cirle-sex flex-center" @tap="startWork">
  24. {{ status == 'working' ? '紧急停止' : '点击启动' }}
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 状态提示 -->
  29. <view class="work-button-tips">
  30. <u-notice-bar type="error" border-radius="50" color="#fff" bg-color="#666" mode="vertical" :list="[curWorkStutesText,curWorkStutesText]"></u-notice-bar>
  31. </view>
  32. </view>
  33. <!-- 说明提示 -->
  34. <view class="work-tips">
  35. <view>
  36. <view class="work-dtime" v-show="status=='start'">
  37. 距离订单强制完成还剩
  38. <u-count-down
  39. v-if="timestamp>0"
  40. @end="endDtime"
  41. separator="zh"
  42. font-size="36"
  43. separator-size="28"
  44. color="#ff0000"
  45. :timestamp="timestamp"
  46. :show-days="false"
  47. :show-hours="false"
  48. ></u-count-down>
  49. </view>
  50. <view class="work-remarks">
  51. <view class="title">说明:</view>
  52. <view v-if="status=='start'">
  53. 支付完成后
  54. <text class="red">请尽快启动洗车服务</text>
  55. ,否则订单将在5分钟后自动完成。
  56. </view>
  57. <view v-else>
  58. <view>设备启动中请注意安全,如果设备工作中出现故障,请按紧急停止按钮或联系客服。</view>
  59. <view @click="callPhone">如有疑问,请联系客服:<text>18237162131</text> </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 正在启动,归位弹框提示 -->
  65. <u-popup v-model="showStart" :mask-close-able="false" border-radius="10" mode="center" width="500rpx" height="400rpx">
  66. <view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
  67. <!-- 启动中 -->
  68. <view v-if="status == 'starting'">
  69. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  70. <view style="padding: 15rpx;">洗车机正在启动...</view>
  71. </view>
  72. <!-- 停止中 -->
  73. <view v-if="status == 'stoping'">
  74. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  75. <view style="padding: 15rpx;">洗车机正在停止中...</view>
  76. </view>
  77. <!-- 归位中 -->
  78. <view v-if="status == 'reseting'">
  79. <u-image width="216px" height="120px" src="/static/img/reset.png"></u-image>
  80. <view style="padding: 15rpx;">洗车机正在归位中...</view>
  81. </view>
  82. </view>
  83. </u-popup>
  84. <!-- 错误提示 -->
  85. <u-popup v-model="showError" :mask-close-able="false" border-radius="10" mode="center" width="500rpx">
  86. <view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
  87. <view>
  88. <u-image width="64px" height="64px" src="/static/img/end.png"></u-image>
  89. <view style="padding: 10px 0 20px;">洗车已完成</view>
  90. <view>
  91. <u-button long type="success">确定</u-button>
  92. </view>
  93. </view>
  94. </view>
  95. </u-popup>
  96. <!-- 急停提示弹框 -->
  97. <u-popup v-model="showStop" :mask-close-able="false" border-radius="10" mode="center" width="80%">
  98. <view style="padding: 30rpx;text-align: center;">
  99. <view>
  100. <view style="font-weight: bold;">设备提示</view>
  101. <view style="display: flex;justify-content: center;padding: 10rpx 0;">
  102. <u-image width="165px" height="138px" src="/static/img/sbts.png"></u-image>
  103. </view>
  104. <u-divider>可能原因</u-divider>
  105. <view style="padding: 15rpx;text-align: left;">
  106. <view>1、洗车机紧急停止,本次服务结束</view>
  107. <view>2、因设备故障无法继续为您服务,所支付金额将退至您的支付账户</view>
  108. <view>3、如需再次服务,请退出车辆重新进入,再扫码支付洗车</view>
  109. <view>4、如需帮助请联系客服</view>
  110. </view>
  111. <view style="display: flex;padding: 20rpx 0;justify-content: center;">
  112. <u-button @click="callPhone" style="width: 45%;border-radius: 0;margin-right: 5%;">联系客服</u-button>
  113. <u-button @click="sendCmdRabt('reset')" style="width: 45%;" type="error">洗车机归位</u-button>
  114. </view>
  115. </view>
  116. </view>
  117. </u-popup>
  118. </view>
  119. </template>
  120. <script>
  121. export default {
  122. data() {
  123. return {
  124. timestamp: 0, // 初始情况下5分钟后自动结束
  125. rdeg: -135, // 进度条初始角度
  126. ldeg: -135, /// 进度条初始角度
  127. step: 0, // 进度条增值,共60步
  128. status: 'linking', // 状态,linking 连接中,start 开始启动, starting 启动中,working 正在工作,stoping 停止中, reset 归位,reseting 归位中, end 洗车完成,error-end 异常结束
  129. curWorkStutesText: '设备准备就绪', // 当前机器运行的进度提示
  130. showError: false, // 错误提示
  131. showStart: false ,// 启动弹框提示
  132. showStop: false, // 急停提示
  133. washCarType: '', // 洗车服务类型,不同的类型对应的时间不一样
  134. washDuration: 7.5, // 机器运行步骤,共8步,等分60
  135. orderNo: '',// 订单编号
  136. };
  137. },
  138. onShow() {
  139. console.log("onShow")
  140. // 更新进度条
  141. if(this.$store.state.vuex_workStatus == 'working'){
  142. this.step = this.$store.state.vuex_workStep
  143. this.loading()
  144. }
  145. },
  146. onLoad(options) {
  147. console.log("onLoad")
  148. // 创建websocket
  149. this.$store.commit('$webSocket')
  150. // uni.showLoading({
  151. // title: '正在连接...',
  152. // mask: true
  153. // })
  154. // 第一次进入洗车页面
  155. if(this.$store.state.vuex_orderDjs == 0){
  156. // 记录当前的时间
  157. this.$store.state.vuex_orderDjs = new Date().getTime()
  158. }
  159. // 获取用户及订单信息
  160. let orderInfo = this.$store.state.vuex_orderInfo
  161. this.washCarType = orderInfo.itemCode
  162. this.orderNo = orderInfo.orderNo
  163. // 监听消息
  164. uni.$on('wsMessage', this.watchMessage)
  165. },
  166. onUnload() {
  167. // 关闭socket
  168. this.$store.commit("$closeWebsocket")
  169. uni.$off('wsMessage', this.watchMessage)
  170. },
  171. methods: {
  172. // 电话客服
  173. callPhone () {
  174. uni.makePhoneCall({
  175. phoneNumber: '18237162131'
  176. })
  177. },
  178. // 更新当前倒计时
  179. updateDjs(){
  180. let od = this.$store.state.vuex_orderDjs
  181. if(od!=0){
  182. let d = new Date().getTime() - od
  183. this.timestamp = 300 - d/1000
  184. }
  185. },
  186. // 倒计时结束时,自动完成洗车订单
  187. endDtime() {
  188. console.log('endDtime',this.status)
  189. if(this.status == 'start'){
  190. this.washCarSuccess()
  191. }
  192. },
  193. // 监听socket消息
  194. watchMessage(e){
  195. if(typeof e == 'string'){
  196. // 连接成功后
  197. if(e=='connected'){
  198. console.log('connected---')
  199. uni.hideLoading()
  200. if(this.$store.state.vuex_workStatus == 'linking'){
  201. this.status = 'start'
  202. this.$store.state.vuex_workStatus = 'start'
  203. }
  204. }
  205. // 重连连接打开时发送获取当前状态的命令
  206. if(e=='connectOpen'){
  207. console.log('connectOpen---')
  208. this.sendCmdRabt("order_run_status")
  209. }
  210. }
  211. if(typeof e == 'object' && e.type == 'xcz'){
  212. console.log(e.data.level,e.data.msgCodeInfo,e.data.msgCodeSrc)
  213. // 自定义消息,不是机器返回的
  214. if(e.data.level == 'O'){
  215. // 启动超时
  216. if(e.data.msgCode == "PAUSE"){
  217. this.startWashCarFail()
  218. }
  219. // 停车位置不正确,
  220. if(e.data.msgCode=="TCWZ_CW"){
  221. uni.showModal({
  222. title: '提示',
  223. content: e.data.msgCodeInfo,
  224. showCancel: false,
  225. });
  226. }
  227. // 重新进入页面且还未启动洗车时
  228. if(e.data.msgCode == "PAID"){
  229. // 更新当前倒计时
  230. this.updateDjs()
  231. }
  232. // 订单异常
  233. if(e.data.msgCode == "0"){
  234. // 更新当前倒计时
  235. this.devError(e.data.msgCodeInfo)
  236. }
  237. }
  238. // 进度消息
  239. if(e.data.level == 'C'&&this.status!="reseting"){
  240. this.curWorkStutesText= e.data.msgCodeInfo
  241. // 启动成功
  242. this.startWashCarSuccess()
  243. // 更新进度条
  244. this.step = e.data.msgCodeSrc?Number(e.data.msgCodeSrc.split('-')[1]):0
  245. this.$store.state.vuex_workStep = this.step
  246. this.loading()
  247. // 洗车完成
  248. if(e.data.msgCode=="XCWC" && this.status != 'end'){
  249. this.washCarSuccess()
  250. }
  251. }
  252. // 错误消息
  253. if(e.data.level == 'F'&&this.status!="reseting"){
  254. this.curWorkStutesText= e.data.msgCodeInfo
  255. // 启动成功
  256. this.startWashCarSuccess()
  257. // 显示复位提示弹框
  258. this.showReset()
  259. }
  260. // 急停
  261. if(e.data.level == 'A'){
  262. if(e.data.msgCode=="JJTZ"||e.data.msgCode=="XCX_JJTZ"){
  263. this.curWorkStutesText= e.data.msgCodeInfo
  264. // 显示复位提示弹框
  265. this.showReset()
  266. }else{
  267. if(this.status != "error-end"){
  268. this.devError()
  269. }
  270. }
  271. }
  272. // 复位状态
  273. if(e.data.level == 'D'){
  274. // 开始复位中
  275. if(e.data.msgCode=="FW_START"){
  276. this.reseting()
  277. }
  278. // 复位成功
  279. else if(e.data.msgCode=="FW_SUCC"){
  280. this.resetRabtSuccess()
  281. }
  282. // 设备离线,设备异常,暂停营业或复位失败,设备使用中
  283. else if(e.data.msgCode=="PAUSE" || e.data.msgCode == "FW_FAIL" || e.data.msgCode == 'ERROR' || e.data.msgCode == 'SB_SYZ'){
  284. if(this.status != "error-end"){
  285. this.devError(e.data.msgCodeInfo)
  286. }
  287. }
  288. }
  289. }
  290. },
  291. // 重置到进度条初始状态
  292. resetLoadingStatus(){
  293. this.rdeg= -135;
  294. this.ldeg= -135;
  295. },
  296. // 洗车机进度条动画
  297. loading() {
  298. if(this.step==16){this.step = 8}
  299. let second = this.step*this.washDuration
  300. if (second <= 30) {
  301. this.rdeg = -135 + 6 * second;
  302. this.ldeg = -135;
  303. } else {
  304. this.rdeg = 45;
  305. this.ldeg = -135 + 6 * (second - 30);
  306. }
  307. },
  308. // 操作按钮
  309. startWork() {
  310. let _this = this
  311. // 启动
  312. if (this.status == 'start') {
  313. this.sendCmdRabt("start")
  314. this.starting()
  315. }
  316. // 急停
  317. if (this.status == 'working') {
  318. uni.showModal({
  319. title: '提示',
  320. content: '确定紧急停止洗车机?',
  321. success: function (res) {
  322. if (res.confirm) {
  323. _this.sendCmdRabt("stop")
  324. _this.stoping()
  325. }
  326. }
  327. });
  328. }
  329. },
  330. // 启动中
  331. starting(){
  332. this.showStart = true;
  333. this.status = 'starting';
  334. this.$store.state.vuex_workStatus = 'starting';
  335. this.curWorkStutesText='设备启动中';
  336. },
  337. // 启动成功
  338. startWashCarSuccess(){
  339. this.showStart = false;
  340. this.status = 'working';
  341. this.$store.state.vuex_workStatus = 'working';
  342. },
  343. // 启动超时
  344. startWashCarFail(){
  345. this.showStart = false;
  346. this.status = 'start';
  347. this.$store.state.vuex_workStatus = 'start';
  348. this.curWorkStutesText='设备启动超时,请重新点击启动'
  349. uni.showToast({
  350. title: "设备启动超时",
  351. duration: 3000
  352. })
  353. },
  354. // 发送命令,start 启动,stop 急停,reset 归位
  355. sendCmdRabt(cmdCode){
  356. // 归位命令
  357. let cmd = {
  358. orderNo: this.orderNo, // 订单编号
  359. operateType: cmdCode, //操作命令
  360. washType: this.washCarType,// 洗车模式
  361. }
  362. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  363. },
  364. // 停止中
  365. stoping(){
  366. this.showStart = true;
  367. this.status = 'stoping';
  368. this.$store.state.vuex_workStatus = 'stoping';
  369. this.curWorkStutesText='设备停止中';
  370. },
  371. // 停止成功后或有F类错误时,显示复位弹框
  372. showReset(){
  373. this.showStart = false;
  374. this.showStop = true;
  375. this.status = 'reset';
  376. this.$store.state.vuex_workStatus = 'reset'
  377. this.resetLoadingStatus();
  378. },
  379. // 归位中
  380. reseting(){
  381. this.status = 'reseting';
  382. this.$store.state.vuex_workStatus = 'reseting';
  383. this.showStart = true;
  384. this.showStop = false;
  385. },
  386. // 归位结束后
  387. resetRabtSuccess(){
  388. this.curWorkStutesText='设备已归位';
  389. this.status = 'end';
  390. this.$store.state.vuex_workStatus = 'end';
  391. // 关闭socket
  392. this.$store.commit("$closeWebsocket");
  393. // 跳转到复位成功页面
  394. uni.redirectTo({
  395. url:"/pages/work/success/success?type=1"
  396. })
  397. },
  398. // 洗车完成
  399. washCarSuccess(){
  400. this.status = 'end';
  401. this.$store.state.vuex_workStatus = 'end';
  402. this.curWorkStutesText='洗车已结束';
  403. this.resetLoadingStatus();
  404. // uni.showModal({
  405. // title: '提示',
  406. // content: '洗车已结束',
  407. // showCancel: false,
  408. // success: function (res) {
  409. // if (res.confirm) {
  410. // // 跳转到成功页面
  411. // uni.redirectTo({
  412. // url:"/pages/work/success/success?type=0"
  413. // })
  414. // }
  415. // }
  416. // });
  417. this.showError = true
  418. // 关闭socket
  419. this.$store.commit("$closeWebsocket")
  420. },
  421. // 设备异常
  422. devError(msg){
  423. this.status = "error-end";
  424. this.$store.state.vuex_workStatus = 'error-end'
  425. this.resetLoadingStatus();
  426. uni.showModal({
  427. title: '提示',
  428. content: msg || '设备异常,请联系客服',
  429. showCancel: false,
  430. success: function (res) {
  431. if (res.confirm) {
  432. uni.navigateBack()
  433. }
  434. }
  435. });
  436. // 关闭socket
  437. this.$store.commit("$closeWebsocket");
  438. },
  439. }
  440. };
  441. </script>
  442. <style lang="scss">
  443. // 扇形圆环
  444. .circle_process {
  445. position: absolute;
  446. width: 390rpx;
  447. height: 390rpx;
  448. }
  449. .circle_process .wrapper {
  450. width: 195rpx;
  451. height: 390rpx;
  452. position: absolute;
  453. top: 0;
  454. overflow: hidden;
  455. }
  456. .circle_process .right {
  457. right: 0;
  458. }
  459. .circle_process .left {
  460. left: 0;
  461. }
  462. .circle_process .circle {
  463. width: 390rpx;
  464. height: 390rpx;
  465. border: 20rpx solid transparent;
  466. border-radius: 50%;
  467. position: absolute;
  468. top: 0;
  469. transform: rotate(-135deg);
  470. }
  471. .circle_process .rightcircle {
  472. border-top: 20rpx solid #4CD964;
  473. border-right: 20rpx solid #4CD964;
  474. right: 1px;
  475. }
  476. .circle_process .leftcircle {
  477. border-bottom: 20rpx solid #4CD964;
  478. border-left: 20rpx solid #4CD964;
  479. left: 1px;
  480. }
  481. // 动画
  482. @keyframes mymove {
  483. 0% {
  484. transform: scale(1); /*开始为原始大小*/
  485. opacity: 1;
  486. }
  487. 50% {
  488. transform: scale(1.2); /*放大1.1倍*/
  489. opacity: 0;
  490. }
  491. }
  492. .work-pages {
  493. width: 100%;
  494. .flex-center {
  495. display: flex;
  496. align-items: center;
  497. justify-content: center;
  498. }
  499. .work-cons {
  500. height: 50vh;
  501. background-image: linear-gradient(0deg, #666, #333);
  502. border-bottom-left-radius: 500rpx 50rpx;
  503. border-bottom-right-radius: 500rpx 50rpx;
  504. position: relative;
  505. // 按钮
  506. .work-button-wrap {
  507. width: 400rpx;
  508. margin-top: -50rpx;
  509. .work-button {
  510. background: #666;
  511. border-radius: 100%;
  512. width: 390rpx;
  513. height: 390rpx;
  514. box-shadow:inset 0rpx 2rpx 10rpx #000;
  515. .cirle-one {
  516. background-image: linear-gradient(180deg, #666, #333 30%);
  517. width: 370rpx;
  518. height: 370rpx;
  519. border-radius: 100%;
  520. position: absolute;
  521. box-shadow: 0rpx 2rpx 10rpx #333;
  522. }
  523. .cirle-two {
  524. width: 370rpx;
  525. height: 370rpx;
  526. border-radius: 100%;
  527. position: absolute;
  528. .sector {
  529. transform-origin: center center;
  530. width: 350rpx;
  531. height: 5rpx;
  532. background: #777;
  533. }
  534. }
  535. .cirle-three {
  536. background: #444;
  537. width: 280rpx;
  538. height: 280rpx;
  539. border-radius: 100%;
  540. position: absolute;
  541. box-shadow: inset 0rpx 3rpx 10rpx #000;
  542. }
  543. .cirle-free, .cirle-free-1, .cirle-free-2 {
  544. width: 230rpx;
  545. height: 230rpx;
  546. border-radius: 100%;
  547. position: absolute;
  548. animation: mymove 5s infinite;
  549. }
  550. .cirle-free-1{
  551. width: 210rpx;
  552. height: 210rpx;
  553. animation: mymove 4.5s infinite;
  554. }
  555. .cirle-free-2{
  556. width: 190rpx;
  557. height: 190rpx;
  558. animation: mymove 4s infinite;
  559. }
  560. .cirle-sex {
  561. background-image: linear-gradient(180deg, #888, #333 50%);
  562. box-shadow: 0rpx 5rpx 10rpx #333;
  563. width: 210rpx;
  564. height: 210rpx;
  565. border-radius: 100%;
  566. position: absolute;
  567. color: #ffffff;
  568. font-size: 28rpx;
  569. color: #eee;
  570. &:active {
  571. background-image: linear-gradient(-180deg, #666, #333 80%);
  572. }
  573. }
  574. .w-start {
  575. background: #ffc800;
  576. }
  577. .w-stop {
  578. background: #ff0000;
  579. }
  580. }
  581. }
  582. .work-button-tips {
  583. width: 80%;
  584. color: #eee;
  585. text-align: center;
  586. padding-top: 30rpx;
  587. .u-swiper-item{
  588. justify-content: center;
  589. }
  590. }
  591. }
  592. .work-tips {
  593. padding: 45rpx;
  594. .work-dtime {
  595. text-align: center;
  596. font-weight: bold;
  597. font-size: 34rpx;
  598. }
  599. .work-remarks {
  600. padding-top: 50rpx;
  601. .red {
  602. color: red;
  603. }
  604. .title {
  605. font-weight: bold;
  606. }
  607. }
  608. }
  609. }
  610. </style>