monthlyCardBuy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <view>
  3. <ujp-navbar title="包月卡购买"></ujp-navbar>
  4. <!-- 卡片 -->
  5. <view class="monthly-card-bgc">
  6. <view class="monthly-card">
  7. <view class="main">
  8. <view class="title-1">
  9. 充电服务费包月卡
  10. </view>
  11. <view class="title-2">
  12. 到期时间:{{userCard&&ispay?userCard.endTime:'未购买'}}<br />
  13. 有效期内,合约充电站使用度数无上限
  14. </view>
  15. </view>
  16. <img class="cover" src="../../assets/img/cover@3.png" alt="">
  17. </view>
  18. </view>
  19. <view class="slogan-1">
  20. 充电服务费包月卡
  21. </view>
  22. <view class="slogan-2">
  23. 单次购买、整月受益!
  24. </view>
  25. <!-- <view class="slogan-3" style="color: #ead9b4;" >
  26. 限时活动结束时间2022年8月8日0点结束
  27. </view> -->
  28. <!-- 营运车辆 -->
  29. <view class="operating-coach">
  30. <view class="type">
  31. <view class="title">
  32. <text class="img">
  33. <img src="../../assets/img/antFill-crown@3x.png" alt="">
  34. </text>非营运车专享卡
  35. </view>
  36. <view class="hint">
  37. 有效期内,每月优惠度数无上限
  38. </view>
  39. </view>
  40. <view class="price">
  41. <text class="num">59.90</text>
  42. <text class="unit">元</text>
  43. </view>
  44. </view>
  45. <!-- 非营运车辆 -->
  46. <view class="non-operational-car">
  47. <view class="type">
  48. <view class="title">
  49. <text class="img">
  50. <img src="../../assets/img/antFill-crown Copy.svg" alt="">
  51. </text>营运车包月卡
  52. </view>
  53. <view class="hint">
  54. 有效期内,每月优惠度数无上限
  55. </view>
  56. </view>
  57. <view class="price">
  58. <text class="num">199.00</text>
  59. <text class="unit">元</text>
  60. </view>
  61. </view>
  62. <view class="slogan-3">
  63. <view v-html="ykgz"></view>
  64. <view class="slogan-4" @click="gotoUrl('pages/monthlyCardActivity/monthlyCardList?cardId='+cardId)">
  65. 查看本活动适用站点
  66. </view>
  67. </view>
  68. <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
  69. <u-modal v-model="showModel" :show-cancel-button="true" @cancel="getUserInfo()" @confirm="confirm"
  70. confirm-text="支付成功?" title="扫码支付">
  71. <view style="
  72. text-align: center;
  73. ">
  74. <img id="qrcode2" :src="qrCodeImg">
  75. </view>
  76. <view style="
  77. text-align: center;
  78. ">请使用支付宝扫码</view>
  79. </u-modal>
  80. <img id="qrcode" style="display: none;">
  81. <view class="bottom" v-if="!show2" @click="gotoGz">
  82. <button class="dredge">关注公众号</button>
  83. </view>
  84. <view class="bottom" v-else-if="!infoSet" @click="gotoUrl('pages/user/dataSet')">
  85. <button class="dredge">完善个人信息</button>
  86. </view>
  87. <view class="bottom" v-else-if="!endCardBool">
  88. <button class="dredge">已下架</button>
  89. </view>
  90. <!-- 立即开通 -->
  91. <view class="bottom" v-else-if="ispay">
  92. <button class="dredge">已购买</button>
  93. </view>
  94. <!-- 立即开通 -->
  95. <view class="bottom" v-else-if="!ispay&&detail.price">
  96. <button class="dredge" v-if="detail.putShelf&&!detail.isVip" @click="show = true">立即开通
  97. ¥{{detail.price.toFixed(2)}}/月</button>
  98. <button class="dredge" v-if="detail.putShelf&&detail.isVip" @click="show = true">{{detail.platformText}}车主特惠
  99. ¥{{detail.price.toFixed(2)}}/月<span
  100. style="font-size: 12px; text-decoration: line-through;">¥{{detail.oldPrice.toFixed(2)}}</span></button>
  101. <button class="dredge" v-if="!detail.putShelf" @click="putShelf"> 已下架</button>
  102. <p>开通表示阅读并同意
  103. <text class="agreement" @click="gotoUrl('pages/article/details?code=FWFZKXY')">《服务费折扣协议》</text>
  104. </p>
  105. </view>
  106. <u-modal v-model="show1" @confirm="gotoGz" cancel-text="暂不关注" confirm-text="前往关注" confirm-color="#53b56b"
  107. :show-cancel-button="true" ref="uModal2" :asyncClose="true">
  108. <view style="padding: 15px;">请先关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,购买月卡</view>
  109. </u-modal>
  110. <u-modal v-model="infoSet1" @confirm="infoSet1=false,gotoUrl('pages/user/dataSet')" cancel-text="取消"
  111. confirm-text="完善个人信息" confirm-color="#53b56b" :show-cancel-button="true" ref="uModal2" :asyncClose="true">
  112. <view style="padding: 15px;">购买月卡需要完善以下2点<br />
  113. 1.填写真实姓名<br />
  114. 2.填写车牌号<br />
  115. </view>
  116. </u-modal>
  117. </view>
  118. </template>
  119. <script>
  120. import * as API_weixin from '@/apis/weixin.js'
  121. import * as Pay from '@/apis/weixin.js'
  122. import * as API from '@/apis/card.js'
  123. import * as loginApi from '@/apis/login.js'
  124. import QRCode from 'qrcodejs2'
  125. import {
  126. newDate,
  127. convertCanvasToImage,
  128. } from '@/utils'
  129. import {
  130. wxPayJs
  131. } from '@/utils/wxpay'
  132. export default {
  133. data() {
  134. return {
  135. cardId: '3e1b0f8f-61b0-405f-a285-929b5346479f',
  136. qrCodeImg: "",
  137. showModel: false,
  138. projectName: "",
  139. list: [{
  140. text: '微信',
  141. }, {
  142. text: '支付宝'
  143. }],
  144. show: false,
  145. submitForm: {},
  146. ykgz: '',
  147. detail: {},
  148. ispay: true,
  149. show2: false,
  150. show1: false,
  151. infoSet: false,
  152. infoSet1: false,
  153. userCard: null,
  154. }
  155. },
  156. onLoad() {
  157. this.projectName = process.car.ProjectName;
  158. },
  159. onReady() {
  160. this.ykgz = this.carhelp.getConfig().ykgz
  161. //this.checkSubscribe()
  162. },
  163. onShow() {
  164. this.checkSubscribe();
  165. },
  166. computed: {
  167. endCardBool() {
  168. var date = new Date().getTime()
  169. if (!this.detail.endTime) {
  170. return true;
  171. }
  172. var date2 = newDate(this.detail.endTime).getTime();
  173. if (date < date2) {
  174. return true;
  175. } else {
  176. return false;
  177. }
  178. }
  179. },
  180. methods: {
  181. gotoGz() {
  182. this.carhelp.setGzDate()
  183. var url = "https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
  184. window.location.href = url
  185. },
  186. checkSubscribe() {
  187. API_weixin.checkSubscribe({
  188. openId: this.carhelp.getOpenId()
  189. }).then((res) => {
  190. if (res.data == "0") {
  191. this.show1 = true
  192. } else {
  193. this.getInfo();
  194. this.getUserInfo()
  195. this.show2 = true;
  196. //this.carhelp.setGzDate()
  197. }
  198. //setGzDate
  199. }).catch(error => {
  200. uni.showToast({
  201. title: error
  202. })
  203. })
  204. },
  205. userCardBool(userCard) {
  206. if (userCard) {
  207. var date = new Date().getTime()
  208. var date2 = newDate(userCard.endTime).getTime();
  209. if (date < date2) {
  210. return true;
  211. }
  212. }
  213. return false
  214. },
  215. getUserInfo() {
  216. uni.showLoading({
  217. title: "加载中",
  218. mask: true,
  219. })
  220. loginApi.findByOpenId({
  221. openId: this.carhelp.getOpenId(),
  222. noerror: true
  223. }).then((res) => {
  224. uni.hideLoading();
  225. if (res.code == 200 && res.result) {
  226. if (res.data.regUser) {
  227. var userInfo = res.data.regUser
  228. if (userInfo.carId && userInfo.realName) {
  229. this.infoSet = true;
  230. } else {
  231. this.infoSet = false;
  232. this.infoSet1 = true;
  233. }
  234. var userCard = res.data.userCard;
  235. this.userCard = userCard
  236. this.ispay = this.userCardBool(userCard)
  237. } else {
  238. }
  239. }
  240. }).catch(error => {
  241. uni.showToast({
  242. title: error,
  243. icon: "none"
  244. })
  245. })
  246. },
  247. putShelf2() {
  248. uni.showToast({
  249. title: "暂不支持重复购买"
  250. })
  251. },
  252. putShelf() {
  253. uni.showToast({
  254. title: "已下架,暂不支持购买"
  255. })
  256. },
  257. getInfo() {
  258. uni.showLoading({
  259. title: "加载中",
  260. mask: true,
  261. })
  262. API.cardDetail({
  263. cardId: this.cardId
  264. }).then((response) => {
  265. console.log(response)
  266. this.detail = response.data.monthlyRentCard
  267. uni.hideLoading()
  268. }).catch(error => {
  269. uni.showToast({
  270. title: error
  271. })
  272. })
  273. },
  274. submit(type) {
  275. if (!this.endCardBool) {
  276. return
  277. }
  278. uni.showLoading({
  279. title: "加载中",
  280. mask: true,
  281. })
  282. API.openCard({
  283. cardId: this.cardId
  284. }).then((response) => {
  285. this.submitForm.id = response.data.orderInfoId
  286. if (type == 0) {
  287. this.wxpy()
  288. }
  289. if (type == 1) {
  290. this.alpy()
  291. }
  292. }).catch(error => {
  293. uni.showToast({
  294. title: error
  295. })
  296. })
  297. },
  298. alpy() {
  299. uni.showLoading({
  300. title: "加载中",
  301. mask: true,
  302. })
  303. Pay.alpay(this.submitForm).then((response) => {
  304. let qrcode = new QRCode('qrcode', {
  305. width: 200,
  306. height: 200,
  307. text: response.data.qr_code,
  308. correctLevel: QRCode.CorrectLevel.M,
  309. })
  310. this.outOrderNo = response.data.outOrderNo;
  311. var canvas = document.getElementsByTagName('canvas')[0];
  312. this.qrCodeImg = convertCanvasToImage(canvas);
  313. uni.hideLoading()
  314. this.showModel = true
  315. }).catch(error => {
  316. uni.showToast({
  317. title: error
  318. })
  319. })
  320. },
  321. wxpy() {
  322. Pay.wxpay(this.submitForm).then((response) => {
  323. if (!response.result) {
  324. uni.showToast({
  325. title: response.message
  326. })
  327. return
  328. }
  329. var data = response.data
  330. uni.hideLoading()
  331. //("Pay+"+new Date().getTime())
  332. wxPayJs(data);
  333. }).catch(error => {
  334. uni.showToast({
  335. title: error
  336. })
  337. })
  338. },
  339. confirm() {
  340. this.getUserInfo();
  341. uni.redirectTo({
  342. url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
  343. })
  344. },
  345. click(index) {
  346. console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
  347. this.submit(index);
  348. }
  349. }
  350. }
  351. </script>
  352. <style lang="scss" scoped>
  353. page {
  354. background-color: #2a2c31;
  355. padding-bottom: 200px;
  356. }
  357. .monthly-card-bgc {
  358. padding: 20px;
  359. background-color: #101010;
  360. height: 150px;
  361. position: relative;
  362. }
  363. // 卡片
  364. .monthly-card {
  365. border-radius: 16px;
  366. height: 150px;
  367. background: linear-gradient(#F2E6CA, #C9A87B);
  368. .main {
  369. padding: 24px 0 24px 24px;
  370. height: 100%;
  371. background: url(@/assets/img/card@3.png);
  372. background-repeat: no-repeat;
  373. background-position: 30% 10%;
  374. background-size: cover;
  375. color: rgba(255, 255, 255, 100);
  376. border-radius: 6px;
  377. .title-1 {
  378. line-height: 28px;
  379. font-size: 56rpx;
  380. margin-bottom: 8px;
  381. }
  382. .title-2 {
  383. line-height: 24px;
  384. font-size: 34rpx;
  385. }
  386. }
  387. .cover {
  388. width: 100%;
  389. position: absolute;
  390. bottom: -30px;
  391. left: 0px;
  392. right: 0;
  393. }
  394. }
  395. .slogan-1 {
  396. margin-top: 40px;
  397. height: 36px;
  398. color: rgba(234, 217, 180, 100);
  399. font-size: 48rpx;
  400. text-align: center;
  401. margin-bottom: 4px;
  402. }
  403. .slogan-2 {
  404. height: 36px;
  405. color: rgba(234, 217, 180, 100);
  406. font-size: 56rpx;
  407. text-align: center;
  408. margin-bottom: 12px;
  409. }
  410. .slogan-3 {
  411. text-align: initial;
  412. padding: 0 40px;
  413. line-height: 24px;
  414. color: #CCCCCC;
  415. font-size: 28rpx;
  416. }
  417. .slogan-4 {
  418. margin-top: 10px;
  419. text-decoration: underline;
  420. height: 20px;
  421. color: #9F9C99;
  422. font-size: 32rpx;
  423. text-align: center;
  424. }
  425. // 营运车辆,非营业车辆
  426. .operating-coach {
  427. padding: 16px;
  428. width: 89.3%;
  429. margin: 16px auto 0;
  430. background: linear-gradient(to right, #bc9663, #79674d);
  431. display: flex;
  432. justify-content: space-between;
  433. color: #fff;
  434. border-radius: 12px;
  435. .title {
  436. color: rgba(255, 255, 255, 100);
  437. font-size: 18px;
  438. line-height: 20px;
  439. .img {
  440. display: inline-block;
  441. background-color: #fff;
  442. width: 20px;
  443. height: 20px;
  444. border-radius: 4px;
  445. line-height: 18px;
  446. margin-right: 4px;
  447. img {
  448. width: 12px;
  449. height: 12px;
  450. margin-left: 4px;
  451. }
  452. }
  453. }
  454. .hint {
  455. color: rgba(255, 255, 255, 100);
  456. font-size: 12px;
  457. line-height: 24px;
  458. margin-top: 4px;
  459. }
  460. .price {
  461. color: rgba(255, 255, 255, 100);
  462. margin: auto 0;
  463. .num {
  464. font-size: 28px;
  465. }
  466. .unit {
  467. font-size: 16px;
  468. margin-left: 4px;
  469. }
  470. }
  471. }
  472. .non-operational-car{
  473. padding: 16px;
  474. width: 89.3%;
  475. border: 1px solid rgba(100, 90, 77, 100);
  476. margin: 12px auto 16px;
  477. display: flex;
  478. justify-content: space-between;
  479. color: #fff;
  480. border-radius: 12px;
  481. .title {
  482. color: rgba(255, 255, 255, 100);
  483. font-size: 18px;
  484. line-height: 20px;
  485. .img {
  486. display: inline-block;
  487. background:linear-gradient(#f2e6ca,#c9a87b) ;
  488. width: 20px;
  489. height: 20px;
  490. border-radius: 4px;
  491. line-height: 18px;
  492. margin-right: 4px;
  493. img {
  494. width: 12px;
  495. height: 12px;
  496. margin-left: 4px;
  497. }
  498. }
  499. }
  500. .hint {
  501. color: rgba(255, 255, 255, 100);
  502. font-size: 12px;
  503. line-height: 24px;
  504. margin-top: 4px;
  505. }
  506. .price {
  507. color: rgba(211, 189, 158, 100);
  508. margin: auto 0;
  509. .num {
  510. font-size: 28px;
  511. }
  512. .unit {
  513. font-size: 16px;
  514. margin-left: 4px;
  515. }
  516. }
  517. }
  518. // 立即开通
  519. .bottom {
  520. position: fixed;
  521. background-color: #2a2c31;
  522. bottom: 0px;
  523. padding-bottom: 40px;
  524. left: 0;
  525. right: 0;
  526. .dredge {
  527. // width: 72.2%;
  528. margin: 0 20px;
  529. border-radius: 50px;
  530. font-size: 36rpx;
  531. background: linear-gradient(to right, #C9A87B, #F2E6CA);
  532. margin-bottom: 12px;
  533. }
  534. p {
  535. height: 20px;
  536. color: rgba(226, 222, 217, 100);
  537. font-size: 14px;
  538. text-align: center;
  539. }
  540. .agreement {
  541. color: #897a69;
  542. }
  543. }
  544. </style>