123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <view
- class="product-list"
- >
- <view
- class="product-item"
- :style="{width:itemWidth+'px',marginTop:gap+'px'}"
- v-for="(item,index) in list"
- :key="item.id" >
- <view @click="viewPic(item.productImage)">
- <image mode="aspectFit" :src="item.productImage+'?x-oss-process=image/resize,p_30'" style="height: 140px;width: 100%;"></image>
- <view class="back-price" v-if="item.promoRuleValue">返<text>{{item.promoRuleValue}}</text>元</view>
- <view class="product-code"><text class="ellipsis-one" overflow="ellipsis">{{item.productCode}}</text></view>
- </view>
- <view>
- <view class="product-name">{{item.productName}}</view>
- <view class="product-guige"><text class="ellipsis-two" max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text></view>
- <view class="product-button">
- <view class="price-txt">¥<text>{{item.cost}}</text></view>
- <view>
- <button v-if="!item.checked" @click="addToCat(item)" size="mini" type="default" class="bg-0">
- <image style="width: 10px; height: 10px;" mode="aspectFit" src="../static/add.png"></image>
- </button>
- <button v-else @click="addToCat(item)" size="mini" type="primary" class="bg-1">
- <image style="width: 10px; height: 10px;" mode="aspectFit" src="../static/add.png"></image>
- {{item.qty}}
- </button>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'productItemSkline',
- props: {
- list: {
- type: Array,
- default: () => []
- },
- index:{
- type: [Number,String],
- default: 0
- },
- gap:{
- type: [Number,String],
- default: 10
- },
- itemWidth:{
- type: [Number,String],
- default: 0
- }
- },
- data() {
- return {
-
- }
- },
- methods: {
- addToCat(item){
- this.$emit('chooseProduct',item,this.index)
- },
- viewPic(img){
- uni.previewImage({
- urls: [img],
- longPressActions: {
- itemList: ['发送给朋友', '保存图片', '收藏'],
- success: function(data) {
- console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
- },
- fail: function(err) {
- console.log(err.errMsg);
- }
- }
- })
- }
- },
- }
- </script>
- <style lang="less">
- /* 显示一行省略号 */
- .ellipsis-one{
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- word-break: break-all;
- }
- /* 显示两行,省略号 */
- .ellipsis-two{
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .product-list{
- display:flex;
- flex-wrap: wrap;
- justify-content: space-between;
- padding: 0 3%;
- }
- .product-item{
- background: #ffffff;
- border-radius: 10upx;
- box-shadow: 1px 1px 3px #EEEEEE;
- width: 48%;
- margin: 10px 0 0 0;
- display: flex;
- flex-direction: column;
- .price-txt{
- color: red;
- display: flex;
- align-items: center;
- text{
- font-size: 36rpx;
- }
- }
- > view{
- &:first-child{
- position: relative;
- overflow: hidden;
- .product-code{
- color: #666;
- position: absolute;
- width: 100%;
- left:0;
- bottom:0;
- background: rgba(255,255,255,0.7);
- text-align: center;
- }
- }
- &:last-child{
- position: relative;
- flex-grow: 1;
- padding: 10px 10px 40px;
- .product-name{
- font-size: 28rpx;
- font-weight: 900;
- color: #666;
- }
- .product-guige{
- margin: 10rpx 0;
- color: #2196F3;
- }
- }
- .product-button{
- position: absolute;
- left: 5%;
- bottom: 0;
- width: 90%;
- padding: 5px 0 10px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- button{
- display: flex;
- align-items: center;
- text-align: center;
- justify-content: center;
- min-width:50rpx;
- height: 50rpx;
- font-size: 28rpx;
- border-radius: 25rpx;
- padding: 0 10rpx;
- color: #fff;
- &:active{
- background: #2abcff;
- }
- }
- .bg-0{
- background: #066cff;
- }
- .bg-1{
- background: #34aa0a;
- }
- }
- }
- .back-price{
- padding: 6rpx 65rpx;
- background: rgba(255 ,87 ,34 , 1);
- position: absolute;
- top: 18rpx;
- right: -45rpx;
- color: #fff;
- z-index: 2;
- font-size: 20rpx;
- text-align: center;
- transform: rotate(40deg);
- display: flex;
- align-items: center;
- text{
- font-size: 28rpx;
- margin: 0 5rpx;
- }
- }
- }
- </style>
|