App.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <script>
  2. import md5Libs from '@/uni_modules/uview-ui/libs/function/md5';
  3. import Vue from 'vue';
  4. export default {
  5. created() {
  6. // #ifdef APP-PLUS
  7. ime: '', plus.navigator.closeSplashscreen();
  8. // #endif
  9. },
  10. onLaunch: async function () {
  11. console.log('App Launch');
  12. uni.hideTabBar();
  13. // #ifdef APP-PLUS
  14. // plus.android.requestPermissions(['Manifest.permission.READ_PHONE_STATE'], function(e){
  15. // if(e.deniedAlways.length>0){ //权限被永久拒绝
  16. // // 弹出提示框解释为何需要定位权限,引导用户打开设置页面开启
  17. // console.log('Always Denied!!! '+e.deniedAlways.toString());
  18. // }
  19. // if(e.deniedPresent.length>0){ //权限被临时拒绝
  20. // // 弹出提示框解释为何需要定位权限,可再次调用plus.android.requestPermissions申请权限
  21. // console.log('Present Denied!!! '+e.deniedPresent.toString());
  22. // }
  23. // if(e.granted.length>0){ //权限被允许
  24. // //调用依赖获取定位权限的代码
  25. // console.log('Granted!!! '+e.granted.toString());
  26. // }
  27. // }, function(e){
  28. // console.log('Request Permissions error:'+JSON.stringify(e));
  29. // });
  30. this.ime = plus.device.imei;
  31. console.log(this.ime);
  32. plus.device.getInfo({
  33. success: function (e) {
  34. this.ime = JSON.stringify(e);
  35. console.log('getDeviceInfo success: ' + JSON.stringify(e));
  36. },
  37. fail: function (e) {
  38. uni.showToast({
  39. title: '获取设备信息失败',
  40. mask: false,
  41. duration: 1500
  42. });
  43. }
  44. });
  45. let that = this;
  46. plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
  47. console.log(widgetInfo);
  48. uni.request({
  49. url: 'https://mnhcdn.wenlvti.net/api/minnansoul/version/version',
  50. sslVerify: false,
  51. data: {
  52. version: widgetInfo.version
  53. },
  54. success: (result) => {
  55. console.log(result);
  56. var data = result.data.data;
  57. if (data.update && data.wgtUrl) {
  58. uni.showModal({
  59. title: '更新提示',
  60. content: '有新的版本更新,请确认',
  61. showCancel: false,
  62. success(resmodal) {
  63. if (resmodal.confirm) {
  64. plus.runtime.openURL(data.wgtUrl);
  65. }
  66. }
  67. });
  68. }
  69. // 只有apk包的时间
  70. if (data.update && data.pkgUrl && !data.wgtUrl) {
  71. uni.showModal({
  72. title: '更新提示',
  73. content: '有新的版本更新,请确认',
  74. showCancel: false
  75. });
  76. var dtask = plus.downloader.createDownload(data.pkgUrl, {}, function (d, status) {
  77. // 下载完成
  78. if (status == 200) {
  79. plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), {}, {}, function (error) {
  80. uni.showToast({
  81. title: '安装失败',
  82. mask: false,
  83. duration: 1500
  84. });
  85. });
  86. } else {
  87. uni.showToast({
  88. title: '下载失败',
  89. mask: false,
  90. duration: 1500
  91. });
  92. }
  93. });
  94. dtask.start();
  95. }
  96. },
  97. fail(res) {
  98. console.log(res, '错误');
  99. }
  100. });
  101. });
  102. // plus.screen.lockOrientation('portrait-primary'); //锁定屏幕
  103. // const dom = weex.requireModule('dom');
  104. // dom.addRule('fontFace', {
  105. // 'fontFamily': "graceIconfont",
  106. // 'src': "url('/static/grace.ttf')"
  107. // });
  108. // #endif
  109. //加载配置
  110. uni.getSystemInfo({
  111. success: function (e) {
  112. // #ifndef MP
  113. Vue.prototype.StatusBar = e.statusBarHeight;
  114. if (e.platform == 'android') {
  115. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  116. } else {
  117. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  118. }
  119. // #endif
  120. // #ifdef MP-WEIXIN
  121. Vue.prototype.StatusBar = e.statusBarHeight;
  122. let custom = wx.getMenuButtonBoundingClientRect();
  123. Vue.prototype.Custom = custom;
  124. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  125. // #endif
  126. // #ifdef MP-ALIPAY
  127. Vue.prototype.StatusBar = e.statusBarHeight;
  128. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  129. // #endif
  130. }
  131. });
  132. },
  133. onReady() {
  134. // plus.screen.lockOrientation( 'landscape-secondary');
  135. this.plus.screen.lockOrientation('landscape-primary');
  136. },
  137. onShow: function () {
  138. // console.log('App 开启');
  139. uni.hideTabBar();
  140. },
  141. onHide: function () {
  142. // console.log('App 关闭');
  143. },
  144. onLoad: function () {
  145. uni.hideTabBar();
  146. }
  147. };
  148. </script>
  149. <style lang="scss">
  150. @import '@/uni_modules/uview-ui/index.scss';
  151. // @import "common/iconfont.css";
  152. @import 'common/app.css';
  153. @import './GraceUI5/css/graceUI.css';
  154. @import './GraceUI5/skin/black.css';
  155. /* 加载图标字体 - 条件编译模式 */
  156. /* #ifdef APP-PLUS-NVUE */
  157. .gui-icons {
  158. font-family: graceIconfont;
  159. }
  160. /* #endif */
  161. // body {
  162. // max-width: 3840rpx; //最大宽度自己可以调整
  163. // margin: auto !important;
  164. // }
  165. </style>