viewDetail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <view class="title-read">
  5. <view class="title">
  6. <view>{{ areaObj.name }}</view>
  7. <view>整体参观</view>
  8. </view>
  9. <button :class="{
  10. close: areaObj.order_status == '未开放',
  11. free: areaObj.order_status == '空闲',
  12. full: areaObj.order_status == '今日已满',
  13. can: areaObj.order_status == '今日可约',}">
  14. {{areaObj.order_status}}</button>
  15. </view>
  16. </view>
  17. <view class="active-deatil">
  18. <ul>
  19. <li>
  20. <p class="name">开放时间</p>
  21. <p class="deatil-content">{{areaObj.open_days}}:{{areaObj.open_hours}}</p>
  22. </li>
  23. <li style="margin-bottom: 0;">
  24. <p class="name">容纳人数</p>
  25. <p class="deatil-content">{{areaObj.max}}</p>
  26. </li>
  27. </ul>
  28. </view>
  29. <view class="rich">
  30. <activityRichCard :model="textModel" :isFold="true" />
  31. </view>
  32. <view class="share-box">
  33. <view class="button">
  34. <button @click="goSelectTime()" class="start" >
  35. <!-- {{ model.activiteState }} -->
  36. 提交资料
  37. </button>
  38. <!-- <button disabled="true" class="ended" v-if="isJoin">已报名</button> -->
  39. </view>
  40. <!-- "status":"活动状态 0:待开始;1:已开始; 2:已结束
  41. "type":"活动类型 1:线上;2 线下"} -->
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import md5 from "@/common/md5.js";
  47. import activity_rich_card from "../policy/policy_rich_card";
  48. export default {
  49. filters: {
  50. formDateTime(value) {
  51. if (value) {
  52. const time = new Date(value * 1000);
  53. const y = time.getFullYear();
  54. const m =
  55. time.getMonth() + 1 < 10
  56. ? "0" + (time.getMonth() + 1)
  57. : time.getMonth() + 1;
  58. const d = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();
  59. // const h = time.getHours()
  60. // const mm = time.getMinutes();
  61. // const s = time.getSeconds();
  62. return y + "." + m + "." + d;
  63. } else {
  64. return "";
  65. }
  66. },
  67. formDateTimeSecond(value) {
  68. if (value) {
  69. const time = new Date(value * 1000);
  70. // const y = time.getFullYear();
  71. // const m = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
  72. // const d = time.getDate() < 10 ? '0' + time.getDate(): time.getDate();
  73. const h =
  74. time.getHours() < 10 ? "0" + time.getHours() : time.getHours();
  75. const mm =
  76. time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes();
  77. return h + ":" + mm;
  78. } else {
  79. return "";
  80. }
  81. },
  82. },
  83. components: {
  84. activityRichCard: activity_rich_card,
  85. },
  86. data() {
  87. return {
  88. id: "",
  89. activityInfoList:[],
  90. areaObj:{},
  91. textModel: {
  92. title: "",
  93. text: "",
  94. },
  95. };
  96. },
  97. onLoad(op) {
  98. this.id = op.id
  99. this.getAreaDeatil(op.id);
  100. },
  101. methods: {
  102. getAreaDeatil(areaId) {
  103. let md5Sign = md5(
  104. "method=" +
  105. "area" +
  106. "&timestamp=" +
  107. getApp().globalData.globalTimestamp +
  108. "&secret=" +
  109. getApp().globalData.secret
  110. );
  111. let url =
  112. getApp().globalData.shareUrl +
  113. "api/api.php" +
  114. "?method=area&source=area&action=info_by_id&timestamp=" +
  115. getApp().globalData.globalTimestamp +
  116. "&sign=" +
  117. md5Sign;
  118. let postData = {
  119. area_id: areaId,
  120. openId: getApp().globalData.open_id,
  121. };
  122. uni.request({
  123. url: url,
  124. method: "POST",
  125. header: {
  126. "content-type": "application/x-www-form-urlencoded",
  127. },
  128. data: postData,
  129. success: (res) => {
  130. if (res.data.code == 200) {
  131. this.areaObj = res.data.data;
  132. }
  133. this.getRich();
  134. },
  135. fail: () => {
  136. console.log("连接失败");
  137. },
  138. });
  139. },
  140. replaceImg(html) {
  141. let result = html.replace(
  142. /<img [^>]*src=['"]([^'"]+)[^>]*>/gi,
  143. function (match, capture) {
  144. if(capture.includes('http')){
  145. return (
  146. "<img src=" +
  147. capture +
  148. ' style="max-width:100%;height:auto;display:block;margin:10px auto;"/>'
  149. );
  150. }else {
  151. return (
  152. "<img src=" +
  153. getApp().globalData.shareUrl +
  154. capture +
  155. ' style="max-width:100%;height:auto;display:block;margin:10px auto;"/>'
  156. );
  157. }
  158. }
  159. );
  160. return result;
  161. },
  162. getRich() {
  163. uni.request({
  164. url:
  165. getApp().globalData.shareUrl +
  166. `content/area/${Math.floor(this.id / 1000)}/${this.id}.html`+'?version='+ Math.random(),
  167. method: "GET",
  168. header: {
  169. "content-type": "application/x-www-form-urlencoded",
  170. },
  171. success: (res) => {
  172. if (res.statusCode === 200) {
  173. this.textModel.text = this.replaceImg(res.data);
  174. }
  175. },
  176. fail: () => {
  177. console.log("连接失败");
  178. },
  179. });
  180. },
  181. goSelectTime() {
  182. // if(!getApp().globalData.user_phone){
  183. // uni.showToast({
  184. // title: "您还没有登录授权",
  185. // duration: 2500,
  186. // icon: "none",
  187. // });
  188. // uni.navigateTo({
  189. // url:'/pages/auth/index'
  190. // })
  191. // }
  192. uni.navigateTo({
  193. url:'/pages/makeField/selectTime?id=' + this.id
  194. })
  195. },
  196. },
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. .content {
  201. display: flex;
  202. flex-direction: column;
  203. .header {
  204. display: flex;
  205. // height: 150rpx;
  206. padding: 20rpx;
  207. .title-read {
  208. width: 100%;
  209. display: flex;
  210. justify-content: space-evenly;
  211. .title {
  212. font-weight: 600;
  213. letter-spacing: 2rpx;
  214. font-size: 30rpx;
  215. width: 80%;
  216. padding: 20rpx;
  217. }
  218. button {
  219. background: #95f204;
  220. color: #fff;
  221. font-size: 18rpx;
  222. height: 46rpx;
  223. line-height: 46rpx;
  224. margin-top: 5%;
  225. width: 18%;
  226. }
  227. .close {
  228. background: #7f7f7f;
  229. };
  230. .free {
  231. background: #95f204;
  232. };
  233. .full {
  234. background: #f59a23;
  235. }
  236. .can {
  237. background: #5498ff;
  238. }
  239. }
  240. .header-image {
  241. height: 100%;
  242. width: 50%;
  243. image {
  244. width: 100%;
  245. height: 100%;
  246. border-radius: 10%;
  247. }
  248. }
  249. }
  250. .active-deatil {
  251. padding: 20rpx;
  252. ul {
  253. padding: 30rpx;
  254. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  255. border-radius: 32rpx;
  256. li {
  257. margin-bottom: 30rpx;
  258. list-style: none;
  259. .name {
  260. margin-bottom: 10rpx;
  261. font-size: 30rpx;
  262. color: #7f7f7f;
  263. }
  264. .deatil-content {
  265. font-size: 28rpx;
  266. }
  267. }
  268. }
  269. }
  270. .rich {
  271. margin-bottom: 150rpx;
  272. padding: 20rpx;
  273. }
  274. .share-box {
  275. box-sizing: border-box;
  276. height: 150rpx;
  277. width: 100%;
  278. align-items: center;
  279. justify-content: space-evenly;
  280. position: fixed;
  281. bottom: 0;
  282. display: flex;
  283. background: #ffffff;
  284. .share {
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. width: 60rpx;
  289. height: 60rpx;
  290. position: relative;
  291. button::after {
  292. border: none;
  293. }
  294. image {
  295. width: 100%;
  296. height: 100%;
  297. position: absolute;
  298. }
  299. .shareCount {
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. position: absolute;
  304. top: -20%;
  305. right: -25%;
  306. color: #ffffff;
  307. height: 30rpx;
  308. width: 30rpx;
  309. padding: 3rpx;
  310. font-size: 16rpx;
  311. border-radius: 50%;
  312. background: #fe3637;
  313. }
  314. }
  315. .button {
  316. height: 100rpx;
  317. width: 75%;
  318. display: flex;
  319. justify-content: center;
  320. button {
  321. width: 80%;
  322. height: 80%;
  323. border: 1px solid;
  324. outline: none;
  325. background: none;
  326. font-size: 30rpx;
  327. // border-color: #00a8ea;
  328. }
  329. .start {
  330. //待开始
  331. background-color: transparent;
  332. border-color: none;
  333. color: #00a8ea;
  334. }
  335. .begun {
  336. //已开始
  337. border-color: #00a8ea;
  338. color: #00a8ea;
  339. }
  340. .ended {
  341. //已结束
  342. color: #00a8ea;
  343. border-color: #00a8ea;
  344. }
  345. .falseStart {
  346. color: #70b603;
  347. border-color: #70b603;
  348. }
  349. }
  350. }
  351. }
  352. </style>