<template>
    <view class="content">
        <statusNav returnColor="#c2c2c2" navBarTitle="配件列表"></statusNav>
        <container-subgroup-two>
          <view slot="content" style="margin:0rpx -25rpx 0rpx" :style="{paddingTop:statusBarHeight-40 + 'px'}">
        <view class="mountingsList-input"  :style="{top:statusBarHeight + 'px'}">
            <input type="text" class="int" value="" placeholder="请输入关键字" />
            <image class="search" src="../../static/iocn/ss.png" mode=""></image>
            <view class="xian">
                
            </view>
        </view>
        <view class="mountings-list">
            <view class="li" v-for="(item,index) in dataList.data">
                <view class="textCon">
                    <view class="imgCon">
                        <image :src="item.images" class="img" mode="aspectFill"></image>
                    </view>

                    <view class="text">
                        <view class="title">
                            <view class="">
                                {{item.name}}
                            </view>
                            <view class="ispitchOn" @click="ispitchOnFun(item)">
                                <image v-if="item.isJob" src="../../static/iocn/pxz.png" class="icon1" mode=""></image>
                                <view v-else class="icon">

                                </view>
                            </view>
                        </view>
                        <view class="brand p">
                            配件品牌：{{item.brand}}
                        </view>
                        <view class="model p">
                            规格型号{{item.model}}
                        </view>
                        <view class="num p">

                            <view class="">
                                已用数量：{{item.remark}}张
                            </view>
                            <view class="numBtn">
                                <view class="subtract" @click="subtractFun(item)">
                                    -
                                </view>
                                <view class="sum">
                                    {{item.num}}
                                </view>
                                <view class="add" @click="addFun(item)">
                                    +
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="bottom">
                    <view class="p">
                        *请注意规格型号的选择，不同型号不同价格。
                    </view>
                    <view class="sum">
                        费用合计：¥{{item.sum}}
                    </view>
                </view>
            </view>
        </view>
        <button class="submit-button" type="default">确认提交</button>
            </view>
             </container-subgroup-two>
    </view>
</template>

<script>
    import statusNav from '../../components/status-nav.vue';
      import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
    export default {
        components: {
            statusNav,
            containerSubgroupTwo

        },
        data() {
            return {
                    statusBarHeight:uni.getSystemInfoSync().statusBarHeight+40,
               dataList: {
                   list_rows: 10,
                   page: 1,
                   data:{},
                }
            }
        },
        onLoad() {
           this.getData() 
        },
        methods: {
            ispitchOnFun(item) {
                item.isJob = !item.isJob
            },
            subtractFun(item) {
                if (item.num >= 1) {
                    item.num--
                    item.sum = item.price * item.num
                }

            },
            getData() {
                this.$requst.post('/universal/api.accessory/accessory_list', {
                    list_rows: this.dataList.list_rows,
                    page: this.dataList.page,
                }).then(res => {
                    // this.$toolAll.tools.showToast(res.msg);
                    console.log(res.data,"---")
                    if (res.code == 1) {
                        
                        this.dataList.data = res.data
                        for (var i = 0; i <  this.dataList.data.length; i++) {
                             this.$set(this.dataList.data,i,{num:1,...this.dataList.data[i],sum:this.dataList.data[i].price,isJob:false})
                        }
                    } else {
            
                    }
                })
            },
            addFun(item) {
                console.log(item)
                item.num++
                item.sum = item.price * item.num
            }
        }
    }
</script>

<style>
    .content {
        padding-top: 70rpx;
        padding-bottom: 80rpx;
    }
	.mountingsList-input .xian {
		width: 3rpx;
		height: 35rpx;
        z-index: 100;
		position: absolute;
        background-color: #EAEAEA;
		right: 100rpx;
		top: 50%;
		margin-top: -14rpx;
	}
    .submit-button {
        width: 686rpx;
        border-radius: 50rpx;
        height: 90rpx;
        background-color: #02A2ea;
        line-height: 90rpx;
        color: #FFFFFF;
        margin-top: 60rpx;
        text-align: center;
        font-size: 30rpx;
    }

    .mountingsList-input {
        width: 100%;
        position: fixed;
        padding: 40rpx 16rpx;
        
        z-index: 2;
        box-sizing: border-box;
        background-color: #FFFFFF
    }

    .mountingsList-input .int {
        width: 100%;
        background-color: #F7F7F7;
        padding: 0 25rpx;
        height: 67rpx;
        box-sizing: border-box;
        border-radius: 36rpx;
    }

    .mountingsList-input .search {
        width: 28rpx;
        height: 28rpx;
        position: absolute;
        right: 43rpx;
        top: 50%;
        margin-top: -14rpx;
    }

    .mountings-list .li {
        width: 680rpx;
        margin: auto;

        margin-top: 20rpx;
        background-color: #FFFFFF;
        padding: 30rpx 20rpx 0rpx;
    }

    .mountings-list .li .textCon {
        display: flex;
        border-bottom: 2rpx solid #F5F5F5;
    }

    .mountings-list .li .imgCon {
        width: 217rpx;
        height: 137rpx;
        background-color: #CCCCCC;
        border-radius: 5rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 18rpx;
    }

    .mountings-list .li .text {
        flex: 1;
    }

    .mountings-list .li .imgCon .img {
        width: 169rpx;
        height: 104rpx;
        position: relative;
        z-index: 1;
    }

    .mountings-list .li .title {
        font-weight: bold;
        font-size: 24rpx;
        display: flex;
        justify-content: space-between;
    }

    .mountings-list .li .title .ispitchOn .icon {
        width: 26rpx;
        height: 26rpx;
        border: 2rpx solid #CCCCCC;
        box-sizing: border-box;
        border-radius: 50%;
    }

    .mountings-list .li .title .ispitchOn .icon1 {
        width: 26rpx;
        height: 26rpx;
        border-radius: 50%;
    }

    .mountings-list .li .text .p {
        color: #999999;
        font-size: 24rpx;
        margin-top: 5rpx;
    }

    .mountings-list .li .text .num {
        display: flex;
        justify-content: space-between;
    }

    .mountings-list .li .text {
        padding-bottom: 22rpx;
    }

    .numBtn {
        display: flex;
        align-items: center;

    }

    .numBtn .subtract {
        border: 2rpx solid #F5F5F5;
        width: 36rpx;
        height: 36rpx;
        border-radius: 50%;
        text-align: center;
        line-height: 25rpx;
        color: #333333;
        font-size: 50rpx
    }

    .numBtn .sum {
        color: #333333;
        padding: 0 15rpx;
    }

    .numBtn .add {
        width: 36rpx;
        height: 36rpx;
        border-radius: 50%;
        text-align: center;
        line-height: 35rpx;
        font-size: 35rpx;
        background-color: #f82a34;
        color: #FFFFFF;
    }

    .mountings-list .li .bottom {
        padding: 14rpx;
        display: flex;
        justify-content: space-between;
        font-size: 24rpx;
    }

    .mountings-list .li .bottom .p {
        width: 60%;
    }

    .mountings-list .li .bottom .sum {
        color: #ff0000;
    }
 
</style>
