index.vue 17 KB

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