平板端快衣店
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.
 
 
 
 
 

877 lines
22 KiB

<template>
<view class="page1">
<view class="title-box">
<uni-search-bar class="uni-mt-10" radius="5" placeholder="商品名称/货号/供应商" cancelButton="none"
@confirm="search" />
</view>
<view class="content-box">
<view class="content-left">
<view class="left-box" v-for="(item, index) in indexList" :key="item"
:class="item.parentId ? 'left-box-hover':''" @tap="clickLeftBtn(index)">
<text style="width: 100%;height: 90rpx;line-height: 90rpx;display: inline-block;overflow: hidden;" :class="item.parentId ? 'red' :''">{{item.categoryName}}</text>
</view>
</view>
<view class="content-right">
<view class="right-box" v-for="item in shopList" :key="item" @tap="toggle('bottom',item)">
<!-- 当商品的delFlag=0和未入库状态时,显示此遮罩,点击弹出弹窗提示不能操作 -->
<view class="shop-mask" v-if="item.delFlag == 0" @tap.stop="clickMask(item)"></view>
<view class="box-left">
<img :src="item.productPicture" alt="">
</view>
<view class="box-right">
<view class="box-right-name">{{item.productName}}</view>
<view class="box-right-num">{{item.productSn}}</view>
<view class="box-right-price">
<view class="price-box" v-if="storageType == 0">
<text>{{item.purchasePrice == null ?'待入库':item.purchasePrice}}</text>
<text>采购价</text>
</view>
<view class="price-box">
<text>{{item.wholesalePrice}}</text>
<text>批发价</text>
</view>
<view class="price-box">
<text>{{item.price}}</text>
<text>零售价</text>
</view>
<view class="price-box">
<text>{{item.stockCount}}</text>
<text>库存</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="bottom-box">
<view class="bottom-left" @tap="toggle('carPopup')">
<view class="bottom-left-box">
<uni-icons type="cart" size="20" color="#646566"></uni-icons>
<text class="uni-tab__text">已选择</text>
</view>
<text style="background-color:#ff0000;color:#fff;position: absolute;top: 0;right: 10rpx;"
class="uni-tab__dot">{{carList.length}}</text>
</view>
<view class="bottom-right">
<view class="bottom-btn" @tap="backPrevPage">选好了</view>
</view>
</view>
<!-- 弹出层 -->
<view>
<uni-popup ref="popup" background-color="#fff" @change="change">
<view class="popup-content">
<view class="popup-title">
<view class="popup-title-left">
<img :src="goodsDetail.productPicture" alt="">
</view>
<view class="popup-title-right">
<view class="popup-title-right-box" style="color: #088FEB;">{{goodsDetail.productName}}
</view>
<view class="popup-title-right-box">{{goodsDetail.productSn}}</view>
<view class="popup-title-right-box" style="color: darkorange;" @tap="inputDialogToggle">
<!-- <text style="margin-right:20rpx;">¥{{goodsDetail.price}}</text> -->
</view>
</view>
</view>
<view class="popup-container">
<!-- <view class="purchase-price" v-if="storageType == 0">
<view style="margin-right: 20rpx;">采购价</view>
<uni-easyinput type="text" v-model="purchasePrice" placeholder="请输入采购价" />
</view> -->
<ul style="border-top:20rpx;">
<li v-for="(items,index) in goodsDetail.attributeList" :key="index">
<view class="title-fur">
<view class="name">{{items.name}}</view>
</view>
<view class="attrs">
<uni-data-checkbox v-model="value" :localdata="range"
@change="change"></uni-data-checkbox>
<text v-for="(itemTag, index1) in items.value" :key="index1"
@tap.stop="attrNameChange(index,index1) "
:class="itemTag.isChecked ? 'checkedText' : '' "> {{itemTag.value}}</text>
</view>
</li>
</ul>
<view class="checkList" v-for="item in temporaryList">
<view class="checkList-box">
{{item.name}}
</view>
<uni-number-box max="100000" v-model="item.productCount" @change="temporaryChange" />
</view>
</view>
<view class="popup-bottom" v-for="item in temporaryList">
<view class="popup-bottom-left">
<text>数量:{{zNum}} 件</text>
<!-- <text>¥{{zPrice}}</text> -->
</view>
<view class="popup-bottom-right">
<view class="bottom-btn" @tap="temporaryCheck">选好了</view>
</view>
</view>
</view>
</uni-popup>
</view>
<!-- 购物车弹出层 -->
<uni-popup ref="carPopup" background-color="#fff" @change="change">
<view class="popup-content">
<view v-for="(item,index) in carList" :key="index" style="position: relative;">
<view class="popup-title">
<view class="popup-title-left">
<img :src="item.productPicture" alt="">
</view>
<view class="popup-title-right">
<view class="popup-title-right-box" style="color: #088FEB;">{{item.productName}}</view>
<view class="popup-title-right-box">{{item.productSn}}</view>
<view class="popup-title-right-box" style="color: darkorange;" @tap="inputDialogToggle">
<text style="margin-right:20rpx;">¥{{item.price}}</text>
<!-- <uni-icons color="#088FEB" type="compose" size="16"></uni-icons> -->
<view style="position: absolute;top: 30rpx;right: 30rpx;" @tap.stop="delShop(item)">
<uni-icons color="red" type="trash" size="26"></uni-icons>
</view>
</view>
</view>
</view>
<view class="popup-container" v-for="(item1,index1) in item.saleDetailQueryDTO" :key="index1">
<view class="checkList">
<view style="margin-right:5%;" @tap="delShopSpec(item.id,item1.attributeList)">
<uni-icons color="red" type="minus" size="26"></uni-icons>
</view>
<view class="checkList-box">
{{item1.attributeList | sliceMsg}}
</view>
<uni-number-box max="100000" v-model="item1.productCount" @change="carChange($event,index,index1)" />
</view>
</view>
</view>
<view class="popup-bottom">
<view class="popup-bottom-left">
<text>{{carType}} 款 {{carNum}} 件</text>
</view>
<view class="popup-bottom-right">
<view class="bottom-btn" @tap="this.$refs.carPopup.close()">关闭</view>
</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
components: {},
data() {
return {
indexList: [],
pageNum: 1, //分页的页码
shopList: [],
info: 0,
categoryId: '', //分类id
searchName: '', //搜索框输入值
shopId: '', //店铺id,
checkbox: [], //需要分享的商品id
temporaryNum: 0,
goodsDetail: [],
attrNameList: [],
temporaryList: [],
carList: [],
columns: [],
keyList: [],
evalue: [],
attributeList: [],
purchasePrice: "",
zPrice:0,
zNum:0,
storageType:0,
carNum:0,
carType:0
}
},
filters: {
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + '/'
}
}
return name;
},
maxNum(val) {
if (val >= 10) {
return 10
} else if (val < 0) {
return 0
}
}
},
onLoad() {
this.getGategoryList()
this.storageType = uni.getStorageSync('type')
},
methods: {
//初始化获取分类列表
getGategoryList() {
this.tui.request("/app/productCategory/list", "get", {
// shopId: 1,
}, false, true).then((res) => {
if (res.code == 200) {
this.indexList = res.result;
for (var i = 0; i < this.indexList.length; i++) {
if (i == 0) {
this.indexList[i].parentId = true
} else {
this.indexList[i].parentId = false
}
}
this.categoryId = this.indexList[0].id
this.getShareList(this.indexList[0].id);
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
attrNameChange(index, index1) {
this.goodsDetail.attributeList[index].value.forEach(item => {
item.isChecked = false;
})
this.goodsDetail.attributeList[index].isChecked = true;
this.goodsDetail.attributeList[index].value[index1].isChecked = true;
var name = '',
evalue = [],
obj = {}
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
for (var m = 0, Ien = this.goodsDetail.attributeList[i].value; m < Ien.length; m++) {
if (Ien[m].isChecked == true) {
evalue.push(Ien[m].value)
name += Ien[m].value + '/'
}
}
}
this.keyList.map((item, index) => {
obj[item] = evalue[index]
})
let jishuqi = 0;
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
if (this.goodsDetail.attributeList[i].isChecked == true) {
jishuqi++
}
}
if (this.goodsDetail.attributeList.length == jishuqi) {
let data = {}
this.attributeList = {
attributeList: JSON.stringify(obj),
productCount: this.temporaryNum,
name:name,
price:this.purchasePrice
}
for(let i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsDetail.attributeList[i].isChecked = false;
for (let m=0;m<this.goodsDetail.attributeList[i].value.length;m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
if (this.temporaryList.length == 0) {
this.temporaryList.push(this.attributeList);
} else {
for (var i = 0; i < this.temporaryList.length; i++) {
if (this.temporaryList[i].name.indexOf(this.attributeList.name) != -1) {
return
} else {
if (this.temporaryList.length == (i+1)) {
this.temporaryList.push(this.attributeList);
return
}
}
}
}
}
},
temporaryChange(val) {
this.zNum = 0
for (var i=0;i<this.temporaryList.length;i++) {
this.zNum += this.temporaryList[i].productCount
}
this.zPrice = this.zNum * this.purchasePrice
},
//点击底部选好了,返回上一页
backPrevPage() {
let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
let prevPage = pages[pages.length - 2]; //上一页页面实例
prevPage.$vm.carList1 = this.carList
uni.navigateBack({
delta: 1
})
},
//点击分类获取商品列表
getShareList(id) {
this.tui.request("/app/product/getShareList", "POST", {
categoryId: this.categoryId,
supplierName: this.searchName,
pageNum: this.pageNum,
pageSize: '10'
}, false, false).then((res) => {
if (res.code == 200) {
this.shopList = res.result.records
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//获取弹出层状态
change(e) {
console.log('当前模式:' + e.type + ',状态:' + e.show);
},
carChange(e,index,index1) {
console.log(this.carList)
this.carNum = 0
for (let i = 0; i < this.carList.length; i++) {
this.carList[i].num = 0
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) {
this.carList[i].num += this.carList[i].saleDetailQueryDTO[m].productCount
}
this.carNum += this.carList[i].num
}
},
//弹出购物车或者商品规格选择弹窗
toggle(type, item) {
this.type = type
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
if (type == 'carPopup') {
this.carNum = 0
for (let i=0;i<this.carList.length;i++) {
this.carNum += this.carList[i].num
}
this.carType = this.carList.length
this.$refs.carPopup.open('bottom')
} else {
this.checkGoods(item);
this.$refs.popup.open('bottom')
}
},
//选择商品查询商品规格
checkGoods(item) {
this.goodsDetail = item;
this.temporaryList = []
this.columns = []
this.keyList = []
console.log(this.temporaryList)
console.log(this.carList)
if(this.carList != ''){
this.zNum = 0
for(let i=0;i<this.carList.length;i++){
if(item.id == this.carList[i].id){
this.zNum = this.carList[i].num
this.temporaryList = this.carList[i].saleDetailQueryDTO
}
}
}
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", {
categoryId: this.goodsDetail.categoryId
}, false, true).then((res1) => {
if (res1.code == 200) {
if (typeof(res1.result) == 'string') {
let newObj = JSON.parse(res1.result)
let newArr = []
for (let val in newObj) {
let valueObj = [];
for (var i = 0; i < newObj[val].length; i++) {
valueObj.push({
value: newObj[val][i],
isChecked: false
})
}
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;
})
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//顶部搜索框
search(res) {
this.searchName = res.value
this.getShareList()
},
//未入库遮罩
clickMask(item){
let title = ''
if(item.delFlag == 0){
title = '请将商品上架后再操作!'
}
// else if(item.delFlag == 1){
// title = '请将商品入库后再操作!'
// }
uni.showToast({
title: title,
icon: 'none'
})
},
//点击左侧菜单切换
clickLeftBtn(index) {
for (var i = 0; i < this.indexList.length; i++) {
if (i == index) {
this.indexList[i].parentId = true
} else {
this.indexList[i].parentId = false
}
}
this.categoryId = this.indexList[index].id
this.getShareList(this.indexList[index].id)
},
inputDialogToggle() {
this.$refs.inputDialog.open()
},
//临时改价
changePrice(val) {
this.goodsDetail.price = this.temporaryList[0].price = val
},
//弹窗选择规格后,点击弹窗中选好了按钮
temporaryCheck() {
let data = {
id: this.goodsDetail.id,
price: this.zPrice,
num: this.zNum,
productName: this.goodsDetail.productName,
productSn: this.goodsDetail.productSn,
productPicture: this.goodsDetail.productPicture,
supplierName: this.goodsDetail.supplierName,
saleDetailQueryDTO:this.temporaryList
}
if(this.carList.length == 0){
this.carList.push(data)
}else{
let aa = true;
for(let i = 0; i < this.carList.length; i++){
if(this.carList[i].id == data.id){
this.carList[i] = data
aa = false
}
}
if(aa){
this.carList.push(data)
}
}
for (let i = 0; i < this.carList.length; i++) {
this.carList[i].num = 0
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) {
this.carList[i].num += this.carList[i].saleDetailQueryDTO[m].productCount
}
}
this.temporaryList = []
this.purchasePrice = ""
this.zPrice = ''
this.zNum = ''
for(let i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsDetail.attributeList[i].isChecked = false;
for (let m=0;m<this.goodsDetail.attributeList[i].value.length;m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
this.$refs.popup.close()
console.log(this.carList)
},
//删除整条商品
delShop(item){
var that = this;
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
if (res.confirm) {
for(let i=0;i<that.carList.length;i++){
if(that.carList[i].id == item.id){
that.carNum -= that.carList[i].num
that.carList.splice(i, 1)
}
}
that.carType = that.carList.length
}
that.$forceUpdate()
}
})
},
//删除商品下的某一个规格
delShopSpec(index,index1){
var that = this;
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
if (res.confirm) {
for(let i=0;i<that.carList.length;i++){
for(let m=0;m<that.carList[i].saleDetailQueryDTO.length;m++){
if(that.carList[i].id == index){
if(that.carList[i].saleDetailQueryDTO[m].attributeList == index1){
that.carList[i].num -= that.carList[i].saleDetailQueryDTO[m].productCount
that.carNum -= that.carList[i].saleDetailQueryDTO[m].productCount
that.carList[i].saleDetailQueryDTO.splice(m, 1)
continue;
}
}
}
if(that.carList[i].saleDetailQueryDTO.length == 0){
that.carList.splice(i, 1)
}
}
that.carType = that.carList.length
}
that.$forceUpdate()
}
})
}
}
}
</script>
<style lang="scss">
page {
height: 100%;
}
.page1 {
display: flex;
flex-direction: column;
height: 92%;
}
.uni-tab__dot {
padding: 0 4px;
line-height: 15px;
color: #ffffff;
text-align: center;
font-size: 12px;
background-color: #ff0000;
border-radius: 15px;
}
.popup-content {
align-items: center;
justify-content: center;
padding: 15px;
height: 1200rpx;
background-color: #fff;
}
.popup-title-right-box {
height: 50rpx;
line-height: 50rpx;
}
.popup-title-right {
width: 400rpx;
margin-left: 30rpx;
}
.popup-title-left {
width: 150rpx;
height: 150rpx;
}
.popup-title-left image {
width: 150rpx;
height: 150rpx;
}
.popup-title {
display: flex;
height: 180rpx;
border-bottom: 1px solid #eee;
margin-top: 20rpx;
}
.popup-container {
width: 100%;
background: #fff;
height: 50rpx;
}
.uni-tab__text {
font-size: 12px;
color: #646566;
}
.title-box {
background: #fff;
}
.bottom-box {
width: 100%;
position: fixed;
bottom: 0;
display: flex;
}
.bottom-left {
width: 15%;
position: relative;
}
.bottom-right {
width: 85%;
.bottom-btn {
width: 85%;
line-height: 35px;
height: 70rpx;
text-align: center;
margin-top: 10rpx;
color: #fff;
font-size: 28rpx;
margin: 0 auto;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 70rpx;
}
}
.bottom-left-box {
display: flex;
flex-direction: column;
text-align: center;
}
.content-box {
background: #fff;
flex: 1;
display: flex;
}
.content-left {
width: 170rpx;
background: #eee;
height: 100%;
}
.left-box {
width: 100%;
height: 90rpx;
font-size: 30rpx;
text-align: center;
line-height: 90rpx;
border-bottom: 1px solid #fff;
}
.purchase-price {
display: flex;
line-height: 40px;
height: 80rpx;
width: 95%;
margin: 20rpx auto;
}
.left-box-hover {
width: 100%;
height: 90rpx;
font-size: 30rpx;
text-align: center;
line-height: 90rpx;
border-bottom: 1px solid #fff;
background-color: #fff;
}
.red {
border-right: 3px solid red;
}
.content-right {
// width: 550rpx;
flex: 1;
overflow-y: scroll;
}
.right-box {
width: 100%;
height: 190rpx;
display: flex;
border-bottom: 1px solid #eee;
position: relative;
}
.box-left {
width: 130rpx;
height: 131rpx;
background-size: 100%;
margin: 25rpx 30rpx 35rpx 10rpx;
border-radius: 20rpx;
}
.box-left img {
width: 100%;
height: 100%;
}
.box-right {
margin-top: 17rpx;
}
.box-right-name {
font-size: 30rpx;
font-weight: bold;
}
.box-right-num {
padding: 5rpx 0;
color: #777;
}
.box-right-price {
display: flex;
font-size: 25rpx;
}
.checkbox {
width: 40rpx;
height: 40rpx;
position: absolute;
top: 20rpx;
right: 30rpx;
}
.price-box {
display: flex;
flex-direction: column;
margin-right: 20rpx;
}
.price-box text:first-child {
color: #ffa200
}
.uni-tab__cart-button-right,
.uni-tab__cart-sub-right {
display: none;
flex: none;
}
.title-fur {
width: 95%;
height: 70rpx;
margin: 0 auto;
}
.name {
font-size: 30rpx;
width: 50%;
float: left;
height: 70rpx;
line-height: 70rpx;
}
.content-fur {
padding-bottom: 25rpx;
}
.content-low {
width: auto;
border: 1px solid #eee;
display: inline-block;
min-width: 90rpx;
padding: 5rpx;
font-size: 35rpx;
text-align: center;
color: #777;
margin: 20rpx 0 0 20rpx;
}
.content-low:hover {
background: #eee;
}
.checkList {
display: flex;
height: 50rpx;
font-size: 28rpx;
line-height: 50rpx;
margin: 20rpx 0;
}
.checkList-box {
height: 50rpx;
width: 60%;
}
.popup-bottom {
width: 100%;
height: 100rpx;
position: fixed;
bottom: 0;
display: flex;
}
.popup-bottom-left {
width: 50%;
line-height: 80rpx;
}
.popup-bottom-right {
width: 50%;
line-height: 100rpx;
.bottom-btn {
width: 70%;
line-height: 35px;
height: 70rpx;
text-align: center;
/* margin-top: 10rpx; */
color: #fff;
font-size: 28rpx;
margin: 0 auto;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 70rpx;
}
}
.attrs {
text {
display: inline-block;
border: 1px solid #5fd9ee;
margin: 20rpx;
background-color: #fff;
color: #5fd9ee;
width: 100rpx;
line-height: 70rpx;
height: 70rpx;
text-align: center;
}
.checkedText {
background-color: $u-primary;
color: #fff;
}
}
.shop-mask {
width: 100%;
height: 190rpx;
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.1);
}
</style>