monthlyCardBuy.vue 6.4 KB

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