index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <view class="work-pages">
  3. <!-- 工作控制按钮及进度 -->
  4. <view class="work-cons flex-center">
  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. <!-- 状态提示 -->
  28. <view class="work-button-tips">
  29. {{curWorkStutesText}}
  30. </view>
  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. @end="endDtime"
  40. separator="zh"
  41. font-size="36"
  42. separator-size="28"
  43. color="#ff0000"
  44. :timestamp="timestamp"
  45. :show-days="false"
  46. :show-hours="false"
  47. ></u-count-down>
  48. </view>
  49. <view class="work-remarks">
  50. <view class="title">说明:</view>
  51. <view v-if="status=='start'">
  52. 支付完成后
  53. <text class="red">请尽快启动洗车服务</text>
  54. ,否则订单将在5分钟后自动完成。
  55. </view>
  56. <view v-else>
  57. <view>设备启动中请注意安全,如果设备工作中出现故障,请按紧急停止按钮或联系客服。</view>
  58. <view @click="callPhone">如有疑问,请联系客服:<text>400-xxx-xxx</text> </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 正在启动,归位弹框提示 -->
  64. <u-popup v-model="showStart" :mask-close-able="false" border-radius="10" mode="center" width="500rpx" height="400rpx">
  65. <view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
  66. <!-- 启动中 -->
  67. <view v-if="status == 'start'">
  68. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  69. <view style="padding: 15rpx;">洗车机正在启动...</view>
  70. </view>
  71. <!-- 停止中 -->
  72. <view v-if="status == 'stop'">
  73. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  74. <view style="padding: 15rpx;">洗车机正在停止中...</view>
  75. </view>
  76. <!-- 归位中 -->
  77. <view v-if="status == 'reseting'">
  78. <u-image width="216px" height="120px" src="/static/img/reset.png"></u-image>
  79. <view style="padding: 15rpx;">洗车机正在归位中...</view>
  80. </view>
  81. </view>
  82. </u-popup>
  83. <!-- 急停提示弹框 -->
  84. <u-popup v-model="showStop" :mask-close-able="false" border-radius="10" mode="center" width="80%">
  85. <view style="padding: 30rpx;text-align: center;">
  86. <view>
  87. <view style="font-weight: bold;">设备提示</view>
  88. <view style="display: flex;justify-content: center;padding: 10rpx 0;">
  89. <u-image width="165px" height="138px" src="/static/img/sbts.png"></u-image>
  90. </view>
  91. <u-divider>可能原因</u-divider>
  92. <view style="padding: 15rpx;text-align: left;">
  93. <view>1、洗车机紧急停止,本次服务结束</view>
  94. <view>2、因设备故障无法继续为您服务,所支付金额将退至您的支付账户</view>
  95. <view>3、如需再次服务,请退出车辆重新进入,再扫码支付洗车</view>
  96. <view>4、如需帮助请联系客服</view>
  97. </view>
  98. <view style="display: flex;padding: 20rpx 0;justify-content: center;">
  99. <u-button @click="callPhone" style="width: 45%;border-radius: 0;margin-right: 5%;">联系客服</u-button>
  100. <u-button @click="resetRabt" style="width: 45%;" type="error">洗车机归位</u-button>
  101. </view>
  102. </view>
  103. </view>
  104. </u-popup>
  105. </view>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. return {
  111. timestamp: 300, // 初始情况下5分钟后自动结束
  112. rdeg: -135, // 进度条初始角度
  113. ldeg: -135, /// 进度条初始角度
  114. step: 0, // 进度条增值,共60步
  115. interId: null, // 进度时间id
  116. status: 'start', // 状态,start 开始启动,working 正在工作,stop急停,reseting 归位中, success 洗车成功
  117. curWorkStutesText: '设备准备就绪', // 当前机器运行的进度提示
  118. showStart: false ,// 启动弹框提示
  119. showStop: false, // 急停提示
  120. washCarType: '', // 洗车服务类型,不同的类型对应的时间不一样
  121. washDuration: 0, // 机器运行时间
  122. orderNo: '',// 订单编号
  123. };
  124. },
  125. onLoad(options) {
  126. // 创建websocket
  127. this.$store.commit('$webSocket')
  128. // 获取用户及订单信息
  129. let orderInfo = this.$store.state.vuex_orderInfo
  130. this.washCarType = orderInfo.itemCode
  131. this.orderNo = orderInfo.orderNo
  132. this.washDuration = orderInfo.duration
  133. // 监听消息
  134. uni.$on('wsMessage',(e)=>{
  135. console.log(e.data.level,e.data.msgCode,e.data.msgCodeInfo)
  136. console.log("--------------------------------------------")
  137. if(e.type == 'xcz'){
  138. // 进度消息
  139. if(e.data.level == 'C'){
  140. this.curWorkStutesText= e.data.msgCodeInfo
  141. // 洗车完成
  142. if(e.data.msgCode=="XCWC"){
  143. this.washCarSuccess()
  144. }
  145. }
  146. // 错误消息
  147. if(e.data.level == 'F'){
  148. this.curWorkStutesText= e.data.msgCodeInfo
  149. // 显示复位提示弹框
  150. this.showStop = true;
  151. this.stopWashCarSuccess();
  152. }
  153. // 急停
  154. if(e.data.level == 'A'){
  155. if(e.data.msgCode=="JJTZ"||e.data.msgCode=="XCX_JJTZ"){
  156. this.curWorkStutesText= e.data.msgCodeInfo
  157. // 显示复位提示弹框
  158. this.showStop = true;
  159. this.stopWashCarSuccess();
  160. }else{
  161. this.devError()
  162. }
  163. }
  164. // 复位状态
  165. if(e.data.level == 'D'){
  166. // 开始复位
  167. if(e.data.msgCode=="FW_START"){
  168. this.status = 'reseting';
  169. this.showStart = true;
  170. this.showStop = false;
  171. }
  172. // 复位成功
  173. if(e.data.msgCode=="FW_SUCC"){
  174. this.resetRabtSuccess()
  175. }
  176. // 设备离线,设备暂停营业或复位失败
  177. if(e.data.msgCode=="PAUSE" || e.data.msgCode == "FW_FAIL"){
  178. this.devError()
  179. }
  180. }
  181. }
  182. })
  183. },
  184. onUnload() {
  185. // 开始复位时关闭当前页面
  186. if(this.status = 'reseting'){
  187. // 关闭socket
  188. this.$store.commit("$closeWebsocket");
  189. }
  190. },
  191. methods: {
  192. // 电话客服
  193. callPhone () {
  194. uni.makePhoneCall({
  195. phoneNumber: '15202957025'
  196. })
  197. },
  198. // 倒计时结束时,自动完成洗车订单
  199. endDtime() {
  200. this.washCarSuccess()
  201. },
  202. // 操作按钮
  203. startWork() {
  204. let _this = this
  205. let cmd = {
  206. orderNo: this.orderNo, // 订单编号
  207. washType: this.washCarType,// 洗车模式
  208. }
  209. // 启动
  210. if (this.status == 'start') {
  211. cmd.operateType = 'start' //操作命令
  212. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  213. this.showStart = true
  214. this.$store.state.vuex_workStatus = 'start'
  215. setTimeout(()=>{
  216. this.startWashCarSuccess()
  217. },3000)
  218. }
  219. // 急停
  220. if (this.status == 'working') {
  221. uni.showModal({
  222. title: '提示',
  223. content: '确定紧急停止洗车机?',
  224. success: function (res) {
  225. if (res.confirm) {
  226. cmd.operateType = 'stop' //操作命令
  227. _this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  228. _this.status = 'stop'
  229. }
  230. }
  231. });
  232. }
  233. },
  234. // 启动成功
  235. startWashCarSuccess(){
  236. this.status = 'working';
  237. this.$store.state.vuex_workStatus = 'working'
  238. this.curWorkStutesText='设备已启动';
  239. this.showStart = false;
  240. this.step = 0;
  241. // 进度条,服务时间根据不同的服务类型而不同
  242. let serverTime = this.washDuration/60
  243. this.interId = setInterval(()=>{
  244. // 小于60时说明洗车机正在工作中
  245. if(this.step<=60){
  246. this.loading(this.step++)
  247. }else{
  248. // 洗车机正常状态下工作结束
  249. this.washCarSuccess()
  250. }
  251. },1000*serverTime)
  252. },
  253. // 设备停止成功
  254. stopWashCarSuccess(){
  255. this.$store.state.vuex_workStatus = 'stop'
  256. this.curWorkStutesText='设备已停止';
  257. this.resetLoadingStatus();
  258. },
  259. // 设备异常
  260. devError(){
  261. this.stopWashCarSuccess();
  262. // 关闭socket
  263. this.$store.commit("$closeWebsocket");
  264. uni.showModal({
  265. title: '提示',
  266. content: '设备异常,请联系客服',
  267. showCancel: false,
  268. success: function (res) {
  269. if (res.confirm) {
  270. uni.navigateBack()
  271. }
  272. }
  273. });
  274. },
  275. // 洗车完成
  276. washCarSuccess(){
  277. this.status = "success";
  278. this.$store.state.vuex_workStatus = 'stop'
  279. this.curWorkStutesText='洗车已结束';
  280. this.resetLoadingStatus();
  281. uni.showModal({
  282. title: '提示',
  283. content: '洗车已结束',
  284. showCancel: false,
  285. success: function (res) {
  286. if (res.confirm) {
  287. uni.navigateBack()
  288. }
  289. }
  290. });
  291. // 关闭socket
  292. this.$store.commit("$closeWebsocket")
  293. },
  294. // 重置到进度条初始状态
  295. resetLoadingStatus(){
  296. // 停止进度
  297. this.rdeg= -135;
  298. this.ldeg= -135;
  299. clearInterval(this.interId);
  300. },
  301. // 洗车机进度条动画
  302. loading(second) {
  303. if (second <= 30) {
  304. this.rdeg = -135 + 6 * second;
  305. this.ldeg = -135;
  306. } else {
  307. this.rdeg = 45;
  308. this.ldeg = -135 + 6 * (second - 30);
  309. }
  310. },
  311. // 归位机器
  312. resetRabt(){
  313. // 归位命令
  314. let cmd = {
  315. orderNo: this.orderNo, // 订单编号
  316. operateType: 'reset', //操作命令
  317. washType: this.washCarType,// 洗车模式
  318. }
  319. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  320. },
  321. // 归位结束后
  322. resetRabtSuccess(){
  323. this.curWorkStutesText='设备已归位';
  324. this.status = 'reseting';
  325. this.$store.state.vuex_workStatus = 'stop';
  326. // 关闭socket
  327. this.$store.commit("$closeWebsocket");
  328. uni.redirectTo({
  329. url:"/pages/work/success/success"
  330. })
  331. }
  332. }
  333. };
  334. </script>
  335. <style lang="scss">
  336. // 扇形圆环
  337. .circle_process {
  338. position: absolute;
  339. width: 390rpx;
  340. height: 390rpx;
  341. }
  342. .circle_process .wrapper {
  343. width: 195rpx;
  344. height: 390rpx;
  345. position: absolute;
  346. top: 0;
  347. overflow: hidden;
  348. }
  349. .circle_process .right {
  350. right: 0;
  351. }
  352. .circle_process .left {
  353. left: 0;
  354. }
  355. .circle_process .circle {
  356. width: 390rpx;
  357. height: 390rpx;
  358. border: 20rpx solid transparent;
  359. border-radius: 50%;
  360. position: absolute;
  361. top: 0;
  362. transform: rotate(-135deg);
  363. }
  364. .circle_process .rightcircle {
  365. border-top: 20rpx solid #4CD964;
  366. border-right: 20rpx solid #4CD964;
  367. right: 1px;
  368. }
  369. .circle_process .leftcircle {
  370. border-bottom: 20rpx solid #4CD964;
  371. border-left: 20rpx solid #4CD964;
  372. left: 1px;
  373. }
  374. // 动画
  375. @keyframes mymove {
  376. 0% {
  377. transform: scale(1); /*开始为原始大小*/
  378. opacity: 1;
  379. }
  380. 50% {
  381. transform: scale(1.2); /*放大1.1倍*/
  382. opacity: 0;
  383. }
  384. }
  385. .work-pages {
  386. width: 100%;
  387. .flex-center {
  388. display: flex;
  389. align-items: center;
  390. justify-content: center;
  391. }
  392. .work-cons {
  393. height: 50vh;
  394. background-image: linear-gradient(0deg, #666, #333);
  395. border-bottom-left-radius: 500rpx 50rpx;
  396. border-bottom-right-radius: 500rpx 50rpx;
  397. position: relative;
  398. // 按钮
  399. .work-button-wrap {
  400. width: 400rpx;
  401. margin-top: -50rpx;
  402. .work-button {
  403. background: #666;
  404. border-radius: 100%;
  405. width: 390rpx;
  406. height: 390rpx;
  407. box-shadow:inset 0rpx 2rpx 10rpx #000;
  408. .cirle-one {
  409. background-image: linear-gradient(180deg, #666, #333 30%);
  410. width: 370rpx;
  411. height: 370rpx;
  412. border-radius: 100%;
  413. position: absolute;
  414. box-shadow: 0rpx 2rpx 10rpx #333;
  415. }
  416. .cirle-two {
  417. width: 370rpx;
  418. height: 370rpx;
  419. border-radius: 100%;
  420. position: absolute;
  421. .sector {
  422. transform-origin: center center;
  423. width: 350rpx;
  424. height: 5rpx;
  425. background: #777;
  426. }
  427. }
  428. .cirle-three {
  429. background: #444;
  430. width: 280rpx;
  431. height: 280rpx;
  432. border-radius: 100%;
  433. position: absolute;
  434. box-shadow: inset 0rpx 3rpx 10rpx #000;
  435. }
  436. .cirle-free, .cirle-free-1, .cirle-free-2 {
  437. width: 230rpx;
  438. height: 230rpx;
  439. border-radius: 100%;
  440. position: absolute;
  441. animation: mymove 5s infinite;
  442. }
  443. .cirle-free-1{
  444. width: 210rpx;
  445. height: 210rpx;
  446. animation: mymove 4.5s infinite;
  447. }
  448. .cirle-free-2{
  449. width: 190rpx;
  450. height: 190rpx;
  451. animation: mymove 4s infinite;
  452. }
  453. .cirle-sex {
  454. background-image: linear-gradient(180deg, #888, #333 50%);
  455. box-shadow: 0rpx 5rpx 10rpx #333;
  456. width: 210rpx;
  457. height: 210rpx;
  458. border-radius: 100%;
  459. position: absolute;
  460. color: #ffffff;
  461. font-size: 28rpx;
  462. color: #eee;
  463. &:active {
  464. background-image: linear-gradient(-180deg, #666, #333 80%);
  465. }
  466. }
  467. .w-start {
  468. background: #ffc800;
  469. }
  470. .w-stop {
  471. background: #ff0000;
  472. }
  473. }
  474. .work-button-tips {
  475. color: #eee;
  476. text-align: center;
  477. padding-top: 30rpx;
  478. }
  479. }
  480. }
  481. .work-tips {
  482. padding: 45rpx;
  483. .work-dtime {
  484. text-align: center;
  485. font-weight: bold;
  486. font-size: 34rpx;
  487. }
  488. .work-remarks {
  489. padding-top: 50rpx;
  490. .red {
  491. color: red;
  492. }
  493. .title {
  494. font-weight: bold;
  495. }
  496. }
  497. }
  498. }
  499. </style>