App.vue 2.4 KB

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