diff --git a/src/assets/images/teacher.png b/src/assets/images/teacher.png index 8bee3d7..c2bb586 100644 Binary files a/src/assets/images/teacher.png and b/src/assets/images/teacher.png differ diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue new file mode 100644 index 0000000..171f2db --- /dev/null +++ b/src/components/Pagination/index.vue @@ -0,0 +1,101 @@ + + + + + \ No newline at end of file diff --git a/src/utils/scroll-to.js b/src/utils/scroll-to.js new file mode 100644 index 0000000..c5d8e04 --- /dev/null +++ b/src/utils/scroll-to.js @@ -0,0 +1,58 @@ +Math.easeInOutQuad = function(t, b, c, d) { + t /= d / 2 + if (t < 1) { + return c / 2 * t * t + b + } + t-- + return -c / 2 * (t * (t - 2) - 1) + b +} + +// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts +var requestAnimFrame = (function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } +})() + +/** + * Because it's so fucking difficult to detect the scrolling element, just move them all + * @param {number} amount + */ +function move(amount) { + document.documentElement.scrollTop = amount + document.body.parentNode.scrollTop = amount + document.body.scrollTop = amount +} + +function position() { + return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop +} + +/** + * @param {number} to + * @param {number} duration + * @param {Function} callback + */ +export function scrollTo(to, duration, callback) { + const start = position() + const change = to - start + const increment = 20 + let currentTime = 0 + duration = (typeof (duration) === 'undefined') ? 500 : duration + var animateScroll = function() { + // increment the time + currentTime += increment + // find the value with the quadratic in-out easing function + var val = Math.easeInOutQuad(currentTime, start, change, duration) + // move the document.body + move(val) + // do the animation unless its over + if (currentTime < duration) { + requestAnimFrame(animateScroll) + } else { + if (callback && typeof (callback) === 'function') { + // the animation is done so lets callback + callback() + } + } + } + animateScroll() +} diff --git a/src/views/CatalogResource/index.vue b/src/views/CatalogResource/index.vue index 00841ce..330d487 100644 --- a/src/views/CatalogResource/index.vue +++ b/src/views/CatalogResource/index.vue @@ -7,14 +7,6 @@ -
- - - - - -
-
专题资源 @@ -32,8 +24,8 @@
{{ item.resourceNum }}个资源
- +
@@ -42,6 +34,7 @@ import { ref, onMounted } from 'vue' import { useRouter } from 'vue-router' import { getResourceCatalogList } from '@/apis/catalogResource' +import pagination from '@/components/Pagination/index.vue'; const router = useRouter() @@ -64,16 +57,6 @@ const goTo = (item) => { onMounted(() => { getResourceListData() }) - -const handleCurrentChange = (val) => { - queryParams.value.pageNum = val - getResourceListData() -} - -const handleSizeChange = (val) => { - queryParams.value.pageSize = val - getResourceListData() -}