App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <script>
  2. export default {
  3. data() {
  4. return {}
  5. },
  6. onLoad() {},
  7. onShow() {},
  8. onLaunch() {
  9. const that = this;
  10. // 设备信息
  11. let system = that.$config.system;
  12. if (system.uniPlatform == 'app') {
  13. that.appCheck()
  14. } else if (system.uniPlatform == 'mp-weixin') {
  15. that.weixinCheck()
  16. }
  17. },
  18. methods: {
  19. // app检查版本
  20. appCheck() {
  21. const that = this;
  22. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  23. uni.request({
  24. url: `${that.$config.serverUrl}/files/projectadmin/appVersion.json`,
  25. method: 'GET',
  26. success: (res) => {
  27. if (wgtinfo.version === res.data.version) return;
  28. uni.showModal({
  29. title: '更新',
  30. content: "有新版本,是否下载?",
  31. success: (oneres) => {
  32. if (oneres.confirm) {
  33. // 下载app
  34. this.toUpdateAPK(res.data.url);
  35. }
  36. }
  37. })
  38. }
  39. })
  40. })
  41. },
  42. toUpdateAPK(url) {
  43. if (!url) return;
  44. uni.showLoading({
  45. title: '更新中……',
  46. mask: true,
  47. })
  48. uni.downloadFile({
  49. url: url,
  50. success: (res) => {
  51. uni.hideLoading();
  52. if (res.statusCode == 200) {
  53. uni.showModal({
  54. content: '更新成功,确定现在重启吗?',
  55. confirmText: '重启',
  56. confirmColor: '#EE8F57',
  57. success: modalRes => {
  58. if (modalRes.confirm) {
  59. plus.runtime.install(
  60. res.tempFilePath, {
  61. force: true
  62. },
  63. function(res) {
  64. plus.runtime.restart();
  65. })
  66. }
  67. }
  68. })
  69. }
  70. }
  71. })
  72. },
  73. // 微信检查版本
  74. weixinCheck() {
  75. console.log('微信检查本版');
  76. }
  77. },
  78. }
  79. </script>
  80. <style>
  81. @import url('@/uni.scss');
  82. .textOver {
  83. overflow: hidden;
  84. text-overflow: ellipsis;
  85. white-space: nowrap;
  86. }
  87. page {
  88. /* 主要背景色 */
  89. --rgb000: #000000;
  90. --rgb111: #111111;
  91. --rgbfff: #ffffff;
  92. --rgbf1f: #f1f1f1;
  93. --rgb161: #161616;
  94. --rgbfa4: #FA4343;
  95. --rgb67c: #67c23a;
  96. --rgb313: #31312e;
  97. --rgbffd: #FFD700;
  98. }
  99. </style>