Authored by ccbikai

完善图片上传

@@ -15,8 +15,8 @@ module.exports = { @@ -15,8 +15,8 @@ module.exports = {
15 port: 6004, 15 port: 6004,
16 siteUrl: '//m.yohoblk.com', 16 siteUrl: '//m.yohoblk.com',
17 domains: { 17 domains: {
18 - api: 'http://api.yoho.cn/',  
19 - service: 'http://service.yoho.cn/' 18 + api: 'http://192.168.102.202:8080/gateway/',
  19 + service: 'http://192.168.102.202:8080/gateway/'
20 }, 20 },
21 subDomains: { 21 subDomains: {
22 host: '.m.yohoblk.com', 22 host: '.m.yohoblk.com',
1 <template> 1 <template>
2 <div class="upload"> 2 <div class="upload">
3 <form v-on:change="upload"> 3 <form v-on:change="upload">
4 - <label class="label-input" for="{{inputId}}"> 4 + <label class="label-input icon" for="{{inputId}}">
5 <input id="{{inputId}}" type="file" name="filename"> 5 <input id="{{inputId}}" type="file" name="filename">
6 </label> 6 </label>
7 </form> 7 </form>
@@ -28,6 +28,8 @@ @@ -28,6 +28,8 @@
28 processData: false, // 告诉jQuery不要去处理发送的数据 28 processData: false, // 告诉jQuery不要去处理发送的数据
29 contentType: false // 告诉jQuery不要去设置Content-Type请求头 29 contentType: false // 告诉jQuery不要去设置Content-Type请求头
30 }).then(res => { 30 }).then(res => {
  31 + e.target.value = '';
  32 +
31 if (res.code === 200) { 33 if (res.code === 200) {
32 res.data.imagesList.forEach(imagesPath => { 34 res.data.imagesList.forEach(imagesPath => {
33 this.imageList.push(imagesPath); 35 this.imageList.push(imagesPath);
@@ -167,6 +167,7 @@ @@ -167,6 +167,7 @@
167 167
168 .refund { 168 .refund {
169 .return-amount { 169 .return-amount {
  170 + margin: 30px 0;
170 padding: 0 30px; 171 padding: 0 30px;
171 font-size: 32px; 172 font-size: 32px;
172 line-height: 90px; 173 line-height: 90px;
@@ -37,8 +37,7 @@ @@ -37,8 +37,7 @@
37 } 37 }
38 38
39 .product-list { 39 .product-list {
40 - margin-bottom: 30px;  
41 - background: #fff; 40 + margin-top: -4px;
42 border-top: 1px solid #eee; 41 border-top: 1px solid #eee;
43 border-bottom: 1px solid #eee; 42 border-bottom: 1px solid #eee;
44 } 43 }
@@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
42 height: 170px; 42 height: 170px;
43 font-size: 24px; 43 font-size: 24px;
44 line-height: 1.5; 44 line-height: 1.5;
  45 + background: #fff;
45 46
46 &:after { 47 &:after {
47 content: ""; 48 content: "";
@@ -51,6 +52,7 @@ @@ -51,6 +52,7 @@
51 width: 690px; 52 width: 690px;
52 height: 0; 53 height: 0;
53 border-bottom: 1px solid #eee; 54 border-bottom: 1px solid #eee;
  55 + z-index: 1;
54 } 56 }
55 57
56 .checkbox { 58 .checkbox {
@@ -12,7 +12,16 @@ @@ -12,7 +12,16 @@
12 <option v-for="reason in returnReason" v-bind:value="reason.id" selected="{{reason.id === product.reason.id}}">{{reason.name}}</option> 12 <option v-for="reason in returnReason" v-bind:value="reason.id" selected="{{reason.id === product.reason.id}}">{{reason.name}}</option>
13 </select> 13 </select>
14 </div> 14 </div>
15 - <upload v-bind:image-list="product.imageList"></upload> 15 + <div class="remark">
  16 + <textarea v-model="product.remark" rows="3" max-length="100" placeholder="退货原因说明"></textarea>
  17 + </div>
  18 + <div class="image-list clearfix">
  19 + <div class="image-item" v-for="image in imageListForShow">
  20 + <span v-on:click="deleteImage(image.index)" class="icon icon-close"></span>
  21 + <img v-bind:src="image.path">
  22 + </div>
  23 + <upload v-show="imageListForShow.length < 4" class="image-item" v-bind:image-list="product.imageList"></upload>
  24 + </div>
16 </div> 25 </div>
17 </template> 26 </template>
18 27
@@ -25,7 +34,7 @@ @@ -25,7 +34,7 @@
25 domain = 'static.yhbimg.com/goodsimg'; 34 domain = 'static.yhbimg.com/goodsimg';
26 35
27 url = domain + url; 36 url = domain + url;
28 - if (num === 2) { 37 + if (num === '1') {
29 return '//img11.' + url; 38 return '//img11.' + url;
30 } else { 39 } else {
31 return '//img12.' + url; 40 return '//img12.' + url;
@@ -40,11 +49,26 @@ @@ -40,11 +49,26 @@
40 id: 0, 49 id: 0,
41 name: '请选择' 50 name: '请选择'
42 }].concat(this.refundData.returnReason); 51 }].concat(this.refundData.returnReason);
  52 + },
  53 + imageListForShow() {
  54 + const list = [];
  55 +
  56 + this.product.imageList.forEach((path, index) => {
  57 + list.push({
  58 + index: index,
  59 + path: getImgHost(path) + '?imageView2/2/w/160/h/160'
  60 + });
  61 + });
  62 +
  63 + return list;
43 } 64 }
44 }, 65 },
45 methods: { 66 methods: {
46 showTip() { 67 showTip() {
47 alert(this.refundData.specialNotice.remark); 68 alert(this.refundData.specialNotice.remark);
  69 + },
  70 + deleteImage(index) {
  71 + this.product.imageList.splice(index, 1);
48 } 72 }
49 }, 73 },
50 components: { 74 components: {
@@ -55,13 +79,24 @@ @@ -55,13 +79,24 @@
55 79
56 <style> 80 <style>
57 .reason { 81 .reason {
58 - padding: 0 30px;  
59 font-size: 32px; 82 font-size: 32px;
60 line-height: 90px; 83 line-height: 90px;
  84 + background: #f6f6f6;
  85 +
  86 + &:after {
  87 + content: "";
  88 + display: block;
  89 + width: 100%;
  90 + height: 30px;
  91 + border-top: 1px solid #eee;
  92 + border-bottom: 1px solid #eee;
  93 + }
61 94
62 .tip { 95 .tip {
63 position: relative; 96 position: relative;
  97 + padding: 0 30px;
64 font-size: 26px; 98 font-size: 26px;
  99 + background: #fff;
65 100
66 .icon { 101 .icon {
67 margin-right: 5px; 102 margin-right: 5px;
@@ -80,8 +115,10 @@ @@ -80,8 +115,10 @@
80 115
81 .select-reason { 116 .select-reason {
82 position: relative; 117 position: relative;
  118 + padding: 0 30px;
83 width: 100%; 119 width: 100%;
84 height: 90px; 120 height: 90px;
  121 + background: #fff;
85 122
86 &:after { 123 &:after {
87 content: ""; 124 content: "";
@@ -102,5 +139,73 @@ @@ -102,5 +139,73 @@
102 color: #b0b0b0; 139 color: #b0b0b0;
103 } 140 }
104 } 141 }
  142 +
  143 + .remark {
  144 + margin-top: 20px;
  145 + padding: 0 30px;
  146 + background: #fff;
  147 + border-top: 1px solid #eee;
  148 +
  149 + textarea {
  150 + margin-top: 30px;
  151 + width: 100%;
  152 + font-size: 24px;
  153 + line-height: 40px;
  154 + resize: none;
  155 + }
  156 + }
  157 +
  158 + .image-list {
  159 + padding: 30px;
  160 + background: #fff;
  161 +
  162 + .image-item {
  163 + position: relative;
  164 + float: left;
  165 + margin-right: 20px;
  166 + width: 150px;
  167 + height: 150px;
  168 +
  169 + &:last-child {
  170 + margin-right: 0;
  171 + }
  172 +
  173 + .icon-close {
  174 + position: absolute;
  175 + right: -20px;
  176 + top: -20px;
  177 + font-size: 40px;
  178 + color: #fff;
  179 + background: #b0b0b0;
  180 + border-radius: 100%;
  181 + z-index: 2;
  182 + }
  183 +
  184 + img {
  185 + width: 100%;
  186 + height: 100%;
  187 + }
  188 + }
  189 +
  190 + .label-input {
  191 + position: relative;
  192 + width: 150px;
  193 + height: 150px;
  194 + font-size: 150px;
  195 +
  196 + &:before {
  197 + content: "\e604";
  198 + }
  199 +
  200 + input {
  201 + position: absolute;
  202 + left: 0;
  203 + top: 0;
  204 + width: 0;
  205 + height: 0;
  206 + opacity: 0;
  207 + }
  208 + }
  209 + }
105 } 210 }
106 </style> 211 </style>