monthlyCardBuy.vue 16 KB

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