App.vue 3.0 KB

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