Merge branch 'test'

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

View File

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

View File

@@ -13,7 +13,11 @@
auto-play="3000" auto-play="3000"
> >
<nut-swiper-item v-for="(itm, idx) in bannerList" :key="idx"> <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-item>
</nut-swiper> </nut-swiper>
</view> </view>
@@ -44,6 +48,8 @@ import Popup from "@/components/Popup.vue";
import MerList from "@/components/MerList.vue"; import MerList from "@/components/MerList.vue";
import { getHomeList } from "@/api/home"; import { getHomeList } from "@/api/home";
import { getBanner } from "@/api/user"; import { getBanner } from "@/api/user";
import { parseQueryString } from "@/utils";
import { getMerList } from "@/api/goods";
const searchValue = ref(""); const searchValue = ref("");
@@ -127,6 +133,19 @@ const toDetails = (item: SwiperList) => {
url: item.url as string, 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> </script>
<style lang="scss"> <style lang="scss">

View File

@@ -28,3 +28,28 @@ export function calculateDistance(
function toRadians(degrees: number): number { function toRadians(degrees: number): number {
return (degrees * Math.PI) / 180; 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;
}