index.vue 12 KB

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