App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. @import url("/components/gaoyia-parse/parse.css");
  73. .display-flex-start {
  74. display: flex;
  75. align-items: center;
  76. }
  77. .display-flex-end {
  78. display: flex;
  79. justify-content: flex-end;
  80. align-items: center;
  81. }
  82. .display-between {
  83. display: flex;
  84. justify-content: space-between;
  85. }
  86. .display-around {
  87. display: flex;
  88. justify-content: space-around;
  89. }
  90. .display-between-column {
  91. display: flex;
  92. flex-direction: column;
  93. justify-content: space-between;
  94. }
  95. .display-around-column {
  96. display: flex;
  97. flex-direction: column;
  98. justify-content: space-around;
  99. }
  100. .display-wrap {
  101. display: flex;
  102. flex-wrap: wrap;
  103. }
  104. .items-center {
  105. align-items: center;
  106. }
  107. </style>