Compare commits

...

2 Commits

@ -12,7 +12,16 @@
"outputPath": "" "outputPath": ""
}, },
"useCompilerPlugins": false, "useCompilerPlugins": false,
"minifyWXML": true "minifyWXML": true,
"compileWorklet": false,
"uploadWithSourceMap": true,
"packNpmManually": false,
"minifyWXSS": true,
"localPlugins": false,
"disableUseStrict": false,
"condition": false,
"swc": false,
"disableSWC": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},
@ -21,5 +30,6 @@
"include": [] "include": []
}, },
"appid": "wx6a41b250d82adc97", "appid": "wx6a41b250d82adc97",
"editorSetting": {} "editorSetting": {},
"libVersion": "3.9.1"
} }

@ -9,6 +9,14 @@
"preloadBackgroundData": false, "preloadBackgroundData": false,
"autoAudits": false, "autoAudits": false,
"showShadowRootInWxmlPanel": true, "showShadowRootInWxmlPanel": true,
"compileHotReLoad": true "compileHotReLoad": true,
"useApiHook": true,
"useApiHostProcess": true,
"useStaticServer": false,
"useLanDebug": false,
"showES6CompileOption": false,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": false
} }
} }

@ -37,15 +37,21 @@
}, { }, {
"path": "pages/address/address", "path": "pages/address/address",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "新增地址"
} }
}, },
// {
// "path": "common/common",
// "style": {
// "navigationBarTitleText": ""
// }
// },
{ {
"path" : "common/common", "path": "pages/confirm/confirm",
"style" : "style": {
{ "navigationBarTitleText": "确认订单"
"navigationBarTitleText" : "" }
} } }
], ],
"globalStyle": { "globalStyle": {
// black/white // black/white

@ -35,7 +35,7 @@
总计<text style="color: #f00;font-weight: bold;"> {{totalPrice}}</text> 总计<text style="color: #f00;font-weight: bold;"> {{totalPrice}}</text>
</view> </view>
</view> </view>
<view class="end-right"> <view class="end-right" @click="confirm">
结算({{totalNum}}) 结算({{totalNum}})
</view> </view>
</view> </view>
@ -130,7 +130,7 @@
}) })
return totalNum return totalNum
}) })
//
const totalPrice = computed(() => { const totalPrice = computed(() => {
let totalPrice = 0; let totalPrice = 0;
store.carList.map(item => { store.carList.map(item => {
@ -138,6 +138,12 @@
}) })
return totalPrice return totalPrice
}) })
//
const confirm = (item) => {
uni.navigateTo({
url: '../confirm/confirm'
});
}
</script> </script>
<style lang="scss"> <style lang="scss">
@ -213,7 +219,7 @@
.end-right { .end-right {
width: 30%; width: 30%;
line-height: 90rpx; line-height: 90rpx;
background-color: #F44545; background-color: #F3AF28;
text-align: center; text-align: center;
color: #fff; color: #fff;
} }

@ -0,0 +1,228 @@
<template>
<view class="address" @click="toAddress">
<view>
<view class="info">
<view class="name">
张明
</view>
<view class="phone">
18681xxxxx
</view>
</view>
<view>
北京工业大学
</view>
</view>
<u-icon name="arrow-right" color="#c8c9cc"></u-icon>
</view>
<view style="padding-bottom: 60px;margin-top: 10px;" v-if="goods.length > 0">
<view class="goods-detail" v-for="(item,index) in goods" :key="index">
<view class="detail-left">
<view class="goods-left">
<image style="width: 150rpx; height: 140rpx; margin-left:10px;" :src="item.goodsImage"></image>
</view>
<view class="size">
<text style="font-size: 25rpx;">名称{{item.goodsName}}</text>
<text style="font-size: 25rpx;">规格{{item.specsName}}</text>
<text class="goods-price">{{item.price}}{{item.goodsUnit}}</text>
</view>
</view>
<view class="detail-right">
<text class="num">x{{item.num}}</text>
</view>
</view>
</view>
<view class="end">
<view class="end-left">
<view>
总计<text style="color: #F3AF28;font-weight: bold;">{{totalPrice}}</text>
</view>
</view>
<view class="end-right">
提交订单({{totalNum}})
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
computed
} from 'vue'
import {
orderStore
} from '../../store/order.js'
//store
const store = orderStore()
const goods = computed(() => {
return store.orderList
})
// const goods = reactive([{
// flag: true,
// goodsName: "-M",
// goodsUnit: '/',
// goodsId: 1,
// num: 1,
// specsName: '',
// price: 149,
// goodsImage: "http://192.168.31.70:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
// },
// {
// flag: true,
// goodsName: "-M",
// goodsUnit: '/',
// goodsId: 1,
// specsName: '',
// num: 1,
// price: 149,
// goodsImage: "http://192.168.31.70:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
// },
// {
// flag: true,
// goodsName: "-M",
// goodsUnit: '/',
// goodsId: 1,
// num: 1,
// specsName: '',
// price: 149,
// goodsImage: "http://192.168.31.70:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
// },
// {
// flag: true,
// goodsName: "-M",
// goodsId: 1,
// num: 1,
// goodsUnit: '/',
// specsName: '',
// price: 149,
// goodsImage: "http://192.168.31.70:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
// }
// ])
//
const totalNum = computed(() => {
let totalNum = 0;
store.orderList.map(item => {
item.flag ? totalNum += item.num : totalNum += 0;
})
return totalNum
})
//
const totalPrice = computed(() => {
let totalPrice = 0;
store.orderList.map(item => {
item.flag ? totalPrice += item.num * item.price : totalPrice += 0;
})
return totalPrice
})
//
const toAddress = (item) => {
uni.navigateTo({
url: '../address/address'
});
}
</script>
<style lang="scss">
page {
background-color: #f4f4f4;
}
.address {
display: flex;
justify-content: space-between;
background-color: #FFF;
padding: 10px 20px;
.info {
display: flex;
.name {
font-size: 15px;
font-weight: 600;
}
.phone {
margin-left: 10px;
}
}
}
.goods-detail {
display: flex;
padding: 30rpx 15rpx 30rpx 30rpx;
background-color: #FFF;
justify-content: space-between;
border-bottom: 5rpx solid #f1f1f1;
align-items: center;
.detail-left {
display: flex;
.goods-left {
display: flex;
align-items: center;
}
.size {
display: flex;
flex-direction: column;
justify-content: space-around;
margin-left: 30rpx;
.goods-price {
font-size: 25rpx;
color: #F44545;
}
}
}
.detail-right {
text {
width: 50rpx;
line-height: 50rpx;
text-align: center;
display: inline-block;
background-color: #F7F7F7;
margin-right: 10rpx;
}
.add {
color: #FA4305;
border-radius: 10rpx 30rpx 30rpx 10rpx;
margin-right: 20rpx;
}
.subtract {
border-radius: 30rpx 10rpx 10rpx 30rpx;
}
}
}
.end {
width: 100%;
height: 90rpx;
background-color: #fff;
position: fixed;
bottom: 0;
left: 0;
display: flex;
align-items: center;
.end-left {
width: 70%;
display: flex;
justify-content: space-between;
padding: 0 30rpx;
}
.end-right {
width: 30%;
line-height: 90rpx;
background-color: #F3AF28;
text-align: center;
color: #fff;
}
}
</style>

