monthlyCardBuy.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <template>
  2. <view>
  3. <ujp-navbar title="选购服务费月卡"></ujp-navbar>
  4. <!-- 提示 -->
  5. <!-- <template>
  6. <u-alert-tips type="warning" :title="title" :description="description" :show-icon="true"></u-alert-tips>
  7. </template> -->
  8. <!-- 卡片 -->
  9. <view class="main">
  10. <view class="carNone" v-if="!isReady">
  11. <img src="static/img/暂无数据-缺省页.png" alt="">
  12. <p class="" style="color: #bfdfd5;font-size: 18px;" >加载中</p>
  13. </view>
  14. <view class="carNone" v-if="isReady&&cardList.length == 0">
  15. <img src="static/img/暂无数据-缺省页.png" alt="">
  16. <p class="" style="color: #bfdfd5;font-size: 18px;" >暂无月卡上架</p>
  17. </view>
  18. <view
  19. v-for="(item,i) in cardList" :key="i"
  20. @click="checkboxChange(item.monthlyRentCard)"
  21. :style="'background-image: url('+item.monthlyRentCard.image+') ;'"
  22. class="card-1" >
  23. <view class="tag" v-if="item.monthlyRentCard.isVip">{{item.monthlyRentCard.platformText}}车主</view>
  24. <view class="tag" v-else-if="item.monthlyRentCard.remark">{{item.monthlyRentCard.remark}}</view>
  25. <view class="price">
  26. <view class="current-price" v-if="item.monthlyRentCard.discount">
  27. {{item.monthlyRentCard.price/100*item.monthlyRentCard.discountRate}}<text>元/月</text>
  28. </view>
  29. <view class="current-price" v-else>
  30. {{item.monthlyRentCard.price}}<text>元/月</text>
  31. </view>
  32. <view class="original-cost" v-if="item.monthlyRentCard.discount">
  33. 原价 {{item.monthlyRentCard.price}}元/月
  34. </view>
  35. <p>已有60人购买</p>
  36. <view class="original-cost" v-if="item.monthlyRentCard.isVip">
  37. 原价 {{item.monthlyRentCard.oldPrice}}元/月
  38. </view>
  39. <view class="radio-box">
  40. <u-checkbox-group >
  41. <u-checkbox @change="checkboxChange(item.monthlyRentCard)" v-model="item.monthlyRentCard.checked" active-color="#000000" shape="circle" size="48"></u-checkbox>
  42. </u-checkbox-group>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
  48. <u-modal v-model="showModel" :show-cancel-button="true" @cancel="getUserInfo()" @confirm="confirm"
  49. confirm-text="支付成功?" title="扫码支付">
  50. <view style="
  51. text-align: center;
  52. ">
  53. <img id="qrcode2" :src="qrCodeImg">
  54. </view>
  55. <view style="
  56. text-align: center;
  57. ">请使用支付宝扫码</view>
  58. </u-modal>
  59. <u-modal v-model="show1" @confirm="gotoGz" cancel-text="暂不关注" confirm-text="前往关注" confirm-color="#53b56b"
  60. :show-cancel-button="true" ref="uModal2" :asyncClose="true">
  61. <view style="padding: 15px;">请先关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,购买月卡</view>
  62. </u-modal>
  63. <u-modal v-model="infoSet1" @confirm="infoSet1=false,gotoUrl('pages/user/dataSet')" cancel-text="取消"
  64. confirm-text="完善个人信息" confirm-color="#53b56b" :show-cancel-button="true" ref="uModal2" :asyncClose="true">
  65. <view style="padding: 15px;">购买月卡需要完善以下2点<br />
  66. 1.填写真实姓名<br />
  67. 2.填写车牌号<br />
  68. </view>
  69. </u-modal>
  70. <img id="qrcode" style="display: none;">
  71. <!-- 按钮 -->
  72. <view class="button">
  73. <button class="btn " v-if="!isReady" >加载中
  74. </button>
  75. <button class="btn " v-else-if="ispay" > {{userCard&&ispay?userCard.endTime:''}}到期
  76. </button>
  77. <button class="btn " v-else-if="!endCardBool" >已下架
  78. </button>
  79. <button class="btn " v-else-if="!show2" @click="gotoGz">关注公众号
  80. </button>
  81. <button class="btn " v-else-if="!infoSet" @click="gotoUrl('pages/user/dataSet')" >完善个人信息
  82. </button>
  83. <button class="btn " v-else-if="!cardList.length" @click="putShelf" >已下架
  84. </button>
  85. <button class="btn " @click="show = true" v-else-if="detail.isVip">
  86. <text style="font-size: 14px;">¥</text>
  87. <span >{{detail.price}}</span>
  88. <text class="price">{{detail.oldPrice}}</text> 开通1个月会员
  89. <view class="position">
  90. <view id="talkbubble">{{detail.platformText}}车主</view>
  91. </view>
  92. </button>
  93. <button class="btn " @click="show = true" v-else>
  94. <text style="font-size: 14px;">¥</text>
  95. <span v-if="detail.discount" >
  96. {{detail.price/100*detail.discountRate}}</span>
  97. <span v-else >{{detail.price}}</span>
  98. <text v-if="detail.discount" class="price">{{detail.price}}</text> 开通1个月会员
  99. <view class="position" v-if="detail.remark">
  100. <view id="talkbubble">{{detail.remark}}</view>
  101. </view>
  102. </button>
  103. <view class="hint">
  104. 开通表示阅读并同意<span @click="gotoUrl('pages/article/details?code=FWFZKXY')" style="text-decoration:underline">《服务费折扣协议》</span>
  105. </view>
  106. </view>
  107. <!-- 须知 -->
  108. <view class="notice">
  109. <u-divider fontSize="36" border-color="#bbc039" color="#101010">购卡须知</u-divider>
  110. <view class="text">
  111. <view class="num">
  112. 01
  113. </view>
  114. <view class="">
  115. 服务费月卡默认与购卡人账户进行关联,所涉权益仅可绑定单个车牌,即账户、月卡、车牌三者关联形成一个权益主体。
  116. </view>
  117. </view>
  118. <view class="text">
  119. <view class="num">
  120. 02
  121. </view>
  122. <view class="">
  123. 服务费月卡有效期内,持卡人在指定充电站为绑定车辆充电,可享受充电服务费全免。持卡人给非绑定车辆充电,将正常收取充电服务费。
  124. </view>
  125. </view>
  126. <view class="text">
  127. <view class="num">
  128. 03
  129. </view>
  130. <view class="">
  131. 如车牌等信息填写错误,请致电售后客服进行处理。
  132. </view>
  133. </view>
  134. <view class="text">
  135. <view class="num">
  136. 04
  137. </view>
  138. <view class="">
  139. 本卡一经售出,不支持任何形式的退换。
  140. </view>
  141. </view>
  142. <view class="slogan-4"
  143. v-if="cardId||ispay"
  144. @click="gotoUrl('pages/monthlyCardActivity/monthlyCardList?cardId='+(ispay?userCard.rentCardId:cardId))">
  145. 查看本活动适用站点
  146. </view>
  147. </view>
  148. </view>
  149. </template>
  150. <script>
  151. import * as API_weixin from '@/apis/weixin.js'
  152. import * as Pay from '@/apis/weixin.js'
  153. import * as API from '@/apis/card.js'
  154. import * as loginApi from '@/apis/login.js'
  155. import QRCode from 'qrcodejs2'
  156. import {
  157. newDate,
  158. convertCanvasToImage,
  159. } from '@/utils'
  160. import {
  161. wxPayJs
  162. } from '@/utils/wxpay'
  163. export default {
  164. data() {
  165. return {
  166. description: '盟主能量包本期限时优惠活动将于9月16日结束。',
  167. checked: "false",
  168. cardId: '',
  169. qrCodeImg: "",
  170. showModel: false,
  171. cardList: [],
  172. projectName: "",
  173. list: [{
  174. text: '微信',
  175. }, {
  176. text: '支付宝'
  177. }],
  178. show: false,
  179. submitForm: {},
  180. ykgz: '',
  181. detail: {},
  182. ispay: false,
  183. show2: false,
  184. show1: false,
  185. infoSet: false,
  186. infoSet1: false,
  187. userCard: null,
  188. isReady:false,
  189. }
  190. },
  191. onLoad() {
  192. this.projectName = process.car.ProjectName;
  193. },
  194. onReady() {
  195. this.ykgz = this.carhelp.getConfig().ykgz
  196. //this.checkSubscribe()
  197. },
  198. onShow() {
  199. this.checkSubscribe();
  200. },
  201. computed: {
  202. endCardBool() {
  203. if (!this.cardList.length) {
  204. return false;
  205. }
  206. var date = new Date().getTime()
  207. if (!this.detail.endTime) {
  208. return true;
  209. }
  210. var date2 = newDate(this.detail.endTime).getTime();
  211. if (date < date2) {
  212. return true;
  213. } else {
  214. return false;
  215. }
  216. }
  217. },
  218. methods: {
  219. checkboxChange(monthlyRentCard) {
  220. this.detail=monthlyRentCard;
  221. this.cardId=monthlyRentCard.id
  222. monthlyRentCard.checked=true
  223. for(var i in this.cardList){
  224. var obj=this.cardList[i].monthlyRentCard;
  225. if(this.cardId==obj.id){
  226. }else{
  227. obj.checked=false
  228. }
  229. }
  230. },
  231. gotoGz() {
  232. this.carhelp.setGzDate()
  233. var url = "https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
  234. window.location.href = url
  235. },
  236. checkSubscribe() {
  237. uni.showLoading({
  238. title: "加载中",
  239. mask: true,
  240. })
  241. API_weixin.checkSubscribe({
  242. openId: this.carhelp.getOpenId()
  243. }).then((res) => {
  244. uni.hideLoading()
  245. if (res.data == "0") {
  246. this.show1 = true
  247. } else {
  248. //this.getInfo();
  249. this.getCardList();
  250. this.show2 = true;
  251. //this.carhelp.setGzDate()
  252. }
  253. //setGzDate
  254. }).catch(error => {
  255. uni.showToast({
  256. title: error
  257. })
  258. })
  259. },
  260. userCardBool(userCard) {
  261. if (userCard) {
  262. var date = new Date().getTime()
  263. var date2 = newDate(userCard.endTime).getTime();
  264. if (date < date2) {
  265. return true;
  266. }
  267. }
  268. return false
  269. },
  270. getCardList() {
  271. uni.showLoading({
  272. title: "加载中",
  273. mask: true,
  274. })
  275. API.cardList({
  276. }).then((response) => {
  277. this.cardList = response.data.cardList;
  278. if (this.cardList.length) {
  279. this.detail = this.cardList[0].monthlyRentCard
  280. this.cardId = this.detail.id;
  281. this.cardList[0].monthlyRentCard.checked=true
  282. }
  283. this.getUserInfo()
  284. this.isReady=true;
  285. //cardId: this.cardId
  286. }).catch(error => {
  287. uni.showToast({
  288. title: error
  289. })
  290. })
  291. },
  292. getUserInfo() {
  293. uni.showLoading({
  294. title: "加载中",
  295. mask: true,
  296. })
  297. loginApi.findByOpenId({
  298. openId: this.carhelp.getOpenId(),
  299. noerror: true
  300. }).then((res) => {
  301. if (res.code == 200 && res.result) {
  302. if (res.data.regUser) {
  303. var userInfo = res.data.regUser
  304. if (userInfo.carId && userInfo.realName) {
  305. this.infoSet = true;
  306. } else {
  307. this.infoSet = false;
  308. if (this.endCardBool) {
  309. this.infoSet1 = true;
  310. }
  311. }
  312. var userCard = res.data.userCard;
  313. this.userCard = userCard
  314. this.ispay = this.userCardBool(userCard)
  315. } else {
  316. }
  317. }
  318. uni.hideLoading();
  319. }).catch(error => {
  320. uni.showToast({
  321. title: error,
  322. icon: "none"
  323. })
  324. })
  325. },
  326. putShelf2() {
  327. uni.showToast({
  328. title: "暂不支持重复购买"
  329. })
  330. },
  331. putShelf() {
  332. uni.showToast({
  333. title: "已下架,暂不支持购买"
  334. })
  335. },
  336. getInfo() {
  337. uni.showLoading({
  338. title: "加载中",
  339. mask: true,
  340. })
  341. API.cardDetail({
  342. cardId: this.cardId
  343. }).then((response) => {
  344. this.detail = response.data.monthlyRentCard
  345. uni.hideLoading()
  346. }).catch(error => {
  347. uni.showToast({
  348. title: error
  349. })
  350. })
  351. },
  352. submit(type) {
  353. if (!this.endCardBool) {
  354. return
  355. }
  356. uni.showLoading({
  357. title: "加载中",
  358. mask: true,
  359. })
  360. API.openCard({
  361. cardId: this.cardId
  362. }).then((response) => {
  363. this.submitForm.id = response.data.orderInfoId
  364. if (type == 0) {
  365. this.wxpy()
  366. }
  367. if (type == 1) {
  368. this.alpy()
  369. }
  370. }).catch(error => {
  371. uni.showToast({
  372. title: error
  373. })
  374. })
  375. },
  376. alpy() {
  377. uni.showLoading({
  378. title: "加载中",
  379. mask: true,
  380. })
  381. var listcanvas=document.getElementsByTagName('canvas')
  382. if(listcanvas.length>0){
  383. document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
  384. }
  385. Pay.alpay(this.submitForm).then((response) => {
  386. let qrcode = new QRCode('qrcode', {
  387. width: 200,
  388. height: 200,
  389. text: response.data.qr_code,
  390. correctLevel: QRCode.CorrectLevel.M,
  391. })
  392. this.outOrderNo = response.data.outOrderNo;
  393. var canvas = document.getElementsByTagName('canvas')[0];
  394. this.qrCodeImg = convertCanvasToImage(canvas);
  395. uni.hideLoading()
  396. this.showModel = true
  397. }).catch(error => {
  398. uni.showToast({
  399. title: error
  400. })
  401. })
  402. },
  403. wxpy() {
  404. Pay.wxpay(this.submitForm).then((response) => {
  405. if (!response.result) {
  406. uni.showToast({
  407. title: response.message
  408. })
  409. return
  410. }
  411. var data = response.data
  412. uni.hideLoading()
  413. //("Pay+"+new Date().getTime())
  414. wxPayJs(data);
  415. }).catch(error => {
  416. uni.showToast({
  417. title: error
  418. })
  419. })
  420. },
  421. confirm() {
  422. this.getUserInfo();
  423. uni.redirectTo({
  424. url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
  425. })
  426. },
  427. click(index) {
  428. console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
  429. this.submit(index);
  430. }
  431. }
  432. }
  433. </script>
  434. <style lang="scss" scoped>
  435. /deep/.u-alert-desc {
  436. color: #ff7300;
  437. }
  438. // 卡片
  439. .main {
  440. background-color: #404A5E;
  441. padding: 40rpx 40rpx 30px 40rpx;
  442. .tag {
  443. position: absolute;
  444. background-color: rgba(255, 61, 0, 100);
  445. color: #ffffff;
  446. font-size: 12px;
  447. text-align: center;
  448. line-height: 20px;
  449. padding: 0 6px;
  450. left: 284rpx;
  451. top: 44rpx;
  452. }
  453. @media screen and (max-width:320px) {
  454. .tag {
  455. padding: 0 4rpx;
  456. }
  457. .price {
  458. position: absolute;
  459. top: 24rpx !important;
  460. right: 8rpx !important;
  461. }
  462. .current-price {
  463. font-size: 36rpx;
  464. }
  465. }
  466. .price {
  467. top: 24rpx;
  468. right: 32rpx;
  469. position: absolute;
  470. p{
  471. text-align: right;
  472. color: rgba(0, 0, 0, 0.5);
  473. font-size: 12px
  474. }
  475. }
  476. .current-price {
  477. font-size: 64rpx;
  478. color: #101010;
  479. text-align: right;
  480. text {
  481. font-size: 28rpx;
  482. }
  483. }
  484. .original-cost {
  485. color: rgba(75, 65, 50, 100);
  486. text-decoration: line-through;
  487. }
  488. /deep/.u-iconfont {
  489. font-size: 36rpx !important;
  490. }
  491. .card-1:nth-last-of-type(1){
  492. margin-top: 32rpx;
  493. }
  494. .card-1 {
  495. position: relative;
  496. background-size: cover;
  497. height: 300rpx;
  498. /deep/.u-checkbox__icon-wrap {
  499. background-color: #607d8b;
  500. opacity: 0.3
  501. }
  502. .radio-box {
  503. margin-top: 78rpx;
  504. float: right;
  505. margin-right: -30rpx;
  506. }
  507. }
  508. .card-2 {
  509. position: relative;
  510. background: url(@/assets/img/card_operate.png) no-repeat;
  511. background-size: cover;
  512. height: 300rpx;
  513. margin-top: 32rpx;
  514. /deep/.u-checkbox__icon-wrap {
  515. background-color: #B29467;
  516. }
  517. .radio-box {
  518. margin-top: 78rpx;
  519. float: right;
  520. margin-right: -30rpx;
  521. }
  522. }
  523. }
  524. // 按钮
  525. .button {
  526. margin-top: -20rpx;
  527. border-radius: 16px 16px 0px 0px;
  528. background-color: rgba(255, 255, 255, 100);
  529. padding: 20px 20px 16px 20px;
  530. uni-button:after {
  531. border: none;
  532. }
  533. .btn {
  534. border: none !important;
  535. background: linear-gradient(#E1D0A5, #E4BE84);
  536. box-shadow: 0px 2px 6px 0px rgba(207, 175, 118, 40);
  537. border-radius: 50px;
  538. color: #101010;
  539. font-size: 18px !important;
  540. line-height: 44px;
  541. height: 44px;
  542. overflow: inherit !important;
  543. .price {
  544. text-decoration: line-through;
  545. margin: auto 4px;
  546. font-size: 12px
  547. }
  548. }
  549. .hint {
  550. color: rgba(159, 157, 154, 100);
  551. line-height: 20px;
  552. text-align: center;
  553. margin-top: 8px;
  554. }
  555. .btn-2 {
  556. position: relative;
  557. }
  558. .position {
  559. position: absolute;
  560. top: -16px;
  561. left: 24%;
  562. z-index: 999;
  563. }
  564. #talkbubble {
  565. position: absolute;
  566. top: 0;
  567. left: 0;
  568. width: 60px;
  569. line-height: 20px;
  570. font-size: 12px;
  571. color: #fff;
  572. background: red;
  573. position: relative;
  574. border-radius: 10px;
  575. text-align: center;
  576. }
  577. #talkbubble:before {
  578. content: "";
  579. position: absolute;
  580. top: 100%;
  581. right: 45%;
  582. border-top: 5px solid red;
  583. border-right: 5px solid transparent;
  584. border-left: 5px solid transparent;
  585. }
  586. }
  587. // 须知
  588. .notice {
  589. background-color: #fff;
  590. margin-top: 12px;
  591. padding: 20px 20px 72px 30px;
  592. /deep/.u-divider {
  593. margin-bottom: 16px !important;
  594. }
  595. .text {
  596. color: #666666;
  597. margin-bottom: 12px;
  598. line-height: 24px;
  599. display: flex;
  600. .num {
  601. margin-right: 8px;
  602. }
  603. }
  604. }
  605. .carNone{
  606. display: flex;
  607. flex-direction: column;
  608. justify-content: center;
  609. align-items: center;
  610. img{
  611. width: 100%;
  612. height: 100%;
  613. }
  614. p{
  615. margin-top: -60px;
  616. }
  617. }
  618. .slogan-4 {
  619. margin-top: 10px;
  620. text-decoration: underline;
  621. height: 20px;
  622. color: #9F9C99;
  623. font-size: 32rpx;
  624. text-align: center;
  625. }
  626. </style>