App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/project/appVersion.json`,
  25. method: 'GET',
  26. success: (res) => {
  27. console.log(res.data);
  28. if (wgtinfo.version === res.data.version) return;
  29. uni.showModal({
  30. title: '更新',
  31. content: "有新版本,是否下载?",
  32. success: (oneres) => {
  33. if (oneres.confirm) {
  34. // 下载app
  35. this.toUpdateAPK(res.data.url);
  36. }
  37. }
  38. })
  39. }
  40. })
  41. })
  42. },
  43. toUpdateAPK(url) {
  44. if (!url) return;
  45. uni.showLoading({
  46. title: '更新中……',
  47. mask: true,
  48. })
  49. uni.downloadFile({
  50. url: url,
  51. success: (res) => {
  52. uni.hideLoading();
  53. if (res.statusCode == 200) {
  54. uni.showModal({
  55. content: '更新成功,确定现在重启吗?',
  56. confirmText: '重启',
  57. confirmColor: '#EE8F57',
  58. success: modalRes => {
  59. if (modalRes.confirm) {
  60. plus.runtime.install(
  61. res.tempFilePath, {
  62. force: true
  63. },
  64. function(res) {
  65. plus.runtime.restart();
  66. })
  67. }
  68. }
  69. })
  70. }
  71. }
  72. })
  73. },
  74. // 微信检查版本
  75. weixinCheck() {
  76. console.log('微信检查本版');
  77. }
  78. },
  79. }
  80. </script>
  81. <style>
  82. @import url('@/uni.scss');
  83. .textOver {
  84. overflow: hidden;
  85. text-overflow: ellipsis;
  86. white-space: nowrap;
  87. }
  88. page {
  89. /* 主要背景色 */
  90. --rgb000: #000000;
  91. --rgb111: #111111;
  92. --rgbfff: #ffffff;
  93. --rgbf1f: #f1f1f1;
  94. --rgb161: #161616;
  95. --rgbfa4: #FA4343;
  96. --rgb67c: #67c23a;
  97. }
  98. </style>