App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script>
  2. var md5 = require("./common/md5.js");
  3. export default {
  4. globalData: { //https://stock.xazhima.com/
  5. //shareUrl:'https://f.xazhima.com/api/api.php',
  6. shareUrl: 'https://fenxiao.xazhima.com/api/api.php', //开发环境全局接口域名 线上:https://f.xazhima.com/api/api.php
  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. shareStoreImg:''
  27. },
  28. onLaunch: function() {
  29. // console.log('App Launch')
  30. // let equType = uni.getSystemInfoSync().platform;
  31. //  switch(equType){
  32. //     case 'android':
  33. //        console.log('运行Android上')
  34. //        break;
  35. //     case 'ios':
  36. //        console.log('运行iOS上');
  37. // setTimeout(()=>{
  38. // getApp().globalData.isIos = true
  39. // },100)
  40. //        break;
  41. //     default:
  42. //        console.log('运行在开发者工具上')
  43. //        break;
  44. // }
  45. },
  46. onShow: function() {
  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. @import '/components/gaoyia-parse/parse.css';
  110. page {
  111. height: 100%;
  112. background: #eee;
  113. }
  114. </style>