App.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <script>
  2. import Vue from 'vue'
  3. import Wechat from '@/util/wechat/wechat.js'
  4. import mpWx from '@/common/mpWX.js'
  5. import store from '@/store'
  6. import { updateCheck } from "@/util/index.js"
  7. export default {
  8. computed:{
  9. },
  10. methods: {
  11. // 获取系统栏高度
  12. async setAppInfo() {
  13. let that = this;
  14. let platform = '';
  15. return new Promise((resolve, reject) => {
  16. uni.getSystemInfo({
  17. success: function(e) {
  18. Vue.prototype.StatusBar = e.statusBarHeight;
  19. // #ifdef H5
  20. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  21. Vue.prototype.SystemInfo = e;
  22. if (that.$wxsdk.isWechat()) {
  23. platform = 'wxOfficialAccount';
  24. } else {
  25. platform = 'H5';
  26. }
  27. // #endif
  28. // #ifdef APP-PLUS
  29. platform = 'App';
  30. if (e.platform == 'android') {
  31. uni.setStorageSync('isAndroid', true);
  32. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  33. } else {
  34. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  35. uni.setStorageSync('isAndroid', false);
  36. }
  37. // #endif
  38. // #ifdef MP-WEIXIN
  39. platform = 'wxMiniProgram';
  40. // new Wechat().getWxMiniProgramSessionKey();
  41. let custom = wx.getMenuButtonBoundingClientRect();
  42. Vue.prototype.Custom = custom;
  43. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  44. // #endif
  45. uni.setStorageSync('platform', platform);
  46. resolve(platform);
  47. }
  48. });
  49. });
  50. },
  51. // 自动登录
  52. async autoLogin(options) {
  53. // let initData = data;
  54. var wechat = new Wechat();
  55. if (!uni.getStorageSync('token')) {
  56. // #ifdef H5
  57. // await wechat.login();
  58. // #endif
  59. }else {
  60. // 已经登录
  61. this.jumpPage()
  62. }
  63. },
  64. jumpPage(){
  65. // if(window.location.hash.indexOf('page') < 0){
  66. // // uni.switchTab({
  67. // // url: '/pages/index/index'
  68. // // });
  69. // }else{
  70. // uni.switchTab({
  71. // url: window.location.hash.split('#')[1]
  72. // });
  73. // }
  74. },
  75. wechatLogin() {
  76. // mpWx.checkSession().then(res => {
  77. // console.log(res, 222)
  78. // })
  79. // mpWx.getUserInfo().then(res => {
  80. // console.log(res)
  81. // })
  82. // 微信登录
  83. mpWx.login().then(code => {
  84. // 获取openId
  85. store.dispatch("getOpenId", {code: code}).then(res => {
  86. setTimeout(() => {
  87. uni.reLaunch({
  88. url: '/pages/signs/main/main',
  89. })
  90. })
  91. })
  92. })
  93. // uni.switchTab({
  94. // url: "/pages/signs/me/me"
  95. // })
  96. }
  97. },
  98. onLaunch: async function(options) {
  99. console.log(options)
  100. // 初始化
  101. await this.setAppInfo();
  102. // 检查更新
  103. // #ifdef MP-WEIXIN
  104. updateCheck.call(this)
  105. // #endif
  106. // #ifdef MP-WEIXIN
  107. this.wechatLogin()
  108. // #endif
  109. // #ifdef H5
  110. try {
  111. // await this.autoLogin(options.query);
  112. } catch (e) {
  113. }
  114. // #endif
  115. },
  116. onPageNotFound(){
  117. uni.reLaunch({
  118. url: '/pages/signs/main/main',
  119. })
  120. },
  121. onUnhandledRejection(e) {
  122. // console.log(e)
  123. // console.log(this)
  124. uni.showModal({
  125. title: '提示',
  126. content: "加载失败,请尝试刷新"
  127. });
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. /*每个页面公共css */
  133. @import "@/uni_modules/colorui/main.css";
  134. @import "@/uni_modules/uview-ui/index.scss";
  135. @import "@/uni_modules/uview-ui/theme.scss";
  136. @import "common/demo.scss";
  137. @import "common/fontFamily/fontCss.css";
  138. uni-radio:not([disabled]) .uni-radio-input:hover,
  139. uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  140. border-color: #ccc !important;
  141. }
  142. page {
  143. -webkit-overflow-scrolling: touch; //ios滑动不流畅
  144. height: 100%;
  145. background: #f6f6f6;
  146. width: 100%;
  147. font-size: 30upx;
  148. font-family: NotoSansHans-Bold;
  149. word-break: break-all; //英文文本不换行
  150. color: #333;
  151. }
  152. ::-webkit-scrollbar {
  153. width: 0;
  154. height: 0;
  155. color: transparent;
  156. display: none;
  157. }
  158. page{
  159. height: 100%;
  160. }
  161. .app-full{
  162. background-color: $app-bg-color;
  163. height: 100%;
  164. }
  165. .app-page{
  166. background-color: $app-bg-color;
  167. height: 100%;
  168. padding-bottom: 100rpx;
  169. /* #ifndef H5*/
  170. min-height: 100%
  171. /* #endif */
  172. /* #ifdef H5 */
  173. padding-bottom: 100rpx;
  174. /* #endif */
  175. }
  176. .box-head{
  177. display: flex;
  178. align-items: center;
  179. background: linear-gradient(90deg, rgba(121,169,206,0.4) 0%, rgba(121,169,206,0) 100%);
  180. border-radius: 2rpx;
  181. width: 259rpx;
  182. height: 50rpx;
  183. padding-left: 28rpx;
  184. border-left: 8rpx solid #79A9CE;
  185. .name{
  186. font-size: 28rpx;
  187. font-family: PingFang SC;
  188. font-weight: bold;
  189. color: #333333;
  190. }
  191. }
  192. </style>