时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <script>
  2. export default {
  3. globalData: {
  4. wxlogin: () => {}
  5. },
  6. onLaunch: function() {
  7. this.getUserInfo();
  8. },
  9. onShow: function() {
  10. // #ifdef MP-WEIXIN
  11. this.getUpdateWexin(); // 小程序更新检查
  12. // #endif
  13. },
  14. onHide: function() {
  15. console.log('App Hide')
  16. },
  17. methods: {
  18. // 获取用户信息
  19. getUserInfo(){
  20. this.globalData.wxlogin = this.wxlogin;
  21. let userinfo = uni.getStorageSync('userinfo');
  22. if(userinfo && userinfo.id){
  23. return;
  24. }
  25. this.globalData.wxlogin();
  26. },
  27. wxlogin(){
  28. uni.login({
  29. complete: result => {
  30. if(result.errMsg == 'login:ok'){
  31. let code = result.code;
  32. this.$http(this.API.API_WXLOGIN, { code }).then(res => {
  33. console.log("获得用户信息", res);
  34. uni.setStorageSync('userinfo', res.data);
  35. })
  36. }
  37. }
  38. })
  39. },
  40. // 小程序版本更新检查
  41. getUpdateWexin(){
  42. const updateManager = uni.getUpdateManager(); // 获取版本更新管理器对象
  43. updateManager.onCheckForUpdate(function(res) {
  44. // 请求完新版本信息的回调
  45. if (res.hasUpdate) {
  46. updateManager.onUpdateReady(function(res2) {
  47. uni.showModal({
  48. title: '更新提示',
  49. content: '发现新版本,是否重启应用?',
  50. confirmColor: '#FE9903',
  51. showCancel: false,
  52. success(res2) {
  53. if (res2.confirm) {
  54. // 新的版本已经下载好,调用applyUpdate应用新版本并重启
  55. updateManager.applyUpdate();
  56. }
  57. }
  58. });
  59. });
  60. }
  61. });
  62. updateManager.onUpdateFailed(function(res) {
  63. // 新的版本下载失败
  64. uni.showModal({
  65. title: '提示',
  66. content: '检查到有新版本,但下载失败,请检查网络设置',
  67. confirmColor: '#FE9903',
  68. success(res) {
  69. if (res.confirm) {
  70. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  71. updateManager.applyUpdate();
  72. }
  73. }
  74. });
  75. });
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss">
  81. @import "uview-ui/index.scss";
  82. @import './colorui/main.css';
  83. @import './colorui/icon.css';
  84. @import "@/colorui/animation.css";
  85. @import '@/common/styles/common.css';
  86. /*每个页面公共css */
  87. //底部按钮
  88. .btn-bottom {
  89. position: fixed;
  90. left: 0;
  91. bottom: 0;
  92. width: 100%;
  93. z-index: 1;
  94. }
  95. // loading加载
  96. .loading-more {
  97. align-items: center;
  98. justify-content: center;
  99. padding-top: 10px;
  100. padding-bottom: 10px;
  101. text-align: center;
  102. font-size: 28rpx;
  103. color: #999;
  104. }
  105. .loading-more-text::before {
  106. content: '';
  107. width: 20px;
  108. height: 20px;
  109. display: inline-block;
  110. vertical-align: middle;
  111. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  112. animation: weuiLoading 1s steps(12, end) infinite;
  113. background-repeat: no-repeat;
  114. background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E");
  115. background-size: 100%;
  116. }
  117. @-webkit-keyframes weuiLoading {
  118. 0% {
  119. transform: rotate3d(0, 0, 1, 0deg);
  120. }
  121. 100% {
  122. transform: rotate3d(0, 0, 1, 360deg);
  123. }
  124. }
  125. @keyframes weuiLoading {
  126. 0% {
  127. transform: rotate3d(0, 0, 1, 0deg);
  128. }
  129. 100% {
  130. transform: rotate3d(0, 0, 1, 360deg);
  131. }
  132. }
  133. </style>