Showing
6 changed files
with
77 additions
and
184 deletions
| ... | @@ -4,12 +4,14 @@ import { useVideoList } from '@/composables/useVideoList.js' | ... | @@ -4,12 +4,14 @@ import { useVideoList } from '@/composables/useVideoList.js' |
| 4 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' | 4 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' |
| 5 | import { useBookList } from '@/composables/useBookList.js' | 5 | import { useBookList } from '@/composables/useBookList.js' |
| 6 | import { useShortcutBar } from '@/composables/useShortcutBar.js' | 6 | import { useShortcutBar } from '@/composables/useShortcutBar.js' |
| 7 | +import { useScrollTop } from '@/composables/useScrollTop.js' | ||
| 7 | 8 | ||
| 8 | export { | 9 | export { |
| 9 | useVideoList, | 10 | useVideoList, |
| 10 | useDefaultPerf, | 11 | useDefaultPerf, |
| 11 | useBookList, | 12 | useBookList, |
| 12 | - useShortcutBar | 13 | + useShortcutBar, |
| 14 | + useScrollTop | ||
| 13 | } | 15 | } |
| 14 | 16 | ||
| 15 | /** | 17 | /** | ... | ... |
src/composables/useScrollTop.js
0 → 100644
| 1 | +import { $, _, storeToRefs, mainStore } from '@/utils/generatePackage' | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 页面滚动恢复 | ||
| 5 | + * @returns | ||
| 6 | + */ | ||
| 7 | +export const useScrollTop = () => { | ||
| 8 | + const store = mainStore(); | ||
| 9 | + const resetScrollTop = (key) => { | ||
| 10 | + // 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 11 | + _.times(2, () => { | ||
| 12 | + $("html,body").animate({ "scrollTop": String(storeToRefs(store)[key].value) + 'px' }); | ||
| 13 | + }); | ||
| 14 | + } | ||
| 15 | + return { | ||
| 16 | + resetScrollTop, | ||
| 17 | + store | ||
| 18 | + } | ||
| 19 | +} |
| ... | @@ -4,7 +4,8 @@ | ... | @@ -4,7 +4,8 @@ |
| 4 | <div class="info"> | 4 | <div class="info"> |
| 5 | <van-row> | 5 | <van-row> |
| 6 | <van-col> | 6 | <van-col> |
| 7 | - <van-image v-if="userInfo.avatar" round width="50" height="50" :src="userInfo.avatar" style="padding-right: 1rem;" /> | 7 | + <van-image v-if="userInfo.avatar" round width="50" height="50" :src="userInfo.avatar" |
| 8 | + style="padding-right: 1rem;" /> | ||
| 8 | <van-image v-else round width="50" height="50" :src="icon_avatar" style="padding-right: 1rem;" /> | 9 | <van-image v-else round width="50" height="50" :src="icon_avatar" style="padding-right: 1rem;" /> |
| 9 | </van-col> | 10 | </van-col> |
| 10 | <van-col class="text-wrapper" span="18"> | 11 | <van-col class="text-wrapper" span="18"> |
| ... | @@ -51,92 +52,58 @@ | ... | @@ -51,92 +52,58 @@ |
| 51 | <div style="height: 2rem;"></div> | 52 | <div style="height: 2rem;"></div> |
| 52 | </div> | 53 | </div> |
| 53 | </div> | 54 | </div> |
| 54 | - <van-empty v-if="emptyStatus" | 55 | + <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无作品信息" /> |
| 55 | - class="custom-image" | ||
| 56 | - :image="no_image" | ||
| 57 | - description="暂无作品信息" | ||
| 58 | - /> | ||
| 59 | </template> | 56 | </template> |
| 60 | 57 | ||
| 61 | <script setup> | 58 | <script setup> |
| 59 | +import { ref, onActivated, onMounted } from 'vue' | ||
| 60 | +import { useRoute, onBeforeRouteLeave } from 'vue-router' | ||
| 62 | import { storeToRefs } from 'pinia' | 61 | import { storeToRefs } from 'pinia' |
| 63 | import VideoCard from '@/components/VideoCard/index.vue' | 62 | import VideoCard from '@/components/VideoCard/index.vue' |
| 64 | -import icon_avatar from '@images/que-touxiang@2x.png' | 63 | +import { icon_avatar, no_image } from '@/utils/generateIcons.js' |
| 65 | -import no_image from '@images/que-shuju@2x.png' | 64 | +import { _, Toast } from '@/utils/generatePackage.js' |
| 66 | -import { ref, onActivated } from 'vue' | ||
| 67 | -import { useRoute, onBeforeRouteLeave } from 'vue-router' | ||
| 68 | -import axios from '@/utils/axios'; | ||
| 69 | -import _ from 'lodash'; | ||
| 70 | -import $ from 'jquery' | ||
| 71 | -import { Toast } from 'vant'; | ||
| 72 | import { addPages, store } from '@/hooks/useKeepAlive' | 65 | import { addPages, store } from '@/hooks/useKeepAlive' |
| 66 | +import { perfInfoAPI, addFollowAPI } from '@/api/C/perf.js' | ||
| 67 | +import { useScrollTop } from '@/composables'; | ||
| 68 | + | ||
| 69 | +const { resetScrollTop } = useScrollTop(); // 页面滚动恢复 | ||
| 70 | +resetScrollTop('scrollTopPerson'); | ||
| 73 | 71 | ||
| 74 | const $route = useRoute(); | 72 | const $route = useRoute(); |
| 75 | 73 | ||
| 76 | const userInfo = ref({}); | 74 | const userInfo = ref({}); |
| 77 | // 因为不能让空图标提前出来的写法 | 75 | // 因为不能让空图标提前出来的写法 |
| 78 | const emptyStatus = ref(false); | 76 | const emptyStatus = ref(false); |
| 79 | -// 获取表演者信息 | 77 | + |
| 80 | -axios.get('/srv/?a=perf_info', { | 78 | +onMounted(async () => { |
| 81 | - params: { | 79 | + // 获取表演者信息 |
| 82 | - perf_id: $route.query.perf_id | 80 | + const { data } = await perfInfoAPI({ perf_id: $route.query.perf_id }); |
| 81 | + if (!data.prod.length) { | ||
| 82 | + emptyStatus.value = true; | ||
| 83 | + } else { | ||
| 84 | + _.each(data.prod, (item) => { | ||
| 85 | + item.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用 | ||
| 86 | + }) | ||
| 87 | + userInfo.value = data; | ||
| 83 | } | 88 | } |
| 84 | -}) | 89 | +}); |
| 85 | - .then(res => { | ||
| 86 | - if (res.data.code === 1) { | ||
| 87 | - _.each(res.data.data.prod, (item) => { | ||
| 88 | - item.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用 | ||
| 89 | - }) | ||
| 90 | - userInfo.value = res.data.data; | ||
| 91 | - if (!res.data.data.prod.length) { | ||
| 92 | - emptyStatus.value = true; | ||
| 93 | - } | ||
| 94 | - } else { | ||
| 95 | - console.warn(res); | ||
| 96 | - if (!res.data.show) return false; | ||
| 97 | - Toast({ | ||
| 98 | - icon: 'close', | ||
| 99 | - message: res.data.msg | ||
| 100 | - }); | ||
| 101 | - } | ||
| 102 | - }) | ||
| 103 | - .catch(err => { | ||
| 104 | - console.error(err); | ||
| 105 | - }); | ||
| 106 | 90 | ||
| 107 | // 关注个人用户 | 91 | // 关注个人用户 |
| 108 | -const followUser = (status) => { | 92 | +const followUser = async () => { |
| 109 | - axios.post('/srv/?a=add_follow', { | 93 | + const { msg } = await addFollowAPI({ perf_id: $route.query.perf_id }); |
| 110 | - perf_id: $route.query.perf_id | 94 | + if (msg === 'add follow OK') { |
| 111 | - }) | 95 | + userInfo.value.is_follow = 1 |
| 112 | - .then(res => { | 96 | + Toast.success('关注成功') |
| 113 | - if (res.data.code === 1) { | 97 | + } else { |
| 114 | - if (res.data.msg === 'add follow OK') { | 98 | + userInfo.value.is_follow = 0 |
| 115 | - userInfo.value.is_follow = 1 | 99 | + Toast.success('取消关注') |
| 116 | - Toast.success('关注成功') | 100 | + } |
| 117 | - } else { | ||
| 118 | - userInfo.value.is_follow = 0 | ||
| 119 | - Toast.success('取消关注') | ||
| 120 | - } | ||
| 121 | - } else { | ||
| 122 | - console.warn(res); | ||
| 123 | - if (!res.data.show) return false; | ||
| 124 | - Toast({ | ||
| 125 | - icon: 'close', | ||
| 126 | - message: res.data.msg | ||
| 127 | - }); | ||
| 128 | - } | ||
| 129 | - }) | ||
| 130 | - .catch(err => { | ||
| 131 | - console.error(err); | ||
| 132 | - }) | ||
| 133 | }; | 101 | }; |
| 134 | 102 | ||
| 135 | /****************** keepAlive 模块 *******************/ | 103 | /****************** keepAlive 模块 *******************/ |
| 136 | 104 | ||
| 137 | // TAG: keepAlive 缓存页面 | 105 | // TAG: keepAlive 缓存页面 |
| 138 | addPages() | 106 | addPages() |
| 139 | -const scrollY = ref(0) | ||
| 140 | 107 | ||
| 141 | onActivated(() => { // keepAlive 重置后执行回调 | 108 | onActivated(() => { // keepAlive 重置后执行回调 |
| 142 | // TAG: pinia应用,动态刷新数据 | 109 | // TAG: pinia应用,动态刷新数据 |
| ... | @@ -152,19 +119,8 @@ onActivated(() => { // keepAlive 重置后执行回调 | ... | @@ -152,19 +119,8 @@ onActivated(() => { // keepAlive 重置后执行回调 |
| 152 | }) | 119 | }) |
| 153 | // 触发更新 | 120 | // 触发更新 |
| 154 | userInfo.value.prod = arr.value; | 121 | userInfo.value.prod = arr.value; |
| 155 | - | 122 | + // 滚动恢复 |
| 156 | - const { scrollTopPerson } = storeToRefs(store); | 123 | + resetScrollTop('scrollTopPerson'); |
| 157 | - // 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 158 | - _.times(2, () => { | ||
| 159 | - $("html,body").animate({ "scrollTop": String(scrollTopPerson.value) + 'px' }); | ||
| 160 | - }); | ||
| 161 | - | ||
| 162 | -}); | ||
| 163 | - | ||
| 164 | -const { scrollTopPerson } = storeToRefs(store); | ||
| 165 | -// 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 166 | -_.times(2, () => { | ||
| 167 | - $("html,body").animate({ "scrollTop": String(scrollTopPerson.value) + 'px' }); | ||
| 168 | }); | 124 | }); |
| 169 | 125 | ||
| 170 | onBeforeRouteLeave(() => { | 126 | onBeforeRouteLeave(() => { |
| ... | @@ -175,23 +131,6 @@ onBeforeRouteLeave(() => { | ... | @@ -175,23 +131,6 @@ onBeforeRouteLeave(() => { |
| 175 | 131 | ||
| 176 | </script> | 132 | </script> |
| 177 | 133 | ||
| 178 | -<script> | ||
| 179 | -export default { | ||
| 180 | - name: 'personIndex', | ||
| 181 | - data() { | ||
| 182 | - return { | ||
| 183 | - | ||
| 184 | - } | ||
| 185 | - }, | ||
| 186 | - mounted() { | ||
| 187 | - | ||
| 188 | - }, | ||
| 189 | - methods: { | ||
| 190 | - | ||
| 191 | - } | ||
| 192 | -} | ||
| 193 | -</script> | ||
| 194 | - | ||
| 195 | <style lang="less" scoped> | 134 | <style lang="less" scoped> |
| 196 | .person-index-page { | 135 | .person-index-page { |
| 197 | .header-wrapper { | 136 | .header-wrapper { |
| ... | @@ -251,11 +190,12 @@ export default { | ... | @@ -251,11 +190,12 @@ export default { |
| 251 | .list-title { | 190 | .list-title { |
| 252 | padding: 0 1rem; | 191 | padding: 0 1rem; |
| 253 | background-color: #F7F7F7; | 192 | background-color: #F7F7F7; |
| 193 | + | ||
| 254 | .title { | 194 | .title { |
| 255 | - color: #222222; | 195 | + color: #222222; |
| 256 | - font-size: 1.1rem; | 196 | + font-size: 1.1rem; |
| 257 | - border-bottom: 2px solid @base-color; | 197 | + border-bottom: 2px solid @base-color; |
| 258 | - padding: 0.5rem; | 198 | + padding: 0.5rem; |
| 259 | text-align: center; | 199 | text-align: center; |
| 260 | } | 200 | } |
| 261 | } | 201 | } | ... | ... |
| ... | @@ -14,30 +14,21 @@ | ... | @@ -14,30 +14,21 @@ |
| 14 | 14 | ||
| 15 | <script setup> | 15 | <script setup> |
| 16 | import VideoCard from '@/components/VideoCard/index.vue' | 16 | import VideoCard from '@/components/VideoCard/index.vue' |
| 17 | -import Cookies from 'js-cookie' | ||
| 18 | import no_image from '@images/que-shuju@2x.png' | 17 | import no_image from '@images/que-shuju@2x.png' |
| 19 | -import { mainStore } from '@/store' | 18 | +import { onBeforeRouteLeave } from 'vue-router' |
| 20 | -import { storeToRefs } from 'pinia' | ||
| 21 | -import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' | ||
| 22 | import { ref } from 'vue' | 19 | import { ref } from 'vue' |
| 23 | import axios from '@/utils/axios'; | 20 | import axios from '@/utils/axios'; |
| 24 | import { Toast } from 'vant'; | 21 | import { Toast } from 'vant'; |
| 25 | -import $ from 'jquery' | ||
| 26 | import _ from 'lodash' | 22 | import _ from 'lodash' |
| 23 | +import { useScrollTop } from '@/composables'; | ||
| 27 | 24 | ||
| 28 | -/******************** 返回点击位置 ********************/ | 25 | +const { resetScrollTop, store } = useScrollTop(); // 页面滚动恢复 |
| 29 | -const store = mainStore(); | 26 | +resetScrollTop('scrollTopCollection'); |
| 30 | -const { scrollTopCollection } = storeToRefs(store); | ||
| 31 | -// 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 32 | -_.times(2, () => { | ||
| 33 | - $("html,body").animate({ "scrollTop": String(scrollTopCollection.value) + 'px' }); | ||
| 34 | -}); | ||
| 35 | 27 | ||
| 36 | onBeforeRouteLeave(() => { | 28 | onBeforeRouteLeave(() => { |
| 37 | // 监听记录滚动位置 | 29 | // 监听记录滚动位置 |
| 38 | store.changeScrollTopCollection(window.scrollY) | 30 | store.changeScrollTopCollection(window.scrollY) |
| 39 | -}) | 31 | +}); |
| 40 | -/*****************************************************/ | ||
| 41 | 32 | ||
| 42 | // 处理书籍下作品列表 | 33 | // 处理书籍下作品列表 |
| 43 | const prodList = ref([]) | 34 | const prodList = ref([]) | ... | ... |
| ... | @@ -14,24 +14,17 @@ | ... | @@ -14,24 +14,17 @@ |
| 14 | 14 | ||
| 15 | <script setup> | 15 | <script setup> |
| 16 | import VideoCard from '@/components/VideoCard/index.vue' | 16 | import VideoCard from '@/components/VideoCard/index.vue' |
| 17 | -import Cookies from 'js-cookie' | ||
| 18 | import no_image from '@images/que-shuju@2x.png' | 17 | import no_image from '@images/que-shuju@2x.png' |
| 19 | -import { mainStore } from '@/store' | 18 | +import { onBeforeRouteLeave } from 'vue-router' |
| 20 | -import { storeToRefs } from 'pinia' | ||
| 21 | -import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' | ||
| 22 | import { ref } from 'vue' | 19 | import { ref } from 'vue' |
| 23 | import axios from '@/utils/axios'; | 20 | import axios from '@/utils/axios'; |
| 24 | import { Toast } from 'vant'; | 21 | import { Toast } from 'vant'; |
| 25 | -import $ from 'jquery' | ||
| 26 | import _ from 'lodash' | 22 | import _ from 'lodash' |
| 23 | +import { useScrollTop } from '@/composables'; | ||
| 27 | 24 | ||
| 28 | /******************** 返回点击位置 ********************/ | 25 | /******************** 返回点击位置 ********************/ |
| 29 | -const store = mainStore(); | 26 | +const { resetScrollTop, store } = useScrollTop(); // 页面滚动恢复 |
| 30 | -const { scrollTopLike } = storeToRefs(store); | 27 | +resetScrollTop('scrollTopLike'); |
| 31 | -// 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 32 | -_.times(2, () => { | ||
| 33 | - $("html,body").animate({ "scrollTop": String(scrollTopLike.value) + 'px' }); | ||
| 34 | -}); | ||
| 35 | 28 | ||
| 36 | onBeforeRouteLeave(() => { | 29 | onBeforeRouteLeave(() => { |
| 37 | // 监听记录滚动位置 | 30 | // 监听记录滚动位置 |
| ... | @@ -67,25 +60,6 @@ axios.get('/srv/?a=my_like') | ... | @@ -67,25 +60,6 @@ axios.get('/srv/?a=my_like') |
| 67 | }); | 60 | }); |
| 68 | </script> | 61 | </script> |
| 69 | 62 | ||
| 70 | -<script> | ||
| 71 | -import mixin from 'common/mixin'; | ||
| 72 | - | ||
| 73 | -export default { | ||
| 74 | - mixins: [mixin.init], | ||
| 75 | - data () { | ||
| 76 | - return { | ||
| 77 | - | ||
| 78 | - } | ||
| 79 | - }, | ||
| 80 | - mounted () { | ||
| 81 | - | ||
| 82 | - }, | ||
| 83 | - methods: { | ||
| 84 | - | ||
| 85 | - } | ||
| 86 | -} | ||
| 87 | -</script> | ||
| 88 | - | ||
| 89 | <style lang="less" scoped> | 63 | <style lang="less" scoped> |
| 90 | 64 | ||
| 91 | </style> | 65 | </style> | ... | ... |
| ... | @@ -17,23 +17,21 @@ | ... | @@ -17,23 +17,21 @@ |
| 17 | </template> | 17 | </template> |
| 18 | 18 | ||
| 19 | <script setup> | 19 | <script setup> |
| 20 | -import { mainStore } from '@/store' | ||
| 21 | import { storeToRefs } from 'pinia' | 20 | import { storeToRefs } from 'pinia' |
| 22 | - | ||
| 23 | import no_image from '@images/que-shuju@2x.png' | 21 | import no_image from '@images/que-shuju@2x.png' |
| 24 | - | ||
| 25 | import { useUnwatchList } from '@/composables/useUnwatchList.js' | 22 | import { useUnwatchList } from '@/composables/useUnwatchList.js' |
| 26 | - | ||
| 27 | import VideoCard from '@/components/VideoCard/index.vue' | 23 | import VideoCard from '@/components/VideoCard/index.vue' |
| 28 | - | 24 | +import { ref, onActivated } from 'vue' |
| 29 | -import { ref, onActivated, computed } from 'vue' | 25 | +import { onBeforeRouteLeave } from 'vue-router' |
| 30 | -import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' | ||
| 31 | import $ from 'jquery' | 26 | import $ from 'jquery' |
| 32 | import _ from 'lodash'; | 27 | import _ from 'lodash'; |
| 33 | import { addPages, store } from '@/hooks/useKeepAlive' | 28 | import { addPages, store } from '@/hooks/useKeepAlive' |
| 29 | +import { useScrollTop } from '@/composables'; | ||
| 34 | 30 | ||
| 35 | const { onLoad, prod_list, finished, loading, finishedTextStatus, emptyStatus } = useUnwatchList(); | 31 | const { onLoad, prod_list, finished, loading, finishedTextStatus, emptyStatus } = useUnwatchList(); |
| 36 | 32 | ||
| 33 | +const { resetScrollTop } = useScrollTop(); // 页面滚动恢复 | ||
| 34 | +resetScrollTop('scrollTop'); | ||
| 37 | /****************** keepAlive 模块 *******************/ | 35 | /****************** keepAlive 模块 *******************/ |
| 38 | 36 | ||
| 39 | // TAG: keepAlive 缓存页面 | 37 | // TAG: keepAlive 缓存页面 |
| ... | @@ -55,18 +53,7 @@ onActivated(() => { // keepAlive 重置后执行回调 | ... | @@ -55,18 +53,7 @@ onActivated(() => { // keepAlive 重置后执行回调 |
| 55 | // 触发更新 | 53 | // 触发更新 |
| 56 | prod_list.value = arr.value; | 54 | prod_list.value = arr.value; |
| 57 | 55 | ||
| 58 | - const { scrollTop } = storeToRefs(store); | 56 | + resetScrollTop('scrollTop'); |
| 59 | - // 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 60 | - _.times(2, () => { | ||
| 61 | - $("html,body").animate({ "scrollTop": String(scrollTop.value) + 'px' }); | ||
| 62 | - }); | ||
| 63 | - | ||
| 64 | -}); | ||
| 65 | - | ||
| 66 | -const { scrollTop } = storeToRefs(store); | ||
| 67 | -// 嵌套滚动,执行两个,先滚外面再滚里面 | ||
| 68 | -_.times(2, () => { | ||
| 69 | - $("html,body").animate({ "scrollTop": String(scrollTop.value) + 'px' }); | ||
| 70 | }); | 57 | }); |
| 71 | 58 | ||
| 72 | onBeforeRouteLeave(() => { | 59 | onBeforeRouteLeave(() => { |
| ... | @@ -78,25 +65,5 @@ onBeforeRouteLeave(() => { | ... | @@ -78,25 +65,5 @@ onBeforeRouteLeave(() => { |
| 78 | 65 | ||
| 79 | </script> | 66 | </script> |
| 80 | 67 | ||
| 81 | -<script> | ||
| 82 | -import mixin from 'common/mixin'; | ||
| 83 | - | ||
| 84 | -export default { | ||
| 85 | - name: 'unwatchList', | ||
| 86 | - mixins: [mixin.init], | ||
| 87 | - data() { | ||
| 88 | - return { | ||
| 89 | - | ||
| 90 | - } | ||
| 91 | - }, | ||
| 92 | - mounted() { | ||
| 93 | - | ||
| 94 | - }, | ||
| 95 | - methods: { | ||
| 96 | - | ||
| 97 | - } | ||
| 98 | -} | ||
| 99 | -</script> | ||
| 100 | - | ||
| 101 | <style lang="less" scoped> | 68 | <style lang="less" scoped> |
| 102 | </style> | 69 | </style> | ... | ... |
-
Please register or login to post a comment