This commit is contained in:
2023-09-06 03:49:21 +08:00
parent 8b5de95140
commit b6ca53f70e
39 changed files with 2146 additions and 679 deletions

View File

@@ -29,7 +29,7 @@
<nut-cell
v-if="payType === 'jf'"
title="积分支付"
desc="剩余积分:18888"
:desc="`剩余积分:${info.integral || 0}`"
is-link
@click="goPay()"
>
@@ -46,10 +46,12 @@
</template>
<script setup lang="ts">
import { ref, watch } from "vue";
import { IconFont } from "@nutui/icons-vue-taro";
import Taro from "@tarojs/taro";
import { payOrder } from "@/api/order";
import { payJfOrder } from "@/api/goods";
import { getPersonalInfo } from "@/api/user";
const prop = defineProps({
isShowPay: {
@@ -70,7 +72,28 @@ const prop = defineProps({
},
});
const emit = defineEmits(["closePay"]);
const emit = defineEmits(["closePay", "successPay"]);
const info = ref<any>({});
watch(
() => prop.isShowPay,
() => {
getInfo();
}
);
const getInfo = async () => {
try {
const res = await getPersonalInfo();
info.value = res.data.data;
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
});
}
};
const goPay = async () => {
if (!prop.jfInfo)
@@ -80,7 +103,6 @@ const goPay = async () => {
});
if (prop.payType === "wx") {
try {
console.log(prop.jfInfo);
const { data } = await payOrder({
oid: prop.jfInfo.oid,
});
@@ -90,16 +112,17 @@ const goPay = async () => {
package: data.data.package,
signType: data.data.signType,
paySign: data.data.paySign,
success: function (res) {
console.log(res);
success: function () {
Taro.showToast({
title: "支付成功",
icon: "success",
duration: 2000,
});
Taro.navigateTo({
url: "/pages/hotGoods/hot_list/index",
});
},
fail: function (res) {
console.log(res);
fail: function () {
Taro.showToast({
title: "支付失败",
icon: "none",
@@ -107,6 +130,7 @@ const goPay = async () => {
});
},
});
emit("closePay", false);
} catch (e) {
Taro.showToast({
title: e.msg,
@@ -120,8 +144,11 @@ const goPay = async () => {
icon: "success",
duration: 2000,
});
Taro.navigateTo({
url: "/pages/users/order_list/index",
});
emit("closePay", false);
}
emit("closePay", false);
};
const closePay = () => {

62
src/components/Upload.vue Normal file
View File

@@ -0,0 +1,62 @@
<template>
<view>
<nut-uploader
v-model:file-list="fileList"
:url="config.url"
:maximum="max"
:headers="config.headers"
@success="success"
@failure="failure"
:multiple="false"
></nut-uploader>
</view>
</template>
<script setup lang="ts">
import { BASE_URL } from "@/utils/request";
import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
const props = defineProps({
list: {
type: Array,
default: () => [],
},
max: {
type: Number,
default: 1,
},
});
const emits = defineEmits(["update:list"]);
const fileList = computed({
get: () => props.list,
set: (val) => emits("update:list", val),
});
const config = ref({
url: `${BASE_URL}/upload`,
headers: {
token: Taro.getStorageSync("token"),
},
});
const success = (res: any) => {
const data = JSON.parse(res.responseText.data);
res.fileItem.url = data.data.data;
Taro.showToast({
title: "上传成功",
icon: "success",
});
};
const failure = () => {
Taro.showToast({
title: "上传失败",
icon: "error",
});
};
</script>
<style lang="scss"></style>