抖音c端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

134 řádky
3.6 KiB

  1. const util = require("../../utils/util");
  2. Component({
  3. /**
  4. * 组件的属性列表 util.toHHmmss(res.data.endTime,);
  5. */
  6. properties: {
  7. special:{
  8. type: Boolean,
  9. value: false
  10. },
  11. titleImgUrl:{
  12. type:String,
  13. value:"",
  14. },
  15. isShowCount:{
  16. type: Boolean,
  17. value: false
  18. },
  19. obj:{
  20. type:Object,
  21. value:{}
  22. }
  23. },
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. setIntervalLsit:[]
  29. },
  30. attached: function () {
  31. let this_ =this
  32. let arr = []
  33. let tempLsit = []
  34. // 处理首页定时
  35. if (this_.properties.obj.couponList!=null&&this_.properties.obj.couponList.length>0){
  36. //限时抢购 倒计时
  37. this_.properties.obj.couponList.map((item,index)=>{//初次渲染
  38. if (item.targetAd==2){
  39. let tempObj = {}
  40. let beginTime = item.beginTime;//开始时间
  41. let endTime = item.endTime;//结束时间
  42. let present = new Date().getTime()//当前时间
  43. let textTime = item.beginTime >= present?"距开始":"距结束"
  44. tempObj={
  45. value: item.beginTime >= present ? beginTime - present : endTime - present,
  46. valueText: item.beginTime >= present ? util.toHHmmss(beginTime - present) : util.toHHmmss(endTime - present),
  47. // vaFlag: tempObj.value<=0?true:false,//活动是否结束
  48. index:index,
  49. interval:"" ,
  50. beginTime: beginTime,//开始时间
  51. endTime: endTime,//开始时间
  52. textTime: textTime
  53. }
  54. arr.push(tempObj)
  55. this_.setData({
  56. setIntervalLsit: arr
  57. })
  58. }
  59. })
  60. }
  61. tempLsit =this_.data.setIntervalLsit
  62. tempLsit.map((item,index)=>{//再次渲染
  63. item.interval = setInterval(function(){
  64. let present = new Date().getTime()//当前时间
  65. if(item.value<=1){
  66. clearInterval(item.interval)
  67. item.vaFlag = true,//活动是否结束
  68. console.log(item.value, "活动已经结束")
  69. }else{
  70. let tempTime = item.beginTime >= present ? item.beginTime - present : item.endTime - present
  71. // console.log(tempTime, "presents")
  72. item.value = tempTime,
  73. item.valueText = util.toHHmmss(tempTime - 1000)
  74. item.textTime = item.beginTime >= present ? "距开始" : "距结束",
  75. item.vaFlag= item.value <= 0 ? true : false,//活动是否结束
  76. this_.setData({
  77. setIntervalLsit: tempLsit
  78. })
  79. }
  80. },1000)
  81. })
  82. // 处理首页定时
  83. },
  84. detached: function () {
  85. this.data.setIntervalLsit.map(item=>{
  86. clearInterval(item.interval)
  87. })
  88. console.log("88888")
  89. // 在组件实例被从页面节点树移除时执行 ;
  90. },
  91. /**
  92. * 组件的方法列表
  93. */
  94. methods: {
  95. lookAll(){
  96. tt.navigateTo({
  97. url: `/${this.properties.obj.weappPath}`,
  98. })
  99. },
  100. goDetail(e){
  101. console.log(e.currentTarget.dataset)
  102. let couponChannelId = e.currentTarget.dataset.id
  103. let couponId = e.currentTarget.dataset.couponid
  104. let type = e.currentTarget.dataset.type
  105. if (type==9){
  106. tt.navigateTo({
  107. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${couponChannelId}&couponId=${couponId}`,
  108. })
  109. }else{
  110. tt.navigateTo({
  111. url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`,
  112. })
  113. }
  114. },
  115. gotoTopic(e) {
  116. let id = e.currentTarget.dataset.id
  117. tt.navigateTo({
  118. url: `/pages/topicDetail/index?id=${id}`
  119. })
  120. },
  121. }
  122. })