chenkun 8 months ago
parent
commit
536b38dada
7 changed files with 235 additions and 105 deletions
  1. +1
    -1
      components/address/addressList.vue
  2. +1
    -1
      components/address/redactAddress.vue
  3. +214
    -86
      pages/index/cart.vue
  4. +17
    -15
      pages_order/components/product/submitUnitSelect.vue
  5. +2
    -2
      pages_order/mine/address.vue
  6. +0
    -0
      static/image/address/icon.png
  7. +0
    -0
      static/image/address/selectIcon.png

pages_order/components/address/addressList.vue → components/address/addressList.vue View File

@ -11,7 +11,7 @@
<view class="address-item-top" <view class="address-item-top"
@click="select(item)"> @click="select(item)">
<view class="img-box"> <view class="img-box">
<image src="../../static/address/icon.png" mode="aspectFill"></image>
<image src="/static/image/address/icon.png" mode="aspectFill"></image>
</view> </view>
<view class="address-info"> <view class="address-info">

pages_order/components/address/redactAddress.vue → components/address/redactAddress.vue View File

@ -19,7 +19,7 @@
</uv-input> </uv-input>
<template #right> <template #right>
<view style="padding-right: 40rpx;color: #FBAB32;" @click.stop="selectAddr"> <view style="padding-right: 40rpx;color: #FBAB32;" @click.stop="selectAddr">
<image src="../../static/address/selectIcon.png" mode="aspectFit"></image>定位
<image src="/static/image/address/selectIcon.png" mode="aspectFit"></image>定位
</view> </view>
</template> </template>
</uv-form-item> </uv-form-item>

+ 214
- 86
pages/index/cart.vue View File

