微信

index.vue 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="mainPage flex-v" v-if="showPage">
  3. <div class="flex-item">
  4. <div class="content">
  5. <div class="banner">
  6. <div class="scrollImg">
  7. <img :src='courseDetail.CourseImg' class="cover" alt="">
  8. <!-- <swiper :options="swiperOption" ref="mySwiper">
  9. <swiper-slide class="swiper-slide" v-for="(item,index) in courseDetail.CourseImgs" :key="index">
  10. <img :src='item.ImgUrl' class="cover" alt="">
  11. </swiper-slide>
  12. </swiper> -->
  13. </div>
  14. <div>
  15. <span>{{courseDetail.CourseName}}</span>
  16. <div>
  17. <span>¥<em>{{courseDetail.Price}}</em>起/课时</span>
  18. <span>参与者<em>{{courseDetail.SignupNum}}</em>/{{courseDetail.MaxNum}}人</span>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="subContent time">
  23. <h5>时间</h5>
  24. <span>{{returnDate(courseDetail.BeginDate)}}~{{returnDate(courseDetail.EndDate)}}</span>
  25. <div class="list flex-h">
  26. <div class="flex-item">
  27. <ul :class="{'show':showMoreCourse}">
  28. <li v-for="(item,index) in courseTimeList" :key="index">{{returnCourseTime(item.BeginDate,item.EndDate)}}</li>
  29. </ul>
  30. <a class="moreCourse" @click="triggerCourseTime" v-if="courseTimeList.length>4">
  31. {{showMoreCourse ? '收起' : '更多'}}
  32. <i v-if="!showMoreCourse" class="iconfont icon-jiantou-down"></i>
  33. <i v-if="showMoreCourse" class="iconfont icon-jiantou-up"></i>
  34. </a>
  35. </div>
  36. </div>
  37. </div>
  38. <div style="width:100%;height:.1rem;background:#ebf1f2;"></div>
  39. <div class="subContent address">
  40. <h5>地点</h5>
  41. <div class="flex-h">
  42. <div class="flex-item">
  43. <div class="img">
  44. <a @click="openMap">
  45. <img v-if="courseDetail.CaseInfo !== undefined" :src="courseDetail.CaseInfo.CaseIcon" class="centerLabel cover" alt="">
  46. <div class="flex-h">
  47. <i class="iconfont icon-dingwei"></i>
  48. <div class="flex-item">
  49. <div>
  50. <span v-if="courseDetail.CaseInfo !== undefined">{{courseDetail.CaseInfo.CaseName}}({{courseDetail.CaseInfo.CaseAddress}})</span>
  51. </div>
  52. </div>
  53. </div>
  54. </a>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="subContent address">
  60. <h5 style="padding-bottom:.1rem">课程详情</h5>
  61. <div class="flex-l" style="margin: 0 .26rem">
  62. <img :src="item.ImgUrl" alt="" width="100%" v-for="(item,index) in detailImage" :key="index">
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="flex-h">
  68. <div class="flex-item">
  69. <div>
  70. <span>总计¥<em>{{courseDetail.Price}}</em></span>
  71. <span>优惠券体验</span>
  72. </div>
  73. </div>
  74. <a @click="toBuy" :class="{gray: gray}">去购买</a>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import wxsdk from '../../../util/share'
  80. import logo from '../../../common/icon/indexlogo.jpg'
  81. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  82. import 'swiper/dist/css/swiper.css'
  83. import { mapState, createNamespacedHelpers } from 'vuex'
  84. const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
  85. const wx = require('weixin-js-sdk')
  86. export default {
  87. name: '',
  88. data () {
  89. return {
  90. logo,
  91. gray: false,
  92. swiperOption: {
  93. observer: true,
  94. autoplay: {
  95. disableOnInteraction: false,
  96. }
  97. },
  98. showMoreCourse: false, // 显隐更多课程时间
  99. courseTimeList: [], // 课程时间
  100. detailImage: [],
  101. showPage: false,
  102. topImage: ''
  103. }
  104. },
  105. computed: {
  106. ...mapState({
  107. orgid: x => x.app.orgId,
  108. fiveA: x => x.index.fiveA,
  109. banner: x => x.index.banner,
  110. message: x => x.index.message,
  111. project: x => x.index.project,
  112. cms: x => x.index.cms,
  113. }),
  114. ...mapProjectState({
  115. courseDetail: x => x.courseDetail
  116. }),
  117. MySwiper () {
  118. return this.$refs.mySwiper.swiper
  119. },
  120. },
  121. components: {
  122. swiper,
  123. swiperSlide,
  124. },
  125. created () {
  126. this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
  127. var arr = res.CourseDetail
  128. if (arr === null) {
  129. arr = []
  130. }
  131. this.courseDetail.CourseImgs = this.courseDetail.CourseImgs || []
  132. this.topImage = this.courseDetail.CourseImgs.length > 0 ? this.courseDetail.CourseImgs[0].ImgUrl : ""
  133. if (this.courseDetail.CourseImgs.length > 0) {
  134. this.detailImage = this.courseDetail.CourseImgs.slice(1)
  135. }
  136. console.log(this.detailImage)
  137. this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
  138. let nowDate = Date.now()
  139. let endData = new Date(this.courseDetail.EndDate).getTime()
  140. if (nowDate > endData) {
  141. this.gray = true
  142. }
  143. if (this.courseDetail.SignupNum >= this.courseDetail.MaxNum) {
  144. this.gray = true
  145. }
  146. // console.log(JSON.stringify(res))
  147. this.showPage = true
  148. })
  149. },
  150. methods: {
  151. ...mapProjectActions([
  152. 'getCourseDetailInfo',
  153. ]),
  154. returnCourseTime (val, endVal) { // 返回课时时间
  155. val = new Date(val)
  156. endVal = new Date(endVal)
  157. return this.returnNum(val.getMonth() + 1) + '/' + this.returnNum(val.getDate()) + ' 周' + '日一二三四五六'.split('')[new Date(val).getDay()] + ' ' + this.returnNum(val.getHours()) + ':' + this.returnNum(val.getMinutes()) + '~' + this.returnNum(endVal.getHours()) + ':' + this.returnNum(endVal.getMinutes())
  158. },
  159. returnNum (val) {
  160. return val > 9 ? val : '0' + val
  161. },
  162. returnDate (val) {
  163. val = new Date(val)
  164. return val.getFullYear() + '年' + this.returnNum(val.getMonth() + 1) + '月' + this.returnNum(val.getDate()) + '日'
  165. },
  166. triggerCourseTime () { // 显隐更多课程时间
  167. this.showMoreCourse = !this.showMoreCourse
  168. },
  169. toBuy () {
  170. if (this.gray) {
  171. this.$toast('该课程已过期或参与人数已满')
  172. return
  173. }
  174. let nowDate = Date.now()
  175. let endData = new Date(this.courseDetail.EndDate).getTime()
  176. if (nowDate > endData) {
  177. this.$toast('该课程已过期')
  178. } else {
  179. this.$router.push({ name: 'placeOrderForCourse', query: { id: this.courseDetail.CourseId } })
  180. }
  181. },
  182. openMap () {
  183. wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
  184. title: '城的空间',
  185. desc: '城的空间',
  186. link: `${window.location.origin}${window.location.pathname}#/mainPage/indexPage`,
  187. thu_image: `https://jingcheng-resourceplat.oss-cn-shanghai.aliyuncs.com/citymini%2Findexlogo.jpg`
  188. }).then(() => {
  189. let result = this.courseDetail.CaseInfo.Coordinate.split(",")
  190. let latitude = parseFloat(result[0])
  191. let longitude = parseFloat(result[1])
  192. wx.openLocation({
  193. latitude: latitude, // 纬度,浮点数,范围为90 ~ -90
  194. longitude: longitude, // 经度,浮点数,范围为180 ~ -180。
  195. name: this.courseDetail.CaseInfo.CaseName, // 位置名
  196. // address: '', // 地址详情说明
  197. // scale: 1, // 地图缩放级别,整形值,范围从1~28。默认为最大
  198. // infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  199. })
  200. })
  201. }
  202. }
  203. }
  204. </script>
  205. <!-- Add "scoped" attribute to limit CSS to this component only -->
  206. <style lang="scss" scoped>
  207. @import 'page.scss';
  208. </style>