update.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <u-popup v-model="showModel" close-icon="close-circle-fill" :closeable="upinfo.enforce==0" close-icon-color="#fff"
  3. close-icon-size="44" :mask-close-able="false" @close="close()" mode="center" width="617rpx" height="720rpx"
  4. border-radius="14">
  5. <view class="update u-p-30">
  6. <view class=" u-p-l-50 u-p-r-50" style="margin-top:250rpx;">
  7. <view class="u-font-40 bold u-m-b-20">{{$t('update.text1')}} {{upinfo.version}} {{$t('update.text2')}}</view>
  8. <text class="gray-2 u-font-26" style="height:200rpx;display:block;overflow-y: scroll;">
  9. {{upinfo.content}}
  10. </text>
  11. </view>
  12. <view class="flex1" style="margin-top:30rpx;" v-if="upinfo.enforce==0">
  13. <view class="btn2 yellow center" @click="close()">{{$t('update.btn1')}}</view>
  14. <view class="btn1 white center" @click="update">{{$t('update.btn2')}}</view>
  15. </view>
  16. <view class="center" style="margin-top:30rpx;" v-if="upinfo.enforce==1">
  17. <view class="btn1 white center" @click="update">{{$t('update.btn2')}}</view>
  18. </view>
  19. </view>
  20. </u-popup>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. showModel: {
  26. type:Boolean
  27. },
  28. upinfo: Object
  29. },
  30. mounted() {},
  31. methods: {
  32. close() {
  33. //非强制关闭不在弹出
  34. if (this.upinfo.enforce == 0) {
  35. uni.setStorageSync('showUp', 1)
  36. }
  37. this.$emit('close')
  38. uni.showTabBar(); //显示tabbar
  39. },
  40. update() {
  41. this.close()
  42. if (uni.getStorageSync('phone') == 'ios') {
  43. } else {
  44. let _this = this
  45. console.log(_this.upinfo.url);
  46. uni.downloadFile({
  47. url: _this.upinfo.url,
  48. success: (res) => {
  49. if (res.statusCode === 200) {
  50. plus.runtime.install(res.tempFilePath); //下载成功安装apk
  51. }
  52. },
  53. fail: (err) => {
  54. console.log(err);
  55. uni.showToast({
  56. icon: 'none',
  57. mask: true,
  58. title: this.$t('update.error'),
  59. });
  60. },
  61. })
  62. }
  63. }
  64. },
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. /deep/.u-mode-center-box {
  69. background-color: transparent !important;
  70. }
  71. .update {
  72. width: 100%;
  73. height: 100%;
  74. background: url(../static/update.png) no-repeat center center;
  75. background-size: 100% 100%;
  76. .btn1,
  77. .btn2 {
  78. width: 260rpx;
  79. height: 68rpx;
  80. border-radius: 34rpx;
  81. }
  82. .btn1 {
  83. background: linear-gradient(360deg, #0064E0, #79B8FF);
  84. }
  85. .btn2 {
  86. border: 1px solid $blue;
  87. }
  88. }
  89. </style>