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-11 17:59:16 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7042b6f2c165992a29fdd36be687ff4f81253c8b
7042b6f2
1 parent
ba44084f
✨ feat: 捐书功能模块API联调
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
145 additions
and
40 deletions
src/App.vue
src/components/DonateBook/index.vue
src/components/DonateCert/index.vue
src/utils/axios.js
src/views/client/bookDetail.vue
src/views/client/donateCertificate.vue
src/views/client/finishUpload.vue
src/views/client/wechatpayCallback.vue
src/App.vue
View file @
7042b6f
...
...
@@ -3,16 +3,38 @@
</template>
<script setup>
import Cookies from 'js-cookie'
import axios from '@/utils/axios'
import { useRoute, useRouter } from 'vue-router'
import { onMounted } from 'vue'
import { Toast } from 'vant'
import { mainStore } from './store';
const store = mainStore();
const $router = useRouter();
onMounted(() => {
})
/**
* 获取默认儿童信息
* @returns name, perf_id, kg_id
*/
if (!Cookies.get('default_perf')) {
axios.get('/srv/?a=default_perf')
.then(res => {
if (res.data.code === 1) {
Cookies.set('default_perf', JSON.stringify(res.data.data));
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
});
}
</script>
<style lang="less">
...
...
@@ -37,4 +59,4 @@ body {
padding: 0;
}
}
</style>
\ No newline at end of file
</style>
...
...
src/components/DonateBook/index.vue
View file @
7042b6f
...
...
@@ -5,13 +5,13 @@
<van-row>
<van-col>
<div class="donate-book">
<van-image width="80" height="80"
src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngc434046fdf1f9499d251b280af2568ddbe64839799d00a9aee226edbeb710aed
" />
<van-image width="80" height="80"
:src="item.avatar
" />
</div>
</van-col>
<van-col>
<div class="donate-detail">
<p class="text">
逃家小兔绘本
</p>
<p class="price">¥
59
</p>
<p class="text">
{{ item.name }}
</p>
<p class="price">¥
{{ item.price }}
</p>
</div>
</van-col>
</van-row>
...
...
@@ -50,6 +50,8 @@
</template>
<script setup>
import Cookies from 'js-cookie'
import MyButton from '@/components/MyButton/index.vue'
import { ref, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
...
...
@@ -70,7 +72,7 @@ onMounted(() => {
import mixin from 'common/mixin';
export default {
props: ['showPopup'],
props: ['showPopup'
, 'item'
],
mixins: [mixin.init],
data() {
return {
...
...
@@ -81,6 +83,9 @@ export default {
}
},
mounted() {
// 缺省儿童信息
const default_perf = Cookies.get('default_perf') ? JSON.parse(Cookies.get('default_perf')) : '';
this.donate_name = default_perf.name;
},
watch: {
showPopup(value, pre) {
...
...
@@ -103,13 +108,31 @@ export default {
this.closeBtn();
},
donateBook() {
console.warn(this.donate_name);
console.warn(this.donate_number);
this.closeBtn();
// 爱心捐书接口
axios.post('/srv/?a=add_donate', {
book_id: this.item.book_id,
qty: this.donate_number,
donate_name: this.donate_name,
})
.then(res => {
if (res.data.code === 1) {
console.warn(res.data.data);
this.closeBtn();
// 交易成功跳转回调页面
this.$router.push({
path: '/client/wechatpayCallback'
// 交易成功跳转回调页面
this.$router.push({
path: '/client/wechatpayCallback'
})
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
},
}
...
...
@@ -172,4 +195,4 @@ export default {
flex: 1;
padding: 0 0.5rem;
}
</style>
\ No newline at end of file
</style>
...
...
src/components/DonateCert/index.vue
View file @
7042b6f
...
...
@@ -9,7 +9,7 @@
<span style="font-size: 0.8rem; color: #272727;">尊敬的</span>
</van-col>
<van-col>
<div style="color: #713610; padding: 1rem;" class="van-hairline--bottom">{{ name }}</div>
<div style="color: #713610; padding: 1rem;" class="van-hairline--bottom">{{
item.
name }}</div>
</van-col>
<van-col>:</van-col>
</van-row>
...
...
@@ -19,7 +19,7 @@
</div>
<div class="price">
<div>爱心捐赠</div>
<div>{{
price
}} 元</div>
<div>{{
item.amt
}} 元</div>
</div>
<div class="organizer">
<div class="wrapper">
...
...
@@ -33,7 +33,7 @@
</div>
</div>
</div>
<div class="date">{{
datetim
e }}</div>
<div class="date">{{
item.donate_dat
e }}</div>
</div>
</template>
...
...
@@ -60,6 +60,7 @@ import mixin from 'common/mixin';
export default {
mixins: [mixin.init],
props: ['item'],
data() {
return {
name: '杨桐桐',
...
...
@@ -132,4 +133,4 @@ export default {
padding-right: 2rem;
}
}
</style>
\ No newline at end of file
</style>
...
...
src/utils/axios.js
View file @
7042b6f
...
...
@@ -16,7 +16,6 @@ axios.interceptors.request.use(
// 绑定默认请求头
config
.
params
=
_
.
merge
(
config
.
params
,
{
f
:
'voice'
,
client_id
:
'313939'
})
return
config
;
},
...
...
src/views/client/bookDetail.vue
View file @
7042b6f
...
...
@@ -75,7 +75,7 @@
<span style="font-size: 0.85rem;">订阅</span>
</div>
<div class="button">
<my-button @on-click="
payFor
" type="plain">爱心捐书</my-button>
<my-button @on-click="
toDonate
" type="plain">爱心捐书</my-button>
</div>
<div class="button">
<my-button @on-click="uploadVideo" type="primary">上传作品</my-button>
...
...
@@ -91,6 +91,9 @@
<p>请前往个人中心进行实名认证</p>
</div>
</notice-overlay>
<donate-book :showPopup="showDonate" :item="donateItem" @on-close="closeDonate"></donate-book>
</template>
<script setup>
...
...
@@ -100,6 +103,7 @@ import { useVideoList } from '@/composables/useVideoList.js'
import MyButton from '@/components/MyButton/index.vue'
import VideoCard from '@/components/VideoCard/index.vue'
import NoticeOverlay from '@/components/NoticeOverlay/index.vue'
import DonateBook from '@/components/DonateBook/index.vue'
import icon_video from '@images/video.png'
import icon_up from '@images/icon-guanbi@2x.png'
...
...
@@ -168,11 +172,26 @@ const onSubscribe = () => {
})
}
// 爱心捐书
// TODO: 需要联调捐书接口
const payFor = () => {
console.warn('弹出框');
/*************** 捐书模块START ***************/
const donateItem = ref({})
// 弹出捐赠弹框模块
const showDonate = ref(false);
const toDonate = () => {
showDonate.value = true;
// 捐书数据
donateItem.value = {
book_id: $route.query.id,
avatar: bookInfo.value.cover,
name: bookInfo.value.name,
price: bookInfo.value.price
}
}
const closeDonate = (v) => {
showDonate.value = v;
}
/**********************************/
// 跳转个人中心
const onSubmit = () => {
...
...
@@ -197,9 +216,12 @@ const uploadVideo = () => {
if (res.data.code === 1) {
// 实名认证标识
if (res.data.data.can_upload) {
// TODO: 上传视频直接跳转?不需要表示判断是上传哪个幼儿园吗?
if (Cookies.get('privacy_notice')) { // 已读隐私条例,直接跳转上传页面
location.href = 'https://jinshuju.net/f/NAGn1D';
// 已读隐私条例,直接跳转上传页面
if (Cookies.get('privacy_notice')) {
// x_field_1是金数据表单传入的参数,家长上传的格式为:book_id-perf_id,perf_id是当前缺省的儿童id
let default_perf = Cookies.get('default_perf') ? JSON.parse(Cookies.get('default_perf')) : '';
let str = `${$route.query.id}-${default_perf.perf_id}`
location.href = `https://jinshuju.net/f/NAGn1D?x_field_1=${str}`;
} else {
$router.push({
path: '/client/privacyNotice'
...
...
src/views/client/donateCertificate.vue
View file @
7042b6f
<template>
<div class="donate-certificate-page content-bg">
<donate-cert></donate-cert>
<donate-cert
:item="certItem"
></donate-cert>
</div>
<shortcut-fixed type="C" :item="shortcutItem"></shortcut-fixed>
</template>
<script setup>
import DonateCert from '@/components/DonateCert/index.vue'
import ShortcutFixed from '@/components/ShortcutFixed/index.vue'
import { ref, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
...
...
@@ -15,11 +17,30 @@ import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
// TODO: 捐款成功后,查询生成捐赠证书
// 配置快捷跳转条
const shortcutItem = ref(['home']);
onMounted(() => {
})
const certItem = ref('')
// TODO: 捐款成功后,查询生成捐赠证书
axios.get('/srv/?a=one_cert', {
params: {
donate_id: $route.query.donate_id
}
})
.then(res => {
if (res.data.code === 1) {
certItem.value = res.data.data;
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
</script>
<script>
...
...
@@ -47,4 +68,4 @@ export default {
height: 96vh;
padding: 2vh;
}
</style>
\ No newline at end of file
</style>
...
...
src/views/client/finishUpload.vue
View file @
7042b6f
...
...
@@ -18,7 +18,7 @@
</div>
</div>
<donate-book :showPopup="showDonate" @on-close="closeDonate"></donate-book>
<donate-book :showPopup="showDonate"
:item="donateItem"
@on-close="closeDonate"></donate-book>
</template>
<script setup>
...
...
@@ -35,16 +35,29 @@ import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
// TODO: 作品上传完成后,回调到成功页面
/*************** 捐书模块START ***************/
const donateItem = ref({})
// TODO: 作品上传完成后,回调到成功页面,需要返回书籍的详情
// 弹出捐赠弹框模块
const showDonate = ref(false);
const closeDonate = (v) => { // 查看更多回复
showDonate.value = v;
}
const toDonate = () => {
showDonate.value = true;
// TODO: 这些信息到时候需要后台带过来
donateItem.value = {
book_id: '314134',
avatar: 'https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngc434046fdf1f9499d251b280af2568ddbe64839799d00a9aee226edbeb710aed',
name: '逃家小兔绘本',
price: '59'
}
}
const closeDonate = (v) => {
showDonate.value = v;
}
/**********************************/
const goBack = () => {
$router.push({
path: '/client/bookDetail'
...
...
@@ -81,4 +94,4 @@ export default {
color: #222222;
text-align: center;
}
</style>
\ No newline at end of file
</style>
...
...
src/views/client/wechatpayCallback.vue
View file @
7042b6f
...
...
@@ -52,9 +52,13 @@ export default {
},
methods: {
getCert () {
// TODO: 需要获取 donate_id
// 跳转到捐赠证书页面,替换掉当前页面,不能返回这个页面
this.$router.replace({
path: '/client/donateCertificate'
path: '/client/donateCertificate',
query: {
donate_id: '314358' // 测试默认值
}
});
}
}
...
...
Please
register
or
login
to post a comment