App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. }
  63. },
  64. fail: () => {
  65. console.log("连接失败");
  66. }
  67. });
  68. },
  69. }
  70. };
  71. </script>
  72. <style>
  73. /*每个页面公共css */
  74. @import url("/components/gaoyia-parse/parse.css");
  75. .display-flex-start {
  76. display: flex;
  77. align-items: center;
  78. }
  79. .display-flex-end {
  80. display: flex;
  81. justify-content: flex-end;
  82. align-items: center;
  83. }
  84. .display-between {
  85. display: flex;
  86. justify-content: space-between;
  87. }
  88. .display-around {
  89. display: flex;
  90. justify-content: space-around;
  91. }
  92. .display-between-column {
  93. display: flex;
  94. flex-direction: column;
  95. justify-content: space-between;
  96. }
  97. .display-around-column {
  98. display: flex;
  99. flex-direction: column;
  100. justify-content: space-around;
  101. }
  102. .display-wrap {
  103. display: flex;
  104. flex-wrap: wrap;
  105. }
  106. .items-center {
  107. align-items: center;
  108. }
  109. </style>