weatherCalendarCardList40.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="container">
  3. <div class="weatherCard" v-for="(item,index) in weatherProphetData_40" :key="index">
  4. <weatherCalendarCard40 ref="weatherCalendarCard40"></weatherCalendarCard40>
  5. </div>
  6. </view>
  7. </template>
  8. <script>
  9. import weatherCalendarCard40 from '../../weathercomponents/weatherCalendarCardList40/weatherCalendarCard40/weatherCalendarCard40.vue';
  10. export default {
  11. components: {
  12. "weatherCalendarCard40":weatherCalendarCard40
  13. },
  14. data() {
  15. return {
  16. width:"",
  17. height:"",
  18. weatherProphetData_40:[],
  19. classNameWeatherBackgroundColor: "threeGradeBlue",
  20. weatherIcons: [],
  21. classNameWeatherIconWhite:[],
  22. windowWidth:"",
  23. windowHeight:"",
  24. url:""
  25. };
  26. },
  27. created() {
  28. this.windowWidth=uni.getSystemInfoSync().windowWidth;
  29. this.windowHeight=uni.getSystemInfoSync().windowHeight;
  30. if(this.windowWidth>=768){
  31. this.url="http://49.4.78.143:8081/WeatherfdController/weatherInformationChangePictureName?model=weatherCardList40,weatherCard40,white30&weatherInformation="
  32. }else{
  33. this.url="http://49.4.78.143:8081/WeatherfdController/weatherInformationChangePictureName?model=weatherCardList40,weatherCard40,white22&weatherInformation="
  34. }
  35. },
  36. methods: {
  37. getWeatherData40(width,height,weatherProphetData_40){
  38. let _this=this;
  39. this.width=width;
  40. this.height=height;
  41. this.weatherProphetData_40 = weatherProphetData_40;
  42. //console.log(weatherProphetData_40);
  43. this.weatherIcons=[];
  44. for(let i = 0; i < this.weatherProphetData_40.length; i++) {
  45. this.weatherIcons.push(this.weatherProphetData_40[i].weather);
  46. }
  47. this.commitData();
  48. },
  49. commitData:async function() {
  50. //获取图标请求
  51. let _this=this;
  52. await uni.request({
  53. url: this.url+ this.weatherIcons,
  54. data:{
  55. },
  56. method:'GET',
  57. success: function(res) {
  58. //console.log(res.data)
  59. _this.classNameWeatherIconWhite=[];
  60. for(let i=0;i<res.data.length;i++){
  61. _this.classNameWeatherIconWhite.push(res.data[i]);
  62. }
  63. for(let i=0;i<_this.weatherProphetData_40.length;i++){
  64. _this.$nextTick(function() {
  65. this.$refs.weatherCalendarCard40[i].getWeatherData(this.width,this.height,this.classNameWeatherBackgroundColor, this.classNameWeatherIconWhite[i], this.weatherProphetData_40[i]);
  66. })
  67. }
  68. },
  69. fail: () => {
  70. _this.tips="网络错误,小程序端请检查合法域名";
  71. },
  72. });
  73. },
  74. pushWeatherData(){
  75. let _this=this;
  76. for(let i=0;i<this.weatherProphetData_40.length;i++){
  77. this.$nextTick(function() {
  78. console.log(_this.classNameWeatherIconWhite[0]);
  79. //this.$refs.weatherCalendarCard40[i].getWeatherData(this.width,this.height,this.classNameWeatherBackgroundColor, this.classNameWeatherIconWhite[i], this.weatherProphetData_40[i]);
  80. })
  81. }
  82. }
  83. }
  84. };
  85. </script>
  86. <style scoped="scoped">
  87. .container{
  88. margin: 0px auto;
  89. width: 90%;
  90. height: auto;
  91. /* margin-left: 22px; */
  92. /* border: 0.5px solid #698086; */
  93. }
  94. .weatherCard{
  95. width: 25%;
  96. float: left;
  97. /* margin-left: 6px; */
  98. }
  99. </style>