list.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { CDN_URL,API_BASE_URL,DISTRIBUTION } from '../../config/index';
  2. import http from '../../utils/http';
  3. let app = getApp();
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. cdn_url:CDN_URL,
  15. audioList:DISTRIBUTION,
  16. api_base_url:API_BASE_URL
  17. },
  18. /**
  19. * 组件的方法列表
  20. */
  21. methods: {
  22. getAudiosList(){
  23. http.get('/api/web/audio/list').then(res=>{
  24. let {data} = res;
  25. let target = [];
  26. for(let [key,value] of Object.entries(data)) {
  27. switch (key) {
  28. case '1':
  29. let obj1 = {};
  30. obj1['title'] = '主厅';
  31. obj1['list'] = value
  32. target = [...target,obj1]
  33. break;
  34. case '2':
  35. let obj2 = {};
  36. obj2['title'] = '附厅';
  37. obj2['list'] = value;
  38. target = [...target,obj2]
  39. break;
  40. case '3':
  41. let obj3 = {};
  42. obj3['title'] = '序厅';
  43. obj3['list'] = value;
  44. target = [...target, obj3];
  45. break;
  46. default:
  47. break
  48. }
  49. }
  50. this.setData({
  51. audioList:target
  52. })
  53. })
  54. },
  55. tapTitle(e){
  56. let {tag,index} = e.mark;
  57. let data = this.data.audioList
  58. if (!tag) {
  59. return
  60. }
  61. if (data[index]['tag'] == tag) {
  62. tag = ''
  63. }
  64. data[index]['tag'] = tag
  65. this.setData({
  66. audioList:data
  67. })
  68. }
  69. },
  70. attached: function () {
  71. //获取语音
  72. // this.getAudiosList();
  73. },
  74. detached: function () {
  75. app.globalData.AllExample = [];
  76. }
  77. })