App.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. </template>
  3. <script>
  4. // import {
  5. // getPricePercentReq,
  6. // } from '@/api/test/index.js'
  7. // import {
  8. // getUserInfoReq,
  9. // } from '@/api/test/index.js'
  10. import uploadUrl from '@/common/config.js'
  11. // import PrivacyPopup from "@/components/privacyPopup/index.vue";
  12. export default {
  13. globalData: {
  14. showPrivacy: false,
  15. priceConfig: {},
  16. userInfo: {}
  17. },
  18. async onLaunch(options) {
  19. let _this = this
  20. if (uni.getPrivacySetting) {
  21. uni.getPrivacySetting({
  22. success: res => {
  23. console.log("是否需要授权:", res.needAuthorization, "隐私协议的名称为:", res.privacyContractName)
  24. if (res.needAuthorization) {
  25. getApp().globalData.showPrivacy = true;
  26. } else {
  27. getApp().globalData.showPrivacy = false;
  28. }
  29. },
  30. fail: () => {},
  31. complete: () => {},
  32. })
  33. }
  34. uni.setStorageSync('switchs', [1, 0, 0])
  35. uni.request({
  36. url: uploadUrl.baseUrl + '/api/common/getPriceConfig',
  37. method: "GET",
  38. success: (res) => {
  39. if (res.data.code == 0) {
  40. console.log('app.vue中获取的会员折扣数据', res.data.data)
  41. uni.setStorageSync('priceConfig', res.data.data)
  42. }
  43. }
  44. })
  45. if (uni.getStorageSync('token')) {
  46. uni.request({
  47. url: uploadUrl.baseUrl + '/api/users/getUserInfo',
  48. method: "GET",
  49. header: {
  50. Authorization: uni.getStorageSync('token')
  51. },
  52. success: (res) => {
  53. if (res.data.code == 0) {
  54. console.log('app.vue中获取的用户信息数据', res.data.data)
  55. if ((res.data.data.status == 1 && res.data.data.type == 2) || (res.data.data
  56. .status == 1 && res.data.data.type == 5)) {
  57. uni.setStorageSync('switchs', [0, 1, 0])
  58. }
  59. }
  60. }
  61. })
  62. }
  63. },
  64. async onShow() {},
  65. onHide: function() {
  66. // console.log('App Hide')
  67. },
  68. methods: {
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  74. @import "@/uni_modules/uview-ui/index.scss";
  75. /*每个页面公共css */
  76. @import '@/uni_modules/uni-scss/index.scss';
  77. /* #ifndef APP-NVUE */
  78. @import '@/static/customicons.css';
  79. // 设置整个项目的背景色
  80. page {
  81. // background-color: #f5f5f5;
  82. }
  83. /* #endif */
  84. .example-info {
  85. font-size: 14px;
  86. color: #333;
  87. padding: 10px;
  88. }
  89. </style>