service.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. <template>
  2. <view class="service-home">
  3. <view class="ongoing" v-if="goingOrder" @click="onGoing">
  4. 您有一个正在进行中的订单
  5. </view>
  6. <view class="mobile-frame" v-show="frameIshow">
  7. <view class="frame">
  8. <image src="../../static/image/tips.png" mode=""></image>
  9. <view class="title">
  10. 当前操作需要授权手机号
  11. </view>
  12. <view class="submit">
  13. <button type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即授权</button>
  14. </view>
  15. </view>
  16. <view class="close" @click="frameIshow=false">
  17. <image src="../../static/image/close-white.png" mode=""></image>
  18. </view>
  19. </view>
  20. <view class="top">
  21. <view class="title">
  22. 设备信息
  23. </view>
  24. <view class="top-content">
  25. <view class="left">
  26. <image src="../../static/image/machine.png" mode=""></image>
  27. </view>
  28. <view class="right">
  29. <view class="text">
  30. 编号:{{detail.no ? detail.no : 0}}
  31. </view>
  32. <view class="text">
  33. 水位:{{detail.water_level_warning_text ? detail.water_level_warning_text :0}}
  34. </view>
  35. <view class="text">
  36. 温度:{{detail.temperature ? detail.temperature : 0}}℃
  37. </view>
  38. <view class="text">
  39. 水质:{{detail.water_quality ? detail.water_quality : 0}}mg/L
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="list" v-if="type!==0">
  45. <view class="title">
  46. 气路选择
  47. </view>
  48. <view class="list-item" :class="currentList==index?'listActive':''" v-for="(item,index) in list"
  49. :key='index' @click="changeList(index)">
  50. <view class="list-title">
  51. {{item.name}}
  52. </view>
  53. <!-- <view class="text">
  54. 300
  55. </view> -->
  56. <view class="time">
  57. ¥{{item.money}}/分钟
  58. </view>
  59. </view>
  60. </view>
  61. <view class="select-time">
  62. <view class="title">
  63. 时间选择
  64. </view>
  65. <view class="time-list">
  66. <view class="time-item" :class="currentTime==index?'timeActive':''" @click="changeTime(index)"
  67. v-for="(item,index) in timeList" :key='index'>
  68. {{item.time}}分钟
  69. </view>
  70. <view class="time-item" :class="currentTime==-1?'timeActive':''" @click="changeTime(-1)">
  71. 自定义
  72. </view>
  73. </view>
  74. <view class="customTime" v-show="isShow">
  75. <input type="number" value="" placeholder="请输入时间(最大输入240分钟)" v-model="customTime"
  76. @input="inputCustom()" />
  77. </view>
  78. </view>
  79. <!-- 确认支付底部弹框 -->
  80. <view class="frame-border" v-show="surePay">
  81. <view class="frame">
  82. <view class="close" @click="surePay=false">
  83. <image src="../../static/image/close.png" mode=""></image>
  84. </view>
  85. <view class="frame-content" v-if="prePay.isTimePay==false">
  86. <view class="title" v-if="type!==0">
  87. 当前模式:{{sureMessage.name}}
  88. </view>
  89. <view class="title">
  90. <text>服务时长:{{sureMessage.work_time}}分钟</text><text class="money">¥{{prePay.time_money}}</text>
  91. </view>
  92. <view class="tips" v-if="prePay.meTime!==0 && prePay.isTimePay==false">
  93. <text>您的吸氢卡剩余时长({{prePay.meTime}}分钟)不足,本次吸氢将采用微信支付</text>
  94. </view>
  95. <!-- <view class="tips">
  96. 计费规则
  97. </view> -->
  98. <view class="tips-content">
  99. <text>确认支付之后,若中途关闭设备,将按实际使用时间扣费(最少使用30分钟不满三十分钟将按30分钟扣费),多出费用将在结束订单时原路退还</text>
  100. </view>
  101. </view>
  102. <view class="frame-content" v-if="prePay.isTimePay==true">
  103. <view class="title" v-if="type!==0">
  104. 当前模式:{{sureMessage.name}}
  105. </view>
  106. <view class="title">
  107. <text>服务时长:{{sureMessage.work_time}}分钟</text>
  108. </view>
  109. <view class="title">
  110. <text>吸氢卡剩余时长:{{prePay.meTime}}分钟</text>
  111. </view>
  112. <view class="tips" v-if="sureMessage.work_type==2 && prePay.isTimePay==true">
  113. <text>您选择的吸氢模式为AB双路吸氢,本次服务将扣除2倍时长</text>
  114. </view>
  115. <view class="tips" style="font-size: 32upx; font-weight: 500;">
  116. <text>本次吸氢将使用吸氢卡的剩余时长,中途提前结束将返还多余时长</text>
  117. </view>
  118. </view>
  119. <view class="frame-submit" @click="configPayment()">
  120. 确认支付
  121. </view>
  122. </view>
  123. </view>
  124. <view class="submit" @click="payMent()">
  125. 立即支付
  126. </view>
  127. <!-- 支付成功弹框 -->
  128. <view class="success-frame" v-show="skipShow">
  129. <view class="success-content">
  130. <image src="../../static/image/success.png" mode=""></image>
  131. <view class="text">
  132. 支付成功,即将在{{count}}后跳转
  133. </view>
  134. <view class="skip" @click="jumpNow()">
  135. 立即跳转
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. var app = getApp()
  143. export default {
  144. data() {
  145. return {
  146. type: 0, //设备类型
  147. frameIshow: false,
  148. list: [{
  149. name: "A气路",
  150. money: app.globalData.a_minute_money
  151. },
  152. {
  153. name: "B气路",
  154. money: app.globalData.b_minute_money
  155. },
  156. {
  157. name: "AB气路",
  158. money: app.globalData.ab_minute_money
  159. }
  160. ],
  161. sureMessage: {
  162. work_type: '',
  163. name: '',
  164. work_time: '',
  165. device_id: '',
  166. shop_id: ''
  167. },
  168. prePay: '', //预支付结果
  169. currentList: 0,
  170. currentTime: 0,
  171. isShow: false,
  172. surePay: false, //确认支付
  173. count: 10,
  174. skipShow: false, //跳转
  175. detail: "",
  176. // time1: ['30','60','120'
  177. // ],
  178. timeList: [{
  179. id: 0,
  180. time: 60
  181. },
  182. {
  183. id: 1,
  184. time: 120
  185. },
  186. {
  187. id: 2,
  188. time: 180
  189. },
  190. ],
  191. customTime: '', //自定义时间
  192. goingOrder: ''
  193. }
  194. },
  195. created() {
  196. if (this.skipShow == true) {
  197. this.countDown();
  198. }
  199. },
  200. onShow() {
  201. app.request('/order/is-server-exist', '', 'get').then(res => {
  202. console.log(res, '是否有进行中订单')
  203. this.goingOrder = res.data.data.no
  204. })
  205. },
  206. onLoad(options) {
  207. let that = this
  208. setTimeout(function() {
  209. console.log(app.globalData.is_auth, 'ppppp')
  210. if (app.globalData.is_auth == true) {
  211. that.frameIshow = false
  212. } else {
  213. that.frameIshow = true
  214. }
  215. }, 2000)
  216. console.log(options)
  217. if (options.q !== undefined) {
  218. let scan = decodeURIComponent(options.q);
  219. let n1 = scan.length; //地址的总长度
  220. let n2 = scan.indexOf("="); //取得=号的位置
  221. let id = scan.substr(n2 + 1, n1 - n2); //从=号后面的内容
  222. let params = {
  223. no: id
  224. }
  225. console.log("000000")
  226. this.equipmentDetail(params)
  227. } else
  228. if (options.id) {
  229. let params = {
  230. id: options.id
  231. }
  232. console.log("1111")
  233. this.equipmentDetail(params)
  234. } else {
  235. let params = {
  236. no: options.device_no
  237. }
  238. console.log("22222")
  239. this.equipmentDetail(params)
  240. }
  241. },
  242. methods: {
  243. //获取手机号
  244. getPhoneNumber: function(e) {
  245. console.log(e.detail)
  246. let data = {
  247. session_key: uni.getStorageSync('session_key'),
  248. iv: e.detail.iv,
  249. encryptedData: e.detail.encryptedData
  250. }
  251. app.request('/user/sync-mobile', data, 'post').then(res => {
  252. this.frameIshow = false
  253. app.globalData.is_auth = true
  254. })
  255. },
  256. //设备详情
  257. equipmentDetail: function(params) {
  258. uni.showLoading()
  259. app.request('/device', params, 'get').then(res => {
  260. console.log(res.data.data.data.shop.times, '设备详情')
  261. this.type = res.data.data.data.type
  262. this.detail = res.data.data.data
  263. var time = res.data.data.data.shop.times
  264. // if(res.data.data.data.shop.times){
  265. // this.timeList=time
  266. // }
  267. uni.setStorageSync('device_no', res.data.data.data.no)
  268. this.sureMessage = {
  269. work_type: 0,
  270. name: this.list[0].name,
  271. work_time: this.timeList[0].time,
  272. device_id: this.detail.id,
  273. shop_id: this.detail.shop_id
  274. }
  275. this.list = [{
  276. name: "A气路",
  277. money: res.data.data.data.shop.a_minute_money
  278. },
  279. {
  280. name: "B气路",
  281. money: res.data.data.data.shop.b_minute_money
  282. },
  283. {
  284. name: "AB气路",
  285. money: res.data.data.data.shop.ab_minute_money
  286. }
  287. ],
  288. uni.hideLoading()
  289. })
  290. },
  291. changeList: function(e) {
  292. this.currentList = e
  293. this.sureMessage.name = this.list[e].name
  294. this.sureMessage.work_type = e
  295. },
  296. inputCustom: function() {
  297. this.sureMessage.work_time = this.customTime
  298. },
  299. changeTime: function(e) {
  300. console.log(e)
  301. if (e == -1) {
  302. console.log(this.customTime)
  303. this.isShow = true
  304. this.sureMessage.work_time = ''
  305. } else {
  306. console.log(this.customTime)
  307. this.isShow = false
  308. this.sureMessage.work_time = this.timeList[e].time
  309. }
  310. this.currentTime = e
  311. },
  312. //预支付
  313. payMent: function() {
  314. // surePay=true
  315. if (!this.sureMessage.work_time) {
  316. uni.showToast({
  317. title: "请输入时间",
  318. icon: 'none'
  319. })
  320. } else if (this.sureMessage.work_time > 240) {
  321. uni.showModal({
  322. showCancel: false,
  323. title: '提示',
  324. content: '时间不能大于240分钟'
  325. })
  326. } else {
  327. let params = {
  328. work_type: this.sureMessage.work_type,
  329. work_time: this.sureMessage.work_time,
  330. device_id: this.sureMessage.device_id,
  331. shop_id: this.sureMessage.shop_id,
  332. is_prepay: 1
  333. }
  334. app.request('/order', params, 'post').then(res => {
  335. console.log(res, '确认支付')
  336. if (res.statusCode == 200) {
  337. // this.payMoney = res.data.data.time_money
  338. this.prePay = res.data.data
  339. this.surePay = true
  340. } else {
  341. // uni.showToast({
  342. // title: res.data.message,
  343. // icon: 'none'
  344. // })
  345. }
  346. })
  347. }
  348. },
  349. //正在进行中的订单
  350. onGoing: function() {
  351. uni.navigateTo({
  352. url: './order?order_no=' + this.goingOrder
  353. })
  354. },
  355. //确认支付
  356. configPayment: function() {
  357. let params = {
  358. work_type: this.sureMessage.work_type,
  359. work_time: this.sureMessage.work_time,
  360. device_id: this.sureMessage.device_id,
  361. shop_id: this.sureMessage.shop_id,
  362. }
  363. app.request('/order', params, 'post').then(res => {
  364. console.log(res, '确认支付')
  365. if (res.statusCode == 200) {
  366. let data = res.data.data
  367. if (this.prePay.isTimePay == true) {
  368. let order_no = data.order_no
  369. uni.reLaunch({
  370. url: './order?order_no=' + order_no
  371. })
  372. } else if (data.is_pay == false) {
  373. let order_no = data.order_no
  374. uni.reLaunch({
  375. url: './order?order_no=' + order_no
  376. })
  377. } else {
  378. let order_no = res.data.data.no
  379. uni.setStorageSync('order_no', res.data.data.no)
  380. uni.setStorageSync('device_id', this.sureMessage.device_id)
  381. uni.setStorageSync('work_time', this.sureMessage.work_time)
  382. uni.requestPayment({
  383. provider: 'wxpay',
  384. timeStamp: res.data.data.timeStamp,
  385. nonceStr: res.data.data.nonceStr,
  386. package: res.data.data.package,
  387. signType: res.data.data.signType,
  388. paySign: res.data.data.paySign,
  389. appId: res.data.data.appId,
  390. success: function(res) {
  391. console.log('success:' + JSON.stringify(res));
  392. uni.navigateTo({
  393. url: './surePay?order_no=' + order_no
  394. })
  395. },
  396. fail: function(err) {
  397. console.log('fail:' + JSON.stringify(err));
  398. console.log(res.data.data.timeStamp)
  399. console.log(res.data.data.timeStamp.toString())
  400. console.log(typeof(res.data.data.package))
  401. }
  402. });
  403. }
  404. // this.skipShow = true
  405. // uni.navigateTo({
  406. // url:'./order'
  407. // })
  408. } else {
  409. uni.showToast({
  410. title: res.data.message,
  411. icon: 'none'
  412. })
  413. }
  414. })
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss" scoped>
  420. .service-home {
  421. background-color: #f4f4f4;
  422. height: 100%;
  423. padding-bottom: 50upx;
  424. .ongoing {
  425. position: fixed;
  426. bottom: 20%;
  427. padding: 20upx;
  428. right: 0;
  429. font-size: 28upx;
  430. background-color: $mine-background-color;
  431. color: #FFFFFF;
  432. border-radius: 50upx 0 0 50upx;
  433. }
  434. .mobile-frame {
  435. position: fixed;
  436. height: 100vh;
  437. width: 100%;
  438. background: rgba($color: #000000, $alpha: 0.6);
  439. z-index: 99999;
  440. top: 0;
  441. .frame {
  442. width: 50%;
  443. margin: 0 auto;
  444. padding: 50upx 30upx;
  445. margin-top: 40%;
  446. border-radius: 12upx;
  447. background-color: #FFFFFF;
  448. text-align: center;
  449. image {
  450. height: 90upx;
  451. width: 90upx;
  452. }
  453. .title {
  454. height: 70upx;
  455. line-height: 70upx;
  456. font-size: 28upx;
  457. }
  458. .submit {
  459. margin: 0 auto;
  460. width: 50%;
  461. margin-top: 30upx;
  462. button {
  463. background-color: $mine-background-color;
  464. height: 70upx;
  465. line-height: 70upx;
  466. text-align: center;
  467. font-size: 26upx;
  468. color: #FFFFFF;
  469. background-color: $mine-background-color;
  470. }
  471. }
  472. }
  473. .close {
  474. margin: 0 auto;
  475. height: 100upx;
  476. width: 100upx;
  477. text-align: center;
  478. margin-top: 10%;
  479. image {
  480. height: 50upx;
  481. width: 50upx;
  482. }
  483. }
  484. }
  485. .top {
  486. padding: 30upx;
  487. .title {
  488. font-size: 34upx;
  489. font-family: PingFang SC;
  490. font-weight: bold;
  491. color: #000000;
  492. }
  493. .top-content {
  494. display: flex;
  495. margin-top: 20upx;
  496. .left {
  497. flex: 0 0 230upx;
  498. height: 187upx;
  499. overflow: hidden;
  500. margin-right: 22upx;
  501. image {
  502. width: 230upx;
  503. height: 100%;
  504. }
  505. }
  506. .right {
  507. flex: 1;
  508. .text {
  509. font-size: 30upx;
  510. font-family: PingFang SC;
  511. font-weight: 400;
  512. color: #000000;
  513. margin-top: 5upx;
  514. }
  515. }
  516. }
  517. }
  518. .list {
  519. margin-top: 80upx;
  520. .title {
  521. padding-left: 30upx;
  522. font-size: 34upx;
  523. font-family: PingFang SC;
  524. font-weight: bold;
  525. color: #000000;
  526. }
  527. .list-item {
  528. margin: 30upx 30upx;
  529. background-color: #FFFFFF;
  530. padding: 20upx 30upx;
  531. position: relative;
  532. .list-title {
  533. font-size: 34upx;
  534. font-family: PingFang SC;
  535. font-weight: 800;
  536. color: #000000;
  537. }
  538. .text {
  539. margin-top: 17upx;
  540. font-size: 24upx;
  541. font-family: PingFang SC;
  542. line-height: 35upx;
  543. color: #B6B6B6;
  544. }
  545. .time {
  546. position: absolute;
  547. right: 30upx;
  548. bottom: 20upx;
  549. font-size: 20upx;
  550. font-family: PingFang SC;
  551. color: #E71600;
  552. }
  553. }
  554. .listActive {
  555. background-color: $mine-background-color;
  556. box-shadow: 0upx 2upx 13upx 0upx rgba(150, 150, 150, 0.35);
  557. margin: 30upx 10upx;
  558. .list-title {
  559. color: #FFFFFF;
  560. font-size: 36upx;
  561. line-height: 40upx;
  562. }
  563. .text {
  564. color: #FFFFFF;
  565. font-size: 26upx;
  566. }
  567. .time {
  568. color: #FFFFFF;
  569. font-size: 22upx;
  570. }
  571. }
  572. }
  573. .select-time {
  574. padding: 30upx 0;
  575. margin-top: 50upx;
  576. .title {
  577. padding: 0 30upx;
  578. font-size: 34upx;
  579. font-family: PingFang SC;
  580. font-weight: bold;
  581. color: #000000;
  582. }
  583. .time-list {
  584. display: flex;
  585. padding: 0 10upx;
  586. margin-top: 25upx;
  587. .time-item {
  588. flex: 1;
  589. margin: 0 10upx;
  590. height: 80upx;
  591. line-height: 80upx;
  592. text-align: center;
  593. font-size: 30upx;
  594. font-family: PingFang SC;
  595. font-weight: 500;
  596. background-color: #FFFFFF;
  597. border-radius: 37upx;
  598. }
  599. .timeActive {
  600. font-weight: bold;
  601. background: $mine-background-color;
  602. font-size: 33upx;
  603. box-shadow: 0upx 2upx 13upx 0upx rgba(150, 150, 150, 0.35);
  604. border-radius: 37upx;
  605. color: #FFFFFF;
  606. }
  607. }
  608. .customTime {
  609. height: 90upx;
  610. background-color: #FFFFFF;
  611. margin: 30upx;
  612. input {
  613. height: 90upx;
  614. padding: 0 30upx;
  615. line-height: 90upx;
  616. font-size: 34upx;
  617. }
  618. }
  619. }
  620. .frame-border {
  621. background-color: rgba($color: #000000, $alpha: 0.5);
  622. height: 100vh;
  623. width: 100%;
  624. position: fixed;
  625. z-index: 99999;
  626. top: 0;
  627. .frame {
  628. background-color: #FFFFFF;
  629. position: absolute;
  630. bottom: 0;
  631. padding: 30upx 0;
  632. width: 100%;
  633. padding-top: 70upx;
  634. .close {
  635. position: absolute;
  636. height: 70upx;
  637. width: 100upx;
  638. top: 0;
  639. right: 0;
  640. image {
  641. margin-left: 20upx;
  642. margin-top: 10upx;
  643. height: 50upx;
  644. width: 50upx;
  645. }
  646. }
  647. .frame-content {
  648. // margin: 0 30upx;
  649. width: 100%;
  650. .title {
  651. font-size: 32upx;
  652. font-family: PingFang SC;
  653. font-weight: bold;
  654. margin: 0 30upx;
  655. line-height: 50upx;
  656. .money {
  657. color: #D22928;
  658. font-size: 32upx;
  659. font-weight: 500;
  660. float: right;
  661. }
  662. }
  663. .tips {
  664. margin-left: 30upx;
  665. font-size: 24upx;
  666. font-family: PingFang SC;
  667. // border-left: 5upx solid #D22E2D;
  668. padding-left: 10upx;
  669. font-weight: bold;
  670. color: #D22E2D;
  671. margin-top: 30upx;
  672. }
  673. .tips-content {
  674. margin: 0 30upx;
  675. margin-top: 30upx;
  676. padding: 25upx 15upx;
  677. background-color: #EEEEEE;
  678. color: #063530;
  679. font-size: 24upx;
  680. line-height: 40upx;
  681. font-family: PingFang SC;
  682. font-weight: 400;
  683. }
  684. }
  685. .frame-submit {
  686. width: 80%;
  687. height: 120upx;
  688. line-height: 120upx;
  689. text-align: center;
  690. font-size: 30upx;
  691. font-family: PingFang SC;
  692. font-weight: bold;
  693. color: #FFFFFF;
  694. background-color: $mine-background-color;
  695. margin: 0 auto;
  696. margin-top: 130upx;
  697. border-radius: 60upx;
  698. }
  699. }
  700. }
  701. .submit {
  702. height: 122upx;
  703. line-height: 122upx;
  704. border-radius: 61upx;
  705. color: #FFFFFF;
  706. margin: 50upx 30upx 50upx;
  707. background: $mine-background-color;
  708. text-align: center;
  709. font-size: 30upx;
  710. font-family: PingFang SC;
  711. font-weight: bold;
  712. color: #FFFFFF;
  713. }
  714. .success-frame {
  715. background-color: rgba($color: #000000, $alpha: 0.5);
  716. height: 100vh;
  717. width: 100%;
  718. position: fixed;
  719. z-index: 99999;
  720. top: 0;
  721. .success-content {
  722. width: 70%;
  723. background-color: #FFFFFF;
  724. margin: 0 auto;
  725. padding: 30upx;
  726. margin-top: 35%;
  727. text-align: center;
  728. image {
  729. height: 80upx;
  730. width: 80upx;
  731. margin-top: 10%;
  732. }
  733. .text {
  734. margin-top: 40upx;
  735. font-size: 26upx;
  736. color: #808080;
  737. }
  738. .skip {
  739. height: 80upx;
  740. line-height: 80upx;
  741. text-align: center;
  742. background-color: $mine-background-color;
  743. width: 50%;
  744. margin: 0 auto;
  745. margin-top: 30upx;
  746. border-radius: 20upx;
  747. color: #FFFFFF;
  748. margin-bottom: 50upx;
  749. }
  750. }
  751. }
  752. }
  753. </style>