四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
1.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <script>
  2. export default {
  3. methods: {
  4. // 提前获取二维码并保存起来
  5. async getQrcode() {
  6. uni.getImageInfo({
  7. src: `${this.$config.baseURL}/promotion/qrCode?token=${uni.getStorageSync('token')}`
  8. // #ifdef H5
  9. + '&type=official'
  10. // #endif
  11. ,
  12. success: (image) => {
  13. this.Qrcode = image.path;
  14. this.$store.commit('setQrcode', this.Qrcode)
  15. },
  16. fail: (err) => {
  17. console.error('获取二维码失败:', err);
  18. }
  19. });
  20. },
  21. async getUserInfo() {
  22. const res = await this.$api.login.getUserInfo();
  23. if (res.code === 200) {
  24. this.$store.dispatch('updateUserInfo', this.userInfo)
  25. }
  26. },
  27. },
  28. async onLaunch() {
  29. // 提前获取二维码
  30. this.getQrcode()
  31. // 预加载音色列表(不等待完成,后台加载)
  32. this.$store.dispatch('getVoiceList')
  33. },
  34. async onShow() {
  35. // if(!uni.getStorageSync('token')){
  36. // uni.redirectTo({
  37. // url: '/subPages/login/login',
  38. // })
  39. // }
  40. // 确保配置数据和音色列表都已初始化
  41. await this.$store.dispatch('initData')
  42. console.log('配置数据初始化完成')
  43. // 如果音色列表还没有加载,再次尝试加载
  44. if (this.$store.state.voiceList.length === 0) {
  45. this.$store.dispatch('getVoiceList')
  46. }
  47. if(uni.getStorageSync('token')){
  48. this.getUserInfo()
  49. }
  50. },
  51. onHide: function() {
  52. console.log('App Hide')
  53. },
  54. }
  55. </script>
  56. <style lang="scss">
  57. // @import '@/uni_modules/uv-ui-tools/index.scss';
  58. /* 富文本全局样式 - rich-text组件的class样式必须写在全局中 */
  59. h1, h2, h3, h4, h5, h6 {
  60. font-weight: bold;
  61. margin: 10px 0;
  62. line-height: 1.4;
  63. }
  64. h2 {
  65. font-size: 20px;
  66. color: #333;
  67. }
  68. p {
  69. margin: 8px 0;
  70. line-height: 1.6;
  71. color: #666;
  72. }
  73. strong {
  74. font-weight: bold;
  75. color: #333;
  76. }
  77. /* 首行缩进样式 */
  78. .text-indent {
  79. text-indent: 2em;
  80. }
  81. </style>