course.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <g-toast :is-show="isShowToast">
  3. <scroll-view class="courseDialog" scroll-y="true">
  4. <image
  5. :src="serverUserInfo.link"
  6. mode="widthFix"
  7. class="courseImg"
  8. @click="toCourseList"
  9. />
  10. </scroll-view>
  11. </g-toast>
  12. </template>
  13. <script>
  14. import { toCourseToast } from "../../utils/api/toast.js"
  15. import GToast from "../../components/global/toast.vue"
  16. export default {
  17. components: {
  18. GToast
  19. },
  20. data() {
  21. return {
  22. serverUserInfo: uni.getStorageSync("serverUserInfo"),
  23. initToast: true
  24. }
  25. },
  26. computed: {
  27. isShowToast() {
  28. let { link } = this.serverUserInfo
  29. return this.initToast && link
  30. }
  31. },
  32. methods: {
  33. // 跳转课程
  34. toCourseList() {
  35. toCourseToast().then(res => {
  36. if(res.code === 200) {
  37. let { end_time:e, start_time:s } = this.userServerInfo
  38. let w = Math.ceil((e - s) / (7 * 24 * 60 * 60 * 1000))
  39. uni.navigateTo({
  40. url: '../course/list?week=' + w
  41. })
  42. } else {
  43. uni.showModal({
  44. title: '失败',
  45. content: '课程确认失败',
  46. showCancel: false
  47. })
  48. }
  49. }).catch(() => {
  50. uni.showModal({
  51. title: '失败',
  52. content: '课程确认失败',
  53. showCancel: false
  54. })
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .courseDialog {
  62. width: 80%;
  63. margin: 0 auto;
  64. height: 700rpx;
  65. .courseImg {
  66. display: block;
  67. width: 100%;
  68. }
  69. }
  70. </style>