Browse Source

优选订单完成

cr 4 years ago
parent
commit
86f513af5e
2 changed files with 1394 additions and 1374 deletions
  1. 1052 1039
      src/pages/recommend/detail.vue
  2. 342 335
      src/pages/recommend/spec.vue

File diff suppressed because it is too large
+ 1052 - 1039
src/pages/recommend/detail.vue


+ 342 - 335
src/pages/recommend/spec.vue

@@ -1,407 +1,414 @@
1 1
 <template>
2
-  <div class="g-spec" v-if="show" :class="{ page_red: theme === 1 }">
3
-    <div
4
-      class="g-spec__content"
5
-      :class="{ 'g-spec__content--iphoneX': iphoneX }"
6
-    >
7
-      <div class="g-info">
8
-        <div class="g-info__content">
9
-          <img class="g-info__img" :src="goods.pictureUrls[0]" alt="" />
10
-          <div class="g-info__right">
11
-            <div class="g-info__title">
12
-              {{ goods.name }}
2
+    <div class="g-spec" v-if="show" :class="{ page_red: theme === 1 }">
3
+        <div
4
+            class="g-spec__content"
5
+            :class="{ 'g-spec__content--iphoneX': iphoneX }"
6
+        >
7
+            <div class="g-info">
8
+                <div class="g-info__content">
9
+                    <img
10
+                        class="g-info__img"
11
+                        :src="goods.pictureUrls[0]"
12
+                        alt=""
13
+                    />
14
+                    <div class="g-info__right">
15
+                        <div class="g-info__title">
16
+                            {{ goods.name }}
17
+                        </div>
18
+                        <div class="g-info__price">
19
+                            ¥{{ spec.price | minuteToRmb2 }}
20
+                        </div>
21
+                    </div>
22
+                    <div class="g-info__close" @click="close">
23
+                        <i class="iconfont iconclose g-info__close-icon"></i>
24
+                    </div>
25
+                </div>
26
+            </div>
27
+            <ul class="g-list">
28
+                <li class="g-list__item">
29
+                    <div class="g-list__title">规格</div>
30
+                    <ul class="g-specification">
31
+                        <li
32
+                            class="g-specification__item"
33
+                            :class="{
34
+                                'g-specification__item--active': value.active,
35
+                            }"
36
+                            v-for="(value, key) in specList"
37
+                            :key="key"
38
+                            @click="selectSpec(value, index)"
39
+                        >
40
+                            {{ value.properties }}
41
+                        </li>
42
+                    </ul>
43
+                </li>
44
+            </ul>
45
+            <div class="g-entrepot">
46
+                <div class="g-entrepot__left">
47
+                    <div class="g-entrepot__title">购买数量:</div>
48
+                    <div class="g-entrepot__num">
49
+                        {{
50
+                            "剩余" +
51
+                            (spec ? spec.inventory : goods.totalInventory) +
52
+                            "件"
53
+                        }}
54
+                    </div>
55
+                </div>
56
+                <f-input-number
57
+                    v-model="num"
58
+                    :max="spec.inventory || goods.totalInventory"
59
+                ></f-input-number>
60
+            </div>
61
+            <ul class="g-nav" v-if="type === 'spec'">
62
+                <li class="g-nav__item" @click="addCart">加入购物车</li>
63
+                <li class="g-nav__item" @click="buy">立即购买</li>
64
+            </ul>
65
+            <div class="g-bottom" v-if="type !== 'spec'">
66
+                <div class="g-bottom__btn" @click="affirm">确定</div>
13 67
             </div>
14
-            <div class="g-info__price">¥{{ spec.price | minuteToRmb2 }}</div>
15
-          </div>
16
-          <div class="g-info__close" @click="close">
17
-            <i class="iconfont iconclose g-info__close-icon"></i>
18
-          </div>
19
-        </div>
20
-      </div>
21
-      <ul class="g-list">
22
-        <li class="g-list__item">
23
-          <div class="g-list__title">规格</div>
24
-          <ul class="g-specification">
25
-            <li
26
-              class="g-specification__item"
27
-              :class="{
28
-                'g-specification__item--active': value.active,
29
-              }"
30
-              v-for="(value, key) in specList"
31
-              :key="key"
32
-              @click="selectSpec(value, index)"
33
-            >
34
-              {{ value.properties }}
35
-            </li>
36
-          </ul>
37
-        </li>
38
-      </ul>
39
-      <div class="g-entrepot">
40
-        <div class="g-entrepot__left">
41
-          <div class="g-entrepot__title">购买数量:</div>
42
-          <div class="g-entrepot__num">
43
-            {{ "剩余" + (spec ? spec.inventory : goods.totalInventory) + "件" }}
44
-          </div>
45 68
         </div>
