App.vue 2.4 KB

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