index.vue 11 KB

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