App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. },
  23. onLaunch: function () {
  24. console.log("App Launch");
  25. this.loginLoad();
  26. },
  27. onShow: function () {
  28. console.log("App Show");
  29. uni.hideTabBar({})
  30. },
  31. onHide: function () {
  32. console.log("App Hide");
  33. },
  34. methods:{
  35. loginLoad(){
  36. let that = this;
  37. uni.login({
  38. success(res) {
  39. that.loginRequest(res.code)
  40. }
  41. })
  42. },
  43. loginRequest(codeRes){
  44. let md5Sign = md5("method="+'user'+"&timestamp="+getApp().globalData.globalTimestamp+"&secret="+getApp().globalData.secret)
  45. let url = getApp().globalData.shareUrl+'api/api.php'+'?method=user&source=user&action=login&timestamp='+getApp().globalData.globalTimestamp +'&sign='+md5Sign
  46. uni.request({
  47. url:url,
  48. method: 'POST',
  49. header: {
  50. 'content-type': 'application/x-www-form-urlencoded'
  51. },
  52. data: {
  53. code:codeRes
  54. },
  55. success: (res) => {
  56. console.log(res)
  57. if(res.data.code === 200){
  58. getApp().globalData.session_key = res.data.data.session_key;
  59. getApp().globalData.open_id = res.data.data.openid;
  60. getApp().globalData.user_status = res.data.data.status;
  61. getApp().globalData.user_phone = res.data.data.phone;
  62. uni.hideLoading()
  63. }
  64. },
  65. fail: () => {
  66. console.log("连接失败");
  67. }
  68. });
  69. },
  70. }
  71. };
  72. </script>
  73. <style>
  74. /*每个页面公共css */
  75. @import url("/components/gaoyia-parse/parse.css");
  76. .display-flex-start {
  77. display: flex;
  78. align-items: center;
  79. }
  80. .display-flex-end {
  81. display: flex;
  82. justify-content: flex-end;
  83. align-items: center;
  84. }
  85. .display-between {
  86. display: flex;
  87. justify-content: space-between;
  88. }
  89. .display-around {
  90. display: flex;
  91. justify-content: space-around;
  92. }
  93. .display-between-column {
  94. display: flex;
  95. flex-direction: column;
  96. justify-content: space-between;
  97. }
  98. .display-around-column {
  99. display: flex;
  100. flex-direction: column;
  101. justify-content: space-around;
  102. }
  103. .display-wrap {
  104. display: flex;
  105. flex-wrap: wrap;
  106. }
  107. .items-center {
  108. align-items: center;
  109. }
  110. </style>