index.vue 17 KB

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