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

520 lines
11 KiB

<template>
<view class="page1">
<view style="position: fixed;top: 0;z-index: 99;height: 70px;width: 100%;display: flex;background: #fff;padding-top: 30px;">
<uni-icons type="left" size='10' @tap="backPage"></uni-icons>
</view>
<view class="title-box">
<uni-search-bar class="uni-mt-10" radius="5" placeholder="请输入商品名称" cancelButton="none" @blur="search" @clear="clearSearch" />
</view>
<view class="content-left" style="width:13%;height: 80%;float: left;position: fixed;top: 110px;">
<view class="left-box" v-for="(item, index) in indexList" :key="index"
:class="item.parentId ? 'left-box-hover':''" @tap="clickLeftBtn(index)">
<text style="width: 100%;height: 40px;line-height: 40px;display: inline-block;overflow: hidden;"
:class="item.parentId ? 'red' :''">{{item.categoryName}}</text>
</view>
</view>
<view class="content-right" style="width: 87%;background: #fff;margin-left:13%;margin-top: 110px;">
<view class="table">
<view class="table-th">
<view style="width: 5%;">#</view>
<view style="width: 10%;">商品图</view>
<view style="width: 25%;">货号</view>
<view style="width: 20%;">名称</view>
<view style="width: 20%;">批发价</view>
<view style="width: 20%;">零售价</view>
</view>
<view class="table-tr" v-for="(item,index) in shopList" :key="index">
<view style="width: 5%;background: #fff;" @tap="checkboxChange(item)">
<checkbox-group>
<label>
<checkbox :checked="item.checked" class="checkbox" />
</label>
</checkbox-group>
</view>
<view style="width: 10%;" @tap.stop="largeImg(item)">
<img :src="item.productPicture" alt="" v-if="item.productPicture" style="border-radius:10px;width: 30px;height: 30px;margin: 0 auto;">
<view class="noPic" v-else style="width: 100%;">暂无图片</view>
</view>
<view style="width: 25%;">
{{item.productSn==null?'':item.productSn}}
</view>
<view style="width: 20%;">
{{item.productName == null?'暂无':item.productName}}
</view>
<view style="width: 20%;">
{{item.wholesalePrice}}
</view>
<view style="width: 20%;">
{{item.price}}
</view>
</view>
</view>
<u-loadmore :status="status" />
</view>
<view class="bottom-box">
<button class="bottom-btn" @tap="checkPay()">批量下架</button>
</view>
</view>
</template>
<script>
export default {
components: {},
data() {
return {
indexList: [],
pageNum: 1, //分页的页码
shopList: [],
shopList1: [],
info: 0,
goodsList: [],
categoryId: '', //分类id
searchName: '', //搜索框输入值
shopId: '', //店铺id,
checkbox: '', //需要分享的商品id
id: '',
carList: [],
carNum: 0,
carType: 0,
type: '',
gwcList: [],
checkPayData:'',
data:{},
height:0
}
},
onReachBottom() {
console.log("触底")
if (this.pageNum >= this.pages) return;
// this.status = 'loading';
this.pageNum ++;
this.getShareList();
},
onLoad(options) {
// wx.updateShareMenu({
// withShareTicket: true,
// isPrivateMessage:true,
// success () { }
// })
this.height = wx.getSystemInfoSync().windowHeight
if (options.khid != undefined) {
uni.redirectTo({
url: "/package1/index/downStearmList?khid=" + options.khid
})
}else{
this.type = uni.getStorageSync('type')
this.getGategoryList()
}
},
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.pageNum = 1
this.searchName = ""
this.shopList1 = []
this.shopList = []
this.getShareList();
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//点击分类获取商品列表
async getShareList(type) {
let that = this
this.goodsList = []
await this.tui.request("/app/product/getShareList", "POST", {
categoryId: this.searchName == ""?this.categoryId:"",
searchStr: this.searchName,
pageNum: this.pageNum,
pageSize: '20'
}, false, false).then((res) => {
if (res.code == 200) {
for(var i = 0; i < res.result.records.length; i++){
if(res.result.records != ''){
res.result.records[i].checked = false
}
}
this.$nextTick(()=>{
if(type=='search'){
this.shopList = []
this.status = 'nomore';
if (this.pages == 1) {
this.shopList1 = res.result.records
} else {
this.shopList1 = [...this.shopList1, ...res.result.records]
}
this.pages = res.result.pages
}else{
this.shopList1 = []
this.status = 'nomore';
if (this.pages == 1) {
this.shopList = res.result.records
} else {
this.shopList = [...this.shopList, ...res.result.records]
}
this.pages = res.result.pages
}
})
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
await this.getCheck()
},
backPage(){
uni.navigateBack()
},
//顶部搜索框
search(e) {
if(e.value == ''){
this.searchName = ""
this.getShareList()
}else{
this.searchName = e.value
this.getShareList('search')
}
},
clearSearch(){
this.searchName = ''
this.getGategoryList()
},
getCheck(){
let that = this;
if(that.carList != ''){
if(this.searchName != ''){
for (var i = 0; i < that.carList.length; i++) {
for (var m = 0; m < that.shopList.length; m++) {
if(that.carList[i] == that.shopList[m].id){
that.shopList[m].checked = true
}
}
}
}else{
for (var i = 0; i < that.carList.length; i++) {
for (var m = 0; m < that.shopList.length; m++) {
// for (var j = 0; j < that.shopList[m].length; j++) {
if(that.carList[i] == that.shopList[m].id){
that.shopList[m].checked = true
}
// }
}
}
}
}
console.log(this.shopList)
this.$forceUpdate()
},
//未入库遮罩
clickMask() {
uni.showToast({
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.pageNum = 1
this.searchName = ""
this.shopList1 = []
this.shopList = []
this.getShareList(this.indexList[index].id)
},
//选中商品
checkboxChange(item) {
item.checked = !item.checked
if (this.carList.indexOf(item.id) != -1) {
this.carList.splice(this.carList.indexOf(item.id), 1)
} else {
this.carList.push(item.id)
}
if (this.gwcList.length == 0) {
this.gwcList.push(item)
} else {
for (let i = 0; i < this.gwcList.length; i++) {
if (this.gwcList[i].id == item.id) {
this.gwcList.splice(i, 1)
} else {
if (this.gwcList.length == (i + 1)) {
this.gwcList.push(item)
return
}
}
}
}
},
checkPay(){
if(this.carList.length == 0){
this.tui.toast("请勾选商品后再下架")
return
}
let data = ''
for(let i=0;i<this.carList.length;i++){
if(i == 0){
data += this.carList[i]
}else{
data += ','+this.carList[i]
}
}
this.$nextTick(()=>{
this.tui.request("/app/product/batchDown", "POST", {
ids:data
}, false, true).then((res) => {
if (res.code == 200) {
this.pageNum = 1
this.searchName = ""
this.shopList1 = []
this.shopList = []
this.getShareList()
this.carList = []
this.tui.toast("下架成功!")
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
})
},
}
}
</script>
<style lang="scss">
page,.page1 {
display: flex;
flex-direction: column;
height: 100%;
font-size: 14px;
}
.uni-tab__dot {
padding: 0 8px;
line-height: 30px;
color: #ffffff;
text-align: center;
background-color: #ff0000;
border-radius: 30px;
}
.uni-tab__text {
color: #646566;
}
.title-box {
background: #fff;
position: fixed;
z-index: 99;
width: 100%;
top: 70px;
}
.bottom-box {
width: 100%;
height: 50px;
position: fixed;
bottom: 0;
display: flex;
background: #fff;
z-index: 101;
}
.bottom-btn {
margin: 0;
padding: 0;
width: 90%;
line-height: 40px;
height: 40px;
text-align: center;
margin: 5px auto;
color: #fff;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 40px;
}
.content-left {
width: 170px;
background: #eee;
height: 100%;
overflow: scroll;
}
.red {
border-right: 3px solid red;
}
.content-right {
flex: 1;
height: 100%;
overflow-y: scroll;
}
.right-box {
width: 100%;
height: 190px;
display: flex;
border-bottom: 1px solid #eee;
position: relative;
}
.box-left {
width: 130px;
height: 131px;
background-size: 100%;
margin: 25px 30px 35px 10px;
border-radius: 20px;
}
.box-left img {
width: 100%;
height: 100%;
}
.box-right {
margin-top: 17px;
}
.box-right-name {
font-weight: bold;
}
.box-right-num {
padding: 5px 0;
color: #777;
}
.box-right-price {
display: flex;
}
.checkbox {
width: 30px;
height: 30px;
}
.price-box {
display: flex;
flex-direction: column;
margin-right: 20px;
}
.price-box text:first-child {
color: #ffa200
}
.uni-tab__cart-button-right,
.uni-tab__cart-sub-right {
display: none;
flex: none;
}
.shop-mask {
width: 100%;
height: 190px;
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.1);
z-index: 99;
}
.noPic{
width: 100%;
height: 40px;
text-align: center;
line-height: 40px;
color: #777;
background: #eee;
}
.table {
display: flex;
flex-direction: column;
height: auto;
overflow-x: scroll;
width: 100%;
white-space: nowrap;
overflow: scroll;
min-height: 200px;
}
.table-th {
width: 100%;
height: 30px;
line-height: 30px;
background: #088FEB;
color: #fff;
view {
width: 80px;
float: left;
text-align: center;
border-right: 1px solid #fff;
}
}
.table-tr {
flex: 0 0 auto;
width: 100%;
height: 30px;
position: relative;
line-height: 30px;
color: #000;
view {
width: 80px;
height: 30px;
line-height: 30px;
float: left;
text-align: center;
border-bottom: 1px solid #000;
border-right: 1px solid #000;
}
}
.left-box {
width: 100%;
height: 40px;
text-align: center;
line-height: 40px;
border-bottom: 1px solid #fff;
}
.left-box-hover {
width: 100%;
height: 40px;
text-align: center;
line-height: 40px;
border-bottom: 1px solid #fff;
background-color: #fff;
}
</style>