App.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <script>
  2. var md5 = require("./common/md5.js");
  3. export default {
  4. globalData: {
  5. shareUrl: 'https://stock.xazhima.com/api/api.php', //开发环境全局接口域名
  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. },
  20. onLaunch: function() {
  21. console.log('App Launch')
  22. // 用户登录状态判断
  23. // uni.login({
  24. // success: (res) => {
  25. // this.getCodeRabot(res)
  26. // }
  27. // });
  28. },
  29. onShow: function() {
  30. console.log('App Show')
  31. },
  32. onHide: function() {
  33. console.log('App Hide')
  34. },
  35. methods:{
  36. getCodeRabot(res){
  37. uni.request({
  38. url:getApp().globalData.shareUrl, //需要设置为全局
  39. method: 'POST',
  40. header: {
  41. 'content-type': 'application/x-www-form-urlencoded'
  42. },
  43. data: {
  44. method: 'login',
  45. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  46. code: res.code,
  47. sign: md5('login' + getApp().globalData.globalTimestamp),
  48. // invited:'invited'
  49. },
  50. success: res => {
  51. // 通过openid发起会员登录
  52. getApp().globalData.user_id = res.data.msg.id;
  53. getApp().globalData.open_id = res.data.msg.openid;
  54. getApp().globalData.isAuth = res.data.msg.isauth === '0';
  55. getApp().globalData.user_name = res.data.msg.name;
  56. getApp().globalData.user_headUrl = res.data.msg.headimg;
  57. getApp().globalData.times = res.data.msg.times;
  58. getApp().globalData.total_times = res.data.msg.total_times;
  59. }
  60. });
  61. },
  62. loginRabot(){
  63. uni.request({
  64. url: getApp().globalData.shareUrl, //需要设置为全局
  65. method: 'POST',
  66. header: {
  67. 'content-type': 'application/x-www-form-urlencoded'
  68. },
  69. data: {
  70. method: 'login',
  71. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  72. wx_openid: res.data.data.openid,
  73. sign: md5('login' + getApp().globalData.globalTimestamp)
  74. },
  75. success: res => {
  76. if (res.data.code === 200) {
  77. if (res.data.data === 0) {
  78. // 没有会员数据,走默认注册逻辑
  79. } else {
  80. // 获取每个页面需要的memberId
  81. let member_id = res.data.data.member_id;
  82. getApp().globalData.member_id = member_id;
  83. }
  84. }
  85. }
  86. });
  87. }
  88. },
  89. }
  90. </script>
  91. <style>
  92. /*每个页面公共css */
  93. </style>