index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="work-pages">
  3. <u-no-network></u-no-network>
  4. <!-- 工作控制按钮及进度 -->
  5. <view class="work-cons flex-center" style="flex-direction: column;">
  6. <!-- 操作按钮组件 -->
  7. <view class="work-button-wrap">
  8. <!-- 按钮 -->
  9. <view class="work-button flex-center">
  10. <!-- 扇形进度条 -->
  11. <view class="circle_process">
  12. <view class="wrapper right"><view class="circle rightcircle" :style="{ transform: `rotate(${rdeg}deg)` }"></view></view>
  13. <view class="wrapper left"><view class="circle leftcircle" :style="{ transform: `rotate(${ldeg}deg)` }"></view></view>
  14. </view>
  15. <view class="cirle-one"></view>
  16. <!-- 指针 -->
  17. <view class="cirle-two flex-center" v-for="item in 60" :key="item">
  18. <view class="sector" :style="{ transform: `rotate(${item * 6}deg)` }"></view>
  19. </view>
  20. <view class="cirle-three flex-center"></view>
  21. <view class="cirle-free" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  22. <view class="cirle-free-1" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  23. <view class="cirle-free-2" :class="status == 'working' ? 'w-stop' : 'w-start'"></view>
  24. <view class="cirle-sex flex-center" @tap="startWork">
  25. {{ status == 'working' ? '紧急停止' : '点击启动' }}
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 状态提示 -->
  30. <view class="work-button-tips">
  31. <u-notice-bar type="error" border-radius="50" color="#fff" bg-color="#666" mode="vertical" :list="[curWorkStutesText,curWorkStutesText]"></u-notice-bar>
  32. </view>
  33. </view>
  34. <!-- 说明提示 -->
  35. <view class="work-tips">
  36. <view>
  37. <view class="work-dtime" v-show="status=='start'">
  38. 距离订单强制完成还剩
  39. <u-count-down
  40. v-if="timestamp>0"
  41. @end="endDtime"
  42. separator="zh"
  43. font-size="36"
  44. separator-size="28"
  45. color="#ff0000"
  46. :timestamp="timestamp"
  47. :show-days="false"
  48. :show-hours="false"
  49. ></u-count-down>
  50. </view>
  51. <view class="work-remarks">
  52. <view class="title">说明:</view>
  53. <view v-if="status=='start'">
  54. 支付完成后
  55. <text class="red">请尽快启动洗车服务</text>
  56. ,否则订单将在5分钟后自动完成。
  57. </view>
  58. <view v-else>
  59. <view>设备启动中请注意安全,如果设备工作中出现故障,请按紧急停止按钮或联系客服。</view>
  60. <view @click="callPhone">如有疑问,请联系客服:<text>18237162131</text> </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <!-- 正在启动,归位弹框提示 -->
  66. <u-popup v-model="showStart" :mask-close-able="false" border-radius="10" mode="center" width="500rpx" height="400rpx">
  67. <view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
  68. <!-- 启动中 -->
  69. <view v-if="status == 'starting'">
  70. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  71. <view style="padding: 15rpx;">洗车机正在启动...</view>
  72. </view>
  73. <!-- 停止中 -->
  74. <view v-if="status == 'stoping'">
  75. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  76. <view style="padding: 15rpx;">洗车机正在停止中...</view>
  77. </view>
  78. <!-- 归位中 -->
  79. <view v-if="status == 'reseting'">
  80. <u-image width="216px" height="120px" src="/static/img/reset.png"></u-image>
  81. <view style="padding: 15rpx;">洗车机正在归位中...</view>
  82. </view>
  83. </view>
  84. </u-popup>
  85. <!-- 洗车完成 -->
  86. <u-modal v-model="showTips" @confirm="confirmFun" :content="content"></u-modal>
  87. <!-- 急停提示弹框 -->
  88. <u-popup v-model="showStop" :mask-close-able="false" border-radius="10" mode="center" width="80%">
  89. <view style="padding: 30rpx;text-align: center;">
  90. <view>
  91. <view style="font-weight: bold;">设备提示</view>
  92. <view style="display: flex;justify-content: center;padding: 10rpx 0;">
  93. <u-image width="165px" height="138px" src="/static/img/sbts.png"></u-image>
  94. </view>
  95. <u-divider>可能原因</u-divider>
  96. <view style="padding: 15rpx;text-align: left;">
  97. <view>1、洗车机紧急停止,本次服务结束</view>
  98. <view>2、因设备故障无法继续为您服务,所支付金额将退至您的支付账户</view>
  99. <view>3、如需再次服务,请退出车辆重新进入,再扫码支付洗车</view>
  100. <view>4、如需帮助请联系客服</view>
  101. </view>
  102. <view style="display: flex;padding: 20rpx 0;justify-content: center;">
  103. <u-button @click="callPhone" style="width: 45%;border-radius: 0;margin-right: 5%;">联系客服</u-button>
  104. <u-button :disabled="disabledResetBtn" @click="sendCmdRabt('reset')" style="width: 45%;" type="error">洗车机归位</u-button>
  105. </view>
  106. </view>
  107. </view>
  108. </u-popup>
  109. </view>
  110. </template>
  111. <script>
  112. export default {
  113. data() {
  114. return {
  115. timestamp: 0, // 初始情况下5分钟后自动结束
  116. rdeg: -135, // 进度条初始角度
  117. ldeg: -135, /// 进度条初始角度
  118. step: 0, // 进度条增值,共60步
  119. status: 'linking', // 状态,linking 连接中,start 开始启动, starting 启动中,working 正在工作,stoping 停止中, reset 归位,reseting 归位中, end 洗车完成,error-end 异常结束
  120. curWorkStutesText: '设备准备就绪', // 当前机器运行的进度提示
  121. showTips: false, // 错误提示
  122. content: '', // 消息内容
  123. confirmFun: function(){}, // 消息确认弹框
  124. disabledResetBtn: false,
  125. showStart: false ,// 启动弹框提示
  126. showStop: false, // 急停提示
  127. washCarType: '', // 洗车服务类型,不同的类型对应的时间不一样
  128. washDuration: 7.5, // 机器运行步骤,共8步,等分60
  129. orderNo: '',// 订单编号
  130. };
  131. },
  132. onShow() {
  133. console.log("onShow")
  134. // 更新进度条
  135. if(this.$store.state.vuex_workStatus == 'working'){
  136. this.step = this.$store.state.vuex_workStep
  137. this.loading()
  138. }
  139. },
  140. onLoad(options) {
  141. console.log("onLoad")
  142. // 创建websocket
  143. this.$store.commit('$webSocket')
  144. uni.showLoading({
  145. title: '正在连接...',
  146. mask: true
  147. })
  148. // 监听网络状态
  149. uni.onNetworkStatusChange(function (res) {
  150. console.log(res.isConnected);
  151. console.log(res.networkType);
  152. if(res.isConnected){
  153. uni.showLoading({
  154. title: '正在连接...',
  155. mask: true
  156. })
  157. }
  158. });
  159. // 第一次进入洗车页面
  160. if(this.$store.state.vuex_orderDjs == 0){
  161. // 记录当前的时间
  162. this.$u.vuex('vuex_orderDjs',new Date().getTime())
  163. }
  164. // 获取用户及订单信息
  165. this.washCarType = this.$store.state.vuex_itemCode
  166. this.orderNo = this.$store.state.vuex_orderNo
  167. // 监听消息
  168. uni.$on('wsMessage', this.watchMessage)
  169. },
  170. onUnload() {
  171. // 关闭socket
  172. this.$store.commit("$closeWebsocket")
  173. uni.$off('wsMessage', this.watchMessage)
  174. },
  175. methods: {
  176. // 提示弹框
  177. showModal(content, fun){
  178. this.showTips = true
  179. this.content = content
  180. this.confirmFun = fun || function(){
  181. this.showTips=false
  182. }
  183. },
  184. // 电话客服
  185. callPhone () {
  186. uni.makePhoneCall({
  187. phoneNumber: '18237162131'
  188. })
  189. },
  190. // 更新当前倒计时
  191. updateDjs(){
  192. let od = this.$store.state.vuex_orderDjs
  193. if(od!=0){
  194. let d = new Date().getTime() - od
  195. this.timestamp = 300 - d/1000
  196. }
  197. },
  198. // 倒计时结束时,自动完成洗车订单
  199. endDtime() {
  200. console.log('endDtime',this.status)
  201. if(this.status == 'start'){
  202. this.washCarSuccess()
  203. }
  204. },
  205. // 监听socket消息
  206. watchMessage(e){
  207. if(typeof e == 'string'){
  208. // 连接成功后
  209. if(e=='connected'){
  210. console.log('connected---')
  211. uni.hideLoading()
  212. if(this.$store.state.vuex_workStatus == 'linking'){
  213. this.status = 'start'
  214. this.$u.vuex('vuex_workStatus','start')
  215. }
  216. }
  217. // 重连连接打开时发送获取当前状态的命令
  218. if(e=='connectOpen'){
  219. console.log('connectOpen---')
  220. this.sendCmdRabt("order_run_status")
  221. }
  222. }
  223. if(typeof e == 'object' && e.type == 'xcz'){
  224. console.log(e.data.level,e.data.msgCodeInfo,e.data.msgCodeSrc)
  225. // 自定义消息,不是机器返回的
  226. if(e.data.level == 'O'){
  227. // 启动超时
  228. if(e.data.msgCode == "PAUSE"){
  229. this.startWashCarFail()
  230. }
  231. // 停车位置不正确,
  232. if(e.data.msgCode=="TCWZ_CW"){
  233. this.showModal(e.data.msgCodeInfo)
  234. }
  235. // 重新进入页面且还未启动洗车时
  236. if(e.data.msgCode == "PAID"){
  237. // 更新当前倒计时
  238. this.updateDjs()
  239. }
  240. // 订单异常
  241. if(e.data.msgCode == "0"){
  242. // 更新当前倒计时
  243. this.devError(e.data.msgCodeInfo)
  244. }
  245. }
  246. // 进度消息
  247. if(e.data.level == 'C'&&this.status!="reseting"){
  248. this.curWorkStutesText= e.data.msgCodeInfo
  249. if(e.data.msgCodeInfo != '开始洗车'){
  250. // 启动成功
  251. this.startWashCarSuccess()
  252. }
  253. // 更新进度条
  254. this.step = e.data.msgCodeSrc?Number(e.data.msgCodeSrc.split('-')[1]):0
  255. this.$store.state.vuex_workStep = this.step
  256. this.loading()
  257. // 洗车完成
  258. if(e.data.msgCode=="XCWC" && this.status != 'end'){
  259. this.washCarSuccess()
  260. }
  261. }
  262. // 错误消息
  263. if(e.data.level == 'F'&&this.status!="reseting"){
  264. this.curWorkStutesText= e.data.msgCodeInfo
  265. // 启动成功
  266. this.startWashCarSuccess()
  267. // 显示复位提示弹框
  268. this.showReset()
  269. }
  270. // 急停
  271. if(e.data.level == 'A'){
  272. if(e.data.msgCode=="JJTZ"||e.data.msgCode=="XCX_JJTZ"){
  273. this.curWorkStutesText= e.data.msgCodeInfo
  274. // 显示复位提示弹框
  275. this.showReset()
  276. }else{
  277. if(this.status == 'working'){
  278. this.devError()
  279. }else{
  280. this.showModal(e.data.msgCodeInfo)
  281. }
  282. }
  283. }
  284. // 复位状态
  285. if(e.data.level == 'D'){
  286. // 开始复位中
  287. if(e.data.msgCode=="FW_START"){
  288. this.reseting()
  289. }
  290. // 复位成功
  291. else if(e.data.msgCode=="FW_SUCC"){
  292. this.resetRabtSuccess()
  293. }
  294. // 设备离线,设备异常,暂停营业或复位失败,设备使用中
  295. else if(e.data.msgCode=="PAUSE" || e.data.msgCode == "FW_FAIL" || e.data.msgCode == 'ERROR' || e.data.msgCode == 'SB_SYZ'){
  296. this.devError(e.data.msgCodeInfo)
  297. this.disabledResetBtn = false
  298. }
  299. }
  300. }
  301. },
  302. // 重置到进度条初始状态
  303. resetLoadingStatus(){
  304. this.rdeg= -135;
  305. this.ldeg= -135;
  306. },
  307. // 洗车机进度条动画
  308. loading() {
  309. if(this.step==16){this.step = 8}
  310. let second = this.step*this.washDuration
  311. if (second <= 30) {
  312. this.rdeg = -135 + 6 * second;
  313. this.ldeg = -135;
  314. } else {
  315. this.rdeg = 45;
  316. this.ldeg = -135 + 6 * (second - 30);
  317. }
  318. },
  319. // 操作按钮
  320. startWork() {
  321. let _this = this
  322. // 启动
  323. if (this.status == 'start') {
  324. this.sendCmdRabt("start")
  325. this.starting()
  326. }
  327. // 急停
  328. if (this.status == 'working') {
  329. uni.showModal({
  330. title: '提示',
  331. content: '确定紧急停止洗车机?',
  332. success: function (res) {
  333. if (res.confirm) {
  334. _this.sendCmdRabt("stop")
  335. _this.stoping()
  336. }
  337. }
  338. });
  339. }
  340. },
  341. // 启动中
  342. starting(){
  343. this.showStart = true;
  344. this.status = 'starting';
  345. this.$u.vuex('vuex_workStatus','starting')
  346. this.curWorkStutesText='设备启动中';
  347. },
  348. // 启动成功
  349. startWashCarSuccess(){
  350. this.showStart = false;
  351. this.status = 'working';
  352. this.$u.vuex('vuex_workStatus','working')
  353. },
  354. // 启动超时
  355. startWashCarFail(){
  356. this.showStart = false;
  357. this.status = 'start';
  358. this.$u.vuex('vuex_workStatus','start')
  359. this.curWorkStutesText='设备启动超时'
  360. this.showModal('设备启动超时,请稍后重试或联系客服')
  361. },
  362. // 发送命令,start 启动,stop 急停,reset 归位
  363. sendCmdRabt(cmdCode){
  364. // 归位命令
  365. let cmd = {
  366. orderNo: this.orderNo, // 订单编号
  367. operateType: cmdCode, //操作命令
  368. washType: this.washCarType,// 洗车模式
  369. }
  370. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  371. // 点击复位后
  372. if(cmdCode == 'reset'){
  373. this.disabledResetBtn = true
  374. }
  375. },
  376. // 停止中
  377. stoping(){
  378. this.showStart = true;
  379. this.status = 'stoping';
  380. this.$u.vuex('vuex_workStatus','stoping')
  381. this.curWorkStutesText='设备停止中';
  382. },
  383. // 停止成功后或有F类错误时,显示复位弹框
  384. showReset(){
  385. this.showStart = false;
  386. this.showStop = true;
  387. this.status = 'reset';
  388. this.$u.vuex('vuex_workStatus','reset')
  389. this.resetLoadingStatus();
  390. },
  391. // 归位中
  392. reseting(){
  393. this.status = 'reseting';
  394. this.$u.vuex('vuex_workStatus','reseting')
  395. this.showStart = true;
  396. this.showStop = false;
  397. this.disabledResetBtn = false
  398. },
  399. // 归位结束后
  400. resetRabtSuccess(){
  401. this.curWorkStutesText='设备已归位';
  402. this.status = 'end';
  403. this.$u.vuex('vuex_workStatus','end')
  404. // 关闭socket
  405. this.$store.commit("$closeWebsocket");
  406. // 跳转到复位成功页面
  407. uni.redirectTo({
  408. url:"/pages/work/success/success?type=1"
  409. })
  410. },
  411. // 洗车完成
  412. washCarSuccess(){
  413. this.status = 'end';
  414. this.$u.vuex('vuex_workStatus','end')
  415. this.curWorkStutesText='洗车已结束';
  416. this.resetLoadingStatus();
  417. // 显示弹框
  418. this.showModal('洗车已结束',function(){
  419. // 跳转到成功页面
  420. uni.redirectTo({
  421. url:"/pages/work/success/success?type=0"
  422. })
  423. })
  424. // 关闭socket
  425. this.$store.commit("$closeWebsocket")
  426. },
  427. // 设备异常
  428. devError(msg){
  429. this.status = "error-end";
  430. this.$u.vuex('vuex_workStatus','error-end')
  431. this.resetLoadingStatus();
  432. // 显示弹框
  433. this.showModal(msg || '设备异常,请联系客服',function () {
  434. uni.navigateBack()
  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>