index.vue 17 KB

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