index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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-sex flex-center" @tap="startWork">
  22. {{ status == 'working' ? '紧急停止' : '点击启动' }}
  23. </view>
  24. </view>
  25. <!-- 状态提示 -->
  26. <view class="work-button-tips">
  27. {{status == 'start' ? "设备准备就绪" : "设备启动中"}}
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 说明提示 -->
  32. <view class="work-tips">
  33. <view>
  34. <view class="work-dtime" v-if="status=='start'">
  35. 距离订单强制完成还剩
  36. <u-count-down
  37. @change="changeDtime"
  38. separator="zh"
  39. font-size="36"
  40. separator-size="28"
  41. color="#ff0000"
  42. :timestamp="timestamp"
  43. :show-days="false"
  44. :show-hours="false"
  45. ></u-count-down>
  46. </view>
  47. <view class="work-remarks">
  48. <view class="title">说明:</view>
  49. <view v-if="status=='start'">
  50. 支付完成后
  51. <text class="red">请尽快启动洗车服务</text>
  52. ,否则订单将在5分钟后自动完成。
  53. </view>
  54. <view v-else>
  55. <view>设备启动中请注意安全,如果设备工作中出现故障,请按紧急停止按钮或联系客服。</view>
  56. <view @click="callPhone">如有疑问,请联系客服:<text>400-xxx-xxx</text> </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 正在启动,归位弹框提示 -->
  62. <u-popup v-model="showStart" :mask-close-able="false" border-radius="10" mode="center" width="500rpx" height="400rpx">
  63. <view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
  64. <!-- 启动中 -->
  65. <view v-if="status == 'start'">
  66. <u-image width="216px" height="120px" src="/static/img/start.png"></u-image>
  67. <view style="padding: 15rpx;">洗车机正在启动...</view>
  68. </view>
  69. <!-- 归位中 -->
  70. <view v-if="status == 'reseting'">
  71. <u-image width="216px" height="120px" src="/static/img/reset.png"></u-image>
  72. <view style="padding: 15rpx;">洗车机正在归位中...</view>
  73. </view>
  74. </view>
  75. </u-popup>
  76. <!-- 急停提示弹框 -->
  77. <u-popup v-model="showStop" :mask-close-able="false" border-radius="10" mode="center" width="80%">
  78. <view style="padding: 30rpx;text-align: center;">
  79. <view>
  80. <view style="font-weight: bold;">设备提示</view>
  81. <view style="display: flex;justify-content: center;padding: 10rpx 0;">
  82. <u-image width="165px" height="138px" src="/static/img/sbts.png"></u-image>
  83. </view>
  84. <u-divider>可能原因</u-divider>
  85. <view style="padding: 15rpx;text-align: left;">
  86. <view>1、洗车机紧急停止,本次服务结束</view>
  87. <view>2、因设备故障无法继续为您服务,所支付金额将退至您的支付账户</view>
  88. <view>3、如需再次服务,请退出车辆重新进入,再扫码支付洗车</view>
  89. <view>4、如需帮助请联系客服</view>
  90. </view>
  91. <view style="display: flex;padding: 20rpx 0;justify-content: center;">
  92. <u-button @click="callPhone" style="width: 45%;border-radius: 0;margin-right: 5%;">联系客服</u-button>
  93. <u-button @click="resetRabt" style="width: 45%;" type="error">洗车机归位</u-button>
  94. </view>
  95. </view>
  96. </view>
  97. </u-popup>
  98. </view>
  99. </template>
  100. <script>
  101. export default {
  102. data() {
  103. return {
  104. timestamp: 300, // 初始情况下5分钟后自动结束
  105. rdeg: -135, // 进度条初始角度
  106. ldeg: -135, /// 进度条初始角度
  107. step: 0, // 进度条增值,共60步
  108. interId: null, // 进度时间id
  109. status: 'start', // 状态,start 开始启动,working 正在工作,stop急停,reseting 归位中
  110. showStart: false ,// 启动弹框提示
  111. showStop: false, // 急停提示
  112. washCarType: 1, // 洗车服务类型,不同的类型对应的时间不一样
  113. };
  114. },
  115. onLoad() {},
  116. methods: {
  117. // 倒计时监听,0 时自动结束订单
  118. changeDtime(time) {
  119. console.log(time);
  120. if(time==0){
  121. this.washCarSuccess()
  122. }
  123. },
  124. // 启动,急停按钮
  125. startWork() {
  126. let _this = this
  127. // 启动
  128. if (this.status == 'start') {
  129. _this.startWashCar()
  130. }
  131. // 急停
  132. if (this.status == 'working') {
  133. _this.stopWashCar()
  134. }
  135. },
  136. // 开始启动机器洗车
  137. startWashCar(){
  138. this.showStart = true;
  139. // 启动成功
  140. setTimeout(() => {
  141. this.status = 'working';
  142. this.showStart = false;
  143. // 进度条,服务时间根据不同的服务类型而不同
  144. let serverTime = 1
  145. this.interId = setInterval(()=>{
  146. // 小于60时说明洗车机正在工作中
  147. if(this.step<=60){
  148. this.loading(this.step++)
  149. }else{
  150. // 洗车机正常状态下工作结束
  151. this.washCarSuccess()
  152. }
  153. },1000*serverTime)
  154. }, 3000);
  155. },
  156. // 紧急停止
  157. stopWashCar(){
  158. let _this = this
  159. uni.showModal({
  160. title: '提示',
  161. content: '确定紧急停止洗车机?',
  162. success: function (res) {
  163. if (res.confirm) {
  164. // 显示急停提示弹框
  165. _this.showStop = true;
  166. _this.status = 'stop';
  167. _this.resetLoadingStatus();
  168. }
  169. }
  170. });
  171. },
  172. // 洗车完成
  173. washCarSuccess(){
  174. uni.showModal({
  175. title: '提示',
  176. content: '洗车已结束?',
  177. showCancel: false,
  178. confirmText: "确定并查看订单",
  179. success: function (res) {
  180. if (res.confirm) {
  181. uni.redirectTo({
  182. url: "/pages/order/orderDetail"
  183. })
  184. }
  185. }
  186. });
  187. },
  188. // 重置到进度条初始状态
  189. resetLoadingStatus(){
  190. // 停止进度
  191. this.rdeg= -135;
  192. this.ldeg= -135;
  193. this.step= 0;
  194. clearInterval(this.interId);
  195. },
  196. // 洗车机进度条动画
  197. loading(second) {
  198. if (second <= 30) {
  199. this.rdeg = -135 + 6 * second;
  200. this.ldeg = -135;
  201. } else {
  202. this.rdeg = 45;
  203. this.ldeg = -135 + 6 * (second - 30);
  204. }
  205. },
  206. // 电话客服
  207. callPhone () {
  208. uni.makePhoneCall({
  209. phoneNumber: '15202957025'
  210. })
  211. },
  212. // 归位机器
  213. resetRabt(){
  214. this.status = 'reseting';
  215. this.showStart = true;
  216. this.showStop = false;
  217. // 归位结束后
  218. setTimeout(()=>{
  219. uni.redirectTo({
  220. url:"/pages/work/success/success"
  221. })
  222. },3000)
  223. },
  224. }
  225. };
  226. </script>
  227. <style lang="scss">
  228. // 扇形圆环
  229. .circle_process {
  230. position: absolute;
  231. width: 390rpx;
  232. height: 390rpx;
  233. }
  234. .circle_process .wrapper {
  235. width: 195rpx;
  236. height: 390rpx;
  237. position: absolute;
  238. top: 0;
  239. overflow: hidden;
  240. }
  241. .circle_process .right {
  242. right: 0;
  243. }
  244. .circle_process .left {
  245. left: 0;
  246. }
  247. .circle_process .circle {
  248. width: 390rpx;
  249. height: 390rpx;
  250. border: 20rpx solid transparent;
  251. border-radius: 50%;
  252. position: absolute;
  253. top: 0;
  254. transform: rotate(-135deg);
  255. }
  256. .circle_process .rightcircle {
  257. border-top: 20rpx solid red;
  258. border-right: 20rpx solid red;
  259. right: 1px;
  260. }
  261. .circle_process .leftcircle {
  262. border-bottom: 20rpx solid red;
  263. border-left: 20rpx solid red;
  264. left: 1px;
  265. }
  266. .work-pages {
  267. width: 100%;
  268. .flex-center {
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. }
  273. .work-cons {
  274. height: 50vh;
  275. background-image: linear-gradient(0deg, #666, #333);
  276. border-bottom-left-radius: 500rpx 50rpx;
  277. border-bottom-right-radius: 500rpx 50rpx;
  278. position: relative;
  279. // 按钮
  280. .work-button-wrap {
  281. width: 400rpx;
  282. margin-top: -50rpx;
  283. .work-button {
  284. background: #666;
  285. border-radius: 100%;
  286. width: 390rpx;
  287. height: 390rpx;
  288. .cirle-one {
  289. background-image: linear-gradient(180deg, #555, #333 20%);
  290. width: 370rpx;
  291. height: 370rpx;
  292. border-radius: 100%;
  293. position: absolute;
  294. }
  295. .cirle-two {
  296. width: 370rpx;
  297. height: 370rpx;
  298. border-radius: 100%;
  299. position: absolute;
  300. .sector {
  301. transform-origin: center center;
  302. width: 350rpx;
  303. height: 5rpx;
  304. background: #888;
  305. }
  306. }
  307. .cirle-three {
  308. background: #444;
  309. width: 280rpx;
  310. height: 280rpx;
  311. border-radius: 100%;
  312. position: absolute;
  313. }
  314. .cirle-free {
  315. width: 230rpx;
  316. height: 230rpx;
  317. border-radius: 100%;
  318. position: absolute;
  319. animation: mymove 5s infinite;
  320. }
  321. @keyframes mymove {
  322. 0% {
  323. transform: scale(1); /*开始为原始大小*/
  324. opacity: 1;
  325. }
  326. 25% {
  327. transform: scale(1.1); /*放大1.1倍*/
  328. opacity: 0.5;
  329. }
  330. 50% {
  331. transform: scale(1);
  332. opacity: 1;
  333. }
  334. 75% {
  335. transform: scale(1.1);
  336. opacity: 0.5;
  337. }
  338. }
  339. .cirle-sex {
  340. background-image: linear-gradient(180deg, #888, #333 50%);
  341. width: 210rpx;
  342. height: 210rpx;
  343. border-radius: 100%;
  344. position: absolute;
  345. color: #ffffff;
  346. font-size: 28rpx;
  347. color: #eee;
  348. &:active {
  349. background-image: linear-gradient(180deg, #888, #333 80%);
  350. }
  351. }
  352. .w-start {
  353. background: #ffc800;
  354. }
  355. .w-stop {
  356. background: #ff0000;
  357. }
  358. }
  359. .work-button-tips {
  360. color: #eee;
  361. text-align: center;
  362. padding-top: 30rpx;
  363. }
  364. }
  365. }
  366. .work-tips {
  367. padding: 45rpx;
  368. .work-dtime {
  369. text-align: center;
  370. font-weight: bold;
  371. font-size: 34rpx;
  372. }
  373. .work-remarks {
  374. padding-top: 50rpx;
  375. .red {
  376. color: red;
  377. }
  378. .title {
  379. font-weight: bold;
  380. }
  381. }
  382. }
  383. }
  384. </style>