123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <template>
- <div>
- <!-- 计时卡计时 -->
- <div class="pfi flex timing" v-if="timingVisible">
- <div>{{countdownTime}}</div>
- <img class="wh22" :src="closePath" alt="" @click="handlecountdownTimeClose" />
- </div>
- <!-- 计费规则 -->
- <van-dialog v-model="billingRulesVisible" :show-confirm-button="false" class="billing-rules-modal">
- <div class="tc">
- <img class="billing-rules-img" :src="countdownPath" />
- </div>
- <div class="tc billing-rules-title">
- 计费规则
- </div>
- <div class="tc">进入云机开始计时,点击退出并下机停止计时。点击退出云机仍处于计时状态。</div>
- <div class="tc billing-rules-tips">云机时长剩余:<span class="billing-rules-time">{{countdownTime}}</span>
- </div>
- <div class="billing-rules-btn" @click="getRecommend">我知道了</div>
- </van-dialog>
- <!-- 应用推荐 -->
- <van-dialog v-model="applyRecommendVisible" :show-confirm-button="false" class="apply-recommend-modal">
- <div>
- <div class="tc apply-recommend-title">应用推荐</div>
- <div class="apply-recommend-list">
- <div v-for="(item, index) in recommendList" :key="item.id" :class="['flex w100', {'mt-4': index !== 0}]">
- <div class="left flex-align-c">
- <img :src="item.imageUrl" alt="">
- <div>
- <div class="title ellipsis">{{item.filename}}</div>
- <div class="download-num">有{{item.installNum}}个人下载</div>
- </div>
- </div>
- <div class="right flex-align-c" @click="downAndInstallApk(item)">
- <div>下载</div>
- </div>
- </div>
- </div>
- <div class="apply-recommend-btn tc" @click="getRecommend">换一批</div>
- </div>
- <img class="apply-recommend-close pab" :src="applyClosePath" alt="" @click="applyRecommendVisible = false" />
- </van-dialog>
- </div>
- </template>
- <script>
- /**
- * 计时卡计时
- */
- export default {
- name: 'TimeBalance',
- props: {
- // 当前云机id
- userCardId: {
- type: [String, Number],
- default: ''
- },
- // 云机的类型 0 普通套餐 1、2、3:年卡、普通计时、自动续费普通计时
- userCardType: {
- type: [String, Number],
- default: ''
- },
- // url中获取的参数, 父组件传递
- parametersData: {
- type: Object,
- default: () => ({})
- },
- },
- data() {
- return {
- // 计时卡是否显示
- timingVisible: false,
- // 倒计时时间
- countdownTime: 0,
- // 倒计时定时器
- countdownTimeInterval: null,
- closePath: '../static/img/close.png',
- // 计费规则是否显示
- billingRulesVisible: false,
- countdownPath: '../rtcEngine/img/countdown.png',
- // 应用推荐列表
- applyRecommendVisible: false,
- // 应用推荐列表数据
- recommendList: [],
- applyClosePath: '../rtcEngine/img/close.png',
- }
- },
- methods: {
- // 获取云机剩余时长
- async getResidueTime() {
- clearInterval(this.countdownTimeInterval)
- const { isShowCountdown, isShowRule } = this.parametersData;
- if (![1, 2, 3].includes(+this.userCardType)) return;
- const res = await this.$axios.get(`/resources/yearMember/getResidueTime?userCardId=${this.userCardId}`);
- let time = res.data;
- if (!res.status) {
- this.countdownTime = this.residueTimeStamp(time);
- await this.$axios.get(`/resources/yearMember/startTime?userCardId=${this.userCardId}`);
- // 计时卡显示
- if (+isShowCountdown) this.timingVisible = true;
- // 计费规则显示
- if (+isShowRule) this.billingRulesVisible = true;
- // 倒计时退出云机定时器
- this.countdownTimeInterval = setInterval(() => {
- if (time <= 0) {
- clearInterval(this.countdownTimeInterval)
- // 退出云机
- this.$emit('downline');
- return
- }
- time--
- this.countdownTime = residueTimeStamp(time)
- }, 1000)
- }
- },
- // 关闭倒计时弹窗
- handlecountdownTimeClose() {
- this.$axios.get(`/resources/yearMember/closeRemind?userCardId=${this.userCardId}`).then(res => {
- if (!res.status) {
- clearInterval(this.countdownTimeInterval);
- this.timingVisible = false;
- return
- }
- this.$toast(res.msg);
- })
- },
- // 获取推荐列表
- getRecommend() {
- this.$axios.get(`/public/v1/market/get/recommend?userCardId=${this.userCardId}`).then(res => {
- if (!res.status) {
- this.billingRulesVisible = false;
- this.recommendList = res.data;
- this.recommendList.length && (this.applyRecommendVisible = true)
- }
- })
- },
- // 倒计时处理的时间
- residueTimeStamp(value) {
- let theTime = value;//秒
- let middle = 0;//分
- let hour = 0;//小时
- if (theTime > 59) {
- middle = parseInt(theTime / 60);
- theTime = parseInt(theTime % 60);
- }
- if (middle > 59) {
- hour = parseInt(middle / 60);
- middle = parseInt(middle % 60);
- }
- theTime < 10 ? theTime = '0' + theTime : theTime = theTime
- middle < 10 ? middle = '0' + middle : middle = middle
- hour < 10 ? hour = '0' + hour : hour = hour
- return hour + ':' + middle + ':' + theTime
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .pfi{position: fixed;}
- .tc {text-align: center;}
- .timing {
- top: 2%;
- right: 5%;
- padding: 6px 5px 6px 9px;
- background: rgba(0, 0, 0, 0.6);
- border-radius: 30px;
- font-size: 14px;
- z-index: 1;
- color: #FFF;
- & > div {
- vertical-align: middle;
- height: 20px;
- line-height: 20px;
- &::after {
- border-right: 1px solid #FFFFFF;
- content: "";
- width: 2px;
- height: 45%;
- display: inline-block;
- vertical-align: middle;
- margin-bottom: 3px;
- padding: 0 3px;
- opacity: 0.3;
- }
- }
- & > img {
- width: 20px;
- height: 20px;
- }
- }
- // 计费规则
- .billing-rules-modal {
- text-align: center;
- font-size: 14px;
- color: #757580;
- text-align: center;
- }
- ::v-deep .billing-rules-modal .van-dialog__content {
- padding: 0 28px 28px;
- }
- .billing-rules-modal .billing-rules-img {
- width: 104px;
- height: 140px;
- }
- .billing-rules-modal .billing-rules-title {
- font-size: 18px;
- font-weight: 600;
- color: #363636;
- margin-bottom: 5px;
- }
- .billing-rules-modal .billing-rules-tips {
- margin-top: 5px;
- }
- .billing-rules-modal .billing-rules-time {
- color: #00DB88;
- font-size: 15px;
- }
- .billing-rules-modal .billing-rules-btn {
- height: 50px;
- line-height: 50px;
- text-align: center;
- margin-top: 24px;
- background: linear-gradient(90deg, #00A3FF 0%, #04F79A 100%);
- border-radius: 8px;
- font-size: 12px;
- color: #FFF;
- }
- // 应用推荐
- .apply-recommend-modal {
- overflow: visible;
- }
- ::v-deep .apply-recommend-modal .van-dialog__content {
- padding: 10px 28px 28px;
- }
- .apply-recommend-modal .van-dialog__content > div {
- height: 350px;
- display: flex;
- flex-direction: column;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-title {
- font-size: 16px;
- font-weight: 500;
- color: #363636;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list {
- flex: 1;
- overflow-y: auto;
- margin-top: 16px;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list::-webkit-scrollbar {
- display: none;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left {
- width: calc(100% - 68px);
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left > img {
- width: 36px;
- height: 36px;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left > div {
- width: calc(100% - 36px);
- padding-left: 10px;
- box-sizing: border-box;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left .title {
- width: 100%;
- font-size: 16px;
- color: #363636;
- max-width: 100%;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left .download-num {
- font-size: 12px;
- color: #757580;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .right > div {
- width: 68px;
- height: 30px;
- line-height: 30px;
- text-align: center;
- background: linear-gradient(90deg, #00A3FF 0%, #04F79A 100%);
- border-radius: 8px;
- font-size: 12px;
- color: #FFF;
- }
- .apply-recommend-modal .van-dialog__content > div .apply-recommend-btn {
- height: 50px;
- line-height: 50px;
- margin-top: 14px;
- background: linear-gradient(225deg, #FF62F8 0%, #FF9D5C 100%);
- border-radius: 8px;
- font-size: 12px;
- color: #FFF;
- }
- .apply-recommend-modal .van-dialog__content .apply-recommend-close {
- bottom: -12%;
- left: 50%;
- transform: translateX(-50%);
- width: 38px;
- height: 38px;
- position: absolute;
- }
- </style>
|