class.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. <!-- <navigator hover-class="none" :url="`/pages2/wd/course?id=${item.goodsId}&gid=${item.gradeId}`"> -->
  6. <image :src="$method.splitImgHost(item.coverUrl, true)" class="class_img"></image>
  7. <view class="class_text">
  8. <view class="class_title">{{ item.goodsName }}</view>
  9. <view class="content_box">
  10. <image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
  11. <text class="content">{{ item.courseNum }}</text>
  12. <text class="content">{{ item.secAllNum }}</text>
  13. <text class="content">{{ item.classHours }}</text>
  14. 学时
  15. </view>
  16. <view class="content_box">
  17. <image src="/static/icon/wk_icon2.png" class="wk_icon"></image>
  18. 学习有效期:
  19. <text class="content">{{ $method.timestampToTime(item.validityStartTime) }} - {{ $method.timestampToTime(item.validityEndTime) }}</text>
  20. </view>
  21. </view>
  22. <!-- </navigator> -->
  23. <view class="class-warm" v-if="item.classEndTime && (item.classEndTime < sysTime) ">
  24. <u-icon class="class-warm__icon" size="30" color="#FF3B30" name="error-circle-fill"></u-icon>
  25. <view class="class-warm__text">
  26. <view class="date">班级有效期:{{$method.timestampToTime(item.classStartTime)}} - {{$method.timestampToTime(item.classEndTime)}}</view>
  27. <view class="state">班级状态:已过期,有疑问请联系 <text @click="call">020-87085982</text></view>
  28. </view>
  29. </view>
  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. },
  125. onShow() {
  126. this.courseGoodsList();
  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. 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. if(item.rebuildStatus == 0) {
  216. this.$navTo.togo('/pages2/learn/details', {
  217. gradeId:item.gradeId,
  218. goodsId: item.goodsId
  219. });
  220. return;
  221. }
  222. this.$navTo.togo(`/pages2/wd/course?id=${v}&gid=${i}`);
  223. },
  224. appointment(item) {
  225. var data = {
  226. goodsId: item.goodsId,
  227. gradeId: item.gradeId
  228. };
  229. this.$api.getApplysubscribe(data).then(res => {
  230. if (res.data.code === 500) {
  231. uni.showModal({
  232. showCancel: false,
  233. content: res.data.msg
  234. });
  235. }
  236. if (res.data.code === 200) {
  237. this.$navTo.togo('/pages2/appointment/index', {
  238. goodsId: item.goodsId,
  239. gradeId: item.gradeId
  240. });
  241. }
  242. });
  243. },
  244. okPopup() {
  245. this.$api.changeGrade({
  246. goodsId: this.selectItem.goodsId,
  247. gradeId: this.gradeValue,
  248. oldGradeId: this.selectItem.gradeId,
  249. orderGoodsId: this.selectItem.goodsId,
  250. userId: this.selectItem.userId
  251. }).then(res => {
  252. if(res.data.code == 200) {
  253. this.selectClassModal = false;
  254. uni.showToast({
  255. title:'选班成功'
  256. })
  257. } else {
  258. uni.showToast({
  259. icon:'none',
  260. title:res.data.msg
  261. })
  262. }
  263. })
  264. },
  265. call() {
  266. uni.makePhoneCall({
  267. phoneNumber: '020-87085982' //仅为示例
  268. })
  269. }
  270. }
  271. };
  272. </script>
  273. <style>
  274. page {
  275. background: #eaeef1;
  276. }
  277. </style>
  278. <style scope lang="scss">
  279. .box_progress {
  280. display: flex;
  281. justify-content: space-between;
  282. align-items: center;
  283. margin-top: 20rpx;
  284. .disabled {
  285. opacity: 0.6;
  286. }
  287. }
  288. .bottomBox {
  289. background: #ffffff;
  290. width: 94%;
  291. border-bottom-left-radius: 24rpx;
  292. border-bottom-right-radius: 24rpx;
  293. margin: 0 auto;
  294. padding: 20rpx;
  295. .restart {
  296. margin:0 auto;
  297. text-align: center;
  298. line-height: 80rpx;
  299. color:#fff;
  300. font-size: 30rpx;
  301. width: 440rpx;
  302. height: 80rpx;
  303. background: #FF0000;
  304. border-radius: 40rpx 40rpx 40rpx 40rpx;
  305. }
  306. }
  307. .content_box {
  308. font-size: 24rpx;
  309. display: flex;
  310. align-items: center;
  311. color: #999999;
  312. margin-top: 8rpx;
  313. }
  314. .content {
  315. color: #000000;
  316. margin: 0 8rpx;
  317. }
  318. .wk_icon {
  319. width: 24rpx;
  320. height: 24rpx;
  321. margin-right: 8rpx;
  322. }
  323. .class {
  324. margin-bottom: 30rpx;
  325. .class_item {
  326. width: 100%;
  327. background: #ffffff;
  328. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  329. border-radius: 24rpx;
  330. padding: 20rpx;
  331. z-index: 999;
  332. position: relative;
  333. .class_img {
  334. height: 316rpx;
  335. width: 100%;
  336. border-radius: 24rpx;
  337. }
  338. .class_text {
  339. padding:0 20rpx;
  340. .class_title {
  341. color: #333333;
  342. font-weight: bold;
  343. font-size: 32rpx;
  344. }
  345. }
  346. .class-warm {
  347. padding:10rpx 20rpx;
  348. display: flex;
  349. align-items: flex-start;
  350. &__icon {
  351. margin-right:10rpx;
  352. }
  353. &__text {
  354. .date {
  355. font-size: 24rpx;
  356. font-weight: bold;
  357. color: #FF3B30;
  358. }
  359. .state {
  360. margin-top:15rpx;
  361. font-size: 24rpx;
  362. font-weight: bold;
  363. color: #FF3B30;
  364. }
  365. }
  366. }
  367. }
  368. }
  369. .popup_box {
  370. height: 700rpx;
  371. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  372. border-radius: 32rpx 32rpx 0rpx 0rpx;
  373. .line1{
  374. width: 80rpx;
  375. height: 8rpx;
  376. background: #999999;
  377. border-radius: 4rpx;
  378. margin: 0 auto;
  379. margin-top: 15rpx;
  380. }
  381. .grade{
  382. height: 23rpx;
  383. font-size: 24rpx;
  384. color: #999999;
  385. margin: 0 auto;
  386. margin-top: 15rpx;
  387. text-align: center;
  388. }
  389. .confrim-btn{
  390. height: 98rpx;
  391. width: 100%;
  392. display: flex;
  393. align-items: center;
  394. justify-content:center;
  395. .okBtn{
  396. width: 200rpx;
  397. height: 64rpx;
  398. background: linear-gradient(0deg, #015EEA, #00C0FA);
  399. border-radius: 32rpx;
  400. color: #FFFFFF;
  401. text-align: center;
  402. line-height: 64rpx;
  403. }
  404. }
  405. }
  406. </style>