detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="detail">
  3. <div class="detail-body">
  4. <!-- <div class="img-text">
  5. <img :src="activityDetail.annexArray[0]" alt="" />
  6. </div> -->
  7. <div class="collect-part">
  8. <div class="normal-tip by y-bg" v-if="activityDetail.registrationStatus === '1'">
  9. 报名中
  10. </div>
  11. <div class="normal-tip by h-bg" v-else>报名已结束</div>
  12. <div class="right">
  13. <span class="num">{{ !activityDetail.partakeNumber ? 0 : activityDetail.partakeNumber }}人参与</span>
  14. <div class="icon-collect" @click="changeCollectorsStatus()">
  15. <i :class="[
  16. 'iconfont icon-wujiaoxingxingxingshoucangdianji',
  17. active && 'blue',
  18. ]"></i>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="tel-part">
  23. <div class="tel-name">联系电话</div>
  24. <TelNum :num="activityDetail.contactPhone" />
  25. </div>
  26. <div class="info-part">
  27. <div class="info-item">
  28. <div class="custom-item-tit">
  29. <span class="tit">活动名称</span>
  30. </div>
  31. <div class="text">{{ activityDetail.activityName }}</div>
  32. </div>
  33. <div class="info-item">
  34. <div class="custom-item-tit">
  35. <span class="tit">活动举办</span>
  36. </div>
  37. <div class="text">{{ activityDetail.activityHold }}</div>
  38. </div>
  39. <div class="info-item">
  40. <div class="custom-item-tit"><span class="tit">活动详情</span></div>
  41. <rich-text class="text" :nodes="activityDetail.activityContent"></rich-text>
  42. <img v-for="item in imageList" :src="item" alt="" style=" max-width: 100%;">
  43. <!-- <image style="max-width:100%;" src="https://hswkxc.idea-sf.com/gardenTestApi/FileController/download/1402691710487625728">-->
  44. <!-- <image style="width:120rpx;height:120rpx;" src="https://hswkxc.idea-sf.com/gardenTestApi/FileController/download/1403409204810612736"></image>-->
  45. </div>
  46. <div class="info-item">
  47. <div class="custom-item-tit"><span class="tit">活动时间</span></div>
  48. <div class="text">
  49. {{ activityDetail.activityStartTime }} —
  50. {{ activityDetail.activityEndTime }}
  51. </div>
  52. </div>
  53. <div class="info-item">
  54. <div class="custom-item-tit"><span class="tit">活动地址</span></div>
  55. <div class="text">
  56. <span class="add">{{ activityDetail.activityAddress }}</span>
  57. <!-- <span class="dh" @click="goAddress(activityDetail.activityAddress)">导航</span>-->
  58. </div>
  59. </div>
  60. <!-- <div class="info-item">-->
  61. <!-- <div class="custom-item-tit"><span class="tit">报名条件</span></div>-->
  62. <!-- <div class="text">{{ activityDetail.registrationConditions }}</div>-->
  63. <!-- </div>-->
  64. <div class="info-item">
  65. <div class="custom-item-tit"><span class="tit">报名时间</span></div>
  66. <div class="text">
  67. {{ activityDetail.registrationStartTime }} —
  68. {{ activityDetail.registrationEndTime }}
  69. </div>
  70. </div>
  71. <div class="info-item">
  72. <div class="custom-item-tit"><span class="tit">活动参与</span></div>
  73. <div class="text">还有 {{ number }} 个名额</div>
  74. </div>
  75. <div class="info-item uploadBox">
  76. <div class="custom-item-tit"><span class="tit">附件查看</span></div>
  77. <div class="text" style="16rpx 0px">
  78. <div v-for="item in activityDetail.activityFile" :key="item.uid" @click="openFile(item.url)">
  79. {{ item.name }}
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="but-bottom" @click="getApply()" :signInfo="signInfo" v-if="signInfo.signInStatus == 1">
  86. 到场签到
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import TelNum from "../../subPackages/components/tel-number";
  92. import {
  93. getActivityById1,
  94. clickCollect,
  95. getUserLocalStorageInfo,
  96. } from "@/js_sdk/http";
  97. export default {
  98. components: {
  99. TelNum,
  100. },
  101. data() {
  102. return {
  103. signInfo: {},
  104. signInCode: "",
  105. active: false,
  106. id: "",
  107. activityDetail: {
  108. referenceId: "",
  109. },
  110. number: 0,
  111. imageList: []
  112. };
  113. },
  114. onLoad(option) {
  115. // this.getScanCode();
  116. console.log("option", option.id);
  117. console.log(getUserLocalStorageInfo().user.id)
  118. this.id = option.id;
  119. this.getActivityById1();
  120. },
  121. methods: {
  122. openFile(url) {
  123. uni.downloadFile({
  124. url: url, // 网络文档地址
  125. success: (data) => {
  126. if (data.statusCode === 200) {
  127. uni.saveFile({
  128. tempFilePath: data.tempFilePath, //临时路径
  129. success: function (res) {
  130. // 保存路径
  131. console.log(res);
  132. uni.openDocument({
  133. showMenu: true,
  134. filePath: res.savedFilePath,
  135. success: function (res) {
  136. console.log("res", res);
  137. },
  138. fail: function (error) {
  139. console.log(error);
  140. wx.previewImage({
  141. current: "", // 当前显示图片的http链接
  142. urls: [url], // 需要预览的图片http链接列表
  143. });
  144. },
  145. });
  146. },
  147. });
  148. }
  149. },
  150. fail: (err) => {
  151. uni.showToast({
  152. title: "失败请重新下载",
  153. });
  154. },
  155. });
  156. },
  157. extractImagePathsFromString(str) {
  158. const regex = /<img[^>]+src="([^">]+)"/g;
  159. const paths = [];
  160. let match;
  161. while ((match = regex.exec(str)) !== null) {
  162. paths.push(match[1]);
  163. }
  164. return paths;
  165. },
  166. getActivityById1() {
  167. const _this = this;
  168. getActivityById1(this.id, "SCNjNSP7LJ9aarv1cNw", getUserLocalStorageInfo().user.id).then((res) => {
  169. if (res.data) {
  170. if (res.data.activityFile) {
  171. const files = JSON.parse(res.data.activityFile);
  172. if (files && files.length) {
  173. _this.fileList2 = _this.fileList2 ? _this.fileList2 : [];
  174. files.forEach((item) => {
  175. console.log("_this.fileList2", _this.fileList2);
  176. console.log(item);
  177. _this.fileList2.push({
  178. url: item.url,
  179. id: item.id,
  180. });
  181. });
  182. }
  183. }
  184. _this.activityDetail = res.data;
  185. _this.activityDetail.activityFile = JSON.parse(res.data.activityFile);
  186. console.log(
  187. "_this.activityDetail.activityFile",
  188. _this.activityDetail.activityFile
  189. );
  190. // let activityContent=
  191. // res.data.activityContent.replaceAll(
  192. // "<img",
  193. // `<image style="width:120rpx;height:120rpx;"`
  194. // );
  195. // activityContent=activityContent.replaceAll(
  196. // "</figure>",
  197. // `</image></figure>`
  198. // );
  199. console.log()
  200. this.imageList = this.extractImagePathsFromString(_this.activityDetail.activityContent)
  201. _this.activityDetail.activityContent = res.data.activityContent.replaceAll(
  202. "<img",
  203. `<img style="width:120rpx;height:120rpx;"`
  204. );
  205. // </figure>
  206. console.log("registrationStatus", res.data.registrationStatus);
  207. if (
  208. _this.activityDetail.annexArray &&
  209. _this.activityDetail.annexArray.length
  210. ) {
  211. console.log(
  212. "_this.activityDetail.annexArray[0]",
  213. _this.activityDetail.annexArray[0]
  214. );
  215. _this.firstImg = _this.activityDetail.annexArray[0];
  216. }
  217. _this.activityDetail.registrationStartTime =
  218. this.$common.transBaseDateTime(
  219. _this.activityDetail.registrationStartTime
  220. );
  221. _this.activityDetail.registrationEndTime =
  222. this.$common.transBaseToDateTime(
  223. _this.activityDetail.registrationEndTime
  224. );
  225. _this.activityDetail.activityStartTime =
  226. this.$common.transBaseDateTime(
  227. _this.activityDetail.activityStartTime
  228. );
  229. _this.activityDetail.activityEndTime =
  230. this.$common.transBaseToDateTime(
  231. _this.activityDetail.activityEndTime
  232. );
  233. if (_this.activityDetail.collectorsStatus === "2") {
  234. _this.active = true;
  235. } else {
  236. _this.active = false;
  237. }
  238. _this.number =
  239. _this.activityDetail.limitPersonNumber -
  240. _this.activityDetail.partakeNumber;
  241. }
  242. });
  243. },
  244. getApply() {
  245. this.$refs.apply.init(this.signInfo);
  246. },
  247. goAddress(address) {
  248. if (address === null || undefined === address || address === "") {
  249. this.$showToast("地址不能为空");
  250. return false;
  251. } else {
  252. this.navigation(address);
  253. }
  254. },
  255. changeCollectorsStatus() {
  256. if (this.active) {
  257. const _this = this;
  258. clickCollect({
  259. id: this.id,
  260. userId: getUserLocalStorageInfo().user.id,
  261. collectorsStatus: "1",
  262. }).then((res) => {
  263. _this.getActivityById1();
  264. });
  265. } else {
  266. const _this = this;
  267. clickCollect({
  268. id: this.id,
  269. userId: getUserLocalStorageInfo().user.id,
  270. collectorsStatus: "2",
  271. }).then((res) => {
  272. _this.getActivityById1();
  273. });
  274. }
  275. },
  276. },
  277. };
  278. </script>
  279. <style lang="scss" type="text/scss">
  280. .h-bg {
  281. background: #f87a7a;
  282. color: #fff;
  283. }
  284. // 底部按钮
  285. .but-bottom {
  286. position: fixed;
  287. bottom: 0;
  288. left: 0;
  289. // width: 100%;
  290. line-height: 120rpx;
  291. background: $main;
  292. color: #fff;
  293. font-size: 36rpx;
  294. text-align: center;
  295. }
  296. .text {
  297. font-size: 24rpx;
  298. color: $text5;
  299. margin-top: 32rpx;
  300. }
  301. .detail {
  302. box-sizing: border-box;
  303. background-color: #f2f2f2;
  304. padding: 0 0 140rpx;
  305. overflow-y: auto;
  306. .detail-body {
  307. .img-text {
  308. img {
  309. height: 420rpx;
  310. width: 100%;
  311. }
  312. }
  313. .collect-part {
  314. background-color: #fff;
  315. height: 120rpx;
  316. padding: 0 30rpx;
  317. margin-bottom: 10rpx;
  318. @include flex;
  319. .normal-tip {}
  320. .right {
  321. @include flex;
  322. .num {
  323. margin-right: 20rpx;
  324. font-size: 24rpx;
  325. color: #333333;
  326. }
  327. }
  328. }
  329. .tel-part {
  330. display: flex;
  331. width: 100%;
  332. background-color: #fff;
  333. margin-bottom: 10rpx;
  334. padding: 0 30rpx;
  335. align-items: center;
  336. box-sizing: border-box;
  337. justify-content: space-between;
  338. .tel-name {
  339. color: #333;
  340. font-size: 32rpx;
  341. font-weight: 700;
  342. }
  343. .custom-tel-component {
  344. width: 400rpx;
  345. .left {
  346. font-size: 26rpx;
  347. }
  348. }
  349. }
  350. }
  351. .info-part {
  352. background-color: #fff;
  353. overflow-y: auto;
  354. height: 100vh;
  355. box-sizing: border-box;
  356. padding: 40rpx 30rpx;
  357. .tit {
  358. padding-left: 2.667vw;
  359. position: relative;
  360. font-size: 4.267vw;
  361. &::after {
  362. content: "";
  363. width: 0.8vw;
  364. height: 90%;
  365. background-color: #976dec;
  366. border-radius: 0.4vw;
  367. position: absolute;
  368. left: 0;
  369. top: 50%;
  370. -webkit-transform: translateY(-50%);
  371. transform: translateY(-50%);
  372. }
  373. }
  374. .info-item {
  375. padding: 10rpx 0rpx;
  376. margin-bottom: 20rpx;
  377. .custom-item-tit {
  378. font-size: 32rpx;
  379. font-weight: 700;
  380. }
  381. .text {
  382. font-size: 24rpx;
  383. color: $text5;
  384. margin-top: 32rpx;
  385. .add {
  386. margin-right: 40rpx;
  387. }
  388. .dh {
  389. width: 100rpx;
  390. text-align: center;
  391. display: inline-block;
  392. color: $main;
  393. border-left: 1rpx solid #666666;
  394. }
  395. }
  396. &:last-child {
  397. margin-bottom: 0rpx;
  398. }
  399. }
  400. }
  401. }
  402. </style>
  403. <style lang="scss"></style>