monthlyCardBuy.vue 15 KB

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