index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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. orderNo: '',// 订单编号
  117. };
  118. },
  119. onLoad(options) {
  120. // 创建websocket
  121. this.$store.commit('$webSocket')
  122. let orderInfo = this.$store.state.vuex_orderInfo
  123. this.washCarType = orderInfo.itemCode
  124. this.orderNo = orderInfo.orderNo
  125. // 监听消息
  126. uni.$on('wsMessage',(e)=>{
  127. console.log(e)
  128. // 进度消息
  129. // 错误消息
  130. // 启动成功
  131. // 紧急停止成功
  132. // 复位成功
  133. })
  134. },
  135. methods: {
  136. // 倒计时结束时,自动完成洗车订单
  137. endDtime() {
  138. this.washCarSuccess()
  139. },
  140. // 操作按钮
  141. startWork() {
  142. let _this = this
  143. // 启动
  144. if (this.status == 'start') {
  145. _this.startWashCar()
  146. }
  147. // 急停
  148. if (this.status == 'working') {
  149. _this.stopWashCar()
  150. }
  151. },
  152. // 开始启动机器洗车
  153. startWashCar(){
  154. // 启动命令
  155. let cmd = {
  156. orderNo: this.orderNo, // 订单编号
  157. operateType: 'start', //操作命令
  158. washType: this.washCarType,// 洗车模式
  159. }
  160. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  161. this.step= 0;
  162. this.showStart = true;
  163. // 启动成功
  164. setTimeout(() => {
  165. this.status = 'working';
  166. this.curWorkStutesText='设备已启动';
  167. this.showStart = false;
  168. // 进度条,服务时间根据不同的服务类型而不同
  169. let serverTime = 7
  170. console.log(this.step,'step')
  171. this.interId = setInterval(()=>{
  172. // 小于60时说明洗车机正在工作中
  173. if(this.step<=60){
  174. this.loading(this.step++)
  175. }else{
  176. // 洗车机正常状态下工作结束
  177. this.washCarSuccess()
  178. }
  179. },1000*serverTime)
  180. }, 3000);
  181. },
  182. // 紧急停止
  183. stopWashCar(){
  184. let _this = this
  185. uni.showModal({
  186. title: '提示',
  187. content: '确定紧急停止洗车机?',
  188. success: function (res) {
  189. if (res.confirm) {
  190. // 停止命令
  191. let cmd = {
  192. orderNo: _this.orderNo, // 订单编号
  193. operateType: 'stop', //操作命令
  194. washType: _this.washCarType,// 洗车模式
  195. }
  196. _this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  197. // 显示急停提示弹框
  198. _this.showStop = true;
  199. _this.status = 'stop';
  200. _this.curWorkStutesText='设备正在紧急停止';
  201. _this.resetLoadingStatus();
  202. }
  203. }
  204. });
  205. },
  206. // 洗车完成
  207. washCarSuccess(){
  208. this.status = "success";
  209. this.curWorkStutesText='洗车完成';
  210. this.resetLoadingStatus();
  211. // 关闭socket
  212. this.$store.commit("$closeWebsocket")
  213. uni.showModal({
  214. title: '提示',
  215. content: '洗车已结束?',
  216. showCancel: false,
  217. success: function (res) {
  218. if (res.confirm) {
  219. uni.redirectTo({
  220. url: "/pages/order/orderDetail"
  221. })
  222. }
  223. }
  224. });
  225. },
  226. // 重置到进度条初始状态
  227. resetLoadingStatus(){
  228. // 停止进度
  229. this.rdeg= -135;
  230. this.ldeg= -135;
  231. clearInterval(this.interId);
  232. },
  233. // 洗车机进度条动画
  234. loading(second) {
  235. if (second <= 30) {
  236. this.rdeg = -135 + 6 * second;
  237. this.ldeg = -135;
  238. } else {
  239. this.rdeg = 45;
  240. this.ldeg = -135 + 6 * (second - 30);
  241. }
  242. },
  243. // 电话客服
  244. callPhone () {
  245. uni.makePhoneCall({
  246. phoneNumber: '15202957025'
  247. })
  248. },
  249. // 归位机器
  250. resetRabt(){
  251. // 归位命令
  252. let cmd = {
  253. orderNo: this.orderNo, // 订单编号
  254. operateType: 'reset', //操作命令
  255. washType: this.washCarType,// 洗车模式
  256. }
  257. this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
  258. this.status = 'reseting';
  259. this.curWorkStutesText='设备正在归位';
  260. this.showStart = true;
  261. this.showStop = false;
  262. // 归位结束后
  263. setTimeout(()=>{
  264. // 关闭socket
  265. this.$store.commit("$closeWebsocket")
  266. uni.redirectTo({
  267. url:"/pages/work/success/success"
  268. })
  269. },3000)
  270. },
  271. }
  272. };
  273. </script>
  274. <style lang="scss">
  275. // 扇形圆环
  276. .circle_process {
  277. position: absolute;
  278. width: 390rpx;
  279. height: 390rpx;
  280. }
  281. .circle_process .wrapper {
  282. width: 195rpx;
  283. height: 390rpx;
  284. position: absolute;
  285. top: 0;
  286. overflow: hidden;
  287. }
  288. .circle_process .right {
  289. right: 0;
  290. }
  291. .circle_process .left {
  292. left: 0;
  293. }
  294. .circle_process .circle {
  295. width: 390rpx;
  296. height: 390rpx;
  297. border: 20rpx solid transparent;
  298. border-radius: 50%;
  299. position: absolute;
  300. top: 0;
  301. transform: rotate(-135deg);
  302. }
  303. .circle_process .rightcircle {
  304. border-top: 20rpx solid #4CD964;
  305. border-right: 20rpx solid #4CD964;
  306. right: 1px;
  307. }
  308. .circle_process .leftcircle {
  309. border-bottom: 20rpx solid #4CD964;
  310. border-left: 20rpx solid #4CD964;
  311. left: 1px;
  312. }
  313. // 动画
  314. @keyframes mymove {
  315. 0% {
  316. transform: scale(1); /*开始为原始大小*/
  317. opacity: 1;
  318. }
  319. 50% {
  320. transform: scale(1.2); /*放大1.1倍*/
  321. opacity: 0;
  322. }
  323. }
  324. .work-pages {
  325. width: 100%;
  326. .flex-center {
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. }
  331. .work-cons {
  332. height: 50vh;
  333. background-image: linear-gradient(0deg, #666, #333);
  334. border-bottom-left-radius: 500rpx 50rpx;
  335. border-bottom-right-radius: 500rpx 50rpx;
  336. position: relative;
  337. // 按钮
  338. .work-button-wrap {
  339. width: 400rpx;
  340. margin-top: -50rpx;
  341. .work-button {
  342. background: #666;
  343. border-radius: 100%;
  344. width: 390rpx;
  345. height: 390rpx;
  346. box-shadow:inset 0rpx 2rpx 10rpx #000;
  347. .cirle-one {
  348. background-image: linear-gradient(180deg, #666, #333 30%);
  349. width: 370rpx;
  350. height: 370rpx;
  351. border-radius: 100%;
  352. position: absolute;
  353. box-shadow: 0rpx 2rpx 10rpx #333;
  354. }
  355. .cirle-two {
  356. width: 370rpx;
  357. height: 370rpx;
  358. border-radius: 100%;
  359. position: absolute;
  360. .sector {
  361. transform-origin: center center;
  362. width: 350rpx;
  363. height: 5rpx;
  364. background: #777;
  365. }
  366. }
  367. .cirle-three {
  368. background: #444;
  369. width: 280rpx;
  370. height: 280rpx;
  371. border-radius: 100%;
  372. position: absolute;
  373. box-shadow: inset 0rpx 3rpx 10rpx #000;
  374. }
  375. .cirle-free, .cirle-free-1, .cirle-free-2 {
  376. width: 230rpx;
  377. height: 230rpx;
  378. border-radius: 100%;
  379. position: absolute;
  380. animation: mymove 5s infinite;
  381. }
  382. .cirle-free-1{
  383. width: 210rpx;
  384. height: 210rpx;
  385. animation: mymove 4.5s infinite;
  386. }
  387. .cirle-free-2{
  388. width: 190rpx;
  389. height: 190rpx;
  390. animation: mymove 4s infinite;
  391. }
  392. .cirle-sex {
  393. background-image: linear-gradient(180deg, #888, #333 50%);
  394. box-shadow: 0rpx 5rpx 10rpx #333;
  395. width: 210rpx;
  396. height: 210rpx;
  397. border-radius: 100%;
  398. position: absolute;
  399. color: #ffffff;
  400. font-size: 28rpx;
  401. color: #eee;
  402. &:active {
  403. background-image: linear-gradient(-180deg, #666, #333 80%);
  404. }
  405. }
  406. .w-start {
  407. background: #ffc800;
  408. }
  409. .w-stop {
  410. background: #ff0000;
  411. }
  412. }
  413. .work-button-tips {
  414. color: #eee;
  415. text-align: center;
  416. padding-top: 30rpx;
  417. }
  418. }
  419. }
  420. .work-tips {
  421. padding: 45rpx;
  422. .work-dtime {
  423. text-align: center;
  424. font-weight: bold;
  425. font-size: 34rpx;
  426. }
  427. .work-remarks {
  428. padding-top: 50rpx;
  429. .red {
  430. color: red;
  431. }
  432. .title {
  433. font-weight: bold;
  434. }
  435. }
  436. }
  437. }
  438. </style>