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.
404 lines
9.0 KiB
404 lines
9.0 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="padding: 0 40rpx;" :class="item.parentId ? 'red' :''">{{item.categoryName}}</text>
|
|
</view>
|
|
</view>
|
|
<view class="content-right">
|
|
<view class="right-box" v-for="item in shopList" :key="item">
|
|
<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">
|
|
<text>{{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>
|
|
<checkbox-group @change="checkboxChange">
|
|
<label>
|
|
<checkbox :value="item.id" class="checkbox" />
|
|
</label>
|
|
</checkbox-group>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="bottom-box">
|
|
<view class="bottom-left">
|
|
<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">{{ info }}</text>
|
|
</view>
|
|
<view class="bottom-right">
|
|
<button class="bottom-btn" open-type="share" @tap="clickShareBtn('all')">分享全部</button>
|
|
<button class="bottom-btn" open-type="share" @tap="clickShareBtn">分享选中</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
components: {},
|
|
onShareAppMessage(res) {
|
|
if (res.from === 'button') {// 来自页面内分享按钮
|
|
console.log(res.target)
|
|
}
|
|
return {
|
|
title: '自定义分享标题',
|
|
path: '/pages/test/test?id=123'
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
indexList: [],
|
|
pageNum: 1, //分页的页码
|
|
shopList: [],
|
|
info: 0,
|
|
categoryId: '', //分类id
|
|
searchName: '', //搜索框输入值
|
|
shopId: '', //店铺id,
|
|
checkbox: '' //需要分享的商品id
|
|
}
|
|
},
|
|
onLoad() {
|
|
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.getShareList(this.indexList[0].id);
|
|
} else {}
|
|
}).catch((res) => {})
|
|
},
|
|
//点击分类获取商品列表
|
|
getShareList(id) {
|
|
this.shopList = []
|
|
this.tui.request("/app/product/getShareList", "POST", {
|
|
shopId: '002',
|
|
categoryId: id,
|
|
// categoryId: '1695090289036890112',
|
|
supplierName: this.searchName,
|
|
// supplierName: '测试',
|
|
pageNum: this.pageNum,
|
|
pageSize: '10'
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.shopList = res.result.records
|
|
} else {}
|
|
}).catch((res) => {})
|
|
},
|
|
// //底部左侧购物车按钮
|
|
// onClick(e) {
|
|
// uni.showToast({
|
|
// title: `点击${e.content.text}`,
|
|
// icon: 'none'
|
|
// })
|
|
// },
|
|
//顶部搜索框
|
|
search(res) {
|
|
this.searchName = res.value
|
|
uni.showToast({
|
|
title: '搜索:' + res.value,
|
|
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.getShareList(this.indexList[index].id)
|
|
},
|
|
//选中商品
|
|
checkboxChange(e) {
|
|
var items = this.shopList,
|
|
values = e.detail.value;
|
|
for (var i = 0, lenI = items.length; i < lenI; ++i) {
|
|
const item = items[i]
|
|
if (values.includes(item.id)) {
|
|
this.$set(item, 'checked', true)
|
|
} else {
|
|
this.$set(item, 'checked', false)
|
|
}
|
|
}
|
|
},
|
|
//点击分享按钮
|
|
clickShareBtn(e) {
|
|
let data = {}
|
|
if (e == 'all') {
|
|
data = {
|
|
shopId: '002',
|
|
shareType: '1', //1 分享全部
|
|
}
|
|
} else {
|
|
var items = this.shopList;
|
|
for (var i = 0; i < items.length; ++i) {
|
|
if (items[i].checked == true) {
|
|
this.checkbox = this.checkbox + ',' + items[i].id
|
|
}
|
|
}
|
|
data = {
|
|
shopId: '002',
|
|
shareType: '2', //2 分享勾选商品
|
|
shareProductId: this.checkbox //勾选商品的id string类型 中间通过”,“连接
|
|
}
|
|
}
|
|
this.tui.request("/app/productShare/save", "POST", data, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
uni.share({
|
|
provider: "weixin",
|
|
scene: "WXSceneSession",
|
|
type: 1,
|
|
summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
|
|
miniProgram: {
|
|
id: 'gh_dc54e7aacd12', //微信小程序原始id
|
|
path: 'pages/index/index',
|
|
type: 1 //0-正式版; 1-测试版; 2-体验版
|
|
},
|
|
success: function(res) {
|
|
uni.showToast({
|
|
title: '分享成功',
|
|
icon: 'success'
|
|
})
|
|
},
|
|
fail: function(err) {
|
|
uni.showToast({
|
|
title: err,
|
|
icon: 'error'
|
|
})
|
|
}
|
|
});
|
|
} else {}
|
|
}).catch((res) => {})
|
|
// this.info++
|
|
},
|
|
}
|
|
}
|
|
</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;
|
|
}
|
|
|
|
.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%;
|
|
display: flex;
|
|
|
|
.bottom-btn {
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 45%;
|
|
line-height: 35px;
|
|
height: 70rpx;
|
|
text-align: center;
|
|
margin-top: 10rpx;
|
|
color: #fff;
|
|
font-size: 28rpx;
|
|
|
|
}
|
|
|
|
.bottom-btn:first-child {
|
|
background: linear-gradient(90deg, #FF9797, #FFC1E0);
|
|
border-top-left-radius: 70rpx;
|
|
border-bottom-left-radius: 70rpx;
|
|
margin-left: 20rpx;
|
|
}
|
|
|
|
.bottom-btn:last-child {
|
|
background: linear-gradient(90deg, #60F3FF, #088FEB);
|
|
border-top-right-radius: 70rpx;
|
|
border-bottom-right-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;
|
|
}
|
|
|
|
.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;
|
|
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;
|
|
}
|
|
</style>
|