times.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template name="times">
  2. <view>
  3. <view class="cu-timeline" v-for="(v,k) in fetch.times" :key="v.id">
  4. <view class="cu-time">{{v.name}}</view>
  5. <view class="cu-item" :class="v1.id == times ? 'text-blue' : ''" v-for="(v1,k1) in v.child" :key="v1.id" :style="{backgroundImage: v1.icon}">
  6. <view class="content" :style="{color:v1.color,backgroundColor:v1.bgcolor}" @click="openTime(k, k1)">
  7. <view class="cu-capsule radius">
  8. <view class="cu-tag bg-cyan">{{v1.name}}</view>
  9. <view class="cu-tag line-white">
  10. <!--
  11. <picker mode="date" :value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day" :start="v1.year+`-01-01`" :end="(v1.end_year ? v1.end_year : v1.year) +`-12-31`" :fields="`day`" @change="selectDay" :data-year="v1.year" :data-name="v1.name" :data-id="v1.id">
  12. <view class="uni-input">{{fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : '主序时间'}}</view>
  13. </picker>
  14. -->
  15. <view class="uni-input">{{fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : '主序时间'}}</view>
  16. </view>
  17. </view>
  18. <view @click="go(v1)">
  19. <view class="margin-top" v-if="v1.desc&& !v1.pic">{{v1.desc}}</view>
  20. <view class="margin-top" v-if="v1.pic && !v1.desc"><image :src="v1.pic" mode="widthFix" class="slide-image" style="height:auto"></image></view>
  21. </view>
  22. </view>
  23. <w-picker
  24. :visible.sync="v1.visible"
  25. mode="date"
  26. :startYear="v1.year"
  27. :endYear="(v1.end_year ? v1.end_year : v1.year)"
  28. :value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day"
  29. :current="false"
  30. fields="day"
  31. @confirm="selectDay($event,v1.id, v1.year, v1.name)"
  32. :disabled-after="false"
  33. :ref="'date'+v1.id"
  34. ></w-picker>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import wPicker from "@/lib/w-picker/w-picker.vue";
  41. export default {
  42. name: "times",
  43. props: {
  44. content_id : {
  45. type : String,
  46. value : null
  47. },
  48. width : {
  49. type : String,
  50. default : '100%'
  51. },
  52. param : {},
  53. index : 0,
  54. times : 0,
  55. set : 0,
  56. },
  57. data() {
  58. return {
  59. timeVisible:false,
  60. fetch : {},
  61. current : '',
  62. year : '',
  63. month : '',
  64. day : '',
  65. }
  66. },
  67. components:{
  68. wPicker
  69. },
  70. mounted() {
  71. this.fetch = this.param;
  72. this.getDate();
  73. },
  74. methods:{
  75. openTime : function(k, k1) {
  76. this.fetch.times[k].child[k1].visible = true;
  77. },
  78. getDate : function(type) {
  79. const date = new Date();
  80. let year = date.getFullYear();
  81. let month = date.getMonth() + 1;
  82. let day = date.getDate();
  83. this.year = year;
  84. this.month = month > 9 ? month : '0' + month;;
  85. this.day = day > 9 ? day : '0' + day;
  86. this.current = this.year + '-' + this.month + '-' + this.day;
  87. },
  88. getData : function() {
  89. this.$emit('getTimes');
  90. },
  91. getInfo : function(t) {
  92. //触底刷新
  93. },
  94. go : function(times) {
  95. var self = this;
  96. this.Dever.alert('正在进入' + times.name);
  97. // 要拿到最新的page_id
  98. if (this.fetch.user_times[times.id]) {
  99. var day = this.fetch.user_times[times.id].day;
  100. } else {
  101. var day = '主序时间';
  102. }
  103. if (day == '主序时间') {
  104. day = '';
  105. }
  106. var code = this.Dever.config.code;
  107. this.Dever.post('app/collection/?l=api.getPageId', {set:this.set,code:code,times_id:times.id,day:day}, function(t) {
  108. if (t.code) {
  109. self.Dever.location('dream/view?code=' + t.code);
  110. } else {
  111. self.Dever.alert('这是您当前选择的时间');
  112. }
  113. })
  114. },
  115. selectDay : function(res, id, year, name) {
  116. var times = {};
  117. times.id = id;
  118. times.year = year;
  119. times.name = name;
  120. //times = res.currentTarget.dataset;
  121. var value = res.value;
  122. if (!this.fetch.user_times[times.id]) {
  123. this.fetch.user_times[times.id] = {};
  124. this.fetch.user_times[times.id].day = '主序时间';
  125. }
  126. var old = this.fetch.user_times[times.id].day;
  127. this.fetch.user_times[times.id].day = value;
  128. var current = times.year + '-' + this.month + '-' + this.day;
  129. if (this.fetch.user_times[times.id].day == current) {
  130. this.fetch.user_times[times.id].day = '主序时间';
  131. }
  132. if (old != value) {
  133. this.go(times);
  134. }
  135. },
  136. },
  137. }
  138. </script>
  139. <style>
  140. .slide-image {
  141. }
  142. .cu-item {
  143. z-index: unset;
  144. }
  145. </style>