46
-        <f-input-number
47
-          v-model="num"
48
-          :max="spec.inventory || goods.totalInventory"
49
-        ></f-input-number>
50
-      </div>
51
-      <ul class="g-nav" v-if="type === 'spec'">
52
-        <li class="g-nav__item" @click="addCart">加入购物车</li>
53
-        <li class="g-nav__item" @click="buy">立即购买</li>
54
-      </ul>
55
-      <div class="g-bottom" v-if="type !== 'spec'">
56
-        <div class="g-bottom__btn" @click="affirm">确定</div>
57
-      </div>
58 69
     </div>
59
-  </div>
60 70
 </template>
61 71
 
62 72
 <script>
63 73
 import FInputNumber from "../../components/form/inputNumber";
64 74
 
65 75
 export default {
66
-  name: "GSpec",
67
-  components: { FInputNumber },
68
-  props: {
69
-    // 内容
70
-    goods: {
71
-      type: Object,
72
-    },
73
-  },
74
-
75
-  // 数据
76
-  data() {
77
-    return {
78
-      show: false,
79
-      specList: [],
80
-      num: 1,
81
-      type: "",
82
-      callBack: "",
83
-    };
84
-  },
85
-
86
-  // 函数
87
-  methods: {
88
-    // 打开
89
-    open(type, callBack) {
90
-      const self = this;
91
-
92
-      self.show = true;
93
-      self.type = type || "sepc";
94
-      self.callBack = callBack;
76
+    name: "GSpec",
77
+    components: { FInputNumber },
78
+    props: {
79
+        // 内容
80
+        goods: {
81
+            type: Object,
82
+        },
95 83
     },
96 84
 
97
-    // 关闭
98
-    close() {
99
-      const self = this;
100
-
101
-      self.show = false;
85
+    // 数据
86
+    data() {
87
+        return {
88
+            show: false,
89
+            specList: [],
90
+            num: 1,
91
+            type: "",
92
+            callBack: "",
93
+        };
102 94
     },
103 95
 
104
-    // 选择规格
105
-    selectSpec(val, index) {
106
-      const self = this;
107
-      for (let item of self.specList) {
108
-        if (item.skuNo === val.skuNo) {
109
-          item.active = true;
110
-        } else {
111
-          item.active = false;
112
-        }
113
-      }
114
-      this.specList = [...this.specList];
115
-    },
116
-
117
-    // 加入购物车
118
-    addCart() {
119
-      const self = this;
120
-
121
-      if (self.specList.length && !self.spec) {
122
-        self.fn.showToast("请选择商品规格");
123
-      } else {
124
-        self.api
125
-          .post("/Order/AddCart", {
126
-            productId: self.goods.pid,
127
-            count: self.num,
128
-            skuId: self.spec.skuNo,
129
-            productSource: 1,
130
-          })
131
-          .then((res) => {
132
-            self.close();
133
-            if (self.fn.getType(self.callBack) === "function") {
134
-              self.callBack(res);
96
+    // 函数
97
+    methods: {
98
+        // 打开
99
+        open(type, callBack) {
100
+            const self = this;
101
+
102
+            self.show = true;
103
+            self.type = type || "sepc";
104
+            self.callBack = callBack;
105
+        },
106
+
107
+        // 关闭
108
+        close() {
109
+            const self = this;
110
+
111
+            self.show = false;
112
+        },
113
+
114
+        // 选择规格
115
+        selectSpec(val, index) {
116
+            const self = this;
117
+            for (let item of self.specList) {
118
+                if (item.skuNo === val.skuNo) {
119
+                    item.active = true;
120
+                } else {
121
+                    item.active = false;
122
+                }
135 123
             }
136
-          });
137
-      }
138
-    },
139
-
140
-    // 立即购买
141
-    buy() {
142
-      const self = this;
143
-
144
-      if (self.specList.length && !self.spec) {
145
-        self.fn.showToast("请选择商品规格");
146
-      } else {
147
-        self.api
148
-          .post("/Order/BuyNow", {
149
-            productId: self.goods.itemInfo.itemId,
150
-            count: self.num,
151
-            price:
152
-              parseFloat(self.spec.priceFmt) ||
153
-              parseFloat(self.goods.priceInfo.nowPrice),
154
-            skuId: self.spec.skuId,
155
-            roomId: self.roomId || "",
156
-            videoId: Number(self.videoId) || 0,
157
-          })
158
-          .then((res) => {
159
-            self.close();
160
-            if (self.fn.getType(self.callBack) === "function") {
161
-              self.callBack(res);
124
+            this.specList = [...this.specList];
125
+        },
126
+
127
+        // 加入购物车
128
+        addCart() {
129
+            const self = this;
130
+
131
+            if (self.specList.length && !self.spec) {
132
+                self.fn.showToast("请选择商品规格");
133
+            } else {
134
+                self.api
135
+                    .post("/Order/AddCart", {
136
+                        productId: self.goods.pid,
137
+                        count: self.num,
138
+                        skuId: self.spec.skuNo,
139
+                        productSource: 1,
140
+                    })
141
+                    .then((res) => {
142
+                        self.close();
143
+                        if (self.fn.getType(self.callBack) === "function") {
144
+                            self.callBack(res);
145
+                        }
146
+                    });
162 147
             }
163
-          });
164
-      }
165
-    },
148
+        },
149
+
150
+        // 立即购买
151
+        buy() {
152
+            const self = this;
153
+
154
+            if (self.specList.length && !self.spec) {
155
+                self.fn.showToast("请选择商品规格");
156
+            } else {
157
+                self.api
158
+                    .post("/Order/BuyNow", {
159
+                        productId: self.goods.pid,
160
+                        count: self.num,
161
+                        price: parseFloat(self.spec.price / 100),
162
+                        skuId: self.spec.skuNo,
163
+                        productSource: 1,
164
+                    })
165
+                    .then((res) => {
166
+                        self.close();
167
+                        if (self.fn.getType(self.callBack) === "function") {
168
+                            self.callBack(res);
169
+                        }
170
+                    });
171
+            }
172
+        },
166 173
 
167
-    // 确认处理
168
-    affirm() {
169
-      const self = this;
174
+        // 确认处理
175
+        affirm() {
176
+            const self = this;
170 177
 
171
-      if (self.type === "cart") {
172
-        self.addCart();
173
-      } else if (self.type === "buy") {
174
-        self.buy();
175
-      }
178
+            if (self.type === "cart") {
179
+                self.addCart();
180
+            } else if (self.type === "buy") {
181
+                self.buy();
182
+            }
183
+        },
176 184
     },
177
-  },
178 185
 
179
-  // 数据计算
180
-  computed: {
181
-    // 判断主题  1:红色  2:绿色
182
-    theme() {
183
-      return this.$store.state.common.theme;
184
-    },
186
+    // 数据计算
187
+    computed: {
188
+        // 判断主题  1:红色  2:绿色
189
+        theme() {
190
+            return this.$store.state.common.theme;
191
+        },
185 192
 
186
-    spec() {
187
-      const self = this;
193
+        spec() {
194
+            const self = this;
188 195
 
189
-      let result = "";
196
+            let result = "";
190 197
 
191
-      if (self.goods) {
192
-        for (let item of this.specList) {
193
-          if (item.active) {
194
-            result = item;
195
-          }
196
-        }
197
-      }
198
+            if (self.goods) {
199
+                for (let item of this.specList) {
200
+                    if (item.active) {
201
+                        result = item;
202
+                    }
203
+                }
204
+            }
198 205
 
199
-      self.$emit("update:spec", result);
200
-      return result;
206
+            self.$emit("update:spec", result);
207
+            return result;
208
+        },
201 209
     },
202
-  },
203 210
 
204
-  // 数据监听
205
-  watch: {
206
-    goods(val) {
207
-      const self = this;
211
+    // 数据监听
212
+    watch: {
213
+        goods(val) {
214
+            const self = this;
208 215
 
209
-      if (val) {
210
-        self.specList = val.skuList;
211
-      }
216
+            if (val) {
217
+                self.specList = val.skuList;
218
+            }
219
+        },
212 220
     },
213
-  },
214 221
 };
215 222
 </script>
216 223
 
217 224
 <style lang="scss" scoped>
218 225
 .g-spec {
219
-  position: fixed;
220
-  top: 0;
221
-  bottom: 0;
222
-  left: 0;
223
-  right: 0;
224
-  z-index: 996;
225
-  background-color: rgba(0, 0, 0, 0.4);
226
-
227
-  &__content {
228
-    position: absolute;
226
+    position: fixed;
227
+    top: 0;
229 228
     bottom: 0;
230 229
     left: 0;
231 230
     right: 0;
232
-    z-index: 1;
233
-    background-color: #fff;
234
-
235
-    &--iphoneX {
236
-      padding-bottom: px(30);
231
+    z-index: 996;
232
+    background-color: rgba(0, 0, 0, 0.4);
233
+
234
+    &__content {
235
+        position: absolute;
236
+        bottom: 0;
237
+        left: 0;
238
+        right: 0;
239
+        z-index: 1;
240
+        background-color: #fff;
241
+
242
+        &--iphoneX {
243
+            padding-bottom: px(30);
244
+        }
237 245
     }
238
-  }
239 246
 }
240 247
 
241 248
 .g-info {
242
-  padding-left: px(55);
249
+    padding-left: px(55);
243 250
 
244
-  &__content {
245
-    display: flex;
246
-    height: px(300);
247
-    border-bottom: solid px(3) #fafafa;
248
-  }
249
-
250
-  &__img {
251
-    width: px(300);
252
-    height: px(300);
253
-    margin-top: px(-40);
254
-    border-radius: px(10);
255
-  }
256
-
257
-  &__right {
258
-    flex: 1;
259
-    padding: px(35);
260
-  }
261
-
262
-  &__title {
263
-    @include omits(2);
264
-    width: px(500);
265
-    font-size: px(36);
266
-    color: #000;
267
-  }
268
-
269
-  &__price {
270
-    margin-top: px(30);
271
-    font-size: px(34);
272
-    color: #000;
273
-  }
274
-
275
-  &__close {
276
-    position: absolute;
277
-    top: px(-115);
278
-    right: px(55);
279
-    z-index: 1;
280
-    height: px(115);
281
-
282
-    &:after {
283
-      content: "";
284
-      position: absolute;
285
-      bottom: 0;
286
-      left: 50%;
287
-      z-index: 1;
288
-      width: px(2);
289
-      height: px(34);
290
-      transform: translateX(-50%);
291
-      background-color: #fff;
251
+    &__content {
252
+        display: flex;
253
+        height: px(300);
254
+        border-bottom: solid px(3) #fafafa;
255
+    }
256
+
257
+    &__img {
258
+        width: px(300);
259
+        height: px(300);
260
+        margin-top: px(-40);
261
+        border-radius: px(10);
262
+    }
263
+
264
+    &__right {
265
+        flex: 1;
266
+        padding: px(35);
292 267
     }
293
-  }
294 268
 
295
-  &__close-icon {
296
-    font-size: px(84);
297
-    color: #fff;
298
-  }
269
+    &__title {
270
+        @include omits(2);
271
+        width: px(500);
272
+        font-size: px(36);
273
+        color: #000;
274
+    }
275
+
276
+    &__price {
277
+        margin-top: px(30);
278
+        font-size: px(34);
279
+        color: #000;
280
+    }
281
+
282
+    &__close {
283
+        position: absolute;
284
+        top: px(-115);
285
+        right: px(55);
286
+        z-index: 1;
287
+        height: px(115);
288
+
289
+        &:after {
290
+            content: "";
291
+            position: absolute;
292
+            bottom: 0;
293
+            left: 50%;
294
+            z-index: 1;
295
+            width: px(2);
296
+            height: px(34);
297
+            transform: translateX(-50%);
298
+            background-color: #fff;
299
+        }
300
+    }
301
+
302
+    &__close-icon {
303
+        font-size: px(84);
304
+        color: #fff;
305
+    }
299 306
 }
300 307
 
301 308
 .g-list {
302
-  padding: 0 px(55) px(60);
303
-  border-bottom: solid px(3) #fafafa;
309
+    padding: 0 px(55) px(60);
310
+    border-bottom: solid px(3) #fafafa;
304 311
 
305
-  &__item {
306
-    padding-top: px(40);
307
-  }
312
+    &__item {
313
+        padding-top: px(40);
314
+    }
308 315
 
309
-  &__title {
310
-    font-size: px(44);
311
-    color: #333;
312
-  }
316
+    &__title {
317
+        font-size: px(44);
318
+        color: #333;
319
+    }
313 320
 }
314 321
 
315 322
 .g-specification {
316
-  display: flex;
317
-  flex-wrap: wrap;
318
-
319
-  &__item {
320 323
     display: flex;
321
-    justify-content: center;
322
-    align-items: center;
323
-    height: px(85);
324
-    padding: 0 px(30);
325
-    margin: px(30) px(30) 0 0;
326
-    font-size: px(34);
327
-    color: #333;
328
-    border-radius: px(10);
329
-    background-color: #f8f8f8;
330
-
331
-    &--active {
332
-      color: #fff;
333
-      background-color: #262626;
324
+    flex-wrap: wrap;
325
+
326
+    &__item {
327
+        display: flex;
328
+        justify-content: center;
329
+        align-items: center;
330
+        height: px(85);
331
+        padding: 0 px(30);
332
+        margin: px(30) px(30) 0 0;
333
+        font-size: px(34);
334
+        color: #333;
335
+        border-radius: px(10);
336
+        background-color: #f8f8f8;
337
+
338
+        &--active {
339
+            color: #fff;
340
+            background-color: #262626;
341
+        }
334 342
     }
335
-  }
336 343
 }
337 344
 
338 345
 .g-entrepot {
339
-  display: flex;
340
-  justify-content: space-between;
341
-  padding: px(35) px(55);
342
-
343
-  &__title {
344
-    padding-top: px(15);
345
-    font-size: px(38);
346
-    color: #333;
347
-  }
348
-
349
-  &__num {
350
-    margin-top: px(35);
351
-    font-size: px(34);
352
-    color: #9e9e9e;
353
-  }
346
+    display: flex;
347
+    justify-content: space-between;
348
+    padding: px(35) px(55);
349
+
350
+    &__title {
351
+        padding-top: px(15);
352
+        font-size: px(38);
353
+        color: #333;
354
+    }
355
+
356
+    &__num {
357
+        margin-top: px(35);
358
+        font-size: px(34);
359
+        color: #9e9e9e;
360
+    }
354 361
 }
355 362
 
356 363
 .g-nav {
357
-  display: flex;
358
-  justify-content: space-between;
359
-  align-items: center;
360
-  padding: 0 px(55);
361
-  height: px(165);
362
-  border-top: solid px(3) #fafafa;
363
-
364
-  &__item {
365 364
     display: flex;
366
-    justify-content: center;
365
+    justify-content: space-between;
367 366
     align-items: center;
368
-    width: px(470);
369
-    height: px(110);
370
-    font-size: px(38);
371
-    color: #262626;
372
-    border-radius: px(55);
373
-    background-color: #e5e5e5;
374
-
375
-    &:last-child {
376
-      color: #fff;
377
-      background-color: #fe6661;
367
+    padding: 0 px(55);
368
+    height: px(165);
369
+    border-top: solid px(3) #fafafa;
370
+
371
+    &__item {
372
+        display: flex;
373
+        justify-content: center;
374
+        align-items: center;
375
+        width: px(470);
376
+        height: px(110);
377
+        font-size: px(38);
378
+        color: #262626;
379
+        border-radius: px(55);
380
+        background-color: #e5e5e5;
381
+
382
+        &:last-child {
383
+            color: #fff;
384
+            background-color: #fe6661;
385
+        }
378 386
     }
379
-  }
380 387
 }
381 388
 
382 389
 .g-bottom {
383
-  display: flex;
384
-  justify-content: center;
385
-  align-items: center;
386
-  padding: 0 px(55);
387
-  height: px(165);
388
-  border-top: solid px(3) #fafafa;
389
-
390
-  &__btn {
391 390
     display: flex;
392 391
     justify-content: center;
393 392
     align-items: center;
394
-    width: 100%;
395
-    height: px(110);
396
-    font-size: px(38);
397
-    color: #fff;
398
-    border-radius: px(55);
399
-    background-color: #27a34f;
400
-  }
393
+    padding: 0 px(55);
394
+    height: px(165);
395
+    border-top: solid px(3) #fafafa;
396
+
397
+    &__btn {
398
+        display: flex;
399
+        justify-content: center;
400
+        align-items: center;
401
+        width: 100%;
402
+        height: px(110);
403
+        font-size: px(38);
404
+        color: #fff;
405
+        border-radius: px(55);
406
+        background-color: #27a34f;
407
+    }
401 408
 }
402 409
 .page_red {
403
-  .g-bottom__btn {
404
-    background-color: #fe6661;
405
-  }
410
+    .g-bottom__btn {
411
+        background-color: #fe6661;
412
+    }
406 413
 }
407 414
 </style>