App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.code === 200){
  69. getApp().globalData.open_id = res.data.openid;
  70. getApp().globalData.session_key = res.data.session_key
  71. that.$isResolve();
  72. // uni.hideLoading()
  73. }
  74. },
  75. fail: () => {
  76. console.log("连接失败");
  77. }
  78. });
  79. },
  80. }
  81. };
  82. </script>
  83. <style lang="scss">
  84. /*每个页面公共css */
  85. @import '@/common/uni.css';
  86. page {
  87. height: 100%;
  88. background: #f3f3f3;
  89. &:before{
  90. content: '';
  91. position: fixed;
  92. left: 0;
  93. right: 0;
  94. top: 0;
  95. z-index: 1;
  96. height: 1rpx;
  97. background: #e0e0e0;
  98. }
  99. }
  100. button::after{
  101. display: none;
  102. }
  103. *{touch-action: none;}
  104. .display-flex-start {
  105. display: flex;
  106. align-items: center;
  107. }
  108. .display-flex-center {
  109. display: flex;
  110. justify-content: center;
  111. align-items: center;
  112. }
  113. .display-flex-end {
  114. display: flex;
  115. justify-content: flex-end;
  116. align-items: center;
  117. }
  118. .display-between {
  119. display: flex;
  120. justify-content: space-between;
  121. }
  122. .display-around {
  123. display: flex;
  124. justify-content: space-around;
  125. }
  126. .display-between-column {
  127. display: flex;
  128. flex-direction: column;
  129. justify-content: space-between;
  130. }
  131. .display-around-column {
  132. display: flex;
  133. flex-direction: column;
  134. justify-content: space-around;
  135. }
  136. .display-evenly-column {
  137. display: flex;
  138. flex-direction: column;
  139. justify-content: space-evenly;
  140. }
  141. .display-wrap {
  142. flex-wrap: wrap;
  143. }
  144. .items-center {
  145. align-items: center;
  146. }
  147. .margin-top-10{
  148. margin-top: 10%;
  149. }
  150. .shareParent {
  151. width: 100%;
  152. height: 100%;
  153. position: fixed;
  154. }
  155. .margin-right-10 {
  156. margin-right: 10rpx;
  157. }
  158. .margin-top-1 {
  159. margin-top: 1%;
  160. }
  161. .margin-right-0 {
  162. margin-right: 0!important;
  163. }
  164. .color-666 {
  165. color: #666666;
  166. }
  167. .color-999 {
  168. color: #999;
  169. }
  170. .width-55 {
  171. width: 55%;
  172. }
  173. </style>