@ -1,49 +1,38 @@
<template> <template>
<view class="page"> <view class="page">
<navbar/>
<navbar />
<view class="user"> <view class="user">
<uv-checkbox-group
shape="circle"
v-model="checkboxValue">
<uv-checkbox-group shape="circle" v-model="checkboxValue">
<uv-swipe-action> <uv-swipe-action>
<view
v-for="(item, index) in list.records"
:key="index">
<view v-for="(item, index) in list.records" :key="index">
<view style="margin-top: 20rpx;"></view> <view style="margin-top: 20rpx;"></view>
<uv-swipe-action-item
:options="options"
@click="delCart(item, index)">
<uv-swipe-action-item :options="options" @click="delCart(item, index)">
<view class="item"> <view class="item">
<view class="checkbox"> <view class="checkbox">
<uv-checkbox
:name="item.id"
activeColor="#FA5A0A"
size="40rpx"
icon-size="35rpx"
></uv-checkbox>
<uv-checkbox :name="item.id" activeColor="#FA5A0A" size="40rpx"
icon-size="35rpx"></uv-checkbox>
</view> </view>
<image
class="image"
:src="item.pic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'"
mode=""></image>
<image class="image"
:src="item.pic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'"
mode=""></image>
<view class="info"> <view class="info">
<view class="title"> <view class="title">
<view class="">
{{ item.name }}
</view>
<view class="">
<uv-number-box v-model="item.num"
@change="e => valChange(item, e)"></uv-number-box>
<view>{{ item.name }}</view>
<view>
<uv-number-box v-model="item.num"
@change="e => valChange(item, e)"></uv-number-box>
</view> </view>
</view> </view>
<view class="unit">
规格{{ item.title }}
<!-- 规格下拉框 -->
<view class="unit" @click="toggleDropdown">
规格{{ selectedOption || item.title }}
<uv-icon name="arrow-down"></uv-icon> <uv-icon name="arrow-down"></uv-icon>
</view> </view>
<view class="price"> <view class="price">
<text>{{ item.price }}</text> <text>{{ item.price }}</text>
</view> </view>
@ -53,18 +42,16 @@
</view> </view>
</uv-swipe-action> </uv-swipe-action>
</uv-checkbox-group> </uv-checkbox-group>
<view class="action"> <view class="action">
<view class="icon"> <view class="icon">
<image src="/static/image/cart/1.png" mode=""></image> <image src="/static/image/cart/1.png" mode=""></image>
<view class="num">
{{ checkboxValue.length }}
</view>
<view class="num">{{ checkboxValue.length }}</view>
</view> </view>
<view class="price"> <view class="price">
<view class="count"> <view class="count">
合计 合计
<view class="">
<view>
<text>{{ totalPrice }}</text> <text>{{ totalPrice }}</text>
</view> </view>
</view> </view>
@ -72,49 +59,61 @@
{{ checkboxValue.length }}已享受更低优惠 {{ checkboxValue.length }}已享受更低优惠
</view> </view>
</view> </view>
<view class="btn" @click="goCleaning">
去结算
</view>
<view class="btn" @click="goCleaning">去结算</view>
</view> </view>
</view> </view>
<!-- 地址弹框 -->
<uv-popup ref="addressPopup" :round="30">
<addressList ref="addressList" height="60vh" @select="selectAddress" />
</uv-popup>
<tabber select="3" /> <tabber select="3" />
</view> </view>
</template> </template>
<script> <script>
import tabber from '@/components/base/tabbar.vue' import tabber from '@/components/base/tabbar.vue'
import addressList from '@/components/address/addressList.vue'
export default { export default {
components: { components: {
tabber, tabber,
addressList,
}, },
data() { data() {
return { return {
value : 0,
checkboxValue : [],
options: [
{
text: '删除',
style: {
backgroundColor: '#FA5A0A'
}
},
],
dropdownVisible: false,
value: 0,
checkboxValue: [],
options: [{
text: '删除',
style: {
backgroundColor: '#FA5A0A'
}
}],
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 10
pageSize: 10,
},
list: [],
addressTotal: 0,
address: {
name: '请选择联系人',
addressDetail: ''
}, },
list : [],
} }
}, },
computed: { computed: {
totalPrice(){
totalPrice() {
if (!this.checkboxValue.length) { if (!this.checkboxValue.length) {
return 0 return 0
} }
let price = 0 let price = 0
this.list.records.forEach(n => { this.list.records.forEach(n => {
if(this.checkboxValue.includes(n.id)){
if (this.checkboxValue.includes(n.id)) {
price += n.price * n.num price += n.price * n.num
} }
}) })
@ -123,40 +122,140 @@
}, },
onShow() { onShow() {
this.getData() this.getData()
this.getAddressListA()
}, },
// //
onReachBottom() { onReachBottom() {
if(this.queryParams.pageSize < this.list.total){
if (this.queryParams.pageSize < this.list.total) {
this.queryParams.pageSize += 10 this.queryParams.pageSize += 10
this.getData() this.getData()
} }
}, },
methods: { methods: {
valChange(item, e){
toggleDropdown() {
this.dropdownVisible = !this.dropdownVisible
},
selectOption(option) {
},
//
goCleaning() {
console.log("===");
this.$refs.addressPopup.open('bottom')
this.ordersPay()
},
//
ordersPay() {
let data = []
console.log(this.address, "this.address");
console.log(this.checkboxValue, "checkboxValue");
for (var i = 0; i < this.list.length; i++) {
if (this.checkboxValue.includes(this.list[i].id)) {
data.push({
id: this.list[i].id, //id
skuId: this.unit.id, //id
addressId: this.address.id, //id
sku: this.unit.title, //
num: this.list[i],
})
}
}
return
this.$api('orderCreate', {
req: JSON.stringify(data)
}, res => {
if (res.code == 200) {
let form = {
id: res.result.id
}
this.$api('orderPay', form, res => {
if (res.code == 200) {
uni.requestPayment({
provider: 'wxpay', //
timeStamp: res.result.timeStamp, //
nonceStr: res.result.nonceStr, //
package: res.result.packageValue,
signType: res.result.signType, //
paySign: res.result.paySign, //
success: function(res) {
// console.log('', res);
uni.redirectTo({
url: '/pages/index/order'
})
},
fail: function(err) {
console.log('支付失败', err);
// self.$refs.confirmationPopup.close()
uni.showToast({
icon: 'none',
title: "支付失败"
})
}
});
}
})
}
})
},
//
unitChange(item, e) {
// TODO
// this.$api('goodsOne', this.queryParams, res => {
// if (res.code == 200) {
// this.list = res.result
// }
// })
},
//
getAddressListA() {
this.$refs.addressList.getAddressList().then(res => {
this.addressTotal = res.total
if (this.addressTotal != 0) {
this.address = res.records[0]
}
})
},
//
selectAddress(e) {
this.address = e
this.$refs.addressPopup.close()
},
valChange(item, e) {
console.log(e.value); console.log(e.value);
this.$api('cartNum', { this.$api('cartNum', {
id : item.id,
num : e.value,
id: item.id,
num: e.value,
}) })
}, },
//
goCleaning(){
},
// //
getData(){
getData() {
this.$api('cartPage', this.queryParams, res => { this.$api('cartPage', this.queryParams, res => {
if(res.code == 200){
if (res.code == 200) {
this.list = res.result this.list = res.result
} }
}) })
}, },
// //
delCart(item, index){
delCart(item, index) {
this.$api('cartDel', { this.$api('cartDel', {
id : item.id
id: item.id
}, res => { }, res => {
if(res.code == 200){
if (res.code == 200) {
this.getData() this.getData()
uni.showToast({ uni.showToast({
title: '删除成功', title: '删除成功',
@ -170,53 +269,63 @@
<style scoped lang="scss"> <style scoped lang="scss">
.page { .page {
/deep/ .uv-swipe-action{
/deep/ .uv-swipe-action {
width: 100%; width: 100%;
} }
} }
.user { .user {
.item{
.item {
background-color: #fff; background-color: #fff;
display: flex; display: flex;
padding: 30rpx; padding: 30rpx;
.checkbox{
.checkbox {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.image{
.image {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
border-radius: 20rpx; border-radius: 20rpx;
} }
.info{
.info {
flex: 1; flex: 1;
.title{
.title {
display: flex; display: flex;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
justify-content: space-between; justify-content: space-between;
} }
.unit{
.unit {
font-size: 24rpx; font-size: 24rpx;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
color: #717171; color: #717171;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.price{
.price {
color: $uni-color; color: $uni-color;
font-size: 28rpx; font-size: 28rpx;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
text{
text {
font-size: 36rpx; font-size: 36rpx;
font-weight: 900; font-weight: 900;
} }
} }
} }
} }
.action{
.action {
width: 700rpx; width: 700rpx;
position: fixed; position: fixed;
bottom: 220rpx; bottom: 220rpx;
@ -229,16 +338,19 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
.icon{
.icon {
position: relative; position: relative;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
margin: 0 20rpx; margin: 0 20rpx;
image{
image {
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
} }
.num{
.num {
position: absolute; position: absolute;
right: 10rpx; right: 10rpx;
top: 0rpx; top: 0rpx;
@ -253,26 +365,31 @@
align-items: center; align-items: center;
} }
} }
.price{
.count{
.price {
.count {
display: flex; display: flex;
font-size: 26rpx; font-size: 26rpx;
align-items: center; align-items: center;
view{
view {
color: $uni-color; color: $uni-color;
margin-left: 10rpx; margin-left: 10rpx;
text{
text {
font-size: 32rpx; font-size: 32rpx;
font-weight: 900; font-weight: 900;
} }
} }
} }
.text{
.text {
font-size: 20rpx; font-size: 20rpx;
color: #717171; color: #717171;
} }
} }
.btn{
.btn {
margin-left: auto; margin-left: auto;
background-color: $uni-color; background-color: $uni-color;
height: 100%; height: 100%;
@ -284,4 +401,15 @@
} }
} }
} }
.example-body {
padding: 12px;
background-color: #FFFFFF;
}
.result-box {
text-align: center;
padding: 20px 0px;
font-size: 16px;
}
</style> </style>

+ 17
- 15
pages_order/components/product/submitUnitSelect.vue View File

@ -4,7 +4,7 @@
<!-- 地址 --> <!-- 地址 -->
<view class="address" @click="openAddress"> <view class="address" @click="openAddress">
<image src="../../static/address/selectIcon.png" mode=""></image>
<image src="/static/image/address/selectIcon.png" mode=""></image>
<view class=""> <view class="">
{{ address.name }} {{ address.name }}
</view> </view>
@ -82,7 +82,7 @@
</template> </template>
<script> <script>
import addressList from '../address/addressList.vue'
import addressList from '../../../components/address/addressList.vue'
export default { export default {
components: { components: {
addressList, addressList,
@ -162,21 +162,23 @@
}, },
orderPay() { orderPay() {
let data = {
id: this.detail.id, //id
skuId: this.unit.id, //id
addressId: this.address.id, //id
sku: this.unit.title, //
num: this.num,
}
let data = [
{
id: this.detail.id, //id
skuId: this.unit.id, //id
addressId: this.address.id, //id
sku: this.unit.title, //
num: this.num,
}
]
if (this.$utils.verificationAll(data, {
skuId: '请选择规格',
addressId: '请选择地址',
})) {
return
}
// if (this.$utils.verificationAll(data, {
// skuId: '',
// addressId: '',
// })) {
// return
// }
this.$api('orderCreate', {req:JSON.stringify(data)}, res => { this.$api('orderCreate', {req:JSON.stringify(data)}, res => {
if (res.code == 200) { if (res.code == 200) {


+ 2
- 2
pages_order/mine/address.vue View File

@ -29,8 +29,8 @@
</template> </template>
<script> <script>
import redactAddress from '../components/address/redactAddress.vue'
import addressList from '../components/address/addressList.vue'
import redactAddress from '../../components/address/redactAddress.vue'
import addressList from '../../components/address/addressList.vue'
export default { export default {
components: { components: {


pages_order/static/address/icon.png → static/image/address/icon.png View File


pages_order/static/address/selectIcon.png → static/image/address/selectIcon.png View File


Loading…
Cancel
Save