zxl
2 天以前 cb084b230023cfed42249b0145e177deb4b8261c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<template>
  <div class="goods-type-wrapper">
    <!-- 商品部分 -->
    <div class="goods-list flex">
      <div
        class="goods-list-item"
        v-for="(item, index) in data.options.list"
        :key="index"
      >
        <div>
          <div class="goods-name wes-2">{{ item.title }}</div>
          <div class="goods-desc">{{ item.desc }}</div>
        </div>
        <div class="goods-img">
          <img :src="item.img" />
        </div>
      </div>
      <div class="setup-box">
        <div>
          <Button
            size="small"
            @click.stop="handleSelectModel(data.options.list)"
          >编辑</Button
          >
        </div>
      </div>
    </div>
 
    <Modal
      v-model="showModal"
      title="装修"
      draggable
      width="800"
      :z-index="100"
      :mask-closable="false"
    >
      <div class="modal-tab-bar">
            <div class="flex flex-a-c">
              <Button class="add-goods" @click="addCurrentGoods">
                添加商品
              </Button>
            </div>
 
            <div
              v-for="(item, index) in data.options.list"
              :key="index"
              class="draggable"
            >
              <div class="flex">
                <img :src="item.img" class="column-img" />
                <div class="flex column-goods-config">
                  <div class="column-config">
                    <div>
                      标题:
                      <Input v-model="item.title"></Input>
                    </div>
                    <div>
                      描述:
                      <Input v-model="item.desc"></Input>
                    </div>
                  </div>
                  <Button @click="delGoods(item,index)">删除</Button>
                </div>
              </div>
            </div>
 
      </div>
    </Modal>
 
    <!-- 选择商品。链接 -->
    <liliDialog
      ref="liliDialog"
      @selectedLink="selectedLink"
      @selectedGoodsData="selectedGoodsData"
    ></liliDialog>
  </div>
</template>
 
<script>
 
export default {
  name: "onlyGoodsList",
  props: {
    data: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      flag:false,
      tabIndex:0,
      current: 0,
      showModal: false,
      selected: {}, // 已选数据
      picModelFlag: false,
    };
  },
  mounted(){
 
  },
  methods: {
    // 删除商品
    delGoods(val,i) {
      this.data.options.list.splice(i, 1);
    },
    // 添加当前选项卡中的商品
    addCurrentGoods() {
      this.$refs.liliDialog.open("goods");
    },
    // 编辑模块
    handleSelectModel(item) {
      console.log(item);
      this.selected = item;
      this.showModal = true;
    },
    // 选择商品回调
    selectedGoodsData(val) {
      if (val.length) {
        val.forEach((item) => {
          const pushGoodsDetail = {
            img: item.thumbnail,
            price: item.price,
            title: item.goodsName,
            desc: "",
            url: `/goodsDetail?skuId=${item.id}&goodsId=${item.goodsId}`,
          };
          this.data.options.list.push(pushGoodsDetail);
        });
      }
    },
    // 选择链接回调
    selectedLink(val) {
      this.selected[this.current].url =
        this.$options.filters.formatLinkType(val);
      this.selected[this.current].type =
        val.___type === "other" && val.url === "" ? "link" : "other";
 
      console.log(this.selected[this.current]);
    },
    handleSelectLink(index) {
      // 调起选择链接弹窗
      this.$refs.liliDialog.open("link");
      this.current = index;
    },
  },
};
</script>
 
<style scoped lang="scss">
@import "./setup-box.scss";
.goods-type-wrapper {
  position: relative;
}
.del-btn{
  margin-left:10px;
}
.tab-bar {
  margin-bottom: 20px;
}
.draggable {
  padding: 10px;
  border-bottom: 1px solid #ededed;
  transition: 0.35s;
 
  &:hover {
    background-color: #ededed;
  }
}
.column-config {
  margin-left: 10px;
  > * {
    margin: 4px;
  }
}
.column-img {
  width: 100px;
  height: 100px;
}
.add-goods {
  margin-left: 20px;
  margin-bottom: 10px;
}
.goods-list {
  position: relative;
  flex-wrap: wrap;
  justify-content: space-between;
  &:hover {
    > .setup-box {
      display: block;
    }
  }
}
.column-goods-config {
  flex: 2;
  align-items: center;
  justify-content: space-between;
}
.goods-list-item {
  padding-top: 34.8px;
  margin-bottom: 14.3px;
  width: 287px;
  height: 343.7px;
  border-radius: 9.8px;
  opacity: 1;
  cursor: pointer;
  background: #ffffff;
  transition: 0.35s;
  box-shadow: 0px 1px 13px 0px #e5e5e5;
  &:hover {
    box-shadow: 0px 1px 14px 0px #c5c5c5;
  }
}
.goods-img {
  text-align: center;
  > img {
    width: auto;
    max-height: 183px;
  }
}
.goods-name {
  margin-bottom: 11.9px;
  font-size: 25px;
  font-weight: normal;
  line-height: 30px;
  text-align: center;
  letter-spacing: 0px;
 
  color: #333333;
 
  -webkit-text-stroke: #979797 0.7px; /* 浏览器可能不支持 */
}
.goods-desc {
  margin-bottom: 30px;
  font-size: 16px;
  font-weight: normal;
  line-height: 19px;
  text-align: center;
  letter-spacing: 0px;
 
  color: #666666;
 
  -webkit-text-stroke: #979797 0.7px; /* 浏览器可能不支持 */
}
.goods-price {
  font-size: 25.2px;
  font-weight: normal;
  line-height: 30px;
  text-align: center;
  letter-spacing: 0px;
 
  color: #f31947;
  -webkit-text-stroke: #979797 0.7px; /* 浏览器可能不支持 */
}
.goods-type-line {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}
.goods-type-title {
  font-size: 31px;
  font-weight: normal;
  line-height: 37px;
  letter-spacing: 0px;
 
  color: #333333;
}
.active {
  color: #f31947;
}
.goods-type-labels {
  font-size: 21px;
  font-weight: normal;
  line-height: 25px;
  letter-spacing: 0px;
}
.goods-type-item {
  margin-left: 28px;
}
</style>