App.vue 2.1 KB

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