123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <template>
- <view>
- <ujp-navbar title="包月卡购买"></ujp-navbar>
- <!-- 卡片 -->
- <view class="monthly-card">
- <view class="main">
- <view class="title-1">
- 充电服务费包月卡
- </view>
- <view class="title-2">
- 有效期内,合约充电站使用度数无上限
- </view>
- </view>
- <img class="cover" src="../../assets/img/cover@3.png" alt="">
- </view>
- <view class="slogan-1">
- 充电服务费包月卡
- </view>
- <view class="slogan-2">
- 单次购买、整月受益!
- </view>
- <view class="slogan-3" style="color: #ead9b4;" >
- 限时活动结束时间2022年8月8日0点结束
- </view>
- <view class="slogan-3" >
- 仅限车主购买,适用于平台对外开放充电站
- </view>
- <view class="slogan-4" @click="gotoUrl('pages/monthlyCardActivity/monthlyCardList?cardId='+cardId)">
- 查看适用站点
- </view>
-
-
-
- <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
- <u-modal v-model="showModel" :show-cancel-button="true" @cancel="getUserInfo()" @confirm="confirm" confirm-text="支付成功?" title="扫码支付">
- <view style="
- text-align: center;
- ">
- <img id="qrcode2" :src="qrCodeImg">
- </view>
- <view style="
- text-align: center;
- ">请使用支付宝扫码</view>
- </u-modal>
- <img id="qrcode" style="display: none;">
-
- <view class="bottom" v-if="!show2" @click="gotoGz" >
- <button class="dredge" >关注公众号</button>
- </view>
- <view class="bottom" v-else-if="!infoSet" @click="gotoUrl('pages/user/dataSet')" >
- <button class="dredge" >完善个人信息</button>
- </view>
- <view class="bottom" v-else-if="!endCardBool" >
- <button class="dredge" >已下架</button>
-
- </view>
-
- <!-- 立即开通 -->
- <view class="bottom" v-else-if="ispay" >
- <button class="dredge" >已购买</button>
- </view>
-
- <!-- 立即开通 -->
- <view class="bottom" v-else-if="!ispay&&detail.price" >
- <button class="dredge" v-if="detail.putShelf&&!detail.isVip" @click="show = true">立即开通 ¥{{detail.price.toFixed(2)}}/月</button>
- <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>
-
- <button class="dredge" v-if="!detail.putShelf" @click="putShelf" > 已下架</button>
-
- <p>开通表示阅读并同意
- <text class="agreement" @click="gotoUrl('pages/article/details?code=FWFZKXY')">《服务费折扣协议》</text>
- </p>
- </view>
-
-
- <u-modal v-model="show1" @confirm="gotoGz"
- cancel-text="暂不关注"
- confirm-text="前往关注"
-
- confirm-color="#53b56b"
- :show-cancel-button="true"
- ref="uModal2" :asyncClose="true"
- >
- <view style="padding: 15px;"
-
- >请先关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,购买月卡</view>
-
-
- </u-modal>
-
-
- <u-modal v-model="infoSet1" @confirm="infoSet1=false,gotoUrl('pages/user/dataSet')"
- cancel-text="取消"
- confirm-text="完善个人信息"
-
- confirm-color="#53b56b"
- :show-cancel-button="true"
- ref="uModal2" :asyncClose="true"
- >
- <view style="padding: 15px;"
-
- >购买月卡需要完善以下2点<br/>
- 1.填写昵称<br/>
- 2.填写车牌号<br/>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- import * as API_weixin from '@/apis/weixin.js'
-
- import * as Pay from '@/apis/weixin.js'
- import * as API from '@/apis/card.js'
- import * as loginApi from '@/apis/login.js'
- import QRCode from 'qrcodejs2'
- import {
- newDate,
- convertCanvasToImage,
- } from '@/utils'
- import {
- wxPayJs
- } from '@/utils/wxpay'
- export default {
- data() {
- return {
- cardId:'3e1b0f8f-61b0-405f-a285-929b5346479f',
- qrCodeImg: "",
- showModel: false,
- projectName:"",
- list: [{
- text: '微信',
- }, {
- text: '支付宝'
- }],
- show: false,
- submitForm:{},
- detail:{},
- ispay:true,
- show2:false,
- show1:false,
- infoSet:false,
- infoSet1:false,
- endTime:"2022-08-08"
- }
- },
- onLoad() {
- this.projectName=process.car.ProjectName;
-
- },
- onReady() {
-
- //this.checkSubscribe()
-
- },
- onShow(){
- this.checkSubscribe();
- },
- computed:{
- endCardBool(){
- var date=new Date().getTime()
- var date2=new Date(this.endTime).getTime();
-
- if(date<date2){
- return true;
- }else{
- return false;
- }
- }
- },
- methods: {
- gotoGz(){
- this.carhelp.setGzDate()
- var url="https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
- window.location.href=url
-
- },
- checkSubscribe(){
- API_weixin.checkSubscribe({
- openId: this.carhelp.getOpenId()
- }).then((res) => {
-
- if(res.data=="0"){
- this.show1=true
-
- }else{
- this.getInfo();
- this.getUserInfo()
- this.show2=true;
- //this.carhelp.setGzDate()
- }
-
- //setGzDate
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
-
- },
- userCardBool(userCard){
-
-
- if(userCard){
- var date=new Date().getTime()
- var date2=newDate(userCard.endTime).getTime();
- if(date<date2){
- return true;
- }
- }
- return false
- },
-
- getUserInfo(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- loginApi.findByOpenId({
- openId: this.carhelp.getOpenId(),
- noerror:true
- }).then((res) => {
- uni.hideLoading();
-
- if (res.code == 200&&res.result) {
-
- if(res.data.regUser){
- var userInfo=res.data.regUser
-
- if(userInfo.carId&&userInfo.nickName){
- this.infoSet=true;
-
- }else{
- this.infoSet=false;
- this.infoSet1=true;
- }
-
- var userCard=res.data.userCard;
- this.ispay= this.userCardBool(userCard)
-
- }else{
-
- }
-
- }
-
-
-
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- putShelf2(){
- uni.showToast({
- title:"暂不支持重复购买"
- })
- },
- putShelf(){
- uni.showToast({
- title:"已下架,暂不支持购买"
- })
- },
- getInfo(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.cardDetail({
- cardId:this.cardId
- }).then((response) => {
- console.log(response)
- this.detail=response.data.monthlyRentCard
- uni.hideLoading()
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
- },
- submit(type){
- if(!this.endCardBool){
- return
- }
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.openCard({
- cardId:this.cardId
- }).then((response) => {
- this.submitForm.id=response.data.orderInfoId
-
- if(type==0){
- this.wxpy()
- }
- if(type==1){
- this.alpy()
- }
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
-
- },
- alpy() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- Pay.alpay(this.submitForm).then((response) => {
- let qrcode = new QRCode('qrcode', {
- width: 200,
- height: 200,
- text: response.data.qr_code,
- correctLevel: QRCode.CorrectLevel.M,
- })
- this.outOrderNo = response.data.outOrderNo;
- var canvas = document.getElementsByTagName('canvas')[0];
- this.qrCodeImg = convertCanvasToImage(canvas);
- uni.hideLoading()
- this.showModel = true
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
- },
- wxpy() {
- Pay.wxpay(this.submitForm).then((response) => {
- if (!response.result) {
- uni.showToast({
- title: response.message
- })
- return
- }
- var data = response.data
- uni.hideLoading()
- //("Pay+"+new Date().getTime())
- wxPayJs(data);
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
- },
- confirm() {
- this.getUserInfo();
- uni.redirectTo({
- url: "/pages/user/finance/rechargeRes?id=" + this.outOrderNo
- })
- },
- click(index) {
- console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
- this.submit(index);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #2a2c31;
- }
- // 卡片
- .monthly-card {
- margin: 20px;
- border-radius: 16px;
- height: 150px;
- background: linear-gradient(#F2E6CA, #C9A87B);
- position: relative;
- .main {
- padding: 24px 0 24px 24px;
- height: 100%;
- background: url(@/assets/img/card@3.png);
- background-repeat: no-repeat;
- background-position: 30% 10%;
- background-size: cover;
- color: rgba(255, 255, 255, 100);
- border-radius: 6px;
- .title-1 {
- line-height: 28px;
- font-size: 56rpx;
- margin-bottom: 8px;
- }
- .title-2 {
- line-height: 24px;
- font-size: 34rpx;
- }
- }
- .cover {
- width: 102%;
- position: absolute;
- bottom: -10px;
- left: -2px;
- right: 0;
- }
- }
- .slogan-1 {
- height: 36px;
- color: rgba(234, 217, 180, 100);
- font-size: 48rpx;
- text-align: center;
- margin-bottom: 4px;
- }
- .slogan-2 {
- height: 36px;
- color: rgba(234, 217, 180, 100);
- font-size: 56rpx;
- text-align: center;
- margin-bottom: 12px;
- }
- .slogan-3 {
- height: 20px;
- color: rgba(255, 255, 255, 100);
- font-size: 28rpx;
- text-align: center;
- }
- .slogan-4 {
- text-decoration:underline;
- height: 20px;
- color: #9F9C99;
- font-size: 32rpx;
- text-align: center;
- }
- // 立即开通
- .bottom {
- position: fixed;
- background-color: #2a2c31;
- bottom: 0px;
- padding-bottom: 40px;
- left: 0;
- right: 0;
- .dredge {
- // width: 72.2%;
- margin: 0 20px;
- border-radius: 50px;
- font-size: 36rpx;
- background: linear-gradient(to right, #C9A87B, #F2E6CA);
- margin-bottom: 12px;
- }
- p {
- height: 20px;
- color: rgba(226, 222, 217, 100);
- font-size: 14px;
- text-align: center;
- }
- .agreement {
- color: #897a69;
- }
- }
- </style>
|