123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <view class="navigationBarView">
- <view class="back-btn" @click="back">
- <image class="arrow-bg" :src="require('../static/images/icon-back-bg.png')"></image>
- <!-- <text>返回</text> -->
- </view>
- <view class="countdown" v-if="maxTimer">{{timer}}s</view>
- </view>
- </template>
- <script>
- export default {
- props: {
- maxTimer: {
- type: Number
- }
- },
- data() {
- return {
- timer: 60,
- navTimer: ''
- };
- },
- created() {
- console.log(1)
- if (this.maxTimer) {
- this.timer = this.maxTimer;
- this.countdown()
- }
- },
- beforeDestroy() {
- clearInterval(this.navTimer)
- },
- methods: {
- countdown() {
- const $this = this;
- clearInterval(this.navTimer);
- this.navTimer = setInterval(function() {
- // console.log($this.timer)
- $this.timer = $this.timer - 1;
- if ($this.timer == 0) {
- clearInterval($this.navTimer);
- uni.navigateBack();
- return;
- }
- }, 1000)
- },
- back() {
- uni.navigateBack();
- },
- clearTimer() {
- clearInterval(this.navTimer);
- }
- }
- }
- </script>
- <style lang="scss">
- .navigationBarView {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100vw;
- padding-top: 5.4vw;
- z-index: 1;
- .back-btn {
- position: relative;
- display: flex;
- align-items: center;
- // justify-content: center;
- width: 39.8vw;
- height: 12.5vw;
- border-radius: 0 12.5vw 12.5vw 0;
-
-
- .arrow-bg {
- position: absolute;
- top: 0;
- left: 0;
- width: 39.8vw;
- height: 12.5vw;
- }
- .arrow {
- width: 2.5vw;
- height: 4.2vw;
- margin-right: 1.7vw;
- }
-
- text {
- position: relative;
- margin-left: 10.4vw;
- color: #FFFFFF;
- font-size: 5vw;
- }
- }
- .countdown {
- color: #1994D7;
- margin-right: 3.3vw;
- font-size: 5vw;
- font-weight: 600;
- }
- }
- </style>
|