杨磊
4 天以前 ef37c59e055a990ce247b265b27d3fcef430a243
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<template>
  <div>
    <div class="title spaceBetween">
      <span
        :class="paymentStatus == 0 ? 'paymentStatus' : 'place'"
        @click="changeTabs(0)"
        >全部</span
      >
      <span class="splitline"></span>
      <span
        :class="paymentStatus == 1 ? 'paymentStatus' : 'place'"
        @click="changeTabs(1)"
        >已支付</span
      >
      <span class="splitline"></span>
      <span
        :class="paymentStatus == 2 ? 'paymentStatus' : 'place'"
        @click="changeTabs(2)"
        >待支付</span
      >
    </div>
 
    <div class="content" v-loading="orderListloading">
      <el-empty
        v-if="orderList.length == 0"
        :image-size="200"
        description="暂无数据"
      ></el-empty>
      <template v-else>
        <div class="" v-for="(item, index) in orderList" :key="index">
          <div class="orderNum">
            <span>订单编号:{{ item.orderNumber }}</span>
            <span>创建日期:{{ item.createDate.split("T")[0] }}</span>
          </div>
          <div class="bookItem">
            <div class="wrapImg">
              <img
                class="autoImg"
                :src="
                  getPublicImage(
                    item.saleMethodLinks[0].orderSaleMethod.product.icon
                  )
                "
                alt=""
              />
            </div>
            <div class="information">
              <div>
                <span
                  class="name ellipsis"
                  :title="item.saleMethodLinks[0].orderSaleMethod.product.name"
                  >{{
                    item.saleMethodLinks[0].orderSaleMethod.product.name
                  }}</span
                >
                <span
                  style="float: right; color: #00873c"
                  v-if="item.state == 'Success'"
                  >已支付</span
                >
                <span
                  style="float: right; color: #e50021"
                  v-else-if="item.state == 'WaitPay'"
                  >待支付</span
                >
                <span
                  style="float: right; color: #ccc"
                  v-else-if="item.state == 'Cancel'"
                  >已取消</span
                >
              </div>
              <!-- <p class="author">
              作者:{{ item.author }}
            </p> -->
              <p class="payPrice">
                支付价格:
                <span
                  >¥ <span>{{ item.payPrice }}</span>
                </span>
              </p>
              <p class="quantity">数量:{{ item.saleMethodLinks[0].count }}</p>
              <!-- 不需要显示快递消息 10988 -->
              <!-- <div class="express" v-if="item.state == 'Success'">
              <p>快递信息:{{ item.expressCompany }}</p>
              <p>快递单号:{{ item.courierNumber }}</p>
              <p class="ellipsis" :title="item.receivingInformation">
                收货信息: {{ item.receivingInformation }}
              </p>
            </div> -->
              <!-- 
              2023-04-11 暂时屏蔽
              <div class="succeeded" v-if="item.state == 'Success'">
              <el-button
                size="medium"
                @click="
                  () => {
                    drawABill = true;
                  }
                "
                >开具发票</el-button
              >
            </div> -->
              <div class="unpaid" v-if="item.state == 'WaitPay'">
                <el-button size="medium" @click="toPay(item.orderNumber)"
                  >立即支付</el-button
                >
                <el-button
                  type="danger"
                  plain
                  @click="cancelOrder(item.orderNumber)"
                  >取消订单</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </template>
    </div>
 
    <!-- 开具发票模态框 -->
    <el-dialog
      v-loading="loading"
      title="提示"
      :visible="drawABill"
      width="40%"
      :before-close="handleClose"
    >
      <el-form
        :model="billData"
        ref="form"
        label-position="left"
        :rules="rules"
        label-width="130px"
      >
        <el-form-item label="发票类型"> 增值税纸质普通发票 </el-form-item>
        <el-form-item label="抬头类型">
          <el-radio v-model="billData.type" label="1">个人或事业单位</el-radio>
          <el-radio v-model="billData.type" label="2">公司</el-radio>
        </el-form-item>
        <el-form-item label="发票抬头" prop="name">
          <el-input
            v-model="billData.name"
            placeholder="请填写需要开具发票的姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="发票内容" prop="phone">
          <el-input v-model="billData.content" placeholder="明细"></el-input>
        </el-form-item>
        <el-form-item label="收货地址" prop="phone">
          <el-radio
            v-model="billData.type"
            label="2"
            v-for="(item, index) in addressList"
            :key="index"
          >
            <div></div>
            <span>
              {{ item.city + item.address }}
            </span>
            <div>{{ item.name }} {{ item.tel }}</div>
          </el-radio>
        </el-form-item>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-form>
    </el-dialog>
    <!-- 分页 -->
    <div class="pageinateBox" v-if="orderList.length > 0">
      <el-pagination
        @size-change="
          (val) => {
            paginationData.limit = val;
            getData();
          }
        "
        @current-change="
          (val) => {
            paginationData.page = val;
            getData();
          }
        "
        background=""
        :current-page="paginationData.page - 0"
        :page-size="paginationData.limit"
        prev-text="上一页"
        next-text="下一页"
        layout="total, prev, pager, next, slot, jumper"
        :total="paginationData.totalCount"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { getPublicImage } from "@/assets/js/middleGround/tool";
 
