monthlyCardBuy.vue 17 KB

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