App.vue 3.1 KB

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