index.vue 16 KB

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