courseOrder.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="container">
  3. <view class="course-item">
  4. <view class="course-item-image">
  5. <image class="course-image" :src="course.imgUrl" mode="aspectFill"></image>
  6. </view>
  7. <view class="course-item-content">
  8. <view class="course-title">
  9. <text>{{ course.courseName }}</text>
  10. <image style="width: 25rpx;height: 25rpx;padding-left: 20rpx;"
  11. :src="course.hasFavi ? `${FILE_URL}/edu-icon/favi-icon.png` : `${FILE_URL}/edu-icon/no-favi-icon.png`">
  12. </image>
  13. </view>
  14. <view class="course-type">{{ course.courseType }}</view>
  15. <view class="course-teacher">
  16. <u-icon name="account" size="28"></u-icon>
  17. {{ course.name }}
  18. </view>
  19. <view class="course-date">
  20. <u-icon name="clock" size="28"></u-icon>
  21. {{ getDateWeek(course.courseDate) }}
  22. </view>
  23. <view class="course-price">¥{{ course.price }}元</view>
  24. </view>
  25. </view>
  26. <view class="course-form" style="margin-top: 20rpx;">
  27. <view class="course-form-item">
  28. <view class="course-label">
  29. 开课时间
  30. </view>
  31. <view class="course-value">
  32. {{ course.courseDate }}{{ course.courseTime }}开课
  33. </view>
  34. </view>
  35. <view class="course-form-item">
  36. <view class="course-label">
  37. 支付方式
  38. </view>
  39. <view class="course-value" @click="show = true">
  40. {{ activePayType }}<i class="iconfont icon-sangedian-copy"></i>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="course-form" style="margin-top: 20rpx;">
  45. <view class="course-form-item">
  46. <view class="course-label">
  47. 课程金额
  48. </view>
  49. <view class="course-value">
  50. ¥{{ course.price }}
  51. </view>
  52. </view>
  53. <view class="course-form-item">
  54. <view class="course-label">
  55. 积分抵扣
  56. </view>
  57. <view class="course-value">
  58. </view>
  59. </view>
  60. <view class="course-form-item">
  61. <view class="course-label">
  62. 合计金额
  63. </view>
  64. <view class="course-value">
  65. ¥{{ price }}
  66. </view>
  67. </view>
  68. </view>
  69. <view class="course-form" style="margin-top: 20rpx;">
  70. <view class="course-form-item">
  71. <view class="course-label">
  72. 课程有效期:<text class="text-red">{{ course.expirationDate }}</text>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="course-form" style="background: none;">
  77. <view class="course-form-item">
  78. <text class="text-red" style="font-weight: bold;">个人会员或单位会员免费,点击现在入会></text>
  79. </view>
  80. </view>
  81. <view class="pay">
  82. <view class="pay-price">
  83. ¥:{{price}}
  84. </view>
  85. <view>
  86. <button class="pay-btn" @click="toBuy">立即购买</button>
  87. </view>
  88. </view>
  89. <u-action-sheet :list="list" v-model="show" @click="clickAction" safe-area-inset-bottom></u-action-sheet>
  90. </view>
  91. </template>
  92. <script setup>
  93. import {
  94. ref
  95. } from 'vue'
  96. import {
  97. onLoad
  98. } from '@dcloudio/uni-app'
  99. import configService from '@/utils/baseurl.js'
  100. import { loadCourseDetail } from "@/api/edu.js"
  101. const FILE_URL = configService.FILE_URL;
  102. const courseId = ref("");
  103. const course = ref({})
  104. const price = ref(0)
  105. const activePayType = ref("微信支付")
  106. const list = ref([{
  107. text: '微信支付'
  108. }])
  109. const show = ref(false)
  110. const toBuy = () => {
  111. uni.redirectTo({
  112. url: "/pages/goOnEdu/course/courseDetail/coursePay?id=" + courseId.value
  113. })
  114. }
  115. const clickAction = (i) =>{
  116. // console.log(i)
  117. activePayType.value = list.value[i].text
  118. show.value = false
  119. }
  120. // 加载数据
  121. // const init = (id) => {
  122. // // 加载数据
  123. // courseId.value = id
  124. // course.value = {
  125. // id: id,
  126. // courseName: "11Vue.js 从入门到精通",
  127. // courseType: "领袖锻造营",
  128. // name: "李老师11",
  129. // courseDate: "2023-09-15",
  130. // imgUrl: "https://tse4-mm.cn.bing.net/th/id/OIP-C.X_J8jL0bSPQ_jgOrdIbsgQHaEK?rs=1&pid=ImgDetMain",
  131. // price: 199.00,
  132. // hasBuy: true,
  133. // hasFavi: false,
  134. // payType: "会员免费",
  135. // expirationDate: "用户注销前有效"
  136. // }
  137. // course.courseTime = "18:00"
  138. // price.value = course.value.price
  139. // }
  140. // 日期格式:xxxx年xx月xx日(星期x)
  141. function getDateWeek(val) {
  142. const date = new Date(val);
  143. const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
  144. const year = date.getFullYear();
  145. const month = date.getMonth() + 1; // 注意:月份从0开始
  146. const day = date.getDate();
  147. const dayOfWeek = daysOfWeek[date.getUTCDay()];
  148. // const result = `${year}年${month}月${day}日(星期${dayOfWeek})`
  149. return `${year}年${month}月${day}日(星期${dayOfWeek})`
  150. }
  151. // 初始化
  152. function init(id) {
  153. loadCourseDetail(id).then(res=>{
  154. if(res?.data){
  155. course.value = res.data;
  156. }
  157. })
  158. }
  159. onLoad((option) => {
  160. const {
  161. id
  162. } = option;
  163. init(id);
  164. console.log('onLoad', id)
  165. })
  166. </script>
  167. <style lang="scss" scoped>
  168. .container {
  169. height: 100vh;
  170. width: 100vw;
  171. background-color: $uni-bg-color;
  172. // padding: 0 20rpx;
  173. }
  174. .course-item {
  175. padding: 20rpx;
  176. background-color: #fff;
  177. display: flex;
  178. overflow: hidden;
  179. margin: 0 20rpx;
  180. border-radius: 10rpx;
  181. .course-item-image {
  182. width: 200rpx;
  183. height: 280rpx;
  184. flex: 0 0 auto;
  185. margin-right: 20rpx;
  186. .course-image {
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. .course-item-content {
  192. flex: 1;
  193. position: relative;
  194. view {
  195. margin-bottom: 22rpx;
  196. }
  197. .course-title {
  198. font-weight: bold;
  199. margin-right: 10px;
  200. font-size: 28rpx;
  201. color: #000;
  202. }
  203. .course-type,
  204. .course-teacher,
  205. .course-date,
  206. .course-price {
  207. font-size: 30rpx;
  208. color: #000;
  209. }
  210. .course-price {
  211. color: #fe0000;
  212. letter-spacing: 2rpx;
  213. }
  214. .button::after {
  215. content: none;
  216. /* 移除内容 */
  217. }
  218. .button {
  219. position: absolute;
  220. right: 0;
  221. bottom: 0;
  222. min-width: 80px;
  223. padding: 0 40rpx;
  224. white-space: nowrap;
  225. height: 45rpx;
  226. line-height: 45rpx;
  227. font-size: 22rpx;
  228. /* padding: 0; */
  229. border-radius: 50rpx;
  230. color: white;
  231. border: none;
  232. }
  233. .free {
  234. background-color: #006af4;
  235. }
  236. .purchase {
  237. background-color: #fe0000;
  238. }
  239. .member-free {
  240. background-color: transparent;
  241. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  242. background-size: cover;
  243. background-repeat: no-repeat;
  244. color: #000;
  245. height: initial;
  246. padding: 6rpx 0 3rpx;
  247. border-radius: 0;
  248. }
  249. .replay {
  250. background-color: #006af4;
  251. }
  252. .purchased {
  253. background-color: #006af4;
  254. }
  255. }
  256. }
  257. .course-form {
  258. padding: 20rpx;
  259. background-color: #fff;
  260. display: flex;
  261. overflow: hidden;
  262. border-radius: 10rpx;
  263. flex-direction: column;
  264. font-size: 30rpx;
  265. margin: 0 20rpx;
  266. .course-form-item {
  267. display: flex;
  268. justify-content: space-between;
  269. width: 100%;
  270. margin: 20rpx 0;
  271. .iconfont {
  272. display: inline-block;
  273. font-size: 24rpx;
  274. }
  275. }
  276. }
  277. .pay {
  278. position: fixed;
  279. bottom: 0;
  280. width: 100%;
  281. display: flex;
  282. justify-content: space-between;
  283. padding: 40rpx 20rpx env(safe-area-inset-bottom, 0);
  284. background-color: #fff;
  285. align-items: center;
  286. .pay-price {
  287. font-size: 60rpx;
  288. color: red;
  289. font-weight: bold;
  290. }
  291. .pay-btn {
  292. width: 200rpx;
  293. height: 70rpx;
  294. line-height: 70rpx;
  295. background-color: red;
  296. color: #fff;
  297. border-radius: 40rpx;
  298. }
  299. }
  300. .text-red {
  301. color: red;
  302. }
  303. </style>