微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 v-if="courseDetail.CaseInfo !== undefined">{{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.customercouponid == '' ? '暂未选择优惠券' : '已选择优惠券'}}</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>{{couponList.length ? couponList.length + '张可用优惠券' : '暂无优惠券'}}</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. <div class="top">
  102. <i class="iconfont icon-guanbi"></i>
  103. </div>
  104. <div class="body flex-h">
  105. <div class="flex-item">
  106. <div>
  107. <ul>
  108. <li v-for="(item,index) in couponList" :key="index" @click="selectCouponItem(item)" :class="{'active':item.select}">
  109. <i class="iconfont icon-gouxuan"></i>
  110. <discounts :data="item"></discounts>
  111. </li>
  112. </ul>
  113. </div>
  114. </div>
  115. </div>
  116. <a @click="sureSelectCoupon">确定</a>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { mapState, createNamespacedHelpers } from 'vuex'
  123. const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
  124. const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
  125. import discounts from '../../../components/discounts/discounts'
  126. export default {
  127. name: '',
  128. data () {
  129. return {
  130. couponList: [],
  131. getCouponOff: false,
  132. agreementOff: false, // 是否同意协议
  133. courseTimeList: [],
  134. postData: {
  135. CouponId: '',
  136. CouponName: '',
  137. customercouponid: ''
  138. },
  139. showLayer: false, // 显隐选择优惠券弹窗
  140. }
  141. },
  142. components: {
  143. discounts,
  144. },
  145. computed: {
  146. ...mapState({
  147. orgid: x => x.app.orgId,
  148. fiveA: x => x.index.fiveA,
  149. banner: x => x.index.banner,
  150. message: x => x.index.message,
  151. project: x => x.index.project,
  152. cms: x => x.index.cms,
  153. user: x => x.userCenter.userInfo
  154. }),
  155. ...mapProjectState({
  156. courseDetail: x => x.courseDetail
  157. }),
  158. },
  159. created () {
  160. this.getCouponList().then((res) => {
  161. this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
  162. var arr = res.CourseDetail
  163. this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
  164. })
  165. var id = this.$route.query.id, arr = [], nowDate = Date.now()
  166. for (var n = 0; n < res.length; n++) {
  167. if (res[n].Coupon.CouponType === 'coupon' && res[n].Status === 1) {
  168. if (res[n].Coupon.IsAll) {
  169. this.couponList.push({
  170. title: res[n].Coupon.CouponName,
  171. desc: res[n].Coupon.Share.UseInstruction,
  172. time: this.toolClass.dateFormat(res[n].EndDate),
  173. useType: '未使用',
  174. tag: '课程',
  175. id: res[n].CustomerCouponId,
  176. select: false,
  177. })
  178. } else {
  179. for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
  180. if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
  181. this.couponList.push({
  182. title: res[n].Coupon.CouponName,
  183. desc: res[n].Coupon.Share.UseInstruction,
  184. time: this.toolClass.dateFormat(res[n].EndDate),
  185. useType: '未使用',
  186. tag: '课程',
  187. id: res[n].CustomerCouponId,
  188. select: false,
  189. })
  190. }
  191. }
  192. }
  193. }
  194. }
  195. this.getCouponOff = true
  196. // console.log(JSON.stringify(this.couponList))
  197. })
  198. },
  199. methods: {
  200. ...caseTableActions([
  201. 'getCouponList',
  202. ]),
  203. sureSelectCoupon () {
  204. var bool = false
  205. for (var n = 0; n < this.couponList.length; n++) {
  206. if (this.couponList[n].select) {
  207. bool = true
  208. this.postData.customercouponid = this.couponList[n].id
  209. }
  210. }
  211. if (!bool) {
  212. this.postData.customercouponid = ''
  213. }
  214. this.showLayer = false
  215. },
  216. selectCouponItem (item) { // 选择优惠券
  217. if (!item.select) {
  218. for (var n = 0; n < this.couponList.length; n++) {
  219. this.couponList[n].select = false
  220. }
  221. item.select = true
  222. } else {
  223. item.select = false
  224. }
  225. },
  226. placeOrder () { // 下单
  227. if (!this.agreementOff) {
  228. this.$toast('请先阅读服务协议并同意')
  229. return false
  230. }
  231. this.placeOrderForCourse({
  232. order: {
  233. CourseId: this.courseDetail.CourseId,
  234. CaseId: this.courseDetail.CaseId,
  235. CustomerId: this.user.CustomerId,
  236. Price: this.courseDetail.Price
  237. },
  238. customercouponid: this.postData.customercouponid
  239. }).then((res) => {
  240. // console.log(JSON.stringify(res))
  241. this.$dialog.alert({
  242. message: '下单成功!'
  243. }).then(() => {
  244. // this.$router.push({name: 'majorProjects'})
  245. window.history.go(-2)
  246. })
  247. })
  248. },
  249. ...mapProjectActions([
  250. 'getCourseDetailInfo',
  251. 'placeOrderForCourse',
  252. ]),
  253. returnCourseTime (val, endVal) { // 返回课时时间
  254. val = new Date(val)
  255. endVal = new Date(endVal)
  256. 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())
  257. },
  258. returnNum (val) {
  259. return val > 9 ? val : '0' + val
  260. },
  261. returnDate (val) {
  262. val = new Date(val)
  263. return this.returnNum(val.getMonth() + 1) + '月' + this.returnNum(val.getDate()) + '日'
  264. },
  265. onConfirm (value, index) {
  266. this.postData.CouponId = value.id
  267. this.postData.CouponName = value.value
  268. this.showLayer = false
  269. },
  270. onCancel () {
  271. this.showLayer = false
  272. },
  273. agreement () { // 同意协议
  274. this.agreementOff = !this.agreementOff
  275. },
  276. }
  277. }
  278. </script>
  279. <!-- Add "scoped" attribute to limit CSS to this component only -->
  280. <style lang="scss" scoped>
  281. @import 'page.scss';
  282. </style>