App.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. .c-abnor {
  105. position: fixed;
  106. left: 50%;
  107. top: 50%;
  108. transform: translate(-50%, -50%);
  109. display: flex;
  110. flex-direction: column;
  111. white-space: nowrap;
  112. align-items: center;
  113. font-size: 27.47rpx;
  114. color: #999;
  115. .icon {
  116. width: 137.36rpx;
  117. height: 137.36rpx;
  118. margin-bottom: 41.21rpx;
  119. }
  120. }
  121. * {
  122. touch-action: none;
  123. }
  124. .display-flex-start {
  125. display: flex;
  126. align-items: center;
  127. }
  128. .display-flex-center {
  129. display: flex;
  130. justify-content: center;
  131. align-items: center;
  132. }
  133. .display-flex-end {
  134. display: flex;
  135. justify-content: flex-end;
  136. align-items: center;
  137. }
  138. .display-between {
  139. display: flex;
  140. justify-content: space-between;
  141. }
  142. .display-around {
  143. display: flex;
  144. justify-content: space-around;
  145. }
  146. .display-between-column {
  147. display: flex;
  148. flex-direction: column;
  149. justify-content: space-between;
  150. }
  151. .display-around-column {
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: space-around;
  155. }
  156. .display-evenly-column {
  157. display: flex;
  158. flex-direction: column;
  159. justify-content: space-evenly;
  160. }
  161. .display-wrap {
  162. flex-wrap: wrap;
  163. }
  164. .items-center {
  165. align-items: center;
  166. }
  167. .margin-top-10 {
  168. margin-top: 10%;
  169. }
  170. .shareParent {
  171. width: 100%;
  172. height: 100%;
  173. position: fixed;
  174. }
  175. .margin-right-10 {
  176. margin-right: 10rpx;
  177. }
  178. .margin-top-1 {
  179. margin-top: 1%;
  180. }
  181. .margin-right-0 {
  182. margin-right: 0 !important;
  183. }
  184. .color-666 {
  185. color: #666666;
  186. }
  187. .color-999 {
  188. color: #999;
  189. }
  190. .width-55 {
  191. width: 55%;
  192. }
  193. </style>