IosUpdateModal.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <Popup ref="popRef" mode="center" closeOnClickOverlay zIndex="10077">
  3. <template #content>
  4. <view class="content">
  5. <view class="content_success">
  6. <image src="/static/login.png" class="img"></image>
  7. <trans _t="新版本"></trans>
  8. </view>
  9. </view>
  10. </template>
  11. <template #footer>
  12. <view class="footer">
  13. <view class="submit_btn submit_shop" @click="close">
  14. <trans _t="关闭" />
  15. </view>
  16. <view class="submit_btn" @click="toUpdate">
  17. <trans _t="立即升级" />
  18. </view>
  19. </view>
  20. </template>
  21. </Popup>
  22. </template>
  23. <script setup>
  24. import { ref, watch, computed, nextTick } from "vue";
  25. import Popup from "./popup.vue";
  26. import { t } from "@/locale";
  27. import { useSystemStore } from "@/store";
  28. import { openUrl } from "@/utils";
  29. import { storeToRefs } from "pinia";
  30. const useSystem = useSystemStore();
  31. const { getAppinfo: appinfo } = storeToRefs(useSystem);
  32. const popRef = ref(null);
  33. const open = () => {
  34. popRef.value && popRef.value.open();
  35. };
  36. const close = () => {
  37. popRef.value && popRef.value.close();
  38. };
  39. const toUpdate = () => {
  40. openUrl(appinfo.value?.url);
  41. close();
  42. };
  43. watch(
  44. appinfo,
  45. (newVal) => {
  46. if (newVal.update) {
  47. // #ifdef APP-PLUS
  48. const systemInfo = uni.getSystemInfoSync();
  49. if (systemInfo.platform === "ios") {
  50. nextTick(() => {
  51. open();
  52. });
  53. }
  54. // #endif
  55. } else {
  56. close();
  57. }
  58. },
  59. {
  60. immediate: true, // 初始化时立即执行一次
  61. deep: true, // 监听深层属性变化(如 appinfo.value.url 变化)
  62. }
  63. );
  64. defineExpose({ open, close });
  65. </script>
  66. <style lang="less" scoped>
  67. @import url("@/style.less");
  68. :deep(.conts) {
  69. min-width: 78vw;
  70. }
  71. .content {
  72. flex: 1;
  73. .flex_center();
  74. &_success {
  75. .flex_center();
  76. flex-direction: column;
  77. gap: 20rpx;
  78. }
  79. .img {
  80. width: 120rpx;
  81. height: 120rpx;
  82. }
  83. }
  84. .footer {
  85. .flex_position(space-between);
  86. .submit_btn {
  87. height: 76rpx;
  88. line-height: 76rpx;
  89. padding: 0 30rpx;
  90. background-color: var(--black);
  91. color: var(--light);
  92. .flex_center();
  93. border-radius: 16rpx;
  94. .size(24rpx);
  95. &.submit_shop {
  96. background-color: var(--bg);
  97. border: 1rpx solid var(--black);
  98. color: var(--black);
  99. }
  100. }
  101. }
  102. </style>