courseOrder.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. const FILE_URL = configService.FILE_URL;
  101. const courseId = ref("");
  102. const course = ref({})
  103. const price = ref(0)
  104. const activePayType = ref("微信支付")
  105. const list = ref([{
  106. text: '微信支付'
  107. }, {
  108. text: '支付宝支付'
  109. }])
  110. const show = ref(false)
  111. const toBuy = () => {
  112. uni.redirectTo({
  113. url: "/pages/goOnEdu/course/courseDetail/coursePay?id=" + courseId.value
  114. })
  115. }
  116. const clickAction = (i) =>{
  117. // console.log(i)
  118. activePayType.value = list.value[i].text
  119. show.value = false
  120. }
  121. // 加载数据
  122. const init = (id) => {
  123. // 加载数据
  124. courseId.value = id
  125. course.value = {
  126. id: id,
  127. courseName: "11Vue.js 从入门到精通",
  128. courseType: "领袖锻造营",
  129. name: "李老师11",
  130. courseDate: "2023-09-15",
  131. imgUrl: "https://tse4-mm.cn.bing.net/th/id/OIP-C.X_J8jL0bSPQ_jgOrdIbsgQHaEK?rs=1&pid=ImgDetMain",
  132. price: 199.00,
  133. hasBuy: true,
  134. hasFavi: false,
  135. payType: "会员免费",
  136. expirationDate: "用户注销前有效"
  137. }
  138. course.courseTime = "18:00"
  139. price.value = course.value.price
  140. }
  141. // 日期格式:xxxx年xx月xx日(星期x)
  142. function getDateWeek(val) {
  143. const date = new Date(val);
  144. const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
  145. const year = date.getFullYear();
  146. const month = date.getMonth() + 1; // 注意:月份从0开始
  147. const day = date.getDate();
  148. const dayOfWeek = daysOfWeek[date.getUTCDay()];
  149. // const result = `${year}年${month}月${day}日(星期${dayOfWeek})`
  150. return `${year}年${month}月${day}日(星期${dayOfWeek})`
  151. }
  152. onLoad((option) => {
  153. const {
  154. id
  155. } = option;
  156. init(id);
  157. console.log('onLoad', id)
  158. })
  159. </script>
  160. <style lang="scss" scoped>
  161. .container {
  162. height: 100vh;
  163. width: 100vw;
  164. background-color: $uni-bg-color;
  165. // padding: 0 20rpx;
  166. }
  167. .course-item {
  168. padding: 20rpx;
  169. background-color: #fff;
  170. display: flex;
  171. overflow: hidden;
  172. margin: 0 20rpx;
  173. border-radius: 10rpx;
  174. .course-item-image {
  175. width: 200rpx;
  176. height: 280rpx;
  177. flex: 0 0 auto;
  178. margin-right: 20rpx;
  179. .course-image {
  180. width: 100%;
  181. height: 100%;
  182. }
  183. }
  184. .course-item-content {
  185. flex: 1;
  186. position: relative;
  187. view {
  188. margin-bottom: 22rpx;
  189. }
  190. .course-title {
  191. font-weight: bold;
  192. margin-right: 10px;
  193. font-size: 28rpx;
  194. color: #000;
  195. }
  196. .course-type,
  197. .course-teacher,
  198. .course-date,
  199. .course-price {
  200. font-size: 30rpx;
  201. color: #000;
  202. }
  203. .course-price {
  204. color: #fe0000;
  205. letter-spacing: 2rpx;
  206. }
  207. .button::after {
  208. content: none;
  209. /* 移除内容 */
  210. }
  211. .button {
  212. position: absolute;
  213. right: 0;
  214. bottom: 0;
  215. min-width: 80px;
  216. padding: 0 40rpx;
  217. white-space: nowrap;
  218. height: 45rpx;
  219. line-height: 45rpx;
  220. font-size: 22rpx;
  221. /* padding: 0; */
  222. border-radius: 50rpx;
  223. color: white;
  224. border: none;
  225. }
  226. .free {
  227. background-color: #006af4;
  228. }
  229. .purchase {
  230. background-color: #fe0000;
  231. }
  232. .member-free {
  233. background-color: transparent;
  234. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  235. background-size: cover;
  236. background-repeat: no-repeat;
  237. color: #000;
  238. height: initial;
  239. padding: 6rpx 0 3rpx;
  240. border-radius: 0;
  241. }
  242. .replay {
  243. background-color: #006af4;
  244. }
  245. .purchased {
  246. background-color: #006af4;
  247. }
  248. }
  249. }
  250. .course-form {
  251. padding: 20rpx;
  252. background-color: #fff;
  253. display: flex;
  254. overflow: hidden;
  255. border-radius: 10rpx;
  256. flex-direction: column;
  257. font-size: 30rpx;
  258. margin: 0 20rpx;
  259. .course-form-item {
  260. display: flex;
  261. justify-content: space-between;
  262. width: 100%;
  263. margin: 20rpx 0;
  264. .iconfont {
  265. display: inline-block;
  266. font-size: 24rpx;
  267. }
  268. }
  269. }
  270. .pay {
  271. position: fixed;
  272. bottom: 0;
  273. width: 100%;
  274. display: flex;
  275. justify-content: space-between;
  276. padding: 40rpx 20rpx env(safe-area-inset-bottom, 0);
  277. background-color: #fff;
  278. align-items: center;
  279. .pay-price {
  280. font-size: 60rpx;
  281. color: red;
  282. font-weight: bold;
  283. }
  284. .pay-btn {
  285. width: 200rpx;
  286. height: 70rpx;
  287. line-height: 70rpx;
  288. background-color: red;
  289. color: #fff;
  290. border-radius: 40rpx;
  291. }
  292. }
  293. .text-red {
  294. color: red;
  295. }
  296. </style>