index.vue 13 KB

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