Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-06 09:52:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
57d3caa4ab6c18814a5424151851db3122d67e5e
57d3caa4
1 parent
a2f65c8f
✨ feat(书籍详情页): API联调
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
25 deletions
src/composables/useVideoList.js
src/views/client/bookDetail.vue
src/composables/useVideoList.js
View file @
57d3caa
...
...
@@ -8,9 +8,18 @@ export const useVideoList = ($route) => {
const
checkMandarin
=
ref
(
true
);
// 普通话选项卡
const
checkLocalism
=
ref
(
false
);
// 方言选项卡
const
chooseLanguage
=
ref
({
text
:
'普通话'
,
val
:
'普通话'
});
// 默认选中普通话
const
toggleLanguage
=
()
=>
{
checkMandarin
.
value
=
!
checkMandarin
.
value
;
checkLocalism
.
value
=
!
checkLocalism
.
value
;
/**
* 切换视频语言回调
* @param {*} type
*/
const
toggleLanguage
=
(
type
)
=>
{
if
(
type
===
'mandarin'
)
{
checkMandarin
.
value
=
true
;
checkLocalism
.
value
=
false
;
}
else
{
checkMandarin
.
value
=
false
;
checkLocalism
.
value
=
true
;
}
// 修改默认语言绑定数据
if
(
checkLocalism
.
value
)
{
// tslint:disable-next-line:no-string-literal
...
...
@@ -19,40 +28,45 @@ export const useVideoList = ($route) => {
chooseLanguage
.
value
=
{
text
:
'普通话'
,
val
:
'普通话'
};
}
// 切换语言需要更新列表数据
offset
.
value
=
0
prod_list
.
value
=
[]
loading
.
value
=
true
;
finished
.
value
=
false
;
onLoad
()
onReload
()
}
// 方言选择项
const
columns
=
[
{
text
:
'所有方言'
,
val
:
'所有方言'
},
{
text
:
'沪语'
,
val
:
'沪语
'
},
{
text
:
'粤语'
,
val
:
'粤语
'
},
{
text
:
'上海话'
,
val
:
'上海话
'
},
{
text
:
'广东话'
,
val
:
'广东话
'
},
];
const
showPicker
=
ref
(
false
);
/**
* 选择方言确认后回调
* @param {*} param
*/
const
onConfirm
=
({
selectedOptions
})
=>
{
showPicker
.
value
=
false
;
chooseLanguage
.
value
=
{
text
:
selectedOptions
[
0
].
text
,
val
:
selectedOptions
[
0
].
val
}
onReload
()
};
// 绑定页面数据
const
bookInfo
=
ref
(
''
);
// tslint:disable-next-line: variable-name
const
prod_list
=
ref
([]);
const
limit
=
ref
(
1
)
const
limit
=
ref
(
10
)
const
offset
=
ref
(
0
)
// 处理书籍下作品列表
const
loading
=
ref
(
false
);
const
finished
=
ref
(
false
);
/**
* 向下滚动查询数据
*/
const
onLoad
=
()
=>
{
// 异步更新数据
axios
.
get
(
'/srv/?a=book_info'
,
{
...
...
@@ -89,6 +103,17 @@ export const useVideoList = ($route) => {
})
};
/**
* 重载刷新程序
*/
const
onReload
=
()
=>
{
offset
.
value
=
0
prod_list
.
value
=
[]
loading
.
value
=
true
;
finished
.
value
=
false
;
onLoad
()
}
return
{
toggleLanguage
,
onLoad
,
...
...
src/views/client/bookDetail.vue
View file @
57d3caa
...
...
@@ -36,10 +36,10 @@
<div class="book-video-language">
<van-row>
<van-col span="6">
<div @click="toggleLanguage" :class="[checkMandarin ? 'checked' : 'uncheck']">普通话</div>
<div @click="toggleLanguage
('mandarin')
" :class="[checkMandarin ? 'checked' : 'uncheck']">普通话</div>
</van-col>
<van-col span="6">
<div @click="toggleLanguage" :class="[checkLocalism ? 'checked' : 'uncheck']">方言</div>
<div @click="toggleLanguage
('localism')
" :class="[checkLocalism ? 'checked' : 'uncheck']">方言</div>
</van-col>
<van-col span="12" v-if="checkLocalism" @click="showPicker = true">
<div class="choose-wrapper">
...
...
@@ -156,10 +156,33 @@ onMounted(() => {
})
})
// 书籍订阅
/**
* 书籍订阅
*/
let is_subscribe = ref(false);
const onSubscribe = () => {
is_subscribe.value = !is_subscribe.value
axios.post('/srv/?a=prod_action', {
action_type: 'like',
prod_id: $route.query.id
})
.then(res => {
if (res.data.code === 1) {
if (res.data.msg === 'like-add-OK') {
is_subscribe.value = true;
} else {
is_subscribe.value = false;
}
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
}
// 爱心捐书
...
...
@@ -172,20 +195,37 @@ const showNotice = ref(false)
const closeNotice = () => {
showNotice.value = false;
}
/**
* 上传作品回调
*/
const uploadVideo = () => {
axios.get('/srv/?a=can_upload')
.then(res => {
if (res.data.code === 1) {
if (res.data.data.can_upload) {
// 实名认证之后直接跳转上传页面
location.href = 'http://jsj.onwall.cn/f/gZntnp';
} else {
// 如果没有实名认证需要提示用户实名认证
showNotice.value = true;
// 实名认证之后直接跳转上传页面
}
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
}
</script>
<script>
import mixin from 'common/mixin';
function transCaseList(url, pic) {
return { url, pic }
}
export default {
mixins: [mixin.init],
data() {
...
...
@@ -283,11 +323,6 @@ export default {
}
}
}
.book-video-list {
// height: 20rem;
// overflow: scroll;
}
}
.book-bar {
...
...
Please
register
or
login
to post a comment