App.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. console.log('App Launch');
  5. // #ifdef APP-PLUS
  6. // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=2226
  7. if(plus.runtime.appid !== 'HBuilder'){ // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid
  8. uni.request({
  9. url: 'https://7a3e3fa9-7820-41d0-be80-11927ac2026c.bspapp.com/http/update', //检查更新的服务器地址
  10. data: {
  11. appid: plus.runtime.appid,
  12. version: plus.runtime.version,
  13. imei: plus.device.imei
  14. },
  15. success: (res) => {
  16. if (res.statusCode == 200 && res.data.isUpdate) {
  17. // 提醒用户更新
  18. uni.showModal({
  19. title: '更新提示',
  20. content: res.data.note ? res.data.note : '是否选择更新',
  21. success: (ee) => {
  22. if (ee.confirm) {
  23. plus.runtime.openURL(res.data.url);
  24. }
  25. }
  26. })
  27. }
  28. }
  29. })
  30. }
  31. // #endif
  32. },
  33. onShow: function() {
  34. console.log('App Show')
  35. },
  36. onHide: function() {
  37. console.log('App Hide')
  38. },
  39. globalData: {
  40. test: ''
  41. }
  42. }
  43. </script>
  44. <style>
  45. /* #ifndef APP-PLUS-NVUE */
  46. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  47. @import './common/uni.css';
  48. /* 以下样式用于 hello uni-app 演示所需 */
  49. page {
  50. background-color: #F4F5F6;
  51. height: 100%;
  52. font-size: 28rpx;
  53. line-height: 1.8;
  54. }
  55. .uni-header-logo {
  56. padding: 30rpx;
  57. flex-direction: column;
  58. justify-content: center;
  59. align-items: center;
  60. margin-top: 10rpx;
  61. }
  62. .uni-header-image {
  63. width: 100px;
  64. height: 100px;
  65. }
  66. .uni-hello-text {
  67. color: #7A7E83;
  68. }
  69. .uni-hello-addfile {
  70. text-align: center;
  71. line-height: 300rpx;
  72. background: #FFF;
  73. padding: 50rpx;
  74. margin-top: 10px;
  75. font-size: 38rpx;
  76. color: #808080;
  77. }
  78. /* #endif*/
  79. </style>