clientDynamic.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <view class="tab ddflex">
  4. <view class="tab-item fflex" :class="tabIndex==1?'tab-item-active':''" @click="tabChange(1)">今日动态</view>
  5. <view class="tab-item fflex" :class="tabIndex==2?'tab-item-active':''" @click="tabChange(2)">历史动态</view>
  6. </view>
  7. <view style="height: 120rpx;"></view>
  8. <view class="log">
  9. <view v-if="logsList && logsList.length > 0" v-for="(it, index) in logsList" :key="index">
  10. <view class="time-year" v-if="todayYear!=it.year && index==0 || (index!=0 && (it.year!=logsList[index-1].year))">{{ it.year }}年</view>
  11. <view class="dflex">
  12. <view class="time-sort">
  13. <block v-if="index==0 || (index!=0 && (it.day!=logsList[index-1].day||it.month!=logsList[index-1].month||it.year!=logsList[index-1].year))">
  14. <text v-if="todayYear==it.year&&todayMonth==it.month&&todayDay==it.day">今日</text>
  15. <block v-else>
  16. <text>{{it.day}}</text>{{ it.month }}月
  17. </block>
  18. </block>
  19. </view>
  20. <view class="li fflex">
  21. <image src="/mine/static/images/jcico.png" class="jcico"></image>
  22. <view class="time">{{ it.time }}</view>
  23. <!-- <view class="des" v-if="it.brief">{{ it.brief }}</view> -->
  24. <rich-text class="des" :nodes="it.content"></rich-text>
  25. </view>
  26. </view>
  27. </view>
  28. <view v-if="!logsList || logsList.length == 0" class="nodata">
  29. <image src="/mine/static/images/empty.png" mode="aspectFill"></image>
  30. <view>暂无记录~</view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. const app = getApp();
  37. const req = require("../../utils/request.js");
  38. export default {
  39. components: {},
  40. props: {},
  41. data() {
  42. return {
  43. id:'',
  44. tabIndex:1,
  45. isLoad: true,
  46. form: {
  47. page: 1,
  48. limit: 10
  49. },
  50. logsList:[{
  51. createDate:'2023-03-04',
  52. brief:'阅读了《3·15|手把手教你读懂“食品标签”,拒绝被“坑”》',
  53. logsContent:'sss',
  54. year:"2022",
  55. month:"10",
  56. day:'30',
  57. time:'12:00'
  58. },{
  59. createDate:'2023-03-04',
  60. brief:'阅读了《3·15|手把手教你读懂“食品标签”,拒绝被“坑”》',
  61. logsContent:'sss',
  62. year:"2023",
  63. month:"4",
  64. day:'30',
  65. time:'12:00'
  66. },{
  67. createDate:'2023-03-04',
  68. brief:'浏览了中医馆私域解决方案',
  69. logsContent:'sss',
  70. year:"2023",
  71. month:"3",
  72. day:'04',
  73. time:'12:00'
  74. },{
  75. createDate:'2023-03-04',
  76. brief:'填写了表单《英才少儿教育精品VIP课程试听报名》',
  77. logsContent:'sss',
  78. year:"2023",
  79. month:"3",
  80. day:'03',
  81. time:'12:00'
  82. },{
  83. createDate:'2023-03-04',
  84. brief:'浏览了中医馆私域解决方案',
  85. logsContent:'sss',
  86. year:"2023",
  87. month:"3",
  88. day:'03',
  89. time:'12:00'
  90. },{
  91. createDate:'2023-03-04',
  92. brief:'填写了表单《英才少儿教育精品VIP课程试听报名》',
  93. logsContent:'sss',
  94. year:"2023",
  95. month:"2",
  96. day:'04',
  97. time:'12:00'
  98. },{
  99. createDate:'2023-03-04',
  100. brief:'浏览了中医馆私域解决方案',
  101. logsContent:'sss',
  102. year:"2022",
  103. month:"2",
  104. day:'04',
  105. time:'12:00'
  106. },{
  107. createDate:'2023-03-04',
  108. brief:'填写了表单《英才少儿教育精品VIP课程试听报名》',
  109. logsContent:'sss',
  110. year:"2022",
  111. month:"2",
  112. day:'03',
  113. time:'12:00'
  114. }],
  115. todayYear:'',
  116. todayMonth:'',
  117. todayDay:''
  118. }
  119. },
  120. onLoad(options) {
  121. this.id = options.id
  122. this.todayYear = new Date().getFullYear()
  123. this.todayMonth = new Date().getMonth() + 1
  124. this.todayDay = new Date().getDate()
  125. this.getPageList()
  126. },
  127. onShow() {
  128. },
  129. onReachBottom: function() {
  130. this.form.page++;
  131. this.getPageList(false);
  132. },
  133. methods: {
  134. tabChange(index){
  135. if(this.tabIndex==index) return false
  136. this.tabIndex = index
  137. this.form.page = 1
  138. this.isLoad = true;
  139. this.getPageList(true)
  140. },
  141. getPageList(isShow) {
  142. if (!this.isLoad) return false;
  143. this.isLoad = false;
  144. let form = this.form;
  145. form.uid = this.id
  146. if(this.tabIndex==1) form.today = 1
  147. else form.today = ''
  148. uni.showLoading();
  149. req.getRequest(
  150. '/api/user/getUserTrends',
  151. form,
  152. res => {
  153. res = res?res.list:[]
  154. if(res&&res.length>0){
  155. res.map(item=>{
  156. let t = this.getDate(item.createDate)
  157. item.year = t.year
  158. item.month = t.month
  159. item.day = t.day
  160. item.time = t.hour+':'+t.minute
  161. })
  162. }
  163. this.isShow = true;
  164. if (res && res.length == 10) {
  165. this.isLoad = true;
  166. }
  167. if (this.form.page > 1) {
  168. res = this.logsList.concat(res);
  169. }else{
  170. this.goTop()
  171. }
  172. this.logsList = res;
  173. uni.hideLoading();
  174. },
  175. isShow
  176. );
  177. },
  178. getDate(dateStr){
  179. if(!dateStr) return false
  180. let date = new Date(dateStr)
  181. const year = date.getFullYear();
  182. const month = date.getMonth() + 1;
  183. const day = date.getDate();
  184. const hour = date.getHours();
  185. const minute = date.getMinutes();
  186. const second = date.getSeconds();
  187. return {
  188. year:year,
  189. month:month,
  190. day:day,
  191. hour:hour,
  192. minute:minute,
  193. second:second,
  194. }
  195. },
  196. goTop(e) {
  197. // 一键回到顶部
  198. if (uni.pageScrollTo) {
  199. uni.pageScrollTo({
  200. scrollTop: 0,
  201. duration:100
  202. });
  203. }
  204. }
  205. },
  206. mounted() {
  207. },
  208. }
  209. </script>
  210. <style>
  211. @import "./clientDynamic.css";
  212. </style>