App.vue 3.0 KB

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