Showing
1 changed file
with
53 additions
and
46 deletions
| ... | @@ -55,7 +55,7 @@ import Cookies from 'js-cookie' | ... | @@ -55,7 +55,7 @@ import Cookies from 'js-cookie' |
| 55 | import icon_avatar from '@images/que-touxiang@2x.png' | 55 | import icon_avatar from '@images/que-touxiang@2x.png' |
| 56 | 56 | ||
| 57 | import MyButton from '@/components/MyButton/index.vue' | 57 | import MyButton from '@/components/MyButton/index.vue' |
| 58 | -import { ref, reactive, onMounted } from 'vue' | 58 | +import { ref, reactive, onMounted, watch, nextTick } from 'vue' |
| 59 | import { useRoute, useRouter } from 'vue-router' | 59 | import { useRoute, useRouter } from 'vue-router' |
| 60 | import axios from '@/utils/axios'; | 60 | import axios from '@/utils/axios'; |
| 61 | import $ from 'jquery' | 61 | import $ from 'jquery' |
| ... | @@ -63,63 +63,29 @@ import { Toast } from 'vant'; | ... | @@ -63,63 +63,29 @@ import { Toast } from 'vant'; |
| 63 | const $route = useRoute(); | 63 | const $route = useRoute(); |
| 64 | const $router = useRouter(); | 64 | const $router = useRouter(); |
| 65 | 65 | ||
| 66 | -// TODO: 微信支付 | 66 | +const props = defineProps({ |
| 67 | - | 67 | + item: Object, |
| 68 | -onMounted(() => { | 68 | + showPopup: Boolean |
| 69 | - | ||
| 70 | }) | 69 | }) |
| 71 | -</script> | ||
| 72 | 70 | ||
| 73 | -<script> | 71 | +const emit = defineEmits(['on-close']); |
| 74 | -import mixin from 'common/mixin'; | ||
| 75 | 72 | ||
| 76 | -export default { | 73 | +let donate_number = ref(1) |
| 77 | - props: ['showPopup', 'item'], | 74 | +const donateBook = () => { |
| 78 | - mixins: [mixin.init], | ||
| 79 | - data() { | ||
| 80 | - return { | ||
| 81 | - popupHeight: '60%', | ||
| 82 | - show: false, | ||
| 83 | - donate_number: 1, | ||
| 84 | - } | ||
| 85 | - }, | ||
| 86 | - mounted() { | ||
| 87 | - }, | ||
| 88 | - watch: { | ||
| 89 | - showPopup(value, pre) { | ||
| 90 | - if (value) { | ||
| 91 | - this.show = value; | ||
| 92 | - // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果 | ||
| 93 | - this.$nextTick(() => { | ||
| 94 | - let height = $('.donate-wrapper').height(); | ||
| 95 | - this.popupHeight = height + 10 + 'px'; | ||
| 96 | - }) | ||
| 97 | - } | ||
| 98 | - } | ||
| 99 | - }, | ||
| 100 | - methods: { | ||
| 101 | - closeBtn() { | ||
| 102 | - this.$emit('on-close', false) | ||
| 103 | - this.show = false; | ||
| 104 | - }, | ||
| 105 | - cancelDonate() { | ||
| 106 | - this.closeBtn(); | ||
| 107 | - }, | ||
| 108 | - donateBook() { | ||
| 109 | // 爱心捐书接口 | 75 | // 爱心捐书接口 |
| 110 | axios.post('/srv/?a=add_donate', { | 76 | axios.post('/srv/?a=add_donate', { |
| 111 | - book_id: this.item.book_id, | 77 | + book_id: props.item.book_id, |
| 112 | - qty: this.donate_number, | 78 | + qty: donate_number.value, |
| 113 | - donate_name: this.item.perf_name, | 79 | + donate_name: props.item.perf_name, |
| 114 | }) | 80 | }) |
| 115 | .then(res => { | 81 | .then(res => { |
| 116 | if (res.data.code === 1) { | 82 | if (res.data.code === 1) { |
| 117 | console.warn(res.data.data); | 83 | console.warn(res.data.data); |
| 118 | - this.closeBtn(); | 84 | + closeBtn(); |
| 119 | 85 | ||
| 120 | // 交易成功跳转回调页面 | 86 | // 交易成功跳转回调页面 |
| 121 | // TEMP: 临时传参 donate_id | 87 | // TEMP: 临时传参 donate_id |
| 122 | - this.$router.push({ | 88 | + $router.push({ |
| 123 | path: '/client/wechatpayCallback', | 89 | path: '/client/wechatpayCallback', |
| 124 | query: { | 90 | query: { |
| 125 | donate_id: res.data.data.id | 91 | donate_id: res.data.data.id |
| ... | @@ -137,7 +103,48 @@ export default { | ... | @@ -137,7 +103,48 @@ export default { |
| 137 | .catch(err => { | 103 | .catch(err => { |
| 138 | console.error(err); | 104 | console.error(err); |
| 139 | }) | 105 | }) |
| 106 | +} | ||
| 107 | + | ||
| 108 | +const show = ref(false); | ||
| 109 | +let popupHeight = ref('60%'); | ||
| 110 | + | ||
| 111 | +watch(() => props.showPopup, (v) => { | ||
| 112 | + show.value = v | ||
| 113 | + // DOM调整后,把弹出框高度设定到适合高度,配合不同分辨率效果 | ||
| 114 | + nextTick(() => { | ||
| 115 | + let height = $('.donate-wrapper').height(); | ||
| 116 | + popupHeight.value = height + 10 + 'px'; | ||
| 117 | + }) | ||
| 118 | +}) | ||
| 119 | + | ||
| 120 | +const closeBtn = () => { | ||
| 121 | + emit('on-close', false) | ||
| 122 | + show.value = false; | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +const cancelDonate = () => { | ||
| 126 | + closeBtn(); | ||
| 127 | +} | ||
| 128 | + | ||
| 129 | +// TODO: 微信支付 | ||
| 130 | + | ||
| 131 | +onMounted(() => { | ||
| 132 | + | ||
| 133 | +}) | ||
| 134 | +</script> | ||
| 135 | + | ||
| 136 | +<script> | ||
| 137 | +import mixin from 'common/mixin'; | ||
| 138 | + | ||
| 139 | +export default { | ||
| 140 | + mixins: [mixin.init], | ||
| 141 | + data() { | ||
| 142 | + return { | ||
| 143 | + } | ||
| 140 | }, | 144 | }, |
| 145 | + mounted() { | ||
| 146 | + }, | ||
| 147 | + methods: { | ||
| 141 | } | 148 | } |
| 142 | } | 149 | } |
| 143 | </script> | 150 | </script> | ... | ... |
-
Please register or login to post a comment