complete.vue 7.62 KB
Newer Older
朱国瑞's avatar
朱国瑞 committed
1
<template>
朱国瑞's avatar
朱国瑞 committed
2
  <div class="page" :class="{'mobile':_isMobile,'pc':!_isMobile}">
朱国瑞's avatar
朱国瑞 committed
3
    <div class="main_content" id="main">
朱国瑞's avatar
朱国瑞 committed
4
      <img class="page-bg" src="../assets/images/gesture/massage-entry-fullbg.png" alt srcset />
朱国瑞's avatar
朱国瑞 committed
5
      <div class="massage-complete-modal noBaby">
朱国瑞's avatar
朱国瑞 committed
6 7 8 9 10
        <div class="title">
          <!-- <image src="{{images.title}}"></image> -->
          <img class="icon" src="../assets/images/gesture/massage-complete-title-icon.png" />
          {{$t('strings.completeText')}}
        </div>
朱国瑞's avatar
朱国瑞 committed
11
        <!-- <div class="record" v-if="finalBabyStatus != 3 && finalBabyStatus != -1">
朱国瑞's avatar
朱国瑞 committed
12
          <div>{{$t('strings.completeText2')}}: {{time}}s</div>
朱国瑞's avatar
朱国瑞 committed
13
        </div>-->
14 15 16
        <div class="bottom">
          <light-button @click="goHome" :text="$t('strings.completeButtonText')"></light-button>
        </div>
朱国瑞's avatar
朱国瑞 committed
17 18 19 20 21 22
      </div>
    </div>
  </div>
</template>

<script>
朱国瑞's avatar
朱国瑞 committed
23
import { calcAdapt, isMobile } from "../common/util";
24
import lightButton from "../components/lightButton.vue";
朱国瑞's avatar
朱国瑞 committed
25
import DevicePixelRatio from "../utils/evicePixelRatio.js";
朱国瑞's avatar
朱国瑞 committed
26 27 28 29 30 31

let calcs = calcAdapt();
let scale;
const calcCoord = function () {
  let width = 0;
  let height = 0;
朱国瑞's avatar
朱国瑞 committed
32
  if (!isMobile()) {
朱国瑞's avatar
朱国瑞 committed
33
    width = 375;
朱国瑞's avatar
朱国瑞 committed
34
    height =
朱国瑞's avatar
朱国瑞 committed
35
      document.body.clientHeight > 667 ? document.body.clientHeight : 667;
朱国瑞's avatar
朱国瑞 committed
36 37 38 39 40 41
  } else {
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }
  if (height === 0) {
    height = window.innerHeight;
朱国瑞's avatar
朱国瑞 committed
42
    if (!isMobile()) {
朱国瑞's avatar
朱国瑞 committed
43
      height = window.innerHeight > 667 ? window.innerHeight : 667;
朱国瑞's avatar
朱国瑞 committed
44
    }
朱国瑞's avatar
朱国瑞 committed
45 46 47 48 49 50 51 52 53 54
  }
  scale = height / width;
  let k = +scale.toFixed(2);
  if (k >= 2.16) {
    k = 2.16;
  } else if (k <= 1.78) {
    k = 1.78;
  }
  return calcs.calcCoord.call(null, ...arguments, k);
};
朱国瑞's avatar
朱国瑞 committed
55 56 57
var handleTouchmove = function (e) {
  e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
};
朱国瑞's avatar
朱国瑞 committed
58 59 60 61 62 63 64 65 66 67
export default {
  data() {
    return {
      nikeName: "William",
      finalBabyStatus: 0,
      lying: 0,
      time: 0,
      total: 0,
      modalCalc: {
        top: ""
朱国瑞's avatar
朱国瑞 committed
68 69
      },
      _isMobile: false
朱国瑞's avatar
朱国瑞 committed
70 71
    };
  },
72 73 74 75 76 77 78 79
  components: {
    lightButton
  },
  methods: {
    goHome() {
      this.$router.push({
        path: "/"
      });
朱国瑞's avatar
朱国瑞 committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    },
    /**
     * 添加触摸监听
     */
    addTouchmoveListener() {
      document.body.addEventListener("touchmove", handleTouchmove, {
        passive: false
      }); //passive 参数不能省略,用来兼容ios和android
    },
    /**
     * 移除触摸监听
     */
    removeTouchmoveListener() {
      document.body.removeEventListener("touchmove", handleTouchmove, {
        passive: false
      });
96 97
    }
  },
朱国瑞's avatar
朱国瑞 committed
98
  created() {
朱国瑞's avatar
朱国瑞 committed
99 100 101 102 103
    this.$i18n.locale = "en";
    let lang = localStorage.getItem("lang");
    if (lang) {
      this.$i18n.locale = lang;
    }
朱国瑞's avatar
朱国瑞 committed
104
    this._isMobile = isMobile();
朱国瑞's avatar
朱国瑞 committed
105 106 107 108 109 110 111
    if (
      this._isMobile &&
      document.body.clientHeight >= document.body.clientWidth
    ) {
      // 竖屏
      this.addTouchmoveListener();
    }
朱国瑞's avatar
朱国瑞 committed
112
    let lying = this.$route.query.lying;
113 114
    let time = this.$route.query.totalDuration;
    let total = this.$route.query.totalDuration;
朱国瑞's avatar
朱国瑞 committed
115
    this.lying = lying;
116 117
    this.time = time || 0;
    this.total = total || 0;
朱国瑞's avatar
朱国瑞 committed
118
  },
朱国瑞's avatar
朱国瑞 committed
119 120 121 122
  mounted() {
    this.$nextTick(() => {
      new DevicePixelRatio().init();
    });
朱国瑞's avatar
朱国瑞 committed
123 124 125 126 127 128 129 130 131 132 133 134
    window.onresize = () => {
      return (() => {
        // 判断横竖屏
        let width = document.documentElement.clientWidth;
        let height = document.documentElement.clientHeight;
        if (width > height) {
          this.removeTouchmoveListener();
        } else {
          this.addTouchmoveListener();
        }
      })();
    };
朱国瑞's avatar
朱国瑞 committed
135 136 137 138 139
  },
  unmounted() {
    document.body.removeEventListener("touchmove", handleTouchmove, {
      passive: false
    });
朱国瑞's avatar
朱国瑞 committed
140
  }
朱国瑞's avatar
朱国瑞 committed
141 142 143 144 145 146 147 148
};
</script>

