index.vue 4.58 KB
Newer Older
张锡奇's avatar
张锡奇 committed
1 2
<style lang="less" >
    #specimen{
张锡奇's avatar
张锡奇 committed
3
        background: #f1f1f1;
张锡奇's avatar
张锡奇 committed
4
        height:100%;
张锡奇's avatar
张锡奇 committed
5 6 7 8
        .INFO{
            background: white;
            padding: 0 10px;
            .CONTENT{
张锡奇's avatar
张锡奇 committed
9
                >div{
张锡奇's avatar
张锡奇 committed
10 11 12 13 14 15 16 17 18 19 20
                    display: flex;
                    border-bottom: 1px solid #F8F8F8;
                    >p{
                        margin:0;padding:0;
                        height:30px;
                        line-height: 30px;
                    }
                    >p:first-child{
                        width:80px;
                        color:#999999
                    }
张锡奇's avatar
张锡奇 committed
21 22 23 24
                }
            }
        }
        .detail{
张锡奇's avatar
张锡奇 committed
25 26 27 28 29 30 31 32
            margin-top:10px;
            background: #fffeeb;
            padding:20px;
            >div{
                margin-bottom:20px;
                p{
                    margin:0;text-align:center;height:30px;line-height:30px;
                    font-weight: bold;
张锡奇's avatar
张锡奇 committed
33 34
                }
            }
张锡奇's avatar
张锡奇 committed
35 36 37 38 39 40 41 42 43 44
            >div:last-child{
                margin-bottom:0;
            }
            .detailImg{
                width:100%;
                height:200px;
                border-top-left-radius: 40px;
                border-bottom-right-radius: 40px;
            }
            
张锡奇's avatar
张锡奇 committed
45 46 47 48 49
        }
    }
</style>

<template>
张锡奇's avatar
张锡奇 committed
50 51 52 53 54 55 56 57 58
    <div id="specimen">
        <div class="INFO">
            <div class="CONTENT">
                <div><p>产品编号</p><p>{{hdr.sMaterialNo}}</p></div>
                <div><p>产品名称</p><p>{{hdr.sMaterialName}}</p></div>
                <div><p>规格</p><p>{{hdr.sConstruction}}</p></div>
                <div><p>成份</p><p>{{hdr.sComponent}}</p></div>
                <div><p>幅宽</p><p>{{hdr.sWidth}}</p></div>
                <div><p>克重</p><p>{{hdr.sGMWT}}</p></div>
张锡奇's avatar
张锡奇 committed
59
            </div>
张锡奇's avatar
张锡奇 committed
60 61 62 63 64 65
        </div>
        <div class="detail">
            <img src="../../../assets/fabric.jpg" style="width:100%;margin-bottom:10px;"/>
            <div v-for="(item, index) in dtl_src" :key="index">
                <p style="">{{item.sColorName}}({{item.sColorNo}}) —</p>
                <img class="previewer-demo-img detailImg" :src="item.src" width="100" @click="show('dtl',index)" />
张锡奇's avatar
张锡奇 committed
66 67
            </div>
        </div>
张锡奇's avatar
张锡奇 committed
68 69
        <div v-transfer-dom>
            <previewer :list="dtl_src" ref="previewer2" :options="options" @on-index-change="logIndexChange"></previewer>
张锡奇's avatar
张锡奇 committed
70 71 72 73 74
        </div>
    </div>
</template>

<script>
张锡奇's avatar
张锡奇 committed
75 76
import Util from '@/libs/util.js';
import {Previewer , TransferDom} from 'vux';
张锡奇's avatar
张锡奇 committed
77 78 79 80 81 82

export default {
  name: 'specimen',
  data () {
    return {
        dtl_src:[],
张锡奇's avatar
张锡奇 committed
83 84
        iProjectId:'',
        uGuid:'',
张锡奇's avatar
张锡奇 committed
85 86
        hdr:{},
        dtl:[],
张锡奇's avatar
张锡奇 committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
        host:'https://weixin.huansi.net/apiproxy/huansi/service/proxy/',
        options: {
            getThumbBoundsFn (index) {
                // find thumbnail element
                let thumbnail = document.querySelectorAll('.previewer-demo-img')[index]
                // get window scroll Y
                let pageYScroll = window.pageYOffset || document.documentElement.scrollTop
                // optionally get horizontal scroll
                // get position of element relative to viewport
                let rect = thumbnail.getBoundingClientRect()
                // w = width
                return {x: rect.left, y: rect.top + pageYScroll, w: rect.width}
                // Good guide on how to get element coordinates:
                // http://javascript.info/tutorial/coordinates
            }
        }
张锡奇's avatar
张锡奇 committed
103 104
    }
  },
张锡奇's avatar
张锡奇 committed
105 106 107 108 109 110
  directives: {
    TransferDom
  },
  components:{
      Previewer
  },
张锡奇's avatar
张锡奇 committed
111
  async mounted(){
张锡奇's avatar
张锡奇 committed
112
        this.iProjectId = this.$route.params.iProjectId;
张锡奇's avatar
张锡奇 committed
113 114 115 116 117 118 119
        this.$route.params.uGuid.split('.').map((x,y) => {
            this.uGuid += String.fromCharCode(x)
        })
        window.data = this;
        await this.getList();
  },
  methods:{
张锡奇's avatar
张锡奇 committed
120 121 122 123 124 125
    logIndexChange (arg) {
        console.log(arg)
    },
    show (type,index) {
        this.$refs[type == 'hdr' ? 'previewer1' : 'previewer2'].show(index)
    },
张锡奇's avatar
张锡奇 committed
126
    error(item,index,type){
张锡奇's avatar
张锡奇 committed
127
        this.$set(this.dtl[index],'isErr',true)
张锡奇's avatar
张锡奇 committed
128 129 130 131 132 133
    },
    async getList(){
        this.apiGet(`${this.host}${this.$route.params.userId}/goods/onesample/${this.uGuid}/`,{},true).then(res=>{
            this.hdr = res.header;
            this.dtl = res.childs;
            res.childs.map(v=>{
张锡奇's avatar
张锡奇 committed
134 135 136 137 138 139
                v.isErr = false;
                this.dtl_src.push({
                    sColorName:v.sColorName,
                    sColorNo:v.sColorNo,
                    src:`${this.host}${this.$route.params.userId}/goods/image_click/?uGuid=${v.uPictureGuid}&iType=2&random=${Math.random()}`
                })
张锡奇's avatar
张锡奇 committed
140 141 142 143 144 145 146 147
            })
        })
    },
  }
}
</script>