商品详情页跳转首页和购物车页面并新建user.js

pull/45/head
Suk1No 9 months ago
commit 2942d1021c

@ -3,7 +3,6 @@ import http from '../common/http.js'
export const getSwipperListApi = ()=>{
return http.get("/api/home/getSwipperList")
}
//首页热推
export const getHotListApi = ()=>{
return http.get("/api/home/getHotList")

@ -1,4 +1,5 @@
const baseUrl = 'http://localhost:8089'
const baseUrl = 'http://localhost:8089'
//const baseUrl = 'http://192.168.31.70:8089'
const http = (options = {}) => {
return new Promise((resolve, reject) => {
uni.request({

@ -1,5 +1,11 @@
{
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
/* {
"path": "pages/address/address",
"style": {
"navigationBarTitleText": ""
}
}, */
{
"path": "pages/index/index",
"style": {
@ -11,33 +17,35 @@
"navigationBarTitleText": "分类",
"enablePullDownRefresh": false
}
}, {
"path": "pages/car/car",
"style": {
"navigationBarTitleText": "购物车",
"enablePullDownRefresh": false
}
}, {
"path": "pages/mine/mine",
"style": {
"navigationBarTitleText": "我的",
"enablePullDownRefresh": false
}
},
{
}, {
"path": "pages/detail/detail",
"style": {
"navigationBarTitleText": ""
}
},{
}, {
"path": "pages/address/address",
"style": {
"navigationBarTitleText": ""
}
}
},
{
"path" : "common/common",
"style" :
{
"navigationBarTitleText" : ""
} }
],
"globalStyle": {
// black/white

@ -5,6 +5,7 @@
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item"
:class="[current==index ? 'u-tab-item-active' : '']" :data-current="index"
@tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.categoryName}}</text>
</view>
</scroll-view>
@ -17,8 +18,8 @@
</view> -->
<view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.goods" :key="index1">
<image @click="toDetails(item1)" class="item-menu-image" :src="item1.goodsImage.split(',')[0]" mode="">
</image>
<image @click="toDetails(item1)" class="item-menu-image"
:src="item1.goodsImage.split(',')[0]" mode=""></image>
<view class="item-menu-name">{{item1.goodsName}}</view>
</view>
</view>
@ -40,18 +41,21 @@
} from "vue"
//
const instance = getCurrentInstance();
const tabbar = ref([])
const scrollTop = ref(0)
const current = ref(0)
const menuHeight = ref(0)
const menuItemHeight = ref(0)
const menuItemHeight = ref(0) const getImg = ()=>{
const getImg = () => {
return Math.floor(Math.random() * 35)
}
const swichMenu = async (index) => {
if (index == current.value) return;
current.value = index;
// 0
if (menuHeight.value == 0 || menuItemHeight.value == 0) {
await getElRect('menu-scroll-view', 'menuHeight');
await getElRect('u-tab-item', 'menuItemHeight');
@ -59,17 +63,21 @@
// item
scrollTop.value = index * menuItemHeight.value + menuItemHeight.value / 2 - menuHeight.value / 2;
}
{
const getElRect = (elClass, dataVal) => {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(instance);
query.select('.' + elClass).fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
getElRect(elClass);
}, 10);
return;
}
instance[dataVal] = res.height;
@ -215,4 +223,5 @@
width: 120rpx;
height: 120rpx;
}
</style>

@ -82,6 +82,9 @@
</template>
<script setup>
import {
userLogin
} from '../../api/user';
import {
onLoad
} from '@dcloudio/uni-app';
@ -92,6 +95,8 @@
import {
carStore
} from '../../store/car';
//
const content = ref('')
//store
const store = carStore()
//
@ -177,6 +182,7 @@
});
}
onLoad((options) => {
userLogin()
const goods = JSON.parse(options.goods)
swipperList.value = goods.goodsImage.split(',')
console.log(goods)

@ -1,4 +1,5 @@
<template>
<u-swiper name='images' border-radius='1' :duration='duration' :interval='interval' :height="height"
:list="swiperList">
</u-swiper>
@ -8,12 +9,15 @@
<template v-slot:left="{leftList}">
<view class="demo-warter" v-for="(item, index) in leftList" :key="index">
<!-- 警告微信小程序中需要hx2.8.11版本才支持在template中结合其他组件比如下方的lazy-load组件 -->
<u-lazy-load threshold="-450" border-radius="10" :image="item.goodsImage.split(',')[0]" :index="index"></u-lazy-load>
<view class="demo-title">
{{item.goodsName}}
</view>
<view class="price-item">
<view class="demo-price">
{{item.specs[0].goodsPrice}}
</view>
<view class="demo-title">
@ -25,12 +29,15 @@
</template>
<template v-slot:right="{rightList}">
<view class="demo-warter" v-for="(item, index) in rightList" :key="index">
<u-lazy-load threshold="-450" border-radius="10" :image="item.goodsImage.split(',')[0]" :index="index"></u-lazy-load>
<view class="demo-title">
{{item.goodsName}}
</view>
<view class="price-item">
<view class="demo-price">
{{item.specs[0].goodsPrice}}
</view>
<view class="demo-title">
@ -45,6 +52,10 @@
</template>
<script setup>
import {
getSwipperListApi,
getHotListApi
} from '../../api/home';
import {
ref
} from 'vue';
@ -66,11 +77,11 @@
const interval = ref(2000)
//
const duration = ref(500)
//,
const swiperList = ref([])
//,
const flowList = ref([])
//
const flowList = ref([]) //
const toDetails = (item) => {
//details.vue
uni.navigateTo({

Loading…
Cancel
Save