<style lang="scss" scoped>
.page {
  background: #000;
  display: flex;
  justify-content: center;
朱国瑞's avatar
朱国瑞 committed
149
  height: 100%;
朱国瑞's avatar
朱国瑞 committed
150
}
朱国瑞's avatar
朱国瑞 committed
151
.pc {
朱国瑞's avatar
朱国瑞 committed
152
  height: calc(var(--vh, 1vh) * 100);
朱国瑞's avatar
朱国瑞 committed
153
  align-items: center;
朱国瑞's avatar
朱国瑞 committed
154
  .main_content {
朱国瑞's avatar
朱国瑞 committed
155 156
    width: 375px;
    height: 667px;
朱国瑞's avatar
朱国瑞 committed
157 158 159 160 161 162 163 164 165 166
    background: #ffffff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    .page-bg {
      position: absolute;
      left: 0;
      top: 0;
朱国瑞's avatar
朱国瑞 committed
167
      width: 375px;
朱国瑞's avatar
朱国瑞 committed
168
      z-index: 0;
朱国瑞's avatar
朱国瑞 committed
169
    }
朱国瑞's avatar
朱国瑞 committed
170 171 172
  }
  .massage-complete-modal {
    box-sizing: border-box;
朱国瑞's avatar
朱国瑞 committed
173
    width: 330px;
174
    min-height: 210px;
朱国瑞's avatar
朱国瑞 committed
175
    padding: 40px 0 62.5px;
朱国瑞's avatar
朱国瑞 committed
176 177 178 179
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
朱国瑞's avatar
朱国瑞 committed
180
    border-radius: 7px 7px;
朱国瑞's avatar
朱国瑞 committed
181 182 183 184
    margin: 0 auto;
    position: relative;
    z-index: 1;
    &.noBaby {
朱国瑞's avatar
朱国瑞 committed
185
      height: 210px;
朱国瑞's avatar
朱国瑞 committed
186
      .bottom {
朱国瑞's avatar
朱国瑞 committed
187
        margin-top: 50px;
朱国瑞's avatar
朱国瑞 committed
188
      }
朱国瑞's avatar
朱国瑞 committed
189 190
    }
    .nickname {
朱国瑞's avatar
朱国瑞 committed
191
      font-size: 23px;
朱国瑞's avatar
朱国瑞 committed
192 193
      color: #fb7c76;
      font-family: "Gotham-Book";
朱国瑞's avatar
朱国瑞 committed
194
      text-shadow: 1px 1px 2px #ffffff;
朱国瑞's avatar
朱国瑞 committed
195
      span {
朱国瑞's avatar
朱国瑞 committed
196
        font-size: 30px;
朱国瑞's avatar
朱国瑞 committed
197
      }
朱国瑞's avatar
朱国瑞 committed
198 199
    }
    .title {
朱国瑞's avatar
朱国瑞 committed
200
      margin-top: 20.5px;
朱国瑞's avatar
朱国瑞 committed
201
      color: #fb7c76;
朱国瑞's avatar
朱国瑞 committed
202 203
      font-size: 23px;
      line-height: 26.5012px;
朱国瑞's avatar
朱国瑞 committed
204 205
      font-weight: bolder;
      .icon {
朱国瑞's avatar
朱国瑞 committed
206 207
        width: 34.5px;
        height: 22.5px;
朱国瑞's avatar
朱国瑞 committed
208
      }
朱国瑞's avatar
朱国瑞 committed
209 210 211 212 213
    }
    .subTitle {
      width: 100%;
      text-align: center;
      color: #fb7c76;
朱国瑞's avatar
朱国瑞 committed
214 215
      font-size: 13px;
      margin-top: 10px;
朱国瑞's avatar
朱国瑞 committed
216 217 218
      font-weight: bolder;
      &.underline {
        text-decoration: underline;
朱国瑞's avatar
朱国瑞 committed
219 220
      }
    }
朱国瑞's avatar
朱国瑞 committed
221
    .record {
朱国瑞's avatar
朱国瑞 committed
222 223 224 225 226 227 228
      margin-top: 50px;
      margin-bottom: 50px;
      width: 280px;
      height: 48px;
      line-height: 48px;
      border-radius: 24px 24px;
      font-size: 17.3362px;
朱国瑞's avatar
朱国瑞 committed
229 230 231
      color: #999999;
      background-color: #f5f5f5;
      text-align: center;
朱国瑞's avatar
朱国瑞 committed
232
      text-shadow: 1px 1px 2px #ffffff;
朱国瑞's avatar
朱国瑞 committed
233 234 235 236 237
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
    }
朱国瑞's avatar
朱国瑞 committed
238 239 240
  }
}

