App.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <script>
  2. var md5 = require("./common/md5.js");
  3. export default {
  4. globalData: { //https://stock.xazhima.com/
  5. //shareUrl:'https://stock.xazhima.com/api/api.php',
  6. shareUrl: 'http://fenxiao.xazhima.com/api/api.php', //开发环境全局接口域名 线上:https://guolu.xazhima.com/
  7. globalTimestamp: (Date.now()).toString(),
  8. user_id: '',
  9. open_id:'',
  10. user_status:'',
  11. user_name:'',
  12. user_phone:'',
  13. user_headUrl:'',
  14. isAuth:true,
  15. session_key: '',
  16. inviteId:'',
  17. cleanPayTime: '',
  18. pageSize: '', // 列表加载的pageSize
  19. isAndroid:Boolean,
  20. isIos:false,
  21. globalShareCounts:'',
  22. appId:'wx78d5c9d2169503fa',
  23. appSecret:'9241c2a4d722946571c696e59c00f235'
  24. },
  25. onLaunch: function() {
  26. // console.log('App Launch')
  27. // let equType = uni.getSystemInfoSync().platform;
  28. //  switch(equType){
  29. //     case 'android':
  30. //        console.log('运行Android上')
  31. //        break;
  32. //     case 'ios':
  33. //        console.log('运行iOS上');
  34. // setTimeout(()=>{
  35. // getApp().globalData.isIos = true
  36. // },100)
  37. //        break;
  38. //     default:
  39. //        console.log('运行在开发者工具上')
  40. //        break;
  41. // }
  42. },
  43. onShow: function() {
  44. console.log(2)
  45. },
  46. onHide: function() {
  47. console.log('App Hide')
  48. },
  49. methods:{
  50. getCodeRabot(res){
  51. uni.request({
  52. url:getApp().globalData.shareUrl, //需要设置为全局
  53. method: 'POST',
  54. header: {
  55. 'content-type': 'application/x-www-form-urlencoded'
  56. },
  57. data: {
  58. method: 'login',
  59. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  60. code: res.code,
  61. sign: md5('login' + getApp().globalData.globalTimestamp),
  62. // invited:'invited'
  63. },
  64. success: res => {
  65. // 通过openid发起会员登录
  66. getApp().globalData.user_id = res.data.msg.id;
  67. getApp().globalData.open_id = res.data.msg.openid;
  68. getApp().globalData.isAuth = res.data.msg.isauth === '0';
  69. getApp().globalData.user_name = res.data.msg.name;
  70. getApp().globalData.user_headUrl = res.data.msg.headimg;
  71. getApp().globalData.times = res.data.msg.times;
  72. getApp().globalData.total_times = res.data.msg.total_times;
  73. }
  74. });
  75. },
  76. loginRabot(){
  77. uni.request({
  78. url: getApp().globalData.shareUrl, //需要设置为全局
  79. method: 'POST',
  80. header: {
  81. 'content-type': 'application/x-www-form-urlencoded'
  82. },
  83. data: {
  84. method: 'login',
  85. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  86. wx_openid: res.data.data.openid,
  87. sign: md5('login' + getApp().globalData.globalTimestamp)
  88. },
  89. success: res => {
  90. if (res.data.code === 200) {
  91. if (res.data.data === 0) {
  92. // 没有会员数据,走默认注册逻辑
  93. } else {
  94. // 获取每个页面需要的memberId
  95. let member_id = res.data.data.member_id;
  96. getApp().globalData.member_id = member_id;
  97. }
  98. }
  99. }
  100. });
  101. }
  102. },
  103. }
  104. </script>
  105. <style>
  106. /*每个页面公共css */
  107. page {
  108. height: 100%;
  109. background: #eee;
  110. }
  111. </style>