Commit d6be2004 authored by Zhang Xiaojie's avatar Zhang Xiaojie

贷款产品store

parent 8e5beb98
...@@ -62,6 +62,8 @@ const fetchList = () => { ...@@ -62,6 +62,8 @@ const fetchList = () => {
queryLoanProductInfo({ uuid }).then((ret) => { queryLoanProductInfo({ uuid }).then((ret) => {
const { rate_lower, max_amount, max_date, inst_name, product_name,product_status } = const { rate_lower, max_amount, max_date, inst_name, product_name,product_status } =
ret.data; ret.data;
console.log('status',product_status);
if( product_status == 3){ if( product_status == 3){
state.hotProductList.push({ state.hotProductList.push({
rate_lower, rate_lower,
...@@ -77,6 +79,8 @@ const fetchList = () => { ...@@ -77,6 +79,8 @@ const fetchList = () => {
}); });
} }
}); });
console.log('pro',state.hotProductList);
}; };
</script> </script>
......
import { reactive } from "vue"
import { eLoanMode } from "@/views/withMenu/Loan/types"
export const loanMode = {
state: reactive({
mode: eLoanMode.personal
}),
setModeAction(newV: eLoanMode) {
this.state.mode = newV
console.log('newV',newV);
}
}
\ No newline at end of file
import { simpleItemInfo } from "@/views/withMenu/Loan/types"
import { reactive } from "@vue/reactivity"
export const loanSearchState = reactive({ result: [] as simpleItemInfo[] })
export function setSearchResult(newV: simpleItemInfo) {
loanSearchState.result.push(newV)
}
export function clearSearchResult(){
loanSearchState.result=[]
}
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
@load="onLoad" @load="onLoad"
> >
<LoanCard <LoanCard
v-for="item in state.list" v-for="item in state"
:key="item.value" :key="item.value"
:max_amount="item.max_amount" :max_amount="item.max_amount"
:product_name="item.product_name" :product_name="item.product_name"
...@@ -78,6 +78,11 @@ import { ...@@ -78,6 +78,11 @@ import {
import { simpleItemInfo } from "@/views/withMenu/Loan/types"; import { simpleItemInfo } from "@/views/withMenu/Loan/types";
import { iLoanProdcutItem } from "@/service/LoanProductService/type"; import { iLoanProdcutItem } from "@/service/LoanProductService/type";
import { Skeleton } from "vant"; import { Skeleton } from "vant";
import {
loanSearchState,
setSearchResult,
clearSearchResult,
} from "@/store/loanSearchResultStore";
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -90,9 +95,12 @@ export default defineComponent({ ...@@ -90,9 +95,12 @@ export default defineComponent({
}, },
setup() { setup() {
const mode = ref(+useRoute().params.mode); const mode = ref(+useRoute().params.mode);
onMounted(() => { onMounted(() => {
if (loanSearchState.result.length == 0) {
fetchList(); fetchList();
fetchBanks(); fetchBanks();
}
}); });
const onLoad = () => { const onLoad = () => {
...@@ -112,8 +120,8 @@ export default defineComponent({ ...@@ -112,8 +120,8 @@ export default defineComponent({
const loading = ref(false); const loading = ref(false);
const finished = ref(false); const finished = ref(false);
const total = ref(0); const total = ref(0);
let state = reactive({ const state = computed(() => {
list: [] as simpleItemInfo[], return loanSearchState.result;
}); });
const bankList = computed(() => { const bankList = computed(() => {
...@@ -136,7 +144,7 @@ export default defineComponent({ ...@@ -136,7 +144,7 @@ export default defineComponent({
queryLoanProductInfo({ uuid }).then((ret) => { queryLoanProductInfo({ uuid }).then((ret) => {
const { max_amount, inst_name, uuid, features, product_name } = const { max_amount, inst_name, uuid, features, product_name } =
ret.data; ret.data;
state.list.push({ setSearchResult({
max_amount, max_amount,
product_name, product_name,
features, features,
...@@ -262,10 +270,10 @@ export default defineComponent({ ...@@ -262,10 +270,10 @@ export default defineComponent({
queryList() { queryList() {
this.loading = true; this.loading = true;
queryDirectLoanReq({ queryDirectLoanReq({
rate_lower: +this.reqParams.min!?+this.reqParams.min!:0, rate_lower: +this.reqParams.min! ? +this.reqParams.min! : 0,
rate_upper: +this.reqParams.max!?+this.reqParams.max!:1000, rate_upper: +this.reqParams.max! ? +this.reqParams.max! : 1000,
min_amount: +this.reqParams.min2!?+this.reqParams.min2!:0, min_amount: +this.reqParams.min2! ? +this.reqParams.min2! : 0,
max_amount: +this.reqParams.max2!?+this.reqParams.max2!:9999, max_amount: +this.reqParams.max2! ? +this.reqParams.max2! : 9999,
bank_code: this.reqParams.selectedBanks[0], bank_code: this.reqParams.selectedBanks[0],
max_date: this.reqParams.selectedPerids[0] max_date: this.reqParams.selectedPerids[0]
? this.reqParams.selectedPerids[0].max_date ? this.reqParams.selectedPerids[0].max_date
...@@ -281,19 +289,18 @@ export default defineComponent({ ...@@ -281,19 +289,18 @@ export default defineComponent({
}).then((ret) => { }).then((ret) => {
if (ret.code == 200) { if (ret.code == 200) {
this.loading = false; this.loading = false;
this.state.list = []; clearSearchResult();
const list = ret.data.items.map((item) => { ret.data.items.map((item) => {
const { max_amount, inst_name, uuid, features, product_name } = const { max_amount, inst_name, uuid, features, product_name } =
item; item;
return { setSearchResult({
max_amount, max_amount,
product_name, product_name,
features, features,
inst_name, inst_name,
uuid, uuid,
};
}); });
this.state.list = list; });
} }
}); });
}, },
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
:features="features" :features="features"
:inst_name="inst_name" :inst_name="inst_name"
class="mt-5" class="mt-5"
@click="$router.push({ name: 'LoanDetail', params: { uuid: uuid } })" @click="$router.push({ name: 'LoanDetail', params: { uuid: hotLoanUuid } })"
/> />
</Skeleton> </Skeleton>
<group-title class="mt-7" title="精彩直播" /> <group-title class="mt-7" title="精彩直播" />
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
@click=" @click="
$router.push({ $router.push({
name: 'ActivityDetail', name: 'ActivityDetail',
params: { uuid: uuid }, params: { uuid: activityUuid },
}) })
" "
/> />
...@@ -121,11 +121,12 @@ export default defineComponent({ ...@@ -121,11 +121,12 @@ export default defineComponent({
constants: {}, constants: {},
hotNews: [], hotNews: [],
src: "", src: "",
uuid: "", activityUuid: "",
max_amount: 0, max_amount: 0,
product_name: "", product_name: "",
features: "", features: "",
inst_name: "", inst_name: "",
hotLoanUuid:""
}; };
}, },
mounted() { mounted() {
...@@ -166,7 +167,7 @@ export default defineComponent({ ...@@ -166,7 +167,7 @@ export default defineComponent({
if (ret.code === 200) { if (ret.code === 200) {
this.skeLoading = false; this.skeLoading = false;
this.src = getImageSrcFromFileHash(ret.data.items[0]?.file_name); this.src = getImageSrcFromFileHash(ret.data.items[0]?.file_name);
this.uuid = ret.data.items[0]?.uuid; this.activityUuid = ret.data.items[0]?.uuid;
} }
}, },
async fetchLoanProductList() { async fetchLoanProductList() {
...@@ -179,9 +180,11 @@ export default defineComponent({ ...@@ -179,9 +180,11 @@ export default defineComponent({
}); });
if (ret.code === 200) { if (ret.code === 200) {
this.skeLoading = false; this.skeLoading = false;
this.uuid = ret.data.uuid[0]; this.hotLoanUuid = ret.data.uuid[0];
const uuid = this.uuid; const uuid = this.hotLoanUuid;
queryLoanProductInfo({ uuid }).then((ret) => { queryLoanProductInfo( {uuid} ).then((ret) => {
console.log('uuid',uuid);
if (ret.code === 200) { if (ret.code === 200) {
this.max_amount = ret.data.max_amount; this.max_amount = ret.data.max_amount;
this.inst_name = ret.data.inst_name; this.inst_name = ret.data.inst_name;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
color: color:
eLoanMode.personal === mode ? 'rgba(62, 79, 175, 1)' : '', eLoanMode.personal === mode ? 'rgba(62, 79, 175, 1)' : '',
}" }"
@click="setMode(eLoanMode.personal)" @click="loanMode.setModeAction(eLoanMode.personal)"
>个人贷</span >个人贷</span
> >
<span <span
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
:style="{ :style="{
color: eLoanMode.company === mode ? 'rgba(62, 79, 175, 1)' : '', color: eLoanMode.company === mode ? 'rgba(62, 79, 175, 1)' : '',
}" }"
@click="setMode(eLoanMode.company)" @click="loanMode.setModeAction(eLoanMode.company)"
>企业贷</span >企业贷</span
> >
</div> </div>
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</div> </div>
</div> </div>
<!-- 热门贷款 --> <!-- 热门贷款 -->
<GroupTitle title="热门贷款" class="mt-2.5" v-if="count" /> <GroupTitle title="热门贷款" class="mt-2.5" v-if="count" iconName="" />
<LoanHotSwipe :loanMode="mode" class="mt-5" /> <LoanHotSwipe :loanMode="mode" class="mt-5" />
<!-- 非热门贷款 --> <!-- 非热门贷款 -->
<GroupTitle <GroupTitle
...@@ -130,7 +130,13 @@ import GroupTitle from "@/components/GroupTitle/index.vue"; ...@@ -130,7 +130,13 @@ import GroupTitle from "@/components/GroupTitle/index.vue";
import HotNews from "@/components/HotNews/index.vue"; import HotNews from "@/components/HotNews/index.vue";
import { queryActivityList } from "@/service/ActivityService"; import { queryActivityList } from "@/service/ActivityService";
import { getImageSrcFromFileHash } from "@/service/FileService"; import { getImageSrcFromFileHash } from "@/service/FileService";
import { onMounted, PropType, reactive, watch } from "@vue/runtime-core"; import {
computed,
onMounted,
PropType,
reactive,
watch,
} from "@vue/runtime-core";
import { getNewsList } from "@/service/NewsService/index"; import { getNewsList } from "@/service/NewsService/index";
import { simpleItemInfo } from "./types"; import { simpleItemInfo } from "./types";
import { Skeleton } from "vant"; import { Skeleton } from "vant";
...@@ -139,12 +145,10 @@ import { ...@@ -139,12 +145,10 @@ import {
queryLoanProductInfo, queryLoanProductInfo,
queryLimit, queryLimit,
} from "@/service/LoanProductService"; } from "@/service/LoanProductService";
import { loanMode } from "@/store/loanModeStore";
const mode = ref(eLoanMode.personal); import { clearSearchResult } from "@/store/loanSearchResultStore"
let skeLoading = ref(false); let skeLoading = ref(false);
const setMode = (v: eLoanMode) => {
mode.value = v;
};
let state = reactive({ allProductList: [] as Array<simpleItemInfo> }); let state = reactive({ allProductList: [] as Array<simpleItemInfo> });
const src = ref(""); const src = ref("");
const uuid = ref(""); const uuid = ref("");
...@@ -157,10 +161,18 @@ const limit = reactive({ ...@@ -157,10 +161,18 @@ const limit = reactive({
}); });
const count = ref(0); const count = ref(0);
watch(mode, () => { const mode = computed(() => {
return loanMode.state.mode;
});
watch(
() => loanMode.state.mode,
() => {
state.allProductList = []; state.allProductList = [];
clearSearchResult();
fetchList(); fetchList();
}); }
);
const getNews = () => { const getNews = () => {
getNewsList({ getNewsList({
...@@ -218,7 +230,7 @@ const fetchList = () => { ...@@ -218,7 +230,7 @@ const fetchList = () => {
}); });
} }
}); });
count.value = 0 count.value = 0;
}; };
const formatLimit = (limit: string): string => { const formatLimit = (limit: string): string => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment