monthlyCardBuy.vue 13 KB

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