微信

index.vue 10KB

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="couponList.length ? showLayer = true : showLayer = false">
  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" v-if="couponList.length"></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>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="flex-h">
  91. <div class="flex-item">
  92. <div>
  93. <span>总计¥<em>{{courseDetail.Price}}</em></span>
  94. </div>
  95. </div>
  96. <a @click="placeOrder">确认订单</a>
  97. </div>
  98. <div class="layer" :class="{'show': showLayer}">
  99. <div>
  100. <div class="top">
  101. <i class="iconfont icon-guanbi"></i>
  102. </div>
  103. <div class="body flex-h">
  104. <div class="flex-item">
  105. <div>
  106. <ul>
  107. <li v-for="(item,index) in couponList" :key="index" @click="selectCouponItem(item)" :class="{'active':item.select}">
  108. <i class="iconfont icon-gouxuan"></i>
  109. <discounts :data="item"></discounts>
  110. </li>
  111. </ul>
  112. </div>
  113. </div>
  114. </div>
  115. <a @click="sureSelectCoupon">确定</a>
  116. </div>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import { mapState, createNamespacedHelpers } from 'vuex'
  122. const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
  123. const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
  124. import discounts from '../../../components/discounts/discounts'
  125. export default {
  126. name: '',
  127. data () {
  128. return {
  129. couponList: [],
  130. getCouponOff: false,
  131. agreementOff: true, // 是否同意协议
  132. courseTimeList: [],
  133. postData: {
  134. CouponId: '',
  135. CouponName: '',
  136. customercouponid: ''
  137. },
  138. showLayer: false, // 显隐选择优惠券弹窗
  139. }
  140. },
  141. components: {
  142. discounts,
  143. },
  144. computed: {
  145. ...mapState({
  146. orgid: x => x.app.orgId,
  147. fiveA: x => x.index.fiveA,
  148. banner: x => x.index.banner,
  149. message: x => x.index.message,
  150. project: x => x.index.project,
  151. cms: x => x.index.cms,
  152. user: x => x.userCenter.userInfo
  153. }),
  154. ...mapProjectState({
  155. courseDetail: x => x.courseDetail
  156. }),
  157. },
  158. created () {
  159. this.getCouponList().then((res) => {
  160. this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
  161. var arr = res.CourseDetail
  162. this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
  163. var id = this.$route.query.id, arr = [], nowDate = Date.now()
  164. for (var n = 0; n < res.length; n++) {
  165. console.log(res[n])
  166. if (res[n].Coupon.CouponType === 'course' && res[n].Status === 1) {
  167. if (res[n].Coupon.IsAll) {
  168. this.couponList.push({
  169. title: res[n].Coupon.CouponName,
  170. desc: res[n].Coupon.Share.UseInstruction,
  171. time: this.toolClass.dateFormat(res[n].EndDate),
  172. useType: '未使用',
  173. tag: '课程',
  174. id: res[n].CustomerCouponId,
  175. select: false,
  176. })
  177. } else {
  178. for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
  179. if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
  180. this.couponList.push({
  181. title: res[n].Coupon.CouponName,
  182. desc: res[n].Coupon.Share.UseInstruction,
  183. time: this.toolClass.dateFormat(res[n].EndDate),
  184. useType: '未使用',
  185. tag: '课程',
  186. id: res[n].CustomerCouponId,
  187. select: false,
  188. })
  189. }
  190. }
  191. }
  192. }
  193. }
  194. this.getCouponOff = true
  195. // console.log(JSON.stringify(this.couponList))
  196. })
  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>