App.vue 3.1 KB

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