monthlyCardBuy.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <view>
  3. <ujp-navbar title="包月卡购买"></ujp-navbar>
  4. <!-- 卡片 -->
  5. <view class="monthly-card-bgc">
  6. <view class="monthly-card">
  7. <view class="main">
  8. <view class="title-1">
  9. 充电服务费包月卡
  10. </view>
  11. <view class="title-2">
  12. 有效期内,合约充电站使用度数无上限
  13. </view>
  14. </view>
  15. <img class="cover" src="../../assets/img/cover@3.png" alt="">
  16. </view>
  17. </view>
  18. <view class="slogan-1">
  19. 充电服务费包月卡
  20. </view>
  21. <view class="slogan-2">
  22. 单次购买、整月受益!
  23. </view>
  24. <view class="slogan-3" style="color: #ead9b4;" >
  25. 限时活动结束时间2022年8月8日0点结束
  26. </view>
  27. <view class="slogan-3" >
  28. 仅限车主购买,适用于平台对外开放充电站
  29. </view>
  30. <view class="slogan-4" @click="gotoUrl('pages/monthlyCardActivity/monthlyCardList?cardId='+cardId)">
  31. 查看适用站点
  32. </view>
  33. <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
  34. <u-modal v-model="showModel" :show-cancel-button="true" @cancel="getUserInfo()" @confirm="confirm" confirm-text="支付成功?" title="扫码支付">
  35. <view style="
  36. text-align: center;
  37. ">
  38. <img id="qrcode2" :src="qrCodeImg">
  39. </view>
  40. <view style="
  41. text-align: center;
  42. ">请使用支付宝扫码</view>
  43. </u-modal>
  44. <img id="qrcode" style="display: none;">
  45. <view class="bottom" v-if="!show2" @click="gotoGz" >
  46. <button class="dredge" >关注公众号</button>
  47. </view>
  48. <view class="bottom" v-else-if="!infoSet" @click="gotoUrl('pages/user/dataSet')" >
  49. <button class="dredge" >完善个人信息</button>
  50. </view>
  51. <view class="bottom" v-else-if="!endCardBool" >
  52. <button class="dredge" >已下架</button>
  53. </view>
  54. <!-- 立即开通 -->
  55. <view class="bottom" v-else-if="ispay" >
  56. <button class="dredge" >已购买</button>
  57. </view>
  58. <!-- 立即开通 -->
  59. <view class="bottom" v-else-if="!ispay&&detail.price" >
  60. <button class="dredge" v-if="detail.putShelf&&!detail.isVip" @click="show = true">立即开通 ¥{{detail.price.toFixed(2)}}/月</button>
  61. <button class="dredge" v-if="detail.putShelf&&detail.isVip" @click="show = true">{{detail.platformText}}车主特惠 ¥{{detail.price.toFixed(2)}}/月<span style="font-size: 12px; text-decoration: line-through;">¥{{detail.oldPrice.toFixed(2)}}</span></button>
  62. <button class="dredge" v-if="!detail.putShelf" @click="putShelf" > 已下架</button>
  63. <p>开通表示阅读并同意
  64. <text class="agreement" @click="gotoUrl('pages/article/details?code=FWFZKXY')">《服务费折扣协议》</text>
  65. </p>
  66. </view>
  67. <u-modal v-model="show1" @confirm="gotoGz"
  68. cancel-text="暂不关注"
  69. confirm-text="前往关注"
  70. confirm-color="#53b56b"
  71. :show-cancel-button="true"
  72. ref="uModal2" :asyncClose="true"
  73. >
  74. <view style="padding: 15px;"
  75. >请先关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,购买月卡</view>
  76. </u-modal>
  77. <u-modal v-model="infoSet1" @confirm="infoSet1=false,gotoUrl('pages/user/dataSet')"
  78. cancel-text="取消"
  79. confirm-text="完善个人信息"
  80. confirm-color="#53b56b"
  81. :show-cancel-button="true"
  82. ref="uModal2" :asyncClose="true"
  83. >
  84. <view style="padding: 15px;"
  85. >购买月卡需要完善以下2点<br/>
  86. 1.填写真实姓名<br/>
  87. 2.填写车牌号<br/>
  88. </view>
  89. </u-modal>
  90. </view>
  91. </template>
  92. <script>
  93. import * as API_weixin from '@/apis/weixin.js'
  94. import * as Pay from '@/apis/weixin.js'
  95. import * as API from '@/apis/card.js'
  96. import * as loginApi from '@/apis/login.js'
  97. import QRCode from 'qrcodejs2'
  98. import {
  99. newDate,
  100. convertCanvasToImage,
  101. } from '@/utils'
  102. import {
  103. wxPayJs
  104. } from '@/utils/wxpay'
  105. export default {
  106. data() {
  107. return {
  108. cardId:'3e1b0f8f-61b0-405f-a285-929b5346479f',
  109. qrCodeImg: "",
  110. showModel: false,
  111. projectName:"",
  112. list: [{
  113. text: '微信',
  114. }, {
  115. text: '支付宝'
  116. }],
  117. show: false,
  118. submitForm:{},
  119. detail:{},
  120. ispay:true,
  121. show2:false,
  122. show1:false,
  123. infoSet:false,
  124. infoSet1:false,
  125. endTime:"2022-08-08"
  126. }
  127. },
  128. onLoad() {
  129. this.projectName=process.car.ProjectName;
  130. },
  131. onReady() {
  132. //this.checkSubscribe()
  133. },
  134. onShow(){
  135. this.checkSubscribe();
  136. },
  137. computed:{
  138. endCardBool(){
  139. var date=new Date().getTime()
  140. var date2=new Date(this.endTime).getTime();
  141. if(date<date2){
  142. return true;
  143. }else{
  144. return false;
  145. }
  146. }
  147. },
  148. methods: {
  149. gotoGz(){
  150. this.carhelp.setGzDate()
  151. var url="https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
  152. window.location.href=url
  153. },
  154. checkSubscribe(){
  155. API_weixin.checkSubscribe({
  156. openId: this.carhelp.getOpenId()
  157. }).then((res) => {
  158. if(res.data=="0"){
  159. this.show1=true
  160. }else{
  161. this.getInfo();
  162. this.getUserInfo()
  163. this.show2=true;
  164. //this.carhelp.setGzDate()
  165. }
  166. //setGzDate
  167. }).catch(error => {
  168. uni.showToast({
  169. title: error
  170. })
  171. })
  172. },
  173. userCardBool(userCard){
  174. if(userCard){
  175. var date=new Date().getTime()
  176. var date2=newDate(userCard.endTime).getTime();
  177. if(date<date2){
  178. return true;
  179. }
  180. }
  181. return false
  182. },
  183. getUserInfo(){
  184. uni.showLoading({
  185. title: "加载中",
  186. mask: true,
  187. })
  188. loginApi.findByOpenId({
  189. openId: this.carhelp.getOpenId(),
  190. noerror:true
  191. }).then((res) => {
  192. uni.hideLoading();
  193. if (res.code == 200&&res.result) {
  194. if(res.data.regUser){
  195. var userInfo=res.data.regUser
  196. if(userInfo.carId&&userInfo.realName){
  197. this.infoSet=true;
  198. }else{
  199. this.infoSet=false;
  200. this.infoSet1=true;
  201. }
  202. var userCard=res.data.userCard;
  203. this.ispay= this.userCardBool(userCard)
  204. }else{
  205. }
  206. }
  207. }).catch(error => {
  208. uni.showToast({
  209. title: error,
  210. icon: "none"
  211. })
  212. })
  213. },
  214. putShelf2(){
  215. uni.showToast({
  216. title:"暂不支持重复购买"
  217. })
  218. },
  219. putShelf(){
  220. uni.showToast({
  221. title:"已下架,暂不支持购买"
  222. })
  223. },
  224. getInfo(){
  225. uni.showLoading({
  226. title: "加载中",
  227. mask: true,
  228. })
  229. API.cardDetail({
  230. cardId:this.cardId
  231. }).then((response) => {
  232. console.log(response)
  233. this.detail=response.data.monthlyRentCard
  234. uni.hideLoading()
  235. }).catch(error => {
  236. uni.showToast({
  237. title: error
  238. })
  239. })
  240. },
  241. submit(type){
  242. if(!this.endCardBool){
  243. return
  244. }
  245. uni.showLoading({
  246. title: "加载中",
  247. mask: true,
  248. })
  249. API.openCard({
  250. cardId:this.cardId
  251. }).then((response) => {
  252. this.submitForm.id=response.data.orderInfoId
  253. if(type==0){
  254. this.wxpy()
  255. }
  256. if(type==1){
  257. this.alpy()
  258. }
  259. }).catch(error => {
  260. uni.showToast({
  261. title: error
  262. })
  263. })
  264. },
  265. alpy() {
  266. uni.showLoading({
  267. title: "加载中",
  268. mask: true,
  269. })
  270. Pay.alpay(this.submitForm).then((response) => {
  271. let qrcode = new QRCode('qrcode', {
  272. width: 200,
  273. height: 200,
  274. text: response.data.qr_code,
  275. correctLevel: QRCode.CorrectLevel.M,
  276. })
  277. this.outOrderNo = response.data.outOrderNo;
  278. var canvas = document.getElementsByTagName('canvas')[0];
  279. this.qrCodeImg = convertCanvasToImage(canvas);
  280. uni.hideLoading()
  281. this.showModel = true
  282. }).catch(error => {
  283. uni.showToast({
  284. title: error
  285. })
  286. })
  287. },
  288. wxpy() {
  289. Pay.wxpay(this.submitForm).then((response) => {
  290. if (!response.result) {
  291. uni.showToast({
  292. title: response.message
  293. })
  294. return
  295. }
  296. var data = response.data
  297. uni.hideLoading()
  298. //("Pay+"+new Date().getTime())
  299. wxPayJs(data);
  300. }).catch(error => {
  301. uni.showToast({
  302. title: error
  303. })
  304. })
  305. },
  306. confirm() {
  307. this.getUserInfo();
  308. uni.redirectTo({
  309. url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
  310. })
  311. },
  312. click(index) {
  313. console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
  314. this.submit(index);
  315. }
  316. }
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. page {
  321. background-color: #2a2c31;
  322. }
  323. .monthly-card-bgc{
  324. padding: 20px;
  325. background-color: #101010;
  326. height: 150px;
  327. position: relative;
  328. }
  329. // 卡片
  330. .monthly-card {
  331. border-radius: 16px;
  332. height: 150px;
  333. background: linear-gradient(#F2E6CA, #C9A87B);
  334. .main {
  335. padding: 24px 0 24px 24px;
  336. height: 100%;
  337. background: url(@/assets/img/card@3.png);
  338. background-repeat: no-repeat;
  339. background-position: 30% 10%;
  340. background-size: cover;
  341. color: rgba(255, 255, 255, 100);
  342. border-radius: 6px;
  343. .title-1 {
  344. line-height: 28px;
  345. font-size: 56rpx;
  346. margin-bottom: 8px;
  347. }
  348. .title-2 {
  349. line-height: 24px;
  350. font-size: 34rpx;
  351. }
  352. }
  353. .cover {
  354. width: 100%;
  355. position: absolute;
  356. bottom: -30px;
  357. left: 0px;
  358. right: 0;
  359. }
  360. }
  361. .slogan-1 {
  362. margin-top: 50px;
  363. height: 36px;
  364. color: rgba(234, 217, 180, 100);
  365. font-size: 48rpx;
  366. text-align: center;
  367. margin-bottom: 4px;
  368. }
  369. .slogan-2 {
  370. height: 36px;
  371. color: rgba(234, 217, 180, 100);
  372. font-size: 56rpx;
  373. text-align: center;
  374. margin-bottom: 12px;
  375. }
  376. .slogan-3 {
  377. height: 20px;
  378. color: rgba(255, 255, 255, 100);
  379. font-size: 28rpx;
  380. text-align: center;
  381. }
  382. .slogan-4 {
  383. text-decoration:underline;
  384. height: 20px;
  385. color: #9F9C99;
  386. font-size: 32rpx;
  387. text-align: center;
  388. }
  389. // 立即开通
  390. .bottom {
  391. position: fixed;
  392. background-color: #2a2c31;
  393. bottom: 0px;
  394. padding-bottom: 40px;
  395. left: 0;
  396. right: 0;
  397. .dredge {
  398. // width: 72.2%;
  399. margin: 0 20px;
  400. border-radius: 50px;
  401. font-size: 36rpx;
  402. background: linear-gradient(to right, #C9A87B, #F2E6CA);
  403. margin-bottom: 12px;
  404. }
  405. p {
  406. height: 20px;
  407. color: rgba(226, 222, 217, 100);
  408. font-size: 14px;
  409. text-align: center;
  410. }
  411. .agreement {
  412. color: #897a69;
  413. }
  414. }
  415. </style>