hookehuyr

✨ feat(书籍详情页): 幼儿园捐钱API联调

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-26 23:52:36 3 * @Date: 2022-05-26 23:52:36
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-05-31 10:09:23 5 + * @LastEditTime: 2022-06-01 17:39:48
6 * @FilePath: /tswj/src/App.vue 6 * @FilePath: /tswj/src/App.vue
7 * @Description: 7 * @Description:
8 --> 8 -->
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 import { mainStore, useTitle } from '@/utils/generatePackage' 19 import { mainStore, useTitle } from '@/utils/generatePackage'
20 import { computed, watchEffect } from 'vue'; 20 import { computed, watchEffect } from 'vue';
21 import { useRoute } from 'vue-router' 21 import { useRoute } from 'vue-router'
22 +import { Toast } from 'vant';
22 // 会根据配置判断是否显示调试控件 23 // 会根据配置判断是否显示调试控件
23 // eslint-disable-next-line no-unused-vars 24 // eslint-disable-next-line no-unused-vars
24 import vConsole from '@/utils/vconsole' 25 import vConsole from '@/utils/vconsole'
...@@ -35,6 +36,11 @@ watchEffect( ...@@ -35,6 +36,11 @@ watchEffect(
35 } 36 }
36 ) 37 )
37 38
39 +Toast.setDefaultOptions({
40 + duration: 2000,
41 + className: 'xxx'
42 +});
43 +
38 </script> 44 </script>
39 45
40 <style lang="less"> 46 <style lang="less">
...@@ -71,4 +77,8 @@ body { ...@@ -71,4 +77,8 @@ body {
71 top: 50%; 77 top: 50%;
72 transform: translateY(-50%); 78 transform: translateY(-50%);
73 } 79 }
80 +
81 +.xxx {
82 + z-index: 4500 !important;
83 +}
74 </style> 84 </style>
......
1 +/*
2 + * @Author: hookehuyr hookehuyr@gmail.com
3 + * @Date: 2022-06-01 16:00:48
4 + * @LastEditors: hookehuyr hookehuyr@gmail.com
5 + * @LastEditTime: 2022-06-01 16:37:19
6 + * @FilePath: /tswj/src/api/C/donate.js
7 + * @Description: 捐钱操作API
8 + */
9 +import { fn, fetch } from '@/api/fn';
10 +
11 +const Api = {
12 + PREPARE_DONATE: '/srv/?a=prepare_donate',
13 + ADD_DONATE: '/srv/?a=add_donate',
14 +}
15 +
16 +/**
17 + * @description: 当前用户捐献所需信息
18 + * @summary 适用于 访客进入操作,幼儿园节目操作,表演者节目操作
19 + * @param {String} kg_id 幼儿园ID
20 + * @param {String} perf_id 表演者ID
21 + * @returns
22 + */
23 +export const prepareDonateAPI = (params) => fn(fetch.post(Api.PREPARE_DONATE, params));
24 +
25 +/**
26 + * @description: 用户捐献
27 + * @param {Number} qty 数量
28 + * @param {String} donate_name 捐赠人名称
29 + * @param {Number} kg_id 指定助力幼儿园id
30 + * @param {Number} perf_id 指定助力儿童id
31 + * @returns
32 + */
33 +export const addDonateAPI = (params) => fn(fetch.post(Api.ADD_DONATE, params));
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
36 <div class="date">{{ item.donate_date }}</div> 36 <div class="date">{{ item.donate_date }}</div>
37 <!-- TODO: 编号需要联调 --> 37 <!-- TODO: 编号需要联调 -->
38 <div style="color: #713610; padding: 1rem 2rem; font-size: 0.9rem;"> 38 <div style="color: #713610; padding: 1rem 2rem; font-size: 0.9rem;">
39 - 证书编号:TSWJ202205260005 39 + 证书编号:{{ item.cert_code }}
40 </div> 40 </div>
41 <div class="wrapper-border" /> 41 <div class="wrapper-border" />
42 <div style="height: 2rem;" /> 42 <div style="height: 2rem;" />
......
...@@ -24,19 +24,19 @@ ...@@ -24,19 +24,19 @@
24 </van-col> 24 </van-col>
25 </van-row> 25 </van-row>
26 </div> 26 </div>
27 - <div class="donate-name"> 27 + <div v-if="item.kg_name" class="donate-name">
28 <van-row> 28 <van-row>
29 <van-col span="4" style="line-height: 2;">幼儿园</van-col> 29 <van-col span="4" style="line-height: 2;">幼儿园</van-col>
30 <van-col span="18"> 30 <van-col span="18">
31 - <div class="donate-text">杨浦民办科技幼稚园杨浦民办科技幼稚园</div> 31 + <div class="donate-text">{{ item.kg_name }}</div>
32 </van-col> 32 </van-col>
33 </van-row> 33 </van-row>
34 </div> 34 </div>
35 - <div class="donate-name"> 35 + <div v-if="item.perf_name" class="donate-name">
36 <van-row> 36 <van-row>
37 <van-col span="4" style="line-height: 2;">助力人</van-col> 37 <van-col span="4" style="line-height: 2;">助力人</van-col>
38 <van-col span="18"> 38 <van-col span="18">
39 - <div class="donate-text">瑟日古娜</div> 39 + <div class="donate-text">{{ item.perf_name }}</div>
40 </van-col> 40 </van-col>
41 </van-row> 41 </van-row>
42 </div> 42 </div>
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
44 <van-row> 44 <van-row>
45 <van-col span="4" style="line-height: 2;">捐赠人<span style="color: red;">*</span></van-col> 45 <van-col span="4" style="line-height: 2;">捐赠人<span style="color: red;">*</span></van-col>
46 <van-col class="donate-input" span="18"> 46 <van-col class="donate-input" span="18">
47 - <input v-model="item.perf_name" type="text" style="border: 0; padding: 0.25rem;" /> 47 + <input v-model="item.donate_name" type="text" style="border: 0; padding: 0.25rem;">
48 </van-col> 48 </van-col>
49 </van-row> 49 </van-row>
50 </div> 50 </div>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
55 <van-checkbox v-model="agreed" checked-color="#ee0a24">同意&nbsp;</van-checkbox> 55 <van-checkbox v-model="agreed" checked-color="#ee0a24">同意&nbsp;</van-checkbox>
56 </div> 56 </div>
57 <div style="display: flex; flex-direction: column; justify-content: center;"> 57 <div style="display: flex; flex-direction: column; justify-content: center;">
58 - <span style="text-decoration: underline; color: #713610;" @click="handleDonationAgreement">捐赠协议</span> 58 + <span style="text-decoration: underline; color: #713610;" @click="handleDA">捐赠协议</span>
59 </div> 59 </div>
60 </div> 60 </div>
61 </van-col> 61 </van-col>
...@@ -66,99 +66,82 @@ ...@@ -66,99 +66,82 @@
66 <my-button type="plain" @on-click="cancelDonate">取消</my-button> 66 <my-button type="plain" @on-click="cancelDonate">取消</my-button>
67 </div> 67 </div>
68 <div class="donate-imd"> 68 <div class="donate-imd">
69 - <my-button type="primary" @on-click="donateBook">确定</my-button> 69 + <my-button type="primary" @on-click="donateFlower">确定</my-button>
70 </div> 70 </div>
71 </div> 71 </div>
72 </div> 72 </div>
73 </van-popup> 73 </van-popup>
74 - <van-popup v-model:show="showDonationAgreement" position="bottom" :style="{ height: '100%', zIndex: 4000 }"> 74 + <!-- TODO: 正式文案需要更新 -->
75 + <van-popup v-model:show="showDA" position="bottom" :style="{ height: '100%', zIndex: 4000 }">
75 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque earum voluptates architecto! Itaque magnam modi ducimus minima. Ullam quam, excepturi modi cupiditate quidem optio consequuntur minus porro, saepe, neque incidunt! 76 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque earum voluptates architecto! Itaque magnam modi ducimus minima. Ullam quam, excepturi modi cupiditate quidem optio consequuntur minus porro, saepe, neque incidunt!
76 - <div class="bottom-btn" @click="closeDonationAgreement"> 77 + <div class="bottom-btn" @click="closeDA">
77 <div class="text">关闭</div> 78 <div class="text">关闭</div>
78 </div> 79 </div>
79 </van-popup> 80 </van-popup>
80 </template> 81 </template>
81 82
82 <script setup> 83 <script setup>
83 -import Cookies from 'js-cookie'
84 import { icon_flower } from '@/utils/generateIcons' 84 import { icon_flower } from '@/utils/generateIcons'
85 -
86 import MyButton from '@/components/MyButton/index.vue' 85 import MyButton from '@/components/MyButton/index.vue'
87 -import { ref, reactive, onMounted, watch, nextTick } from 'vue' 86 +import { ref, onMounted, watch, nextTick } from 'vue'
88 -import { useRoute, useRouter } from 'vue-router' 87 +import { useRouter } from 'vue-router'
89 -import axios from '@/utils/axios'; 88 +import { $, Toast } from '@/utils/generatePackage'
90 -import $ from 'jquery' 89 +import { addDonateAPI } from '@/api/C/donate.js'
91 -import { Toast, Dialog } from 'vant';
92 -const $route = useRoute();
93 -const $router = useRouter();
94 90
91 +const $router = useRouter();
95 const props = defineProps({ 92 const props = defineProps({
96 item: Object, 93 item: Object,
97 showPopup: Boolean 94 showPopup: Boolean
98 }) 95 })
99 -
100 const emit = defineEmits(['on-close']); 96 const emit = defineEmits(['on-close']);
101 97
102 let donate_number = ref(1); 98 let donate_number = ref(1);
103 -const donateBook = () => { 99 +const donateFlower = async () => {
104 - // 爱心捐书接口 100 + if (!agreed.value) {
105 - axios.post('/srv/?a=add_donate', { 101 + Toast.fail('请选勾选同意按钮!');
106 - book_id: props.item.book_id, 102 + return false;
107 - qty: donate_number.value, 103 + }
108 - donate_name: props.item.perf_name, 104 + // 捐钱接口
109 - }) 105 + const { data } = await addDonateAPI({ qty: donate_number.value, donate_name: props.item.donate_name, kg_id: props.item.kg_id, perf_id: props.item.perf_id });
110 - .then(res => { 106 + if (data.id) {
111 - if (res.data.code === 1) { 107 + closeBtn();
112 - console.warn(res.data.data); 108 + // 交易成功跳转回调页面
113 - closeBtn(); 109 + // TEMP: 临时传参 donate_id
114 - 110 + $router.push({
115 - // 交易成功跳转回调页面 111 + path: '/client/wechatpayCallback',
116 - // TEMP: 临时传参 donate_id 112 + query: {
117 - $router.push({ 113 + donate_id: data.id
118 - path: '/client/wechatpayCallback',
119 - query: {
120 - donate_id: res.data.data.id
121 - }
122 - })
123 - } else {
124 - console.warn(res);
125 - if (!res.data.show) return false;
126 - Toast({
127 - icon: 'close',
128 - message: res.data.msg
129 - });
130 } 114 }
131 }) 115 })
132 - .catch(err => { 116 + }
133 - console.error(err);
134 - })
135 } 117 }
136 118
137 const show = ref(false); 119 const show = ref(false);
138 let popupHeight = ref('100%'); 120 let popupHeight = ref('100%');
139 121
140 watch(() => props.showPopup, (v) => { 122 watch(() => props.showPopup, (v) => {
141 - // 如果没有默认儿童需要用户确认一次 123 + // 现在新需求只要钱,多余步骤先屏蔽掉。
142 - if (v && !props.item.perf_id) { 124 + // // 如果没有默认儿童需要用户确认一次
143 - Dialog.confirm({ 125 + // if (v && !props.item.perf_id) {
144 - title: '温馨提示', 126 + // Dialog.confirm({
145 - message: '默认儿童为空, 是否继续捐书!', 127 + // title: '温馨提示',
146 - confirmButtonColor: '#713610' 128 + // message: '默认儿童为空, 是否继续助力!',
147 - }) 129 + // confirmButtonColor: '#713610'
148 - .then(() => { 130 + // })
149 - show.value = v; 131 + // .then(() => {
150 - // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果 132 + // show.value = v;
151 - nextTick(() => { 133 + // // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果
152 - let height = $('.donate-wrapper').height(); 134 + // nextTick(() => {
153 - popupHeight.value = height + 10 + 'px'; 135 + // let height = $('.donate-wrapper').height();
154 - }) 136 + // popupHeight.value = height + 10 + 'px';
155 - }) 137 + // })
156 - .catch(() => { 138 + // })
157 - // 取消按钮回调 139 + // .catch(() => {
158 - closeBtn(); 140 + // // 取消按钮回调
159 - }); 141 + // closeBtn();
160 - return false; 142 + // });
161 - } 143 + // return false;
144 + // }
162 show.value = v; 145 show.value = v;
163 // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果 146 // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果
164 nextTick(() => { 147 nextTick(() => {
...@@ -190,12 +173,12 @@ const checkList = ref({ ...@@ -190,12 +173,12 @@ const checkList = ref({
190 // 捐赠协议 173 // 捐赠协议
191 const agreed = ref(false); 174 const agreed = ref(false);
192 // 显示捐赠协议弹框 175 // 显示捐赠协议弹框
193 -const showDonationAgreement = ref(false); 176 +const showDA = ref(false);
194 -const handleDonationAgreement = () => { 177 +const handleDA = () => {
195 - showDonationAgreement.value = true 178 + showDA.value = true
196 } 179 }
197 -const closeDonationAgreement = () => { 180 +const closeDA = () => {
198 - showDonationAgreement.value = false 181 + showDA.value = false
199 } 182 }
200 </script> 183 </script>
201 184
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
111 </div> 111 </div>
112 </notice-overlay> 112 </notice-overlay>
113 113
114 - <donate-flower :show-popup="showDonate" :item="userInfo" @on-close="closeDonate" /> 114 + <donate-flower :show-popup="showDonate" :item="donateInfo" @on-close="closeDonate" />
115 115
116 <van-overlay :show="show" z-index="9999"> 116 <van-overlay :show="show" z-index="9999">
117 <div class="wrapper" @click.stop> 117 <div class="wrapper" @click.stop>
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
121 </template> 121 </template>
122 122
123 <script setup> 123 <script setup>
124 -import { ref, onActivated, nextTick } from 'vue' 124 +import { ref, onActivated, nextTick, onMounted } from 'vue'
125 import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' 125 import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
126 import { Cookies, _, storeToRefs, mainStore, Toast, hasEllipsis } from '@/utils/generatePackage' 126 import { Cookies, _, storeToRefs, mainStore, Toast, hasEllipsis } from '@/utils/generatePackage'
127 import { MyButton, VideoCard, NoticeOverlay, DonateFlower, ShortcutFixed } from '@/utils/generateModules' 127 import { MyButton, VideoCard, NoticeOverlay, DonateFlower, ShortcutFixed } from '@/utils/generateModules'
...@@ -129,6 +129,7 @@ import { icon_video, icon_up, icon_down, icon_subscribed, icon_unsubscribe, no_i ...@@ -129,6 +129,7 @@ import { icon_video, icon_up, icon_down, icon_subscribed, icon_unsubscribe, no_i
129 import { JSJ_FORM_C } from '@/constant' 129 import { JSJ_FORM_C } from '@/constant'
130 import { useVideoList, useDefaultPerf, useShortcutBar, useScrollTop } from '@/composables'; 130 import { useVideoList, useDefaultPerf, useShortcutBar, useScrollTop } from '@/composables';
131 import { addSubscribeAPI } from '@/api/C/book.js' 131 import { addSubscribeAPI } from '@/api/C/book.js'
132 +import { prepareDonateAPI } from '@/api/C/donate.js'
132 133
133 const { shortcutItem } = useShortcutBar(['home', 'me']); // 配置快捷跳转条 134 const { shortcutItem } = useShortcutBar(['home', 'me']); // 配置快捷跳转条
134 const { resetScrollTop } = useScrollTop(); // 页面滚动恢复 135 const { resetScrollTop } = useScrollTop(); // 页面滚动恢复
...@@ -140,6 +141,12 @@ const $router = useRouter(); ...@@ -140,6 +141,12 @@ const $router = useRouter();
140 const { toggleLanguage, onLoad, columns, prod_list, finished, loading, bookInfo, showPicker, checkLocalism, checkMandarin, onConfirm, chooseLanguage, finishedTextStatus, emptyStatus } = useVideoList($route); 141 const { toggleLanguage, onLoad, columns, prod_list, finished, loading, bookInfo, showPicker, checkLocalism, checkMandarin, onConfirm, chooseLanguage, finishedTextStatus, emptyStatus } = useVideoList($route);
141 const { userInfo } = useDefaultPerf($route.query.id); 142 const { userInfo } = useDefaultPerf($route.query.id);
142 143
144 +const donateInfo = ref({})
145 +onMounted(async () => {
146 + const { data } = await prepareDonateAPI({ kg_id: $route.query.kg_id });
147 + donateInfo.value = data;
148 +})
149 +
143 // 判断是否显示简介的展开图标 150 // 判断是否显示简介的展开图标
144 const hasToggle = ref(false); // 判断是否有展开文字,默认没有 151 const hasToggle = ref(false); // 判断是否有展开文字,默认没有
145 const isToggle = ref(true); // 判断展开状态,默认展开 152 const isToggle = ref(true); // 判断展开状态,默认展开
...@@ -169,7 +176,6 @@ const onSubscribe = async () => { ...@@ -169,7 +176,6 @@ const onSubscribe = async () => {
169 const showDonate = ref(false); 176 const showDonate = ref(false);
170 177
171 const toDonate = () => { 178 const toDonate = () => {
172 - // TODO:需要新写组件捐钱
173 showDonate.value = true; 179 showDonate.value = true;
174 } 180 }
175 181
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
53 </div> 53 </div>
54 <div class="book-list"> 54 <div class="book-list">
55 <template v-for="(item, key) in kgInfo.book_list" :key="key"> 55 <template v-for="(item, key) in kgInfo.book_list" :key="key">
56 - <book-card type="C" :item="item" @on-click="go('/client/bookDetail', { id: item.id })" /> 56 + <book-card type="C" :item="item" @on-click="go('/client/bookDetail', { id: item.id, kg_id })" />
57 </template> 57 </template>
58 <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍信息" /> 58 <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍信息" />
59 </div> 59 </div>
......