class.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view class="class" v-for="(item, index) in goodsList" :key="index">
  4. <view class="class_item" @click.stop="studyIn(item.goodsId,item.gradeId,item)">
  5. <image :src="$method.splitImgHost(item.coverUrl, true)" class="class_img"></image>
  6. <view class="class_text">
  7. <view class="class_title">{{ item.goodsName }}</view>
  8. <view class="content_box">
  9. <image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
  10. <text class="content">{{ item.courseNum }}</text>
  11. <text class="content">{{ item.secAllNum }}</text>
  12. <text class="content">{{ item.classHours }}</text>
  13. 学时
  14. </view>
  15. <view class="content_box">
  16. <image src="/static/icon/wk_icon2.png" class="wk_icon"></image>
  17. 学习有效期:
  18. <text class="content">{{ $method.timestampToTime(item.validityStartTime) }} - {{ $method.timestampToTime(item.validityEndTime) }}</text>
  19. </view>
  20. </view>
  21. <template v-if="item.classEndTime && (item.classEndTime < sysTime) ">
  22. <view class="class-warm">
  23. <u-icon class="class-warm__icon" size="30" color="#FF3B30" name="error-circle-fill"></u-icon>
  24. <view class="class-warm__text">
  25. <view class="date">班级有效期:{{$method.timestampToTime(item.classStartTime)}} - {{$method.timestampToTime(item.classEndTime)}}</view>
  26. <view class="state">班级状态:已过期,有疑问请联系 <text @click="call">020-87085982</text></view>
  27. </view>
  28. </view>
  29. </template>
  30. </view>
  31. <view class="bottomBox">
  32. <template v-if="item.gradeStatus == 1 && item.status == 1 && (item.studyEndTime > sysTime) && (item.classEndTime && (item.classEndTime < sysTime)) && (item.periodStatus == 0 || item.periodStatus == -1) && item.studyCount > 0">
  33. <view class="restart" @click="selectClass(item)">
  34. 选班重学
  35. </view>
  36. </template>
  37. <template v-else>
  38. <view class="content_box">
  39. <image src="/static/icon/wk_icon3.png" class="wk_icon"></image>
  40. 学习进度:{{ item.stuAllNum }}/{{ item.secAllNum }}
  41. </view>
  42. <view class="box_progress">
  43. <view style="width: 60%;"><u-line-progress :showText="false" height="22" active-color="#ff9900" :show-percent="false" :percent="(item.stuAllNum / item.secAllNum) * 100"></u-line-progress></view>
  44. <view><u-button :class="{disabled:sysTime <= item.validityStartTime || sysTime >= item.validityEndTime}" type="warning" size="mini" @click.stop="studyIn(item.goodsId,item.gradeId,item)">进入学习</u-button></view>
  45. </view>
  46. <view class="box_progress" v-if="item.applyStatus === 1">
  47. <view style="width: 60%;">
  48. <text style="color: #333333;white-space: nowrap;text-overflow: ellipsis;">{{ item.applyName }}</text>
  49. </view>
  50. <view><u-button :plain="true" type="primary" size="mini" @click.stop="appointment(item)">预约考试</u-button></view>
  51. </view>
  52. <view class="box_progress" v-if="item.beforeStatus === 1">
  53. <view style="width: 60%;">
  54. <text style="color: #2979ff;white-space: nowrap;text-overflow: ellipsis;">{{ item.beforeName }}</text>
  55. </view>
  56. <view><u-button type="primary" size="mini" @click="appBeforeAddress(item.goodsId)">进入刷题</u-button></view>
  57. </view>
  58. </template>
  59. </view>
  60. </view>
  61. <view v-if="goodsList.length==0">
  62. <u-empty text="暂无网课" margin-top="500" mode="list"></u-empty>
  63. </view>
  64. <u-popup v-model="selectClassModal" @close="gradeValue = -1" mode="bottom" border-radius="40">
  65. <view class="popup_box">
  66. <view style="margin-bottom: 20rpx;">
  67. <view class="line1"></view>
  68. <view class="grade">选择班级</view>
  69. </view>
  70. <u-line color="#D6D6DB" />
  71. <view>
  72. <scroll-view scroll-y="true" style="height: 500rpx;">
  73. <view>
  74. <u-radio-group v-model="gradeValue" @change="radioGroupChange">
  75. <view v-for="(item, index) in gradeList" :key="index" >
  76. <view style="display: flex;align-items: center;padding: 20rpx;">
  77. <view>
  78. <u-radio
  79. shape="circle"
  80. :name="index"
  81. :disabled="item.studentNum > 0 && item.studentNum == item.studentUpper"
  82. >
  83. <view :class="item.checked?'white-box blue-box':'white-box'" >
  84. <view>
  85. <view class="blackTxt">{{item.className}}</view>
  86. <view class="redTxt" v-if="item.classEndTime">有效期至:{{$method.timestampToTime(item.classEndTime)}}</view>
  87. <view class="redTxt" v-if="item.classEndTime">本班还剩{{$method.GetRTime(item.classEndTime)}}天将结束学习</view>
  88. </view>
  89. </view>
  90. </u-radio>
  91. </view>
  92. </view>
  93. </view>
  94. </u-radio-group>
  95. </view>
  96. </scroll-view>
  97. </view>
  98. <view class="confrim-btn">
  99. <view class="okBtn" @click="okPopup()">确定</view>
  100. </view>
  101. </view>
  102. </u-popup>
  103. </view>
  104. </template>
  105. <script>
  106. export default {
  107. data() {
  108. return {
  109. list: [1, 2, 3],
  110. goodsList: [],
  111. selectClassModal:false,
  112. gradeList:[],
  113. gradeValue:-1,
  114. param:{
  115. pageNum: 1,
  116. pageSize: 10
  117. },
  118. total: 0,
  119. sysTime:0,
  120. selectItem:{}
  121. };
  122. },
  123. onLoad(option) {
  124. this.courseGoodsList();
  125. },
  126. onShow() {
  127. this.commonSystemTime()
  128. },
  129. onReachBottom() {
  130. if (this.goodsList.length < this.total) {
  131. this.param.pageNum++;
  132. this.courseGoodsList();
  133. }
  134. },
  135. methods: {
  136. commonSystemTime() {
  137. this.$api.commonSystemTime().then(res => {
  138. this.sysTime = res.data.data;
  139. })
  140. },
  141. selectClass(item) {
  142. console.log(item)
  143. this.selectItem = item;
  144. this.selectClassModal = true;
  145. this.goodsGradeList(item.goodsId);
  146. },
  147. radioGroupChange(e){
  148. console.log(e)
  149. },
  150. goodsGradeList(id) {
  151. let self = this
  152. this.$api.goodsGradeList({goodsId:id}).then(res => {
  153. if(res.data.code==200){
  154. self.gradeList = res.data.rows
  155. if(self.gradeList.length==0){
  156. let item = {
  157. className:'系统分班',
  158. gradeId:0
  159. }
  160. self.gradeList.push(item)
  161. } else {
  162. let isGradeFull = self.gradeList.every(item => (item.studentNum > 0 && item.studentNum == item.studentUpper))
  163. //所有班级都满了
  164. if(isGradeFull) {
  165. let item = {
  166. className:'系统分班',
  167. gradeId:0
  168. }
  169. self.gradeList.unshift(item)
  170. }
  171. }
  172. }
  173. });
  174. },
  175. appBeforeAddress(goodsId) {
  176. this.$api.appBeforeAddress({
  177. goodsId
  178. }).then(res => {
  179. if(res.data.code == 200) {
  180. uni.navigateToMiniProgram({
  181. appId: res.data.data.url,
  182. success(res) {
  183. // 打开成功
  184. }
  185. })
  186. } else {
  187. uni.showToast({
  188. title: res.data.msg,
  189. icon: 'none',
  190. })
  191. }
  192. })
  193. },
  194. courseGoodsList() {
  195. let self = this;
  196. this.$api.courseGoodsList(this.param).then(res => {
  197. if (res.data.code == 200) {
  198. self.goodsList.push.apply(self.goodsList, res.data.rows);
  199. self.total = res.data.total;
  200. }
  201. });
  202. },
  203. async studyIn(v,i,item) {
  204. if(this.sysTime <= item.validityStartTime || this.sysTime >= item.validityEndTime) {
  205. uni.showToast({
  206. icon:'none',
  207. title:'不在学习时间,不能进入学习'
  208. })
  209. return;
  210. }
  211. if(item.gradeStatus == 1 && item.status == 1 && (item.studyEndTime > this.sysTime) && (item.classEndTime && (item.classEndTime < this.sysTime)) && (item.periodStatus == 0 || item.periodStatus == -1) && item.studyCount > 0) {
  212. this.selectClass(item);
  213. return ;
  214. }
  215. let rebuildStatus = await this.courseGoodsRebuildStatus(item.goodsId)
  216. if(rebuildStatus == 0) {
  217. this.$navTo.togo('/pages2/learn/details', {
  218. gradeId:item.gradeId,
  219. goodsId: item.goodsId
  220. });
  221. return;
  222. }
  223. this.$navTo.togo(`/pages2/wd/course?id=${v}&gid=${i}`);
  224. },
  225. /**
  226. * @param {Object} goodsId 商品id
  227. * 查询商品重修状态
  228. */
  229. courseGoodsRebuildStatus(goodsId) {
  230. return new Promise(resolve => {
  231. this.$api.courseGoodsRebuildStatus({
  232. goodsId:goodsId
  233. }).then(res => {
  234. resolve(res.data.data)
  235. })
  236. })
  237. },
  238. appointment(item) {
  239. var data = {
  240. goodsId: item.goodsId,
  241. gradeId: item.gradeId
  242. };
  243. this.$api.getApplysubscribe(data).then(res => {
  244. if (res.data.code === 500) {
  245. uni.showModal({
  246. showCancel: false,
  247. content: res.data.msg
  248. });
  249. }
  250. if (res.data.code === 200) {
  251. this.$navTo.togo('/pages2/appointment/index', {
  252. goodsId: item.goodsId,
  253. gradeId: item.gradeId
  254. });
  255. }
  256. });
  257. },
  258. okPopup() {
  259. if(this.gradeValue == -1) {
  260. uni.showToast({
  261. icon:'none',
  262. title:'请选择班级'
  263. })
  264. return;
  265. }
  266. this.$api.changeGrade({
  267. goodsId: this.selectItem.goodsId,
  268. gradeId: this.gradeValue,
  269. oldGradeId: this.selectItem.gradeId,
  270. orderGoodsId: this.selectItem.goodsId,
  271. userId: this.selectItem.userId
  272. }).then(res => {
  273. if(res.data.code == 200) {
  274. this.selectClassModal = false;
  275. uni.showToast({
  276. title:'选班成功'
  277. })
  278. } else {
  279. uni.showToast({
  280. icon:'none',
  281. title:res.data.msg
  282. })
  283. }
  284. })
  285. },
  286. call() {
  287. uni.makePhoneCall({
  288. phoneNumber: '020-87085982' //仅为示例
  289. })
  290. }
  291. }
  292. };
  293. </script>
  294. <style>
  295. page {
  296. background: #eaeef1;
  297. }
  298. </style>
  299. <style scope lang="scss">
  300. .box_progress {
  301. display: flex;
  302. justify-content: space-between;
  303. align-items: center;
  304. margin-top: 20rpx;
  305. .disabled {
  306. opacity: 0.6;
  307. }
  308. }
  309. .bottomBox {
  310. background: #ffffff;
  311. width: 94%;
  312. border-bottom-left-radius: 24rpx;
  313. border-bottom-right-radius: 24rpx;
  314. margin: 0 auto;
  315. padding: 20rpx;
  316. .restart {
  317. margin:0 auto;
  318. text-align: center;
  319. line-height: 80rpx;
  320. color:#fff;
  321. font-size: 30rpx;
  322. width: 440rpx;
  323. height: 80rpx;
  324. background: #FF0000;
  325. border-radius: 40rpx 40rpx 40rpx 40rpx;
  326. }
  327. }
  328. .content_box {
  329. font-size: 24rpx;
  330. display: flex;
  331. align-items: center;
  332. color: #999999;
  333. margin-top: 8rpx;
  334. }
  335. .content {
  336. color: #000000;
  337. margin: 0 8rpx;
  338. }
  339. .wk_icon {
  340. width: 24rpx;
  341. height: 24rpx;
  342. margin-right: 8rpx;
  343. }
  344. .class {
  345. margin-bottom: 30rpx;
  346. .class_item {
  347. width: 100%;
  348. background: #ffffff;
  349. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  350. border-radius: 24rpx;
  351. padding: 20rpx;
  352. z-index: 999;
  353. position: relative;
  354. .class_img {
  355. height: 316rpx;
  356. width: 100%;
  357. border-radius: 24rpx;
  358. }
  359. .class_text {
  360. padding:0 20rpx;
  361. .class_title {
  362. color: #333333;
  363. font-weight: bold;
  364. font-size: 32rpx;
  365. }
  366. }
  367. .class-warm {
  368. padding:10rpx 20rpx;
  369. display: flex;
  370. align-items: flex-start;
  371. &__icon {
  372. margin-right:10rpx;
  373. }
  374. &__text {
  375. .date {
  376. font-size: 24rpx;
  377. font-weight: bold;
  378. color: #FF3B30;
  379. }
  380. .state {
  381. margin-top:15rpx;
  382. font-size: 24rpx;
  383. font-weight: bold;
  384. color: #FF3B30;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .popup_box {
  391. height: 700rpx;
  392. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  393. border-radius: 32rpx 32rpx 0rpx 0rpx;
  394. .line1{
  395. width: 80rpx;
  396. height: 8rpx;
  397. background: #999999;
  398. border-radius: 4rpx;
  399. margin: 0 auto;
  400. margin-top: 15rpx;
  401. }
  402. .grade{
  403. height: 23rpx;
  404. font-size: 24rpx;
  405. color: #999999;
  406. margin: 0 auto;
  407. margin-top: 15rpx;
  408. text-align: center;
  409. }
  410. .confrim-btn{
  411. height: 98rpx;
  412. width: 100%;
  413. display: flex;
  414. align-items: center;
  415. justify-content:center;
  416. .okBtn{
  417. width: 200rpx;
  418. height: 64rpx;
  419. background: linear-gradient(0deg, #015EEA, #00C0FA);
  420. border-radius: 32rpx;
  421. color: #FFFFFF;
  422. text-align: center;
  423. line-height: 64rpx;
  424. }
  425. }
  426. }
  427. </style>