index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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-if="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_workStatus == 'linking'){
  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. this.status = 'start'
  198. this.$store.state.vuex_workStatus = 'start'
  199. }
  200. // 连接开始重连,恢复状态为初始
  201. if(e=='reconnect'){
  202. console.log('reconnect---')
  203. this.status = 'linking'
  204. this.$store.state.vuex_workStatus = 'linking'
  205. }
  206. // 重连连接打开时发送获取当前状态的命令
  207. if(e=='connectOpen'){
  208. console.log('connectOpen---')
  209. this.sendCmdRabt("order_run_status")
  210. }
  211. }
  212. if(typeof e == 'object' && e.type == 'xcz'){
  213. console.log(e.data.level,e.data.msgCodeInfo,e.data.msgCodeSrc)
  214. // 自定义消息,不是机器返回的
  215. if(e.data.level == 'O'){
  216. // 启动超时
  217. if(e.data.msgCode == "PAUSE"){
  218. this.startWashCarFail()
  219. }
  220. // 重新进入页面且还未启动洗车时
  221. if(e.data.msgCode == "PAID"){
  222. // 更新当前倒计时
  223. this.updateDjs()
  224. }
  225. // 订单异常
  226. if(e.data.msgCode == "0"){
  227. // 更新当前倒计时
  228. this.devError(e.data.msgCodeInfo)
  229. }
  230. }
  231. // 进度消息
  232. if(e.data.level == 'C'&&this.status!="reseting"&&e.data.msgCodeSrc){
  233. this.curWorkStutesText= e.data.msgCodeInfo
  234. // 启动成功
  235. this.startWashCarSuccess()
  236. // 更新进度条
  237. this.step = e.data.msgCodeSrc?Number(e.data.msgCodeSrc.split('-')[1]):0
  238. this.$store.state.vuex_workStep = this.step
  239. this.loading()
  240. // 洗车完成
  241. if(e.data.msgCode=="XCWC" && this.status != 'end'){
  242. this.washCarSuccess()
  243. }
  244. }
  245. // 错误消息
  246. if(e.data.level == 'F'&&this.status!="reseting"){
  247. this.curWorkStutesText= e.data.msgCodeInfo
  248. // 启动成功
  249. this.startWashCarSuccess()
  250. // 显示复位提示弹框
  251. this.showReset()
  252. }
  253. // 急停
  254. if(e.data.level == 'A'){
  255. if(e.data.msgCode=="JJTZ"||e.data.msgCode=="XCX_JJTZ"){
  256. this.curWorkStutesText= e.data.msgCodeInfo
  257. // 显示复位提示弹框
  258. this.showReset()
  259. }else{
  260. if(this.status != "error-end"){
  261. this.devError()
  262. }
  263. }
  264. }
  265. // 复位状态
  266. if(e.data.level == 'D'){
  267. // 设备在线,正常服务
  268. if(e.data.msgCode == "ON_LINE"){
  269. this.curWorkStutesText= e.data.msgCodeInfo
  270. }
  271. // 开始复位中
  272. else 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=="TCWZ_CW"){
  281. this.curWorkStutesText= e.data.msgCodeInfo
  282. this.showError = true
  283. }
  284. // 停车位置正确
  285. else if(e.data.msgCode=="TCWZ_ZQ"){
  286. this.curWorkStutesText= e.data.msgCodeInfo
  287. this.showError = false
  288. }
  289. // 设备离线,设备异常,暂停营业或复位失败,设备使用中
  290. else if(e.data.msgCode=="PAUSE" || e.data.msgCode == "FW_FAIL" || e.data.msgCode == 'ERROR' || e.data.msgCode == 'SB_SYZ'){
  291. if(this.status != "error-end"){
  292. this.devError(e.data.msgCodeInfo)
  293. }
  294. }
  295. }
  296. }
  297. },
  298. // 重置到进度条初始状态
  299. resetLoadingStatus(){
  300. this.rdeg= -135;
  301. this.ldeg= -135;
  302. },
  303. // 洗车机进度条动画
  304. loading() {
  305. if(this.step==16){this.step = 8}
  306. let second = this.step*this.washDuration
  307. if (second <= 30) {
  308. this.rdeg = -135 + 6 * second;
  309. this.ldeg = -135;
  310. } else {
  311. this.rdeg = 45;
  312. this.ldeg = -135 + 6 * (second - 30);
  313. }
  314. },
  315. // 操作按钮
  316. startWork() {
  317. let _this = this
  318. // 启动
  319. if (this.status == 'start') {
  320. this.sendCmdRabt("start")
  321. this.starting()
  322. }
  323. // 急停
  324. if (this.status == 'working') {
  325. uni.showModal({
  326. title: '提示',
  327. content: '确定紧急停止洗车机?',
  328. success: function (res) {
  329. if (res.confirm) {
  330. _this.sendCmdRabt("stop")
  331. _this.stoping()
  332. }
  333. }
  334. });
  335. }
  336. },
  337. // 启动中
  338. starting(){
  339. this.showStart = true;
  340. this.status = 'starting';
  341. this.$store.state.vuex_workStatus = 'starting';
  342. this.curWorkStutesText='设备启动中';
  343. },
  344. // 启动成功
  345. startWashCarSuccess(){
  346. this.showStart = false;
  347. this.status = 'working';
  348. this.$store.state.vuex_workStatus = 'working';
  349. },
  350. // 启动超时
  351. startWashCarFail(){
  352. this.showStart = false;
  353. this.status = 'start';
  354. this.$store.state.vuex_workStatus = 'start';
  355. this.curWorkStutesText='设备启动超时,请重新点击启动'
  356. uni.showToast({
  357. title: "设备启动超时",
  358. duration: 3000
  359. })
  360. },
  361. // 发送命令,start 启动,stop 急停,reset 归位
  362. sendCmdRabt(cmdCode){
  363. // 归位命令
  364. let cmd = {
  365. orderNo: this.orderNo, // 订单编号
  366. operateType: cmdCode, //操作命令
  367. washType: this.washCarType,// 洗车模式
  368. }
  369. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  370. },
  371. // 停止中
  372. stoping(){
  373. this.showStart = true;
  374. this.status = 'stoping';
  375. this.$store.state.vuex_workStatus = 'stoping';
  376. this.curWorkStutesText='设备停止中';
  377. },
  378. // 停止成功后或有F类错误时,显示复位弹框
  379. showReset(){
  380. this.showStart = false;
  381. this.showStop = true;
  382. this.status = 'reset';
  383. this.$store.state.vuex_workStatus = 'reset'
  384. this.resetLoadingStatus();
  385. },
  386. // 归位中
  387. reseting(){
  388. this.status = 'reseting';
  389. this.$store.state.vuex_workStatus = 'reseting';
  390. this.showStart = true;
  391. this.showStop = false;
  392. },
  393. // 归位结束后
  394. resetRabtSuccess(){
  395. this.curWorkStutesText='设备已归位';
  396. this.status = 'end';
  397. this.$store.state.vuex_workStatus = 'end';
  398. // 关闭socket
  399. this.$store.commit("$closeWebsocket");
  400. // 跳转到复位成功页面
  401. uni.redirectTo({
  402. url:"/pages/work/success/success?type=1"
  403. })
  404. },
  405. // 洗车完成
  406. washCarSuccess(){
  407. this.status = 'end';
  408. this.$store.state.vuex_workStatus = 'end';
  409. this.curWorkStutesText='洗车已结束';
  410. this.resetLoadingStatus();
  411. uni.showModal({
  412. title: '提示',
  413. content: '洗车已结束',
  414. showCancel: false,
  415. success: function (res) {
  416. if (res.confirm) {
  417. // 跳转到成功页面
  418. uni.redirectTo({
  419. url:"/pages/work/success/success?type=0"
  420. })
  421. }
  422. }
  423. });
  424. // 关闭socket
  425. this.$store.commit("$closeWebsocket")
  426. },
  427. // 设备异常
  428. devError(msg){
  429. this.status = "error-end";
  430. this.$store.state.vuex_workStatus = 'error-end'
  431. this.resetLoadingStatus();
  432. uni.showModal({
  433. title: '提示',
  434. content: msg || '设备异常,请联系客服',
  435. showCancel: false,
  436. success: function (res) {
  437. if (res.confirm) {
  438. uni.navigateBack()
  439. }
  440. }
  441. });
  442. // 关闭socket
  443. this.$store.commit("$closeWebsocket");
  444. },
  445. }
  446. };
  447. </script>
  448. <style lang="scss">
  449. // 扇形圆环
  450. .circle_process {
  451. position: absolute;
  452. width: 390rpx;
  453. height: 390rpx;
  454. }
  455. .circle_process .wrapper {
  456. width: 195rpx;
  457. height: 390rpx;
  458. position: absolute;
  459. top: 0;
  460. overflow: hidden;
  461. }
  462. .circle_process .right {
  463. right: 0;
  464. }
  465. .circle_process .left {
  466. left: 0;
  467. }
  468. .circle_process .circle {
  469. width: 390rpx;
  470. height: 390rpx;
  471. border: 20rpx solid transparent;
  472. border-radius: 50%;
  473. position: absolute;
  474. top: 0;
  475. transform: rotate(-135deg);
  476. }
  477. .circle_process .rightcircle {
  478. border-top: 20rpx solid #4CD964;
  479. border-right: 20rpx solid #4CD964;
  480. right: 1px;
  481. }
  482. .circle_process .leftcircle {
  483. border-bottom: 20rpx solid #4CD964;
  484. border-left: 20rpx solid #4CD964;
  485. left: 1px;
  486. }
  487. // 动画
  488. @keyframes mymove {
  489. 0% {
  490. transform: scale(1); /*开始为原始大小*/
  491. opacity: 1;
  492. }
  493. 50% {
  494. transform: scale(1.2); /*放大1.1倍*/
  495. opacity: 0;
  496. }
  497. }
  498. .work-pages {
  499. width: 100%;
  500. .flex-center {
  501. display: flex;
  502. align-items: center;
  503. justify-content: center;
  504. }
  505. .work-cons {
  506. height: 50vh;
  507. background-image: linear-gradient(0deg, #666, #333);
  508. border-bottom-left-radius: 500rpx 50rpx;
  509. border-bottom-right-radius: 500rpx 50rpx;
  510. position: relative;
  511. // 按钮
  512. .work-button-wrap {
  513. width: 400rpx;
  514. margin-top: -50rpx;
  515. .work-button {
  516. background: #666;
  517. border-radius: 100%;
  518. width: 390rpx;
  519. height: 390rpx;
  520. box-shadow:inset 0rpx 2rpx 10rpx #000;
  521. .cirle-one {
  522. background-image: linear-gradient(180deg, #666, #333 30%);
  523. width: 370rpx;
  524. height: 370rpx;
  525. border-radius: 100%;
  526. position: absolute;
  527. box-shadow: 0rpx 2rpx 10rpx #333;
  528. }
  529. .cirle-two {
  530. width: 370rpx;
  531. height: 370rpx;
  532. border-radius: 100%;
  533. position: absolute;
  534. .sector {
  535. transform-origin: center center;
  536. width: 350rpx;
  537. height: 5rpx;
  538. background: #777;
  539. }
  540. }
  541. .cirle-three {
  542. background: #444;
  543. width: 280rpx;
  544. height: 280rpx;
  545. border-radius: 100%;
  546. position: absolute;
  547. box-shadow: inset 0rpx 3rpx 10rpx #000;
  548. }
  549. .cirle-free, .cirle-free-1, .cirle-free-2 {
  550. width: 230rpx;
  551. height: 230rpx;
  552. border-radius: 100%;
  553. position: absolute;
  554. animation: mymove 5s infinite;
  555. }
  556. .cirle-free-1{
  557. width: 210rpx;
  558. height: 210rpx;
  559. animation: mymove 4.5s infinite;
  560. }
  561. .cirle-free-2{
  562. width: 190rpx;
  563. height: 190rpx;
  564. animation: mymove 4s infinite;
  565. }
  566. .cirle-sex {
  567. background-image: linear-gradient(180deg, #888, #333 50%);
  568. box-shadow: 0rpx 5rpx 10rpx #333;
  569. width: 210rpx;
  570. height: 210rpx;
  571. border-radius: 100%;
  572. position: absolute;
  573. color: #ffffff;
  574. font-size: 28rpx;
  575. color: #eee;
  576. &:active {
  577. background-image: linear-gradient(-180deg, #666, #333 80%);
  578. }
  579. }
  580. .w-start {
  581. background: #ffc800;
  582. }
  583. .w-stop {
  584. background: #ff0000;
  585. }
  586. }
  587. }
  588. .work-button-tips {
  589. width: 80%;
  590. color: #eee;
  591. text-align: center;
  592. padding-top: 30rpx;
  593. .u-swiper-item{
  594. justify-content: center;
  595. }
  596. }
  597. }
  598. .work-tips {
  599. padding: 45rpx;
  600. .work-dtime {
  601. text-align: center;
  602. font-weight: bold;
  603. font-size: 34rpx;
  604. }
  605. .work-remarks {
  606. padding-top: 50rpx;
  607. .red {
  608. color: red;
  609. }
  610. .title {
  611. font-weight: bold;
  612. }
  613. }
  614. }
  615. }
  616. </style>