微信

index.vue 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="mainPage flex-v">
  3. <div class="flex-item">
  4. <div>
  5. <h4>订单信息</h4>
  6. <div class="list flex-h">
  7. <div class="flex-item">
  8. <ul>
  9. <li class="flex-h">
  10. <div class="flex-item">
  11. <div>
  12. <span>精品课程名称</span>
  13. </div>
  14. </div>
  15. <span>{{courseDetail.CourseName}}</span>
  16. </li>
  17. <li class="flex-h">
  18. <div class="flex-item">
  19. <div>
  20. <span>预计开班时间</span>
  21. </div>
  22. </div>
  23. <span>{{returnDate(courseDetail.BeginDate)}}</span>
  24. </li>
  25. <li class="flex-h">
  26. <div class="flex-item">
  27. <div>
  28. <span>时间描述</span>
  29. </div>
  30. </div>
  31. <span v-if="courseTimeList.length">{{returnCourseTime(courseTimeList[0].BeginDate,courseTimeList[0].EndDate)}}</span>
  32. </li>
  33. <li class="flex-h">
  34. <div class="flex-item">
  35. <div>
  36. <span>地点</span>
  37. </div>
  38. </div>
  39. <!-- <span>{{courseDetail.CaseInfo.CaseAddress}}</span> -->
  40. </li>
  41. <li class="flex-h">
  42. <div class="flex-item">
  43. <div>
  44. <span>价格</span>
  45. </div>
  46. </div>
  47. <span>¥{{courseDetail.Price}}</span>
  48. </li>
  49. </ul>
  50. <div class="selectTicket">
  51. <div class="flex-h" @click="showLayer = true">
  52. <div class="flex-item">
  53. <div>
  54. <span>优惠信息</span>
  55. </div>
  56. </div>
  57. <span>{{postData.CouponId == '' ? '暂未选择优惠券' : postData.CouponName}}</span>
  58. <i class="iconfont icon-jiantou-right"></i>
  59. </div>
  60. <div class="flex-h">
  61. <div class="flex-item">
  62. <div>
  63. <span>优惠券</span>
  64. </div>
  65. </div>
  66. <span>{{columns.length > 1 ? (columns.length-1) + '张可用优惠券' : '暂无优惠券'}}</span>
  67. </div>
  68. </div>
  69. <div class="agreement">
  70. <span>购前需知</span>
  71. <div class="flex-h">
  72. <div class="flex-item">
  73. <div>
  74. <span>同意《银城精品团课服务协议》</span>
  75. </div>
  76. </div>
  77. <i class="iconfont icon-gouxuan" :class="{'active': agreementOff}" @click="agreement"></i>
  78. </div>
  79. </div>
  80. <div class="protocol">
  81. <div>1、协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容</div>
  82. <div>2、协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容</div>
  83. <div>3、协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容</div>
  84. <div>4、协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容</div>
  85. <div>5、协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容协议内容</div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="flex-h">
  92. <div class="flex-item">
  93. <div>
  94. <span>总计¥<em>{{courseDetail.Price}}</em></span>
  95. </div>
  96. </div>
  97. <a @click="placeOrder">确认订单</a>
  98. </div>
  99. <div class="layer" :class="{'show': showLayer}">
  100. <div>
  101. <van-picker
  102. show-toolbar
  103. title="选择优惠券"
  104. :columns="columns"
  105. @cancel="onCancel"
  106. @confirm="onConfirm"
  107. value-key="value"
  108. />
  109. </div>
  110. </div>
  111. </div>
  112. </template>
  113. <script>
  114. import { mapState, createNamespacedHelpers } from 'vuex'
  115. const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
  116. export default {
  117. name: '',
  118. data () {
  119. return {
  120. agreementOff: false, // 是否同意协议
  121. courseTimeList: [],
  122. postData: {
  123. CouponId: '',
  124. CouponName: '',
  125. },
  126. showLayer: false, // 显隐选择优惠券弹窗
  127. columns: [{ // 优惠券列表
  128. value: '不选择优惠券',
  129. id: '',
  130. }, {
  131. value: '优惠券1',
  132. id: '1',
  133. }, {
  134. value: '优惠券2',
  135. id: '2',
  136. }, {
  137. value: '优惠券3',
  138. id: '3',
  139. }],
  140. }
  141. },
  142. computed: {
  143. ...mapState({
  144. orgid: x => x.app.orgId,
  145. fiveA: x => x.index.fiveA,
  146. banner: x => x.index.banner,
  147. message: x => x.index.message,
  148. project: x => x.index.project,
  149. cms: x => x.index.cms,
  150. user: x => x.userCenter.userInfo
  151. }),
  152. ...mapProjectState({
  153. courseDetail: x => x.courseDetail
  154. }),
  155. },
  156. created () {
  157. this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
  158. var arr = res.CourseDetail
  159. this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
  160. })
  161. },
  162. methods: {
  163. placeOrder () { // 下单
  164. if(!this.agreementOff){
  165. this.$toast('请先阅读服务协议并同意')
  166. return false
  167. }
  168. this.placeOrderForCourse({
  169. order: {
  170. CourseId: this.courseDetail.CourseId,
  171. CaseId: this.courseDetail.CaseId,
  172. CustomerId: this.user.CustomerId,
  173. Price: this.courseDetail.Price
  174. },
  175. coupons: []
  176. }).then((res) => {
  177. // console.log(JSON.stringify(res))
  178. this.$dialog.alert({
  179. message: '下单成功!'
  180. }).then(() => {
  181. // this.$router.push({name: 'majorProjects'})
  182. window.history.go(-2)
  183. })
  184. })
  185. },
  186. ...mapProjectActions([
  187. 'getCourseDetailInfo',
  188. 'placeOrderForCourse',
  189. ]),
  190. returnCourseTime (val, endVal) { // 返回课时时间
  191. val = new Date(val)
  192. endVal = new Date(endVal)
  193. 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())
  194. },
  195. returnNum (val) {
  196. return val > 9 ? val : '0' + val
  197. },
  198. returnDate (val) {
  199. val = new Date(val)
  200. return this.returnNum(val.getMonth() + 1) + '月' + this.returnNum(val.getDate()) + '日'
  201. },
  202. onConfirm (value, index) {
  203. this.postData.CouponId = value.id
  204. this.postData.CouponName = value.value
  205. this.showLayer = false
  206. },
  207. onCancel () {
  208. this.showLayer = false
  209. },
  210. agreement () { // 同意协议
  211. this.agreementOff = !this.agreementOff
  212. },
  213. }
  214. }
  215. </script>
  216. <!-- Add "scoped" attribute to limit CSS to this component only -->
  217. <style lang="scss" scoped>
  218. @import "page.scss";
  219. </style>