guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="activeDetails"> |
| 3 | <!-- #ifndef H5 --> |
| 4 | <view class="bgColor"></view> |
| 5 | <!-- #endif --> |
| 6 | <view v-if="!show"> |
| 7 | <view class="activeDetails-title"> |
| 8 | <text class="activeDetails-title-title">{{article.title}}</text> |
| 9 | <view class="activeDetails-title-author"> |
| 10 | <text class="activeDetails-title-author-author">{{article.author}}</text> |
| 11 | <text class="activeDetails-title-author-date">{{creatime}}</text> |
| 12 | <view></view> |
| 13 | <view class="activeDetails-title-author-watch"> |
| 14 | <u-icon name="eye" color="#9A9A9A" size="28"></u-icon> |
| 15 | <text>{{article.hits}}</text> |
| 16 | </view> |
| 17 | </view> |
| 18 | </view> |
| 19 | <view class="richText"> |
| 20 | <u-parse :html="article.content" :lazy-load="true"></u-parse> |
| 21 | </view> |
guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 22 | <!-- <u-button :custom-style="activeDetailsBtn" @click="join" v-if="isShowBtn">报名</u-button> --> |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 23 | </view> |
| 24 | <u-empty text="活动不存在" mode="page" font-size="40" :show="show" margin-top="300"></u-empty> |
| 25 | </view> |
| 26 | </template> |
| 27 | |
| 28 | <script> |
| 29 | export default { |
| 30 | data() { |
| 31 | return { |
| 32 | article: {}, |
| 33 | creatime: "", |
| 34 | activeDetailsBtn: { |
| 35 | width: "650rpx", |
| 36 | backgroundColor: "#30A8E1", |
| 37 | color: " #FFFFFF", |
| 38 | padding: "50rpx 0 ", |
| 39 | position: "fixed", |
| 40 | bottom: "30rpx", |
| 41 | left: "50%", |
| 42 | transform: "translateX(-50%)", |
| 43 | isShowBtn:false |
| 44 | }, |
| 45 | show: true |
| 46 | } |
| 47 | }, |
| 48 | methods: { |
| 49 | join(){ |
| 50 | uni.showToast({ |
| 51 | title:"此活动暂时无法报名", |
| 52 | icon:"none", |
| 53 | duration:1500 |
| 54 | }) |
| 55 | }, |
| 56 | getArticle(id) { |
| 57 | let that = this |
| 58 | that.$u.post("/i/activity/" + id).then(res => { |
| 59 | that.show = false |
| 60 | that.article = res.data |
| 61 | //修改发布时间 |
| 62 | let time = new Date(res.data.createtime.substr(0, 19)) |
| 63 | //console.log(time) |
| 64 | let year = time.getFullYear() |
| 65 | let month = (time.getMonth() + 1 )> 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1 ) |
| 66 | let date = time.getDay() |
| 67 | let hour = time.getHours() >10 ? time.getHours() : '0' + time.getHours() |
| 68 | let min = time.getMinutes() >10 ? time.getMinutes() : '0' + time.getMinutes() |
| 69 | let sec = time.getSeconds() >10 ? time.getSeconds() : '0' + time.getSeconds() |
| 70 | if (Number(date) < 10) { |
| 71 | date = "0" + date |
| 72 | } |
| 73 | let newtime = year + '-' + month + '-' + date + ' ' + hour + ':' + min + ':' + sec |
| 74 | let now = Number(new Date().getTime()) |
| 75 | let old = Number(new Date(res.data.createtime.substr(0, 19)).getTime()) |
| 76 | let minus = Math.floor((now - old) / (60 * 60 * 1000)) |
| 77 | //console.log(minus) |
| 78 | if (minus > 24) { |
| 79 | that.creatime = newtime |
| 80 | } else if(minus == 0){ |
| 81 | that.creatime = "刚刚" |
| 82 | } else { |
| 83 | that.creatime = minus + "小时前" |
| 84 | } |
| 85 | //修改富文本图片样式 |
| 86 | // const regex = new RegExp('<img', 'gi'); |
| 87 | // res.data.content = res.data.content.replace(regex, `<img style=""`) |
| 88 | }).catch(res=>{ |
| 89 | that.show = true |
| 90 | }) |
| 91 | } |
| 92 | }, |
| 93 | onLoad(option) { |
| 94 | // console.log(option.id) |
| 95 | let type = option.type |
| 96 | if(type == 'OnlineActivities'){ |
| 97 | this.isShowBtn = true |
| 98 | }else{ |
| 99 | this.isShowBtn = false |
| 100 | } |
| 101 | this.getArticle(option.id) |
| 102 | } |
| 103 | } |
| 104 | </script> |
| 105 | |
| 106 | <style lang="scss" scoped> |
| 107 | .richText { |
| 108 | padding: 20rpx 20rpx 150rpx; |
| 109 | text-align: justify; |
| 110 | } |
| 111 | page{ |
| 112 | background-color: #FFFFFF; |
| 113 | } |
| 114 | /* #ifndef H5 */ |
| 115 | .bgColor { |
| 116 | position: fixed; |
| 117 | top: 0; |
| 118 | left: 0; |
| 119 | right: 0; |
| 120 | bottom: 0; |
| 121 | background: #FFFFFF; |
| 122 | z-index: -1; |
| 123 | } |
| 124 | /* #endif */ |
| 125 | |
| 126 | |
| 127 | .activeDetails { |
| 128 | font-family: "PingFang-SC-Medium"; |
| 129 | overflow: hidden; |
| 130 | background-color: #FFFFFF; |
| 131 | |
| 132 | &-btn { |
| 133 | width: 650rpx; |
| 134 | background-color: #30A8E1; |
| 135 | color: #FFFFFF; |
| 136 | padding: 50rpx 0; |
| 137 | position: fixed; |
| 138 | bottom: 30rpx; |
| 139 | left: 50%; |
| 140 | transform: translateX(-50%); |
| 141 | } |
| 142 | |
| 143 | &-title { |
| 144 | display: flex; |
| 145 | flex-direction: column; |
| 146 | padding: 20rpx; |
| 147 | background-color: #FFFFFF; |
| 148 | |
| 149 | &-title { |
| 150 | color: #343434; |
| 151 | font-size: 30rpx; |
| 152 | } |
| 153 | |
| 154 | &-author { |
| 155 | color: #9A9A9A; |
| 156 | font-size: 25rpx; |
| 157 | display: flex; |
| 158 | justify-content: space-between; |
| 159 | margin-top: 10rpx; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | &-condition { |
| 164 | background-color: #FFFFFF; |
| 165 | padding: 20rpx; |
| 166 | |
| 167 | &-con { |
| 168 | &-con { |
| 169 | color: #666666; |
| 170 | font-size: 28rpx; |
| 171 | } |
| 172 | |
| 173 | &-title { |
| 174 | color: #333333; |
| 175 | font-size: 28rpx; |
| 176 | margin-right: 10rpx; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | &-lay { |
| 181 | display: flex; |
| 182 | color: #666666; |
| 183 | |
| 184 | &-con { |
| 185 | display: flex; |
| 186 | flex-direction: column; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | &-introduce { |
| 192 | background-color: #FFFFFF; |
| 193 | display: flex; |
| 194 | font-size: 28rpx; |
| 195 | flex-direction: column; |
| 196 | padding: 0 20rpx 150rpx; |
| 197 | |
| 198 | &-title { |
| 199 | color: #333333; |
| 200 | margin: 30rpx 0; |
| 201 | } |
| 202 | |
| 203 | &-con { |
| 204 | color: #666666; |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | </style> |