@ -1,8 +1,7 @@
<template> <template>
<view>
<u-swiper name='images' border-radius='1' :duration='duration' :interval='interval' :height="height" <u-swiper name='images' border-radius='1' :duration='duration' :interval='interval' :height="height"
:list="swipperList"></u-swiper> :list="swipperList">
</view> </u-swiper>
<view class="info"> <view class="info">
<view class="title"> <view class="title">
{{title}} {{title}}
@ -75,31 +74,29 @@
</view> </view>
</view> </view>
<view class="right"> <view class="right">
<view class="cart btn u-line-1">加入购物</view> <view class="cart btn u-line-1" @click="addCar"></view>
<view class="buy btn u-line-1">立即购买</view> <view @click="addBuy" class="buy btn u-line-1">立即购买</view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
userLogin computed,
} from '../../api/user'; ref
} from 'vue';
import { import {
onLoad onLoad
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
import { carStore } from '../../store/car.js'
import { import {
ref, orderStore
computed } from '../../store/order.js'
} from 'vue'; import {userLogin} from '../../api/user.js'
import {
carStore
} from '../../store/car';
//
const content = ref('')
//store //store
const store = carStore() const store = carStore()
// const ostore = orderStore()
//
const carCount = computed(()=>{ const carCount = computed(()=>{
return store.carList.length return store.carList.length
}) })
@ -134,13 +131,12 @@
price.value = item.goodsPrice price.value = item.goodsPrice
carData.value.price = item.goodsPrice carData.value.price = item.goodsPrice
carData.value.specsName = item.specsName carData.value.specsName = item.specsName
console.log(carData)
} }
//tab //tab
const swiperCurrent = ref(0) const swiperCurrent = ref(0)
const dx = ref(0) const dx = ref(0)
const tabIndex = ref(0) const tabIndex = ref(0)
// //
const carData = ref({ const carData = ref({
flag: true, flag: true,
goodsName: "", goodsName: "",
@ -160,6 +156,15 @@
const addCar = ()=>{ const addCar = ()=>{
store.addCar(carData.value) store.addCar(carData.value)
} }
//
const addBuy = ()=>{
//
ostore.orderList = []
ostore.addOrder(carData.value)
uni.navigateTo({
url: '../confirm/confirm'
});
}
const animationfinish = ({ const animationfinish = ({
detail: { detail: {
current current
@ -201,7 +206,7 @@
}) })
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
page { page {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

@ -52,10 +52,6 @@
</template> </template>
<script setup> <script setup>
import {
getSwipperListApi,
getHotListApi
} from '../../api/home';
import { import {
ref ref
} from 'vue'; } from 'vue';

@ -0,0 +1,45 @@
// 引入
import {
defineStore
} from 'pinia';
//通过defineStore定义一个store,
// defineStore 第一个参数是唯一的
export const orderStore = defineStore('orderStore', {
state: () => {
return {
count: 0,
//存储购物车数据
orderList: []
};
},
// 也可以这样定义
// state: () => ({ count: 0 })
actions: {
//单条数据加入
addOrder(goods) {
//判断是否已经加入到购物车
const index = this.orderList.findIndex(item => goods.goodsId == item.goodsId)
//存在,删除购物车数据里面的数据
if (index > -1) {
//删除原来的数据
this.orderList.splice(index, 1);
}
//加的购物车
this.orderList.push(goods)
},
//多条数据加入
addOrderList(list) {
list.forEach(goods => {
//判断是否已经加入到购物车
const index = this.orderList.findIndex(item => goods.goodsId == item.goodsId)
//存在,删除购物车数据里面的数据
if (index > -1) {
//删除原来的数据
this.orderList.splice(index, 1);
}
//加的购物车
this.orderList.push(goods)
})
}
},
});
Loading…
Cancel
Save