viewDetail.vue 8.2 KB

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