outPayment.vue 8.2 KB

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