Merge branch 'dev' into test

This commit is contained in:
2023-12-15 20:52:32 +08:00
3 changed files with 47 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "jdt-user",
"version": "3.0.4",
"version": "3.0.5",
"private": true,
"description": "",
"templateInfo": {
@@ -9,7 +9,7 @@
"css": "sass"
},
"taroConfig": {
"version": "3.0.4"
"version": "3.0.5"
},
"scripts": {
"build:weapp": "taro build --type weapp",

View File

@@ -13,7 +13,11 @@
auto-play="3000"
>
<nut-swiper-item v-for="(itm, idx) in bannerList" :key="idx">
<img :src="itm.url" :alt="itm.ID.toString()" />
<img
:src="itm.url"
:alt="itm.ID.toString()"
@click="toPage(itm.jump)"
/>
</nut-swiper-item>
</nut-swiper>
</view>
@@ -44,6 +48,8 @@ import Popup from "@/components/Popup.vue";
import MerList from "@/components/MerList.vue";
import { getHomeList } from "@/api/home";
import { getBanner } from "@/api/user";
import { parseQueryString } from "@/utils";
import { getMerList } from "@/api/goods";
const searchValue = ref("");
@@ -127,6 +133,19 @@ const toDetails = (item: SwiperList) => {
url: item.url as string,
});
};
const toPage = async (url: string) => {
// url转对象
const obj = parseQueryString(url);
if (obj.type === "1") {
const { data: res } = await getMerList({});
const mer = res.data.filter((item) => item.bid === obj.bid)[0];
Taro.setStorageSync("mer_info", mer);
}
Taro.navigateTo({
url,
});
};
</script>
<style lang="scss">

View File

@@ -28,3 +28,28 @@ export function calculateDistance(
function toRadians(degrees: number): number {
return (degrees * Math.PI) / 180;
}
// url转对象
interface UrlParams {
type?: string;
gid?: string;
bid?: string;
}
export function parseQueryString(url: string) {
const queryString = url.split("?")[1];
if (!queryString) {
return {};
}
const keyValuePairs = queryString.split("&");
const result: UrlParams = {};
keyValuePairs.forEach((keyValue) => {
const [key, value] = keyValue.split("=");
result[key] = decodeURIComponent(value);
});
return result;
}