export default {
  data() {
    return {
      orderList: [],
      paginationData: {
        page: 1,
        totalCount: 0,
        limit: 5,
        totalPage: 0,
      },
      orderListloading: false,
      paymentStatus: 0,
      drawABill: false, // 开具发票模态框是否展示
      billData: {
        type: 1, // 发票类型,默认为个人
        name: "", // 开发票的姓名
        content: "", // 发票内容
        address: "", // 发票地址
      }, // 发票信息
      rules: {
        name: [
          {
            required: true,
            message: "请填写需要开具发票的姓名",
            trigger: "blur",
          },
        ],
      },
      addressList: [], // 用户地址
      loading: false,
    };
  },
  created() {
    this.getData();
    this.getAddress();
  },
  methods: {
    getPublicImage,
    changeTabs(index) {
      this.paymentStatus = index;
      this.getData();
    },
    getData() {
      this.orderListloading = true;
      let { limit, page } = this.paginationData;
 
      let filterList = [];
 
      if (this.paymentStatus != 0) {
        filterList = [
          {
            value: this.paymentStatus == 1 ? "Success" : "WaitPay",
            field: "State",
          },
        ];
      }
 
      let query = {
        size: limit,
        start: limit * page - limit,
        sort: {
          type: "Desc",
          field: "CreateDate",
        },
        filterList,
      };
      this.MG.store.getUserOrderList(query).then((res) => {
        this.orderListloading = false;
        this.orderList = res.datas;
        this.paginationData.totalCount = res.totalSize;
      });
    },
    toPay(orderNumber) {
      this.$router.push({
        name: "bookStore-order",
        query: {
          orderNum: orderNumber,
        },
      });
    },
    handleClose(done) {
      this.$confirm("确定取消开具发票吗?")
        .then(() => {
          this.drawABill = false;
        })
        .catch((_) => {});
    },
    // 获取所有地址
    getAddress() {
      this.loading = true;
      this.MG.identity.getCurrentAppUser().then((res) => {
        this.loading = false;
        let storeInfoList = res.infoList.find((i) => i.type == "Address");
        if (storeInfoList && storeInfoList.data) {
          this.addressList = JSON.parse(storeInfoList.data);
        } else {
          // 用户为第一次添加地址,则当前所选地址为默认地址
          this.addressItem.ifdefalut = true;
        }
      });
    },
    // 取消订单
    cancelOrder(orderNum) {
      this.$confirm("确定取消支付", "提示", {
        type: "warning",
      })
        .then(() => {
          let query = {
            orderNum: orderNum,
          };
          this.MG.store.cancelOrder(query).then((res) => {
            this.$message({
              type: "success",
              message: "订单已取消",
            });
            this.getData();
          });
        })
        .catch(() => {});
    },
  },
};
</script>
<style lang="less" scoped>
.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.8px;
  border-top: 2px solid #008e3f;
  line-height: 36px;
  padding-left: 40px;
  background: #d8f7e6;
  line-height: 60px;
  color: #00873c;
  .splitline {
    width: 1px;
    height: 24px;
    background-color: #008e3f;
  }
}
.spaceBetween {
  padding-left: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  span {
    font-weight: 400;
  }
  .paymentStatus {
    font-weight: 700;
  }
  .place {
    cursor: pointer;
  }
}
.content {
  padding: 40px 40px 0 40px;
  .orderNum {
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
  }
  .bookItem {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eeeeee;
    padding-bottom: 40px;
    margin-bottom: 40px;
    .wrapImg {
      border: 1px solid #e6e6e6;
      background: #ffffff;
      width: 150px;
      height: 200px;
      position: relative;
    }
    .information {
      width: 520px;
      font-size: 16px;
      .name {
        display: inline-block;
        width: 460px;
        font-size: 24px;
        font-weight: 700;
        line-height: 24px;
        color: #333333;
      }
      .author {
        font-weight: 400;
        color: #666666;
        padding: 14px 0;
      }
      .payPrice {
        color: #333333;
        padding: 14px 0;
        span {
          font-size: 14px;
          color: #e50021;
          span {
            font-size: 24px;
          }
        }
      }
      .quantity {
        color: #333333;
        padding: 5px 0;
        padding-bottom: 20px;
      }
      .express {
        height: 70px;
        background: #f2f7f4;
        border-radius: 4px;
        padding: 10px;
        color: #666666;
        font-size: 14px;
        line-height: 24px;
        margin-bottom: 30px;
      }
      .succeeded {
        :deep(.el-button--medium) {
          padding: 11px 27px;
          border: 1px solid #00873c;
          color: #00873c;
          font-size: 16px;
        }
      }
      // .unpaid {
      //   }
      .pay {
        :deep(.el-button--medium) {
          padding: 11px 27px;
          border: 1px solid #e50021;
          color: #e50021;
          font-size: 16px;
        }
      }
      .cancel {
        :deep(.el-button--medium) {
          padding: 11px 27px;
          // border: 1px solid yellow;
          color: #fff;
          font-size: 16px;
        }
      }
    }
  }
}
.pageinateBox {
  text-align: center;
  padding: 40px 0;
  :deep(.el-pagination.is-background .btn-next) {
    padding: 0 10px;
  }
  :deep(.el-pagination.is-background .btn-prev) {
    padding: 0 10px;
  }
}
</style>