App.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <script>
  2. import md5 from '@/common/md5.js';
  3. export default {
  4. globalData: {
  5. shareUrl: 'https://xnh.xazhima.com/prod-api/wap/business/weixin/',
  6. globalTimestamp: Date.now().toString(),
  7. secret: 'AirQK_weichat_app_zhima',
  8. selectedIndex: 0,
  9. isSider: false,
  10. user_id: '',
  11. open_id: '',
  12. user_status: '',
  13. user_name: '',
  14. user_phone: '',
  15. user_headUrl: '',
  16. globalAuth: false,
  17. session_key: '',
  18. isAndroid: false,
  19. user_department: '',
  20. user_real_name: ''
  21. },
  22. onLaunch: function () {
  23. console.log('App Launch');
  24. // let equType = uni.getSystemInfoSync().platform;
  25. //  switch(equType){
  26. //     case 'android':
  27. //        console.log('运行Android上')
  28. // setTimeout(()=>{
  29. // getApp().globalData.isAndroid = true
  30. // },100)
  31. //        break;
  32. //     case 'ios':
  33. //        console.log('运行iOS上');
  34. //        break;
  35. //     default:
  36. //        console.log('运行在开发者工具上')
  37. //        break;
  38. // }
  39. this.loginLoad();
  40. },
  41. onShow: function () {
  42. console.log('App Show');
  43. // uni.hideTabBar({})
  44. },
  45. onHide: function () {
  46. console.log('App Hide');
  47. },
  48. methods: {
  49. loginLoad() {
  50. let that = this;
  51. uni.login({
  52. success(res) {
  53. that.loginRequest(res.code);
  54. }
  55. });
  56. },
  57. loginRequest(codeRes) {
  58. let that = this;
  59. let url = getApp().globalData.shareUrl + 'login/' + codeRes;
  60. uni.request({
  61. url: url,
  62. method: 'GET',
  63. header: {
  64. 'content-type': 'application/x-www-form-urlencoded'
  65. },
  66. success: (res) => {
  67. console.log(res);
  68. if (res.data.code === 200) {
  69. uni.setStorageSync('openid', res.data.data.openid)
  70. getApp().globalData.open_id = res.data.data.openid;
  71. getApp().globalData.session_key = res.data.data.session_key;
  72. that.$isResolve();
  73. // uni.hideLoading()
  74. }
  75. },
  76. fail: () => {
  77. console.log('连接失败');
  78. }
  79. });
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss">
  85. /*每个页面公共css */
  86. @import '@/common/uni.css';
  87. page {
  88. height: 100%;
  89. background: #f3f3f3;
  90. &:before {
  91. content: '';
  92. position: fixed;
  93. left: 0;
  94. right: 0;
  95. top: 0;
  96. z-index: 1;
  97. height: 1rpx;
  98. background: #e0e0e0;
  99. }
  100. }
  101. button::after {
  102. display: none;
  103. }
  104. * {
  105. touch-action: none;
  106. }
  107. .display-flex-start {
  108. display: flex;
  109. align-items: center;
  110. }
  111. .display-flex-center {
  112. display: flex;
  113. justify-content: center;
  114. align-items: center;
  115. }
  116. .display-flex-end {
  117. display: flex;
  118. justify-content: flex-end;
  119. align-items: center;
  120. }
  121. .display-between {
  122. display: flex;
  123. justify-content: space-between;
  124. }
  125. .display-around {
  126. display: flex;
  127. justify-content: space-around;
  128. }
  129. .display-between-column {
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: space-between;
  133. }
  134. .display-around-column {
  135. display: flex;
  136. flex-direction: column;
  137. justify-content: space-around;
  138. }
  139. .display-evenly-column {
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: space-evenly;
  143. }
  144. .display-wrap {
  145. flex-wrap: wrap;
  146. }
  147. .items-center {
  148. align-items: center;
  149. }
  150. .margin-top-10 {
  151. margin-top: 10%;
  152. }
  153. .shareParent {
  154. width: 100%;
  155. height: 100%;
  156. position: fixed;
  157. }
  158. .margin-right-10 {
  159. margin-right: 10rpx;
  160. }
  161. .margin-top-1 {
  162. margin-top: 1%;
  163. }
  164. .margin-right-0 {
  165. margin-right: 0 !important;
  166. }
  167. .color-666 {
  168. color: #666666;
  169. }
  170. .color-999 {
  171. color: #999;
  172. }
  173. .width-55 {
  174. width: 55%;
  175. }
  176. </style>