App.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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://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. lastId:'',
  15. isAuth:true,
  16. session_key: '',
  17. inviteId:'',
  18. cleanPayTime: '',
  19. pageSize: '', // 列表加载的pageSize
  20. isAndroid:Boolean,
  21. isIos:false,
  22. globalShareCounts:'',
  23. shareImg:'',
  24. shareContent:'',
  25. shareTaobaoCode:''
  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. },
  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. @import '/components/gaoyia-parse/parse.css';
  109. page {
  110. height: 100%;
  111. background: #eee;
  112. }
  113. </style>