active.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="active-box">
  3. <image class="poster" :src="model.url"></image>
  4. <view class="title">{{model.title}}</view>
  5. <view class="content">
  6. <view class="child border-bottom-1">
  7. <image class="time" src="/static/taxation/clock-icon.svg"></image>
  8. <text>{{model.time}}</text>
  9. </view>
  10. <view class="child">
  11. <image class="address" src="/static/taxation/address-icon.svg"></image>
  12. <text>{{model.address}}</text>
  13. </view>
  14. </view>
  15. <view class="detail border-bottom-1">活动详情</view>
  16. <view class="rich-box">
  17. {{model.richText}}
  18. <activityRichCard :model="model.rich" :isFold="true" />
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import md5 from "@/common/md5.js";
  24. import activity_rich_card from "./rich_card.vue";
  25. export default {
  26. filters: {
  27. formDateTime(value) {
  28. if (value) {
  29. const time = new Date(value * 1000);
  30. const y = time.getFullYear();
  31. const m =
  32. time.getMonth() + 1 < 10
  33. ? "0" + (time.getMonth() + 1)
  34. : time.getMonth() + 1;
  35. const d = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();
  36. // const h = time.getHours()
  37. // const mm = time.getMinutes();
  38. // const s = time.getSeconds();
  39. return y + "." + m + "." + d;
  40. } else {
  41. return "";
  42. }
  43. },
  44. formDateTimeSecond(value) {
  45. if (value) {
  46. const time = new Date(value * 1000);
  47. // const y = time.getFullYear();
  48. // const m = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
  49. // const d = time.getDate() < 10 ? '0' + time.getDate(): time.getDate();
  50. const h =
  51. time.getHours() < 10 ? "0" + time.getHours() : time.getHours();
  52. const mm =
  53. time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes();
  54. return h + ":" + mm;
  55. } else {
  56. return "";
  57. }
  58. },
  59. },
  60. components: {
  61. activityRichCard: activity_rich_card,
  62. },
  63. data() {
  64. return {
  65. id: "",
  66. model: {
  67. url: "/static/taxation/active-example.png",
  68. title: "8月供需对接会",
  69. time: '2023-09-13 09:00 至 17:00',
  70. address:'四信大厦5楼会议大厅',
  71. detail:'',
  72. richText:'7月27-29日,“2021机器人与智能制造强国论坛暨第一届数字化智造博览会”在山东济宁隆重召开。此次活动由山东省工业和信息化厅、济宁市人民政府、中国电子信息产业发展研究院共同主办,包括主论坛、两场高峰论坛、供需对接交流会、第一届数字化智造博览会,以及第二十届全国大学生机器人大赛等多项内容。其中,第一届数字化智造博览会在济宁高新区展览馆启幕。整个展区占地面积7000平方米,来自全国各地的118家智能制造企业,以需求为导向,携高端制造装备产品亮相博览会.'
  73. },
  74. };
  75. },
  76. onLoad(op) {
  77. // this.id = op.id;
  78. },
  79. methods: {
  80. getActivityDeatil() {
  81. let md5Sign = md5(
  82. "method=" +
  83. "activity" +
  84. "&timestamp=" +
  85. getApp().globalData.globalTimestamp +
  86. "&secret=" +
  87. getApp().globalData.secret
  88. );
  89. let url =
  90. getApp().globalData.shareUrl +
  91. "api/api.php" +
  92. "?method=activity&source=activity&action=info_by_id&timestamp=" +
  93. getApp().globalData.globalTimestamp +
  94. "&sign=" +
  95. md5Sign;
  96. let postData = {
  97. id: this.id,
  98. openId: getApp().globalData.open_id,
  99. };
  100. //获取文章
  101. uni.request({
  102. url: url,
  103. method: "POST",
  104. header: {
  105. "content-type": "application/x-www-form-urlencoded",
  106. },
  107. data: postData,
  108. success: (res) => {
  109. if (res.data.code == 200) {
  110. let data = res.data.data;
  111. this.isJoin = data.active ? true : false;
  112. if(data.category_list && data.category_list.length > 0){
  113. this.activityInfoList = data.category_list;
  114. this.activityInfoList.forEach((item)=>{
  115. if(item.name === '性别'){
  116. item.value = '男'
  117. }else {
  118. item.value = '';
  119. }
  120. })
  121. }
  122. this.model.title = data.name;
  123. this.model.read = parseInt(data.base_read_count) + parseInt(data.real_read_count);
  124. this.model.url = getApp().globalData.shareUrl + data.pic_url;
  125. let arr = ["start_time", "end_time"];
  126. let ans = [];
  127. for (const item of arr) {
  128. let time = this.$options.filters["formDateTime"](data[item]);
  129. let timeSecond = this.$options.filters["formDateTimeSecond"](data[item]);
  130. ans.push(time + " " + timeSecond);
  131. }
  132. this.model.date = ans.join(" - ");
  133. this.model.type = data.type;
  134. this.model.status = data.status;
  135. this.model.way = data.sponsor;
  136. this.model.max_person = data.max_person;
  137. this.model.person_count = data.person_count;
  138. this.model.share = parseInt(data.real_repost_count) + parseInt(data.base_repost_count);
  139. if (data.status == '待开始') {
  140. if (data.type == 2) {
  141. this.model.activiteState = "我要参加";
  142. } else {
  143. this.model.activiteState = "活动待开始";
  144. }
  145. } else if (data.status == '已开始') {
  146. this.model.activiteState = "活动进行中";
  147. } else {
  148. this.model.activiteState = "活动已结束";
  149. }
  150. }
  151. this.getRich();
  152. },
  153. fail: () => {
  154. console.log("连接失败");
  155. },
  156. });
  157. },
  158. replaceImg(html) {
  159. let result = html.replace(
  160. /<img [^>]*src=['"]([^'"]+)[^>]*>/gi,
  161. function (match, capture) {
  162. if(capture.includes('http')){
  163. return (
  164. "<img src=" +
  165. capture +
  166. ' style="max-width:100%;height:auto;display:block;margin:10px auto;"/>'
  167. );
  168. }else {
  169. return (
  170. "<img src=" +
  171. getApp().globalData.shareUrl +
  172. capture +
  173. ' style="max-width:100%;height:auto;display:block;margin:10px auto;"/>'
  174. );
  175. }
  176. }
  177. );
  178. return result;
  179. },
  180. getRich() {
  181. uni.request({
  182. url:
  183. getApp().globalData.shareUrl +
  184. `content/activity/${Math.floor(this.id / 1000)}/${this.id}.html`+'?version='+ Math.random(),
  185. method: "GET",
  186. header: {
  187. "content-type": "application/x-www-form-urlencoded",
  188. },
  189. success: (res) => {
  190. if (res.statusCode === 200) {
  191. this.textModel.text = this.replaceImg(res.data);
  192. }
  193. },
  194. fail: () => {
  195. console.log("连接失败");
  196. },
  197. });
  198. }
  199. },
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .active-box {
  204. display: flex;
  205. flex-direction: column;
  206. .poster {
  207. width: 99%;
  208. height: 500rpx;
  209. margin-left: 0.5%;
  210. }
  211. .title {
  212. font-size: 40rpx;
  213. padding-left: 40rpx;
  214. width: 100%;
  215. height: 120rpx;
  216. display: flex;
  217. align-items: center;
  218. }
  219. .content {
  220. display: flex;
  221. flex-direction: column;
  222. width: 100%;
  223. height: 196rpx;
  224. border-top: 8px solid #f3f3f3;
  225. border-bottom: 8px solid #f3f3f3;
  226. .child {
  227. display: flex;
  228. align-items: center;
  229. height: 50%;
  230. text {
  231. color: #999;
  232. }
  233. .time {
  234. width: 40rpx;
  235. height: 40rpx;
  236. margin: 0 30rpx 0 40rpx;
  237. }
  238. .address {
  239. width: 40rpx;
  240. height: 50rpx;
  241. margin: 0 30rpx 0 40rpx;
  242. }
  243. }
  244. }
  245. .detail {
  246. font-size: 32rpx;
  247. padding-left: 40rpx;
  248. width: 100%;
  249. height: 100rpx;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .rich-box {
  254. color: #666;
  255. padding: 30rpx 40rpx 30rpx 40rpx;
  256. font-size: 30rpx;
  257. }
  258. }
  259. .border-bottom-1 {
  260. border-bottom: 1px solid #e0e0e0;
  261. }
  262. </style>