App.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <script>
  2. import $http from '@/utils/request.js'
  3. import { urlParameter } from '@/utils/util.js'
  4. export default {
  5. globalData: {
  6. userInfo: {},
  7. },
  8. onLaunch: function(options) {
  9. uni.hideTabBar()
  10. if (options.query && options.query.qrCode) {
  11. const { qrCode } = options.query
  12. let parameter = urlParameter(qrCode)
  13. uni.setStorageSync('code', parameter.id)
  14. }
  15. },
  16. onShow: function(options) {
  17. uni.hideTabBar()
  18. if (options.query && options.query.qrCode) {
  19. const { qrCode } = options.query
  20. let parameter = urlParameter(qrCode)
  21. uni.setStorageSync('code', parameter.id)
  22. }
  23. this.updateManager()
  24. // this.anotherApplet() //打包盲票小程序时候解开
  25. },
  26. methods: {
  27. updateManager() {
  28. const updateManager = uni.getUpdateManager();
  29. if (updateManager) {
  30. updateManager.onCheckForUpdate(res => {
  31. // 请求完新版本信息的回调
  32. })
  33. updateManager.onUpdateReady(() => {
  34. uni.showModal({
  35. title: '更新提示',
  36. content: '新版本已经准备好,即将重启应用',
  37. showCancel: false,
  38. success(res) {
  39. if (res.confirm) {
  40. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  41. updateManager.applyUpdate()
  42. }
  43. }
  44. })
  45. })
  46. updateManager.onUpdateFailed(() => {
  47. // 新的版本下载失败
  48. uni.showModal({
  49. title: '更新提示',
  50. content: '新版本下载失败',
  51. showCancel: false
  52. })
  53. })
  54. }
  55. },
  56. anotherApplet() {
  57. $http.post('/api/v1/mp/user/isJump', {}).then(res => {
  58. if(res.data) {
  59. uni.setStorageSync('anotherApplet',true)
  60. uni.switchTab({
  61. url:'/pages/index/index'
  62. })
  63. }else {
  64. uni.removeStorageSync('anotherApplet')
  65. }
  66. })
  67. },
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  73. @import "uview-ui/index.scss";
  74. // 设置整个项目的背景色
  75. page {
  76. background-color: #F9F7F5;
  77. font-size: 14px;
  78. color: #333;
  79. }
  80. view {
  81. box-sizing: border-box;
  82. word-break: break-all;
  83. }
  84. .container {
  85. background-color: #fff;
  86. font-size: 14px;
  87. color: #333;
  88. padding: 10px;
  89. }
  90. .flex {
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. }
  95. .ells {
  96. overflow: hidden;
  97. text-overflow: ellipsis;
  98. display: -webkit-box;
  99. -webkit-box-orient: vertical;
  100. -webkit-line-clamp: 2;
  101. }
  102. ::v-deep .u-tabs__wrapper__nav__line {
  103. border-radius: 0!important;
  104. bottom: 0px!important;
  105. }
  106. .ells-one {
  107. overflow: hidden;
  108. text-overflow: ellipsis;
  109. display: -webkit-box;
  110. -webkit-box-orient: vertical;
  111. -webkit-line-clamp: 1;
  112. }
  113. @font-face {
  114. font-family: 'YouSheBiaoTiHei';
  115. src: url('https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/YouSheBiaoTiHei.ttf');
  116. }
  117. // 只有在app.vue里面定义的keyframes才能在style里面使用
  118. @keyframes moveLeft {
  119. 0% {
  120. -webkit-transform: translate3d(0, 0, 0);
  121. transform: translate3d(0, 0, 0);
  122. }
  123. 100% {
  124. -webkit-transform: translate3d(-100%, 0, 0);
  125. transform: translate3d(-100%, 0, 0);
  126. }
  127. }
  128. </style>