App.vue 3.0 KB

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