App.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script>
  2. import md5 from '@/common/md5.js';
  3. export default {
  4. globalData: {
  5. //shareUrl: 'https://gdoctor.xazhima.com/api/v1.0/api.php', //开发环境全局接口域名 线上:https://guolu.xazhima.com/
  6. //shareUrl: "https://kiq.xazhima.com/",
  7. shareUrl:"https://kgwxxcx.xixianxinqu.gov.cn/1026airqt/",
  8. globalTimestamp: Date.now().toString(),
  9. secret: "AirQK_weichat_app_zhima",
  10. selectedIndex:0,
  11. isSider:false,
  12. user_id: '',
  13. open_id:'',
  14. user_status:'',
  15. user_name:'',
  16. user_phone:'',
  17. user_headUrl:'',
  18. globalAuth:false,
  19. session_key: '',
  20. contact_name:'',
  21. company_name:'',
  22. company_logo:'',
  23. isAndroid:false
  24. },
  25. onLaunch: function () {
  26. console.log("App Launch");
  27. // let equType = uni.getSystemInfoSync().platform;
  28. //  switch(equType){
  29. //     case 'android':
  30. //        console.log('运行Android上')
  31. // setTimeout(()=>{
  32. // getApp().globalData.isAndroid = true
  33. // },100)
  34. //        break;
  35. //     case 'ios':
  36. //        console.log('运行iOS上');
  37. //        break;
  38. //     default:
  39. //        console.log('运行在开发者工具上')
  40. //        break;
  41. // }
  42. this.loginLoad();
  43. },
  44. onShow: function () {
  45. console.log("App Show");
  46. uni.hideTabBar({})
  47. },
  48. onHide: function () {
  49. console.log("App Hide");
  50. },
  51. methods:{
  52. loginLoad(){
  53. let that = this;
  54. uni.login({
  55. success(res) {
  56. that.loginRequest(res.code)
  57. }
  58. })
  59. },
  60. loginRequest(codeRes){
  61. let md5Sign = md5("method="+'user'+"&timestamp="+getApp().globalData.globalTimestamp+"&secret="+getApp().globalData.secret)
  62. let url = getApp().globalData.shareUrl+'api/api.php'+'?method=user&source=user&action=login&timestamp='+getApp().globalData.globalTimestamp +'&sign='+md5Sign
  63. uni.request({
  64. url:url,
  65. method: 'POST',
  66. header: {
  67. 'content-type': 'application/x-www-form-urlencoded'
  68. },
  69. data: {
  70. code:codeRes
  71. },
  72. success: (res) => {
  73. console.log(res)
  74. if(res.data.code === 200){
  75. getApp().globalData.session_key = res.data.data.session_key;
  76. getApp().globalData.open_id = res.data.data.openid;
  77. getApp().globalData.user_status = res.data.data.status;
  78. getApp().globalData.user_phone = res.data.data.phone;
  79. // uni.hideLoading()
  80. }
  81. },
  82. fail: () => {
  83. console.log("连接失败");
  84. }
  85. });
  86. },
  87. }
  88. };
  89. </script>
  90. <style>
  91. /*每个页面公共css */
  92. @import url("/components/gaoyia-parse/parse.css");
  93. page {
  94. height: 100%;
  95. }
  96. .display-flex-start {
  97. display: flex;
  98. align-items: center;
  99. }
  100. .display-flex-end {
  101. display: flex;
  102. justify-content: flex-end;
  103. align-items: center;
  104. }
  105. .display-between {
  106. display: flex;
  107. justify-content: space-between;
  108. }
  109. .display-around {
  110. display: flex;
  111. justify-content: space-around;
  112. }
  113. .display-between-column {
  114. display: flex;
  115. flex-direction: column;
  116. justify-content: space-between;
  117. }
  118. .display-around-column {
  119. display: flex;
  120. flex-direction: column;
  121. justify-content: space-around;
  122. }
  123. .display-wrap {
  124. display: flex;
  125. flex-wrap: wrap;
  126. }
  127. .items-center {
  128. align-items: center;
  129. }
  130. </style>