App.vue 2.4 KB

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