This commit is contained in:
2023-10-08 22:53:13 +08:00
parent b883b02fb9
commit e36d60d015
83 changed files with 18303 additions and 9590 deletions

View File

@@ -6,7 +6,7 @@
safe-area-inset-bottom
:close-on-click-overlay="false"
:style="{ height: 'auto' }"
v-model:visible="isShowPay"
:visible="isShowPay"
@click-close-icon="closePay"
>
<view class="div">
@@ -46,66 +46,68 @@
</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";
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: {
required: true,
type: Boolean,
default: false,
default: false
},
payType: {
required: true,
type: String,
default: "wx",
default: 'wx'
},
jfInfo: {
type: Object,
default: () => {
return {};
},
},
});
return {}
}
}
})
const emit = defineEmits(["closePay", "successPay"]);
const emit = defineEmits(['closePay', 'successPay'])
const info = ref<any>({});
const info = ref<{ integral?: any }>({})
watch(
() => prop.isShowPay,
() => {
getInfo();
getInfo()
}
);
)
const getInfo = async () => {
try {
const res = await getPersonalInfo();
info.value = res.data.data;
const res = await getPersonalInfo()
info.value = res.data.data
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
});
icon: 'none'
})
throw error
}
};
}
const goPay = async () => {
console.log(prop.jfInfo)
if (!prop.jfInfo)
return Taro.showToast({
title: "未获取到订单信息",
icon: "none",
});
if (prop.payType === "wx") {
title: '未获取到订单信息',
icon: 'none'
})
if (prop.payType === 'wx') {
try {
const { data } = await payOrder({
oid: prop.jfInfo.oid,
});
const {data} = await payOrder({
oid: prop.jfInfo.oid
})
Taro.requestPayment({
timeStamp: data.data.timeStamp,
nonceStr: data.data.nonceStr,
@@ -114,50 +116,51 @@ const goPay = async () => {
paySign: data.data.paySign,
success: function () {
Taro.showToast({
title: "支付成功",
icon: "success",
duration: 2000,
});
title: '支付成功',
icon: 'success',
duration: 2000
})
Taro.navigateTo({
url: "/pages/hotGoods/hot_list/index",
});
url: '/pages/hotGoods/hot_list/index'
})
},
fail: function () {
Taro.showToast({
title: "支付失败",
icon: "none",
duration: 2000,
});
},
});
emit("closePay", false);
title: '支付失败',
icon: 'none',
duration: 2000
})
}
})
emit('closePay', false)
} catch (e) {
Taro.showToast({
title: e.msg,
icon: "none",
});
icon: 'none'
})
throw e
}
} else {
const res = await payJfOrder(prop.jfInfo);
const res = await payJfOrder(prop.jfInfo)
Taro.showToast({
title: res.msg,
icon: "success",
duration: 2000,
});
icon: 'success',
duration: 2000
})
Taro.navigateTo({
url: "/pages/users/order_list/index",
});
emit("closePay", false);
url: '/pages/users/order_list/index?type=0'
})
emit('closePay', false)
}
};
}
const closePay = () => {
Taro.showToast({
title: "取消支付",
icon: "none",
});
emit("closePay", false);
};
title: '取消支付',
icon: 'none'
})
emit('closePay', false)
}
</script>
<style lang="scss">