monthlyCardBuy.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view>
  3. <ujp-navbar title="包月卡购买"></ujp-navbar>
  4. <!-- 卡片 -->
  5. <view class="monthly-card">
  6. <view class="main">
  7. <view class="title-1">
  8. 充电服务费包月卡
  9. </view>
  10. <view class="title-2">
  11. 有效期内,合约充电站使用度数无上限
  12. </view>
  13. </view>
  14. <img class="cover" src="../../assets/img/cover@3.png" alt="">
  15. </view>
  16. <view class="slogan-1">
  17. 充电服务费包月卡
  18. </view>
  19. <view class="slogan-2">
  20. 单次购买、整月受益!
  21. </view>
  22. <view class="slogan-3">
  23. 仅限车主购买,适用于平台对外开放充电站
  24. </view>
  25. <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
  26. <u-modal v-model="showModel" :show-cancel-button="true" @confirm="confirm" confirm-text="支付成功?" title="扫码支付">
  27. <view style="
  28. text-align: center;
  29. ">
  30. <img id="qrcode2" :src="qrCodeImg">
  31. </view>
  32. <view style="
  33. text-align: center;
  34. ">请使用支付宝扫码</view>
  35. </u-modal>
  36. <img id="qrcode" style="display: none;">
  37. <!-- 立即开通 -->
  38. <view class="bottom">
  39. <button class="dredge" @click="show = true">立即开通 ¥{{detail.price}}/月</button>
  40. <p>开通表示阅读并同意
  41. <text class="agreement" @click="gotoUrl('pages/article/details?code=FWFZKXY')">《服务费折扣协议》</text>
  42. </p>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import * as Pay from '@/apis/weixin.js'
  48. import * as API from '@/apis/card.js'
  49. import QRCode from 'qrcodejs2'
  50. import {
  51. convertCanvasToImage,
  52. } from '@/utils'
  53. import {
  54. wxPayJs
  55. } from '@/utils/wxpay'
  56. export default {
  57. data() {
  58. return {
  59. qrCodeImg: "",
  60. showModel: false,
  61. list: [{
  62. text: '微信',
  63. }, {
  64. text: '支付宝'
  65. }],
  66. show: false,
  67. submitForm:{},
  68. detail:{}
  69. }
  70. },
  71. onReady() {
  72. this.getInfo();
  73. },
  74. methods: {
  75. getInfo(){
  76. uni.showLoading({
  77. title: "加载中",
  78. mask: true,
  79. })
  80. API.cardDetail({
  81. cardId:'3e1b0f8f-61b0-405f-a285-929b5346479f'
  82. }).then((response) => {
  83. this.detail=response.data.monthlyRentCard
  84. uni.hideLoading()
  85. }).catch(error => {
  86. uni.showToast({
  87. title: error
  88. })
  89. })
  90. },
  91. submit(type){
  92. uni.showLoading({
  93. title: "加载中",
  94. mask: true,
  95. })
  96. API.openCard({
  97. cardId:'3e1b0f8f-61b0-405f-a285-929b5346479f'
  98. }).then((response) => {
  99. this.submitForm.id=response.data.orderInfoId
  100. if(type==0){
  101. this.wxpy()
  102. }
  103. if(type==1){
  104. this.alpy()
  105. }
  106. }).catch(error => {
  107. uni.showToast({
  108. title: error
  109. })
  110. })
  111. },
  112. alpy() {
  113. uni.showLoading({
  114. title: "加载中",
  115. mask: true,
  116. })
  117. Pay.alpay(this.submitForm).then((response) => {
  118. let qrcode = new QRCode('qrcode', {
  119. width: 200,
  120. height: 200,
  121. text: response.data.qr_code,
  122. correctLevel: QRCode.CorrectLevel.M,
  123. })
  124. this.outOrderNo = response.data.outOrderNo;
  125. var canvas = document.getElementsByTagName('canvas')[0];
  126. this.qrCodeImg = convertCanvasToImage(canvas);
  127. uni.hideLoading()
  128. this.showModel = true
  129. }).catch(error => {
  130. uni.showToast({
  131. title: error
  132. })
  133. })
  134. },
  135. wxpy() {
  136. Pay.wxpay(this.submitForm).then((response) => {
  137. if (!response.result) {
  138. uni.showToast({
  139. title: response.message
  140. })
  141. return
  142. }
  143. var data = response.data
  144. uni.hideLoading()
  145. //("Pay+"+new Date().getTime())
  146. wxPayJs(data);
  147. }).catch(error => {
  148. uni.showToast({
  149. title: error
  150. })
  151. })
  152. },
  153. confirm() {
  154. uni.redirectTo({
  155. url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
  156. })
  157. },
  158. click(index) {
  159. console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
  160. this.submit(index);
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. page {
  167. background-color: #2a2c31;
  168. }
  169. // 卡片
  170. .monthly-card {
  171. margin: 20px;
  172. border-radius: 16px;
  173. height: 150px;
  174. background: linear-gradient(#F2E6CA, #C9A87B);
  175. position: relative;
  176. .main {
  177. padding: 24px 0 24px 24px;
  178. height: 100%;
  179. background: url(@/assets/img/card@3.png);
  180. background-repeat: no-repeat;
  181. background-position: 30% 10%;
  182. background-size: cover;
  183. color: rgba(255, 255, 255, 100);
  184. border-radius: 6px;
  185. .title-1 {
  186. line-height: 28px;
  187. font-size: 56rpx;
  188. margin-bottom: 8px;
  189. }
  190. .title-2 {
  191. line-height: 24px;
  192. font-size: 34rpx;
  193. }
  194. }
  195. .cover {
  196. width: 102%;
  197. position: absolute;
  198. bottom: -10px;
  199. left: -2px;
  200. right: 0;
  201. }
  202. }
  203. .slogan-1 {
  204. height: 36px;
  205. color: rgba(234, 217, 180, 100);
  206. font-size: 48rpx;
  207. text-align: center;
  208. margin-bottom: 4px;
  209. }
  210. .slogan-2 {
  211. height: 36px;
  212. color: rgba(234, 217, 180, 100);
  213. font-size: 56rpx;
  214. text-align: center;
  215. margin-bottom: 12px;
  216. }
  217. .slogan-3 {
  218. height: 20px;
  219. color: rgba(255, 255, 255, 100);
  220. font-size: 28rpx;
  221. text-align: center;
  222. }
  223. // 立即开通
  224. .bottom {
  225. position: fixed;
  226. background-color: #2a2c31;
  227. bottom: 0px;
  228. padding-bottom: 40px;
  229. left: 0;
  230. right: 0;
  231. .dredge {
  232. width: 72.2%;
  233. border-radius: 50px;
  234. font-size: 18px;
  235. background: linear-gradient(to right, #C9A87B, #F2E6CA);
  236. margin-bottom: 12px;
  237. }
  238. p {
  239. height: 20px;
  240. color: rgba(226, 222, 217, 100);
  241. font-size: 14px;
  242. text-align: center;
  243. }
  244. .agreement {
  245. color: #897a69;
  246. }
  247. }
  248. </style>