Pārlūkot izejas kodu

Merge branch '绿洲水稻' of xiongzhu/raex_front into dev

panhui 3 gadi atpakaļ
vecāks
revīzija
cee3cac0f4
1 mainītis faili ar 39 papildinājumiem un 2 dzēšanām
  1. 39 2
      src/views/user/Rice.vue

+ 39 - 2
src/views/user/Rice.vue

@@ -1,6 +1,9 @@
 <template>
     <div class="page">
         <div class="nav-header">
+            <div class="back-conetnt" @click="goBack">
+                <img src="@assets/icon_fanhui2.png" alt="" />
+            </div>
             <span class="title">绿洲水稻</span>
         </div>
         <iframe
@@ -21,7 +24,11 @@ import RiceTask from '../../components/rice/Task.vue';
 import RiceShare from '../../components/rice/Share.vue';
 import { mapState } from 'vuex';
 import { throwStatement } from '@babel/types';
+let fromRoute = null;
 export default {
+    beforeRouteEnter(to, from) {
+        fromRoute = from;
+    },
     mounted() {
         this.$nextTick(() => {
             console.log(this.$refs.game);
@@ -76,6 +83,13 @@ export default {
         }
     },
     methods: {
+        goBack() {
+            if (!fromRoute || !fromRoute.name) {
+                this.$router.replace('/home');
+            } else {
+                this.$router.back();
+            }
+        },
         getCurrent() {
             this.$http.get('/rice/current').then(res => {
                 this.info = res.data;
@@ -113,7 +127,7 @@ export default {
 <style lang="less" scoped>
 .game {
     width: 100vw;
-    height: calc(var(--app-height) - 56px);
+    height: var(--app-height);
     margin: 0 auto;
     display: block;
     overflow: hidden;
@@ -128,12 +142,16 @@ export default {
 }
 
 .nav-header {
-    padding: 16px 0 10px;
+    padding: calc(var(--safe-top) + 16px) 0 10px;
     .flex();
     justify-content: center;
     // position: fixed;
     // top: 0;
     z-index: 20;
+    position: fixed;
+    top: 0;
+    left: 0;
+    right: 0;
     .title {
         font-size: 26px;
         font-family: YouSheBiaoTiYuan;
@@ -142,5 +160,24 @@ export default {
         line-height: 34px;
         text-align: center;
     }
+
+    .back-conetnt {
+        width: 34px;
+        height: 34px;
+        background: rgba(0, 0, 0, 0.5);
+        backdrop-filter: blur(1px);
+        .flex();
+        justify-content: center;
+        border-radius: 100px;
+        box-sizing: border-box;
+        img {
+            width: 18px;
+            height: 18px;
+        }
+        position: absolute;
+        left: 16px;
+        top: calc(var(--safe-top) + 16px);
+        z-index: 20;
+    }
 }
 </style>