outPayment.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view>
  3. <u-navbar title="无车辆扫码停车" :is-back="false"></u-navbar>
  4. <view class="main">
  5. <view class="park-name">
  6. <img src="../../static/img/if-location-pin@2x.png" alt="">
  7. <text>{{detail.parkName}}</text>
  8. </view>
  9. <view class="infos" v-if="!detail.id">
  10. 已抬杆,欢迎下次光临
  11. </view>
  12. <view class="infos" v-if="detail.id">
  13. <view class="item">
  14. <view class="title">
  15. 车牌号
  16. </view>
  17. <view class="content">
  18. {{detail.carNum}}
  19. </view>
  20. </view>
  21. <view class="item">
  22. <view class="title">
  23. 停车费
  24. </view>
  25. <view class="content">
  26. {{detail.price}}元
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="details" v-if="detail.id">
  32. <view class="detail-item">
  33. <view class="title">
  34. 进场时间
  35. </view>
  36. <view class="content">
  37. {{detail.inParkingTime}}
  38. </view>
  39. </view>
  40. <view class="detail-item">
  41. <view class="title">
  42. 离场时间
  43. </view>
  44. <view class="content">
  45. {{detail.outParkingTime}}
  46. </view>
  47. </view>
  48. <view class="detail-item">
  49. <view class="title">
  50. 停车时长
  51. </view>
  52. <view class="content">
  53. {{detail.parkingTimeStr}}
  54. </view>
  55. </view>
  56. <view class="detail-item">
  57. <view class="title">
  58. 收费标准
  59. </view>
  60. <view class="content">
  61. {{detail.hourCost}}元/小时
  62. </view>
  63. </view>
  64. </view>
  65. <view class="payment" v-if="detail.id">
  66. <p>付款方式</p>
  67. <view class="methods">
  68. <view class="recharge-radio" >
  69. <u-radio-group v-model="value" :wrap="true" width="100%">
  70. <u-radio active-color="#0076ff" v-for="(item, index) in list" :key="index"
  71. :name="item.id" :disabled="item.disabled" width="100%">
  72. <view class="recharge-radio-item">
  73. <u-icon :name="item.icon" custom-prefix="custom-icon" :color="item.color" size="48">
  74. </u-icon>
  75. <view class="recharge-radio-name oldTextjp2" oldstyle="font-size:18px">
  76. {{item.name}}
  77. </view>
  78. </view>
  79. </u-radio>
  80. </u-radio-group>
  81. </view>
  82. </view>
  83. </view>
  84. <u-button @click='submit()' v-if="detail.id">缴纳停车费</u-button>
  85. <view class="box">
  86. </view>
  87. <!-- // @confirm="confirm" -->
  88. <u-modal v-model="showModel"
  89. :show-cancel-button="false"
  90. confirm-text="确定"
  91. title="扫码支付" >
  92. <view style="
  93. text-align: center;
  94. ">
  95. <img id="qrcode2" :src="qrCodeImg" >
  96. </view>
  97. <view style="
  98. text-align: center;
  99. ">请使用支付宝扫码</view>
  100. </u-modal>
  101. <img id="qrcode" style="display: none;" >
  102. <u-modal v-model="show" @confirm="confirmPhone" :confirm-text="confirmText" confirm-color="#606266" :show-cancel-button="true" ref="uModal"
  103. :asyncClose="true" :title="title" :content="content" :content-style="{fontSize: '24px',color: '#101010'}"></u-modal>
  104. <view class="service" @click="openModal">
  105. 联系停车场客服
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import * as Pay from '@/apis/weixin.js'
  111. import QRCode from 'qrcodejs2'
  112. import * as newsApi from '@/apis/news.js'
  113. import {
  114. convertCanvasToImage,
  115. } from '@/utils'
  116. import {
  117. wxPayJs
  118. } from '@/utils/wxpay'
  119. import {
  120. aliPayJs
  121. } from '@/utils/alipay'
  122. import * as API from '@/apis/parking.js'
  123. export default {
  124. data() {
  125. return {
  126. title:"客服电话",
  127. confirmText:"拨打电话",
  128. content:'',
  129. show:false,
  130. showModel:false,
  131. qrCodeImg:"",
  132. list: [{
  133. id:'0',
  134. name: '微信',
  135. icon: 'wechat-pay-fill',
  136. color: '#22ac38',
  137. },
  138. {
  139. id:'1',
  140. name: '支付宝',
  141. icon: 'alipay-fill',
  142. color: '#1677ff',
  143. },
  144. ],
  145. value:0,
  146. channelId:'',
  147. detail:{}
  148. }
  149. },onLoad(op) {
  150. this.getPhone()
  151. if(op.id){
  152. this.channelId=op.id
  153. this.getInfo()
  154. }else{
  155. uni.showModal({
  156. content:"参数错误"
  157. })
  158. }
  159. }, methods: {
  160. getPhone(){
  161. newsApi.findConfigureByKey({
  162. key:'consumerPhone'
  163. }).then((res) => {
  164. this.content = res.data.value;
  165. }).catch(error => {
  166. uni.showToast({
  167. title: error,
  168. icon: "none"
  169. })
  170. })
  171. },
  172. openModal() {
  173. this.show = true;
  174. },
  175. confirmPhone(){
  176. this.show = false;
  177. uni.makePhoneCall({
  178. phoneNumber:this.content //仅为示例
  179. });
  180. },
  181. confirm(){
  182. uni.redirectTo({
  183. url:"/pages/parking/paymentResult"
  184. })
  185. },
  186. submit(){
  187. if(this.value=="0"){
  188. this.wxpy()
  189. }else{
  190. this.alpy()
  191. }
  192. },
  193. alpy(){
  194. uni.showLoading({
  195. title: "加载中",
  196. mask: true,
  197. })
  198. API.parkTradePrecreatePay({
  199. id: this.detail.id,
  200. openId: this.carhelp.getOpenId()
  201. }).then((response) => {
  202. let qrcode = new QRCode('qrcode', {
  203. width: 200,
  204. height: 200,
  205. text: response.data,
  206. correctLevel: QRCode.CorrectLevel.M,
  207. })
  208. // this.outOrderNo=response.data.outOrderNo;
  209. var canvas = document.getElementsByTagName('canvas')[0];
  210. this.qrCodeImg = convertCanvasToImage(canvas);
  211. uni.hideLoading()
  212. this.showModel=true
  213. }).catch(error => {
  214. uni.showToast({
  215. title: error
  216. })
  217. })
  218. },
  219. wxpy(){
  220. uni.showLoading({
  221. title: "加载中",
  222. mask: true,
  223. })
  224. API.parkingWxPay({
  225. id: this.detail.id,
  226. openId: this.carhelp.getOpenId()
  227. }).then(data => {
  228. //data.data.url = window.location.href.split("#")[0] + "/#/car/payResult";
  229. uni.hideLoading()
  230. wxPayJs(data.data)
  231. }).catch(error => {
  232. uni.hideLoading()
  233. uni.showToast({
  234. title: error,
  235. icon: "none"
  236. })
  237. })
  238. },
  239. getInfo(){
  240. uni.showLoading({
  241. title: "加载中",
  242. mask: true,
  243. })
  244. API.generateTemporaryCarNum({
  245. openId:this.carhelp.getOpenId(),
  246. channelId:this.channelId
  247. }).then((res) => {
  248. uni.hideLoading();
  249. this.detail = res.data;
  250. }).catch(error => {
  251. uni.hideLoading()
  252. // uni.showToast({
  253. // title: error,
  254. // icon: "none"
  255. // })
  256. uni.showModal({
  257. title:"提示",
  258. content:error,
  259. showCancel:false,
  260. })
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. .main{
  268. height: 200px;
  269. padding: 20px 23px;
  270. background: linear-gradient(#1F55FF,#27ABFF);
  271. .park-name{
  272. line-height: 20px;
  273. color: rgba(255, 255, 255, 100);
  274. font-size: 20px;
  275. position: relative;
  276. text{
  277. margin-left: 25px;
  278. }
  279. img{
  280. width: 20px;
  281. height: 20px;
  282. margin-right: 8px;
  283. position: absolute;
  284. }
  285. }
  286. .infos{
  287. margin-top: 28px;
  288. color: #fff;
  289. font-size: 24px;
  290. .item{
  291. display: flex;
  292. justify-content: space-between;
  293. margin-bottom: 20px;
  294. }
  295. }
  296. }
  297. .details{
  298. width: 89.3%;
  299. padding: 20px 20px 5px;
  300. margin: auto;
  301. border-radius: 12px;
  302. background-color: #fff;
  303. position: relative;
  304. top: -30px;
  305. left: 0;
  306. right: 0;
  307. .detail-item{
  308. display: flex;
  309. justify-content: space-between;
  310. margin-bottom: 15px;
  311. .title{
  312. color: #86898c;
  313. }
  314. }
  315. }
  316. .payment{
  317. width: 89.3%;
  318. margin:0 auto ;
  319. .methods{
  320. border-radius: 8px;
  321. background-color: #fff;
  322. margin-top: 12px;
  323. padding: 0px 12px;
  324. .recharge-radio {
  325. .recharge-radio-item {
  326. display: flex;
  327. align-items: center;
  328. }
  329. .recharge-radio-name {
  330. margin-left: 8px;
  331. }
  332. }
  333. /deep/.u-radio-group {
  334. width: 100%;
  335. }
  336. /deep/.u-radio {
  337. position: relative;
  338. }
  339. /deep/.u-radio__icon-wrap {
  340. position: absolute;
  341. right: 0;
  342. }
  343. }
  344. }
  345. .u-btn{
  346. width: 89.3%;
  347. background-color: #0051db;
  348. border-radius: 12px;
  349. color: #fff;
  350. margin-top: 20px;
  351. }
  352. .box{
  353. width: 100%;
  354. height: 14vh;
  355. }
  356. .service{
  357. color: rgba(0, 90, 217, 100);
  358. font-size: 16px;
  359. text-align: center;
  360. position: fixed;
  361. bottom: 0px;
  362. left: 0;
  363. right: 0;
  364. height: 40px;
  365. background-color: #fff;
  366. z-index: 999;
  367. }
  368. </style>