monthlyCardBuy.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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>
  142. </view>
  143. </template>
  144. <script>
  145. import * as API_weixin from '@/apis/weixin.js'
  146. import * as Pay from '@/apis/weixin.js'
  147. import * as API from '@/apis/card.js'
  148. import * as loginApi from '@/apis/login.js'
  149. import QRCode from 'qrcodejs2'
  150. import {
  151. newDate,
  152. convertCanvasToImage,
  153. } from '@/utils'
  154. import {
  155. wxPayJs
  156. } from '@/utils/wxpay'
  157. export default {
  158. data() {
  159. return {
  160. description: '盟主能量包本期限时优惠活动将于9月16日结束。',
  161. checked: "false",
  162. cardId: '',
  163. qrCodeImg: "",
  164. showModel: false,
  165. cardList: [],
  166. projectName: "",
  167. list: [{
  168. text: '微信',
  169. }, {
  170. text: '支付宝'
  171. }],
  172. show: false,
  173. submitForm: {},
  174. ykgz: '',
  175. detail: {},
  176. ispay: false,
  177. show2: false,
  178. show1: false,
  179. infoSet: false,
  180. infoSet1: false,
  181. userCard: null,
  182. isReady:false,
  183. }
  184. },
  185. onLoad() {
  186. this.projectName = process.car.ProjectName;
  187. },
  188. onReady() {
  189. this.ykgz = this.carhelp.getConfig().ykgz
  190. //this.checkSubscribe()
  191. },
  192. onShow() {
  193. this.checkSubscribe();
  194. },
  195. computed: {
  196. endCardBool() {
  197. if (!this.cardList.length) {
  198. return false;
  199. }
  200. var date = new Date().getTime()
  201. if (!this.detail.endTime) {
  202. return true;
  203. }
  204. var date2 = newDate(this.detail.endTime).getTime();
  205. if (date < date2) {
  206. return true;
  207. } else {
  208. return false;
  209. }
  210. }
  211. },
  212. methods: {
  213. checkboxChange(monthlyRentCard) {
  214. this.detail=monthlyRentCard;
  215. this.cardId=monthlyRentCard.id
  216. monthlyRentCard.checked=true
  217. for(var i in this.cardList){
  218. var obj=this.cardList[i].monthlyRentCard;
  219. if(this.cardId==obj.id){
  220. }else{
  221. obj.checked=false
  222. }
  223. }
  224. },
  225. gotoGz() {
  226. this.carhelp.setGzDate()
  227. var url = "https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
  228. window.location.href = url
  229. },
  230. checkSubscribe() {
  231. uni.showLoading({
  232. title: "加载中",
  233. mask: true,
  234. })
  235. API_weixin.checkSubscribe({
  236. openId: this.carhelp.getOpenId()
  237. }).then((res) => {
  238. uni.hideLoading()
  239. if (res.data == "0") {
  240. this.show1 = true
  241. } else {
  242. //this.getInfo();
  243. this.getCardList();
  244. this.show2 = true;
  245. //this.carhelp.setGzDate()
  246. }
  247. //setGzDate
  248. }).catch(error => {
  249. uni.showToast({
  250. title: error
  251. })
  252. })
  253. },
  254. userCardBool(userCard) {
  255. if (userCard) {
  256. var date = new Date().getTime()
  257. var date2 = newDate(userCard.endTime).getTime();
  258. if (date < date2) {
  259. return true;
  260. }
  261. }
  262. return false
  263. },
  264. getCardList() {
  265. uni.showLoading({
  266. title: "加载中",
  267. mask: true,
  268. })
  269. API.cardList({
  270. }).then((response) => {
  271. this.cardList = response.data.cardList;
  272. if (this.cardList.length) {
  273. this.detail = this.cardList[0].monthlyRentCard
  274. this.cardId = this.detail.id;
  275. this.cardList[0].monthlyRentCard.checked=true
  276. }
  277. this.getUserInfo()
  278. this.isReady=true;
  279. //cardId: this.cardId
  280. }).catch(error => {
  281. uni.showToast({
  282. title: error
  283. })
  284. })
  285. },
  286. getUserInfo() {
  287. uni.showLoading({
  288. title: "加载中",
  289. mask: true,
  290. })
  291. loginApi.findByOpenId({
  292. openId: this.carhelp.getOpenId(),
  293. noerror: true
  294. }).then((res) => {
  295. if (res.code == 200 && res.result) {
  296. if (res.data.regUser) {
  297. var userInfo = res.data.regUser
  298. if (userInfo.carId && userInfo.realName) {
  299. this.infoSet = true;
  300. } else {
  301. this.infoSet = false;
  302. if (this.endCardBool) {
  303. this.infoSet1 = true;
  304. }
  305. }
  306. var userCard = res.data.userCard;
  307. this.userCard = userCard
  308. this.ispay = this.userCardBool(userCard)
  309. } else {
  310. }
  311. }
  312. uni.hideLoading();
  313. }).catch(error => {
  314. uni.showToast({
  315. title: error,
  316. icon: "none"
  317. })
  318. })
  319. },
  320. putShelf2() {
  321. uni.showToast({
  322. title: "暂不支持重复购买"
  323. })
  324. },
  325. putShelf() {
  326. uni.showToast({
  327. title: "已下架,暂不支持购买"
  328. })
  329. },
  330. getInfo() {
  331. uni.showLoading({
  332. title: "加载中",
  333. mask: true,
  334. })
  335. API.cardDetail({
  336. cardId: this.cardId
  337. }).then((response) => {
  338. this.detail = response.data.monthlyRentCard
  339. uni.hideLoading()
  340. }).catch(error => {
  341. uni.showToast({
  342. title: error
  343. })
  344. })
  345. },
  346. submit(type) {
  347. if (!this.endCardBool) {
  348. return
  349. }
  350. uni.showLoading({
  351. title: "加载中",
  352. mask: true,
  353. })
  354. API.openCard({
  355. cardId: this.cardId
  356. }).then((response) => {
  357. this.submitForm.id = response.data.orderInfoId
  358. if (type == 0) {
  359. this.wxpy()
  360. }
  361. if (type == 1) {
  362. this.alpy()
  363. }
  364. }).catch(error => {
  365. uni.showToast({
  366. title: error
  367. })
  368. })
  369. },
  370. alpy() {
  371. uni.showLoading({
  372. title: "加载中",
  373. mask: true,
  374. })
  375. var listcanvas=document.getElementsByTagName('canvas')
  376. if(listcanvas.length>0){
  377. document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
  378. }
  379. Pay.alpay(this.submitForm).then((response) => {
  380. let qrcode = new QRCode('qrcode', {
  381. width: 200,
  382. height: 200,
  383. text: response.data.qr_code,
  384. correctLevel: QRCode.CorrectLevel.M,
  385. })
  386. this.outOrderNo = response.data.outOrderNo;
  387. var canvas = document.getElementsByTagName('canvas')[0];
  388. this.qrCodeImg = convertCanvasToImage(canvas);
  389. uni.hideLoading()
  390. this.showModel = true
  391. }).catch(error => {
  392. uni.showToast({
  393. title: error
  394. })
  395. })
  396. },
  397. wxpy() {
  398. Pay.wxpay(this.submitForm).then((response) => {
  399. if (!response.result) {
  400. uni.showToast({
  401. title: response.message
  402. })
  403. return
  404. }
  405. var data = response.data
  406. uni.hideLoading()
  407. //("Pay+"+new Date().getTime())
  408. wxPayJs(data);
  409. }).catch(error => {
  410. uni.showToast({
  411. title: error
  412. })
  413. })
  414. },
  415. confirm() {
  416. this.getUserInfo();
  417. uni.redirectTo({
  418. url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
  419. })
  420. },
  421. click(index) {
  422. console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
  423. this.submit(index);
  424. }
  425. }
  426. }
  427. </script>
  428. <style lang="scss" scoped>
  429. /deep/.u-alert-desc {
  430. color: #ff7300;
  431. }
  432. // 卡片
  433. .main {
  434. background-color: #404A5E;
  435. padding: 40rpx 40rpx 30px 40rpx;
  436. .tag {
  437. position: absolute;
  438. background-color: rgba(255, 61, 0, 100);
  439. color: #ffffff;
  440. font-size: 12px;
  441. text-align: center;
  442. line-height: 20px;
  443. padding: 0 6px;
  444. left: 284rpx;
  445. top: 44rpx;
  446. }
  447. @media screen and (max-width:320px) {
  448. .tag {
  449. padding: 0 4rpx;
  450. }
  451. .price {
  452. position: absolute;
  453. top: 24rpx !important;
  454. right: 8rpx !important;
  455. }
  456. .current-price {
  457. font-size: 36rpx;
  458. }
  459. }
  460. .price {
  461. top: 24rpx;
  462. right: 32rpx;
  463. position: absolute;
  464. }
  465. .current-price {
  466. font-size: 64rpx;
  467. color: #101010;
  468. text-align: right;
  469. text {
  470. font-size: 28rpx;
  471. }
  472. }
  473. .original-cost {
  474. color: rgba(75, 65, 50, 100);
  475. text-decoration: line-through;
  476. }
  477. /deep/.u-iconfont {
  478. font-size: 36rpx !important;
  479. }
  480. .card-1:nth-last-of-type(1){
  481. margin-top: 32rpx;
  482. }
  483. .card-1 {
  484. position: relative;
  485. background-size: cover;
  486. height: 300rpx;
  487. /deep/.u-checkbox__icon-wrap {
  488. background-color: #607d8b;
  489. opacity: 0.5;
  490. }
  491. .radio-box {
  492. margin-top: 78rpx;
  493. float: right;
  494. margin-right: -30rpx;
  495. }
  496. }
  497. .card-2 {
  498. position: relative;
  499. background: url(@/assets/img/card_operate.png) no-repeat;
  500. background-size: cover;
  501. height: 300rpx;
  502. margin-top: 32rpx;
  503. /deep/.u-checkbox__icon-wrap {
  504. background-color: #B29467;
  505. }
  506. .radio-box {
  507. margin-top: 78rpx;
  508. float: right;
  509. margin-right: -30rpx;
  510. }
  511. }
  512. /deep/.u-checkbox__icon-wrap{
  513. opacity: 0.1;
  514. }
  515. }
  516. // 按钮
  517. .button {
  518. margin-top: -20rpx;
  519. border-radius: 16px 16px 0px 0px;
  520. background-color: rgba(255, 255, 255, 100);
  521. padding: 20px 20px 16px 20px;
  522. uni-button:after {
  523. border: none;
  524. }
  525. .btn {
  526. border: none !important;
  527. background: linear-gradient(#E1D0A5, #E4BE84);
  528. box-shadow: 0px 2px 6px 0px rgba(207, 175, 118, 40);
  529. border-radius: 50px;
  530. color: #101010;
  531. font-size: 18px !important;
  532. line-height: 44px;
  533. height: 44px;
  534. overflow: inherit !important;
  535. .price {
  536. text-decoration: line-through;
  537. margin: auto 4px;
  538. font-size: 12px
  539. }
  540. }
  541. .hint {
  542. color: rgba(159, 157, 154, 100);
  543. line-height: 20px;
  544. text-align: center;
  545. margin-top: 8px;
  546. }
  547. .btn-2 {
  548. position: relative;
  549. }
  550. .position {
  551. position: absolute;
  552. top: -16px;
  553. left: 24%;
  554. z-index: 999;
  555. }
  556. #talkbubble {
  557. position: absolute;
  558. top: 0;
  559. left: 0;
  560. width: 60px;
  561. line-height: 20px;
  562. font-size: 12px;
  563. color: #fff;
  564. background: red;
  565. position: relative;
  566. border-radius: 10px;
  567. text-align: center;
  568. }
  569. #talkbubble:before {
  570. content: "";
  571. position: absolute;
  572. top: 100%;
  573. right: 45%;
  574. border-top: 5px solid red;
  575. border-right: 5px solid transparent;
  576. border-left: 5px solid transparent;
  577. }
  578. }
  579. // 须知
  580. .notice {
  581. background-color: #fff;
  582. margin-top: 12px;
  583. padding: 20px 20px 72px 30px;
  584. /deep/.u-divider {
  585. margin-bottom: 16px !important;
  586. }
  587. .text {
  588. color: #666666;
  589. margin-bottom: 12px;
  590. line-height: 24px;
  591. display: flex;
  592. .num {
  593. margin-right: 8px;
  594. }
  595. }
  596. }
  597. .carNone{
  598. display: flex;
  599. flex-direction: column;
  600. justify-content: center;
  601. align-items: center;
  602. img{
  603. width: 100%;
  604. height: 100%;
  605. }
  606. p{
  607. margin-top: -60px;
  608. }
  609. }
  610. </style>