You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
317 lines
7.5 KiB
317 lines
7.5 KiB
<template>
|
|
<view>
|
|
<view class="headerBox box">
|
|
<!-- <view class="img"> -->
|
|
<image src="../../static/images/logo.png" mode=""></image>
|
|
<!-- </view> -->
|
|
<view class="content">
|
|
<view class="">
|
|
</view>
|
|
<text>{{goodsDetail.productSn }}</text>
|
|
</view>
|
|
</view>
|
|
<!-- <view class="box">
|
|
|
|
</view> -->
|
|
<u-picker :show="show" ref="uPicker" :columns="columns" @confirm="confirm" @change="changeHandler" @cancel="show = false"></u-picker>
|
|
<view class="box">
|
|
<ul>
|
|
<li v-for="(item,index) in showList" class="numli">
|
|
{{item}}
|
|
<u-number-box integer v-model="numList[index]"></u-number-box>
|
|
</li>
|
|
</ul>
|
|
<ul class="price">
|
|
<li>
|
|
采购价: <text>{{goodsDetail.purchasePrice}}</text>
|
|
</li>
|
|
<li>
|
|
批发价: <text>{{goodsDetail.wholesalePrice}}</text>
|
|
</li>
|
|
<li>
|
|
市场价: <text>{{goodsDetail.price}}</text>
|
|
</li>
|
|
</ul>
|
|
<view class="priceText">
|
|
共 <text>{{showList.length}}</text>种<text>{{numAll}}</text>件 <text>¥{{ numAll * goodsDetail.wholesalePrice}}</text>
|
|
</view>
|
|
<view class="text" v-if="goodsDetail.radio1 == 1">
|
|
折扣:<u-number-box :min="0.1" :max="10" v-model="listDetail.discount" step="0.1"
|
|
decimal-length="1"></u-number-box>
|
|
<view class="">
|
|
实付金额:<text>{{ realPrice }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="tui-tabbar">
|
|
|
|
<view class="tui-btn-mr">
|
|
<u-button type="error" :plain="true" shape="circle" @tap.stop="goodsAdd()">添加规格</u-button>
|
|
</view>
|
|
<view class="tui-btn-mr">
|
|
<u-button type="primary" :plain="true" shape="circle" @tap.stop="submit()">确认</u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
listDetail: {
|
|
discount: 10
|
|
},
|
|
show: true,
|
|
columns: [],
|
|
keyList: [],
|
|
shopList: [],
|
|
showList: [],
|
|
numList: [],
|
|
goodsDetail: {},
|
|
attributeList: [],
|
|
};
|
|
},
|
|
onLoad(options) {
|
|
this.goodsDetail = JSON.parse(decodeURIComponent(options.info))
|
|
let newObj = JSON.parse(this.goodsDetail.attributeList)
|
|
console.log("1111")
|
|
console.log(newObj)
|
|
let newArr = []
|
|
for (let val in newObj) {
|
|
let valueObj = [];
|
|
for (var i = 0; i < newObj[val].length; i++) {
|
|
valueObj.push(newObj[val][i])
|
|
}
|
|
newArr.push({
|
|
name: val,
|
|
value: valueObj
|
|
})
|
|
}
|
|
this.goodsDetail.attributeList = newArr;
|
|
this.goodsDetail.attributeList.forEach((item, index) => {
|
|
this.columns[index] = item.value;
|
|
this.keyList[index] = item.name;
|
|
})
|
|
if (options.listDetail) {
|
|
this.listDetail = JSON.parse(decodeURIComponent(options.listDetail))
|
|
this.listDetail.saleDetailQueryDTO.map((item, index) => {
|
|
let obj = JSON.parse(item.attrributeList);
|
|
for (let items in obj) {
|
|
if (!this.showList[index]) {
|
|
this.showList[index] = []
|
|
}
|
|
this.showList[index].push(obj[items])
|
|
}
|
|
this.numList.push(item.productCount)
|
|
})
|
|
}
|
|
console.log(this.goodsDetail, this.listDetail);
|
|
},
|
|
computed: {
|
|
numAll() {
|
|
if (this.numList.length > 0) {
|
|
return this.numList.reduce((prev, curr) => prev + curr)
|
|
} else {
|
|
return 0
|
|
}
|
|
},
|
|
realPrice() {
|
|
if (this.numList.length > 0) {
|
|
return (this.numAll * this.goodsDetail.wholesalePrice * this.listDetail.discount * 0.1).toFixed(2)
|
|
} else {
|
|
return 0
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
goodsAdd() {
|
|
this.show = true;
|
|
},
|
|
confirm(e) {
|
|
let isTrue = true;
|
|
this.showList.find(item => {
|
|
console.log(item, e.value, 'value');
|
|
if (item.toString() === e.value.toString()) {
|
|
isTrue = false;
|
|
uni.showToast({
|
|
title: '此规格已添加',
|
|
icon: "none"
|
|
})
|
|
return
|
|
}
|
|
})
|
|
if (isTrue) {
|
|
var obj = {};
|
|
console.log(this.keyList)//颜色尺码
|
|
this.keyList.map((item, index) => {
|
|
obj[item] = e.value[index]
|
|
})
|
|
console.log("打印出来");
|
|
this.shopList.push(obj);
|
|
console.log(this.shopList);
|
|
this.showList.push(e.value)
|
|
this.numList.push(1)
|
|
this.show = false;
|
|
}
|
|
// console.log('confirm', e, this.shopList, this.showList, this.numList)
|
|
},
|
|
changeHandler(e) {
|
|
const {
|
|
columnIndex,
|
|
value,
|
|
values, // values为当前变化列的数组内容
|
|
index,
|
|
// 微信小程序无法将picker实例传出来,只能通过ref操作
|
|
picker = this.$refs.uPicker
|
|
} = e
|
|
},
|
|
submit() {
|
|
this.listDetail.discountAmount = this.realPrice * 1;
|
|
this.listDetail.realPrice = this.numAll * this.goodsDetail.wholesalePrice;
|
|
this.listDetail.productCount = this.numAll;
|
|
this.listDetail.productId = this.goodsDetail.id;
|
|
console.log(this.shopList)
|
|
this.shopList.map((item, index) => {
|
|
this.attributeList[index] = {
|
|
attributeList: JSON.stringify(item),
|
|
productCount: this.numList[index]
|
|
}
|
|
})
|
|
this.listDetail.saleDetailQueryDTO = this.attributeList;
|
|
console.log(this.listDetail);
|
|
let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
|
|
let nowPage = pages[pages.length - 1]; //当前页页面实例
|
|
let prevPage = pages[pages.length - 2]; //上一页页面实例
|
|
|
|
let result2 = prevPage.$vm.purchaseDetails.findIndex(ele => ele.productId == this.listDetail.productId)
|
|
if (result2 == -1) {
|
|
prevPage.$vm.purchaseDetails.push(this.listDetail)
|
|
} else {
|
|
prevPage.$vm.purchaseDetails[result2] = this.listDetail
|
|
}
|
|
|
|
console.log(prevPage.$vm.purchaseDetails, '111');
|
|
uni.navigateBack()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.box {
|
|
margin: 20rpx;
|
|
padding: 20rpx;
|
|
border-radius: 14rpx;
|
|
box-shadow: 0px 1px 10px 2px #e2e2e2;
|
|
background-color: #fff;
|
|
font-size: 12px;
|
|
color: #909399;
|
|
line-height: 32px;
|
|
|
|
text {
|
|
color: $u-primary;
|
|
font-size: 14px;
|
|
padding: 0 20rpx;
|
|
}
|
|
|
|
ul {
|
|
padding: 15rpx;
|
|
}
|
|
|
|
.numli {
|
|
box-shadow: 0px 1px 5px 2px #e2e2e2;
|
|
padding: 25rpx 15rpx;
|
|
margin: 20rpx 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.price {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 0;
|
|
}
|
|
|
|
.priceText {
|
|
margin: 0 15rpx;
|
|
}
|
|
|
|
.text {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-size: 12px;
|
|
margin: 0 15rpx;
|
|
}
|
|
}
|
|
|
|
.attrs {
|
|
text {
|
|
display: inline-block;
|
|
border: 1px solid $u-primary;
|
|
padding: 7px 20rpx;
|
|
margin: 20rpx;
|
|
background-color: #fff;
|
|
color: $u-primary;
|
|
}
|
|
|
|
.checkedText {
|
|
background-color: $u-primary;
|
|
color: #fff;
|
|
}
|
|
}
|
|
|
|
.headerBox {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
|
|
view {
|
|
flex: 1;
|
|
}
|
|
|
|
image {
|
|
width: 150rpx;
|
|
height: 150rpx;
|
|
}
|
|
|
|
.content {
|
|
padding-left: 14rpx;
|
|
|
|
view {
|
|
line-height: 50rpx;
|
|
}
|
|
|
|
text {
|
|
color: #909399;
|
|
}
|
|
}
|
|
}
|
|
|
|
.tui-tabbar {
|
|
width: 100%;
|
|
height: 98rpx;
|
|
background: #fff;
|
|
position: fixed;
|
|
left: 0;
|
|
bottom: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
font-size: 26rpx;
|
|
box-shadow: 0 0 1px rgba(0, 0, 0, .3);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
z-index: 996;
|
|
padding: 0 20rpx;
|
|
|
|
.tui-btn-mr {
|
|
margin-right: 30rpx;
|
|
}
|
|
|
|
.text {
|
|
flex: 2;
|
|
}
|
|
}
|
|
</style>
|