朱国瑞's avatar
朱国瑞 committed
241 242 243
.mobile {
  .main_content {
    width: 10rem;
朱国瑞's avatar
朱国瑞 committed
244
    height: calc(var(--vh, 1vh) * 100);
朱国瑞's avatar
朱国瑞 committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
    background: #ffffff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    .page-bg {
      position: absolute;
      left: 0;
      top: 0;
      width: 10rem;
      z-index: 0;
    }
  }
  .massage-complete-modal {
    box-sizing: border-box;
    width: 8.8rem;
262
    min-height: 5.6rem;
朱国瑞's avatar
朱国瑞 committed
263 264 265 266 267 268 269 270 271 272 273
    padding: 1.0667rem 0 1.6667rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 0.1867rem 0.1867rem;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    &.noBaby {
      height: 5.6rem;
朱国瑞's avatar
朱国瑞 committed
274 275 276
      .bottom {
        margin-top: 1.3333rem;
      }
朱国瑞's avatar
朱国瑞 committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290
    }
    .nickname {
      font-size: 0.6133rem;
      color: #fb7c76;
      font-family: "Gotham-Book";
      text-shadow: 0.0267rem 0.0267rem 0.0533rem #ffffff;
      span {
        font-size: 0.8rem;
      }
    }
    .title {
      margin-top: 0.5467rem;
      color: #fb7c76;
      font-size: 0.6133rem;
朱国瑞's avatar
朱国瑞 committed
291
      line-height: 0.7067rem;
朱国瑞's avatar
朱国瑞 committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
      font-weight: bolder;
      .icon {
        width: 0.92rem;
        height: 0.6rem;
      }
    }
    .subTitle {
      width: 100%;
      text-align: center;
      color: #fb7c76;
      font-size: 0.3467rem;
      margin-top: 0.2667rem;
      font-weight: bolder;
      &.underline {
        text-decoration: underline;
      }
    }
    .record {
      margin-top: 1.3333rem;
      margin-bottom: 1.3333rem;
      width: 7.4533rem;
      height: 1.28rem;
      line-height: 1.28rem;
      border-radius: 0.64rem 0.64rem;
      font-size: 0.4623rem;
      color: #999999;
      background-color: #f5f5f5;
      text-align: center;
      text-shadow: 0.0267rem 0.0267rem 0.0533rem #ffffff;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
朱国瑞's avatar
朱国瑞 committed
325 326 327
    }
  }
}
朱国瑞's avatar
朱国瑞 committed
328 329 330 331 332 333 334 335 336 337 338
// 横屏
@media only screen and (orientation: landscape) {
  .page {
    &.mobile {
      height: 812px;
      .main_content {
        height: 100%;
      }
    }
  }
}
朱国瑞's avatar
朱国瑞 committed
339
</style>