panhui 4 年之前
父节点
当前提交
e50f4ca22c
共有 7 个文件被更改,包括 312 次插入59 次删除
  1. 1 1
      .env.development
  2. 1 1
      project.config.json
  3. 137 27
      src/components/orderCard.vue
  4. 7 1
      src/pages/my.vue
  5. 128 11
      src/pages/verify.vue
  6. 9 3
      src/pagesMine/city.vue
  7. 29 15
      src/pagesMine/counponDetail.vue

+ 1 - 1
.env.development

@@ -1 +1 @@
-VUE_APP_BASE_URL=http://192.168.1.2:8080
+VUE_APP_BASE_URL=http://192.168.50.104:8080

+ 1 - 1
project.config.json

@@ -185,7 +185,7 @@
                     "id": -1,
                     "name": "核销",
                     "pathName": "pages/verify",
-                    "query": "orderId=1630",
+                    "query": "userCouponId=1142",
                     "scene": null
                 },
                 {

+ 137 - 27
src/components/orderCard.vue

@@ -1,16 +1,38 @@
 <template>
     <van-popup :show="show" round position="bottom" @close="onClose" @click-overlay="onClose">
         <div class="orderInfo">
-            <div class="order-title">核销产品</div>
+            <div class="order-title">{{ isCoupon ? '核销优惠券' : '核销产品' }}</div>
             <div class="product">
-                <img :src="info.img" class="icon" />
-                <div class="right">
+                <div class="coupon-img" v-if="isCoupon">
+                    {{ couponInfo.price }}
+                </div>
+                <img :src="info.img" v-else class="icon" />
+                <div class="right" v-if="isCoupon">
+                    <div class="tag">立减券</div>
+                    <div class="product-name">{{ couponInfo.name }}</div>
+                    <div class="desc">{{ couponInfo.title }}</div>
+                </div>
+                <div class="right" v-else>
                     <div class="product-name">{{ info.name }}</div>
                     <div class="price">¥{{ info.price }}</div>
                 </div>
             </div>
+            <div class="order-list" v-if="isCoupon">
+                <div class="order-list-item">
+                    <div class="label">到期时间</div>
+                    <div class="val">{{ couponInfo.period }}</div>
+                </div>
+                <div class="order-list-item">
+                    <div class="label">使用门店</div>
+                    <div class="val">{{ couponInfo.store }}</div>
+                </div>
+                <div class="order-list-item order-detail">
+                    <div class="label">套餐详情</div>
+                    <div class="val" v-html="couponInfo.content"></div>
+                </div>
+            </div>
 
-            <div class="order-list">
+            <div class="order-list" v-else>
                 <div class="order-list-item">
                     <div class="label">规格</div>
                     <div class="val">{{ info.specification }}</div>
@@ -80,12 +102,30 @@ export default {
         show: {
             type: Boolean,
             default: false
+        },
+        isCoupon: {
+            type: Boolean,
+            default: false
+        },
+        userCoupon: {
+            type: Object,
+            default: () => {
+                return {};
+            }
+        },
+        couponInfo: {
+            type: Object,
+            default: () => {
+                return {};
+            }
         }
     },
     computed: {
         ...mapState(['orderStatus']),
         checkStatus() {
-            if (this.info.status === 'PAID') {
+            if (this.isCoupon && !this.userCoupon.use) {
+                return 'canCheck';
+            } else if (this.info.status === 'PAID') {
                 if (this.info.day) {
                     if (this.info.day === dayjs().format('YYYY-MM-DD')) {
                         return 'canCheck';
@@ -102,11 +142,19 @@ export default {
             }
         },
         statusName() {
-            return (
-                [...this.orderStatus].find(item => {
-                    return this.info.status === item.value;
-                }) || {}
-            ).label;
+            if (this.isCoupon) {
+                if (this.userCoupon.use) {
+                    return '已核销';
+                } else {
+                    return '确认核销';
+                }
+            } else {
+                return (
+                    [...this.orderStatus].find(item => {
+                        return this.info.status === item.value;
+                    }) || {}
+                ).label;
+            }
         }
     },
     methods: {
@@ -121,25 +169,44 @@ export default {
             wx.showLoading({
                 title: '加载中'
             });
-            this.$http
-                .postJson('/userPackageFlow/writeOff', {
-                    orderInfoId: this.info.id,
-                    writeOffUserId: this.$store.state.userInfo.id
-                })
-                .then(res => {
-                    wx.hideLoading();
-                    wx.showToast({
-                        title: '核销成功'
+            if (this.isCoupon) {
+                this.$http
+                    .post('/userCoupon/writeOff?id=' + this.userCoupon.id)
+                    .then(res => {
+                        wx.hideLoading();
+                        wx.showToast({
+                            title: '核销成功'
+                        });
+                        this.onClose();
+                    })
+                    .catch(e => {
+                        wx.showToast({
+                            icon: 'none',
+                            title: e.error
+                        });
+                        this.onClose();
                     });
-                    this.onClose();
-                })
-                .catch(e => {
-                    wx.showToast({
-                        icon: 'none',
-                        title: e.error
+            } else {
+                this.$http
+                    .postJson('/userPackageFlow/writeOff', {
+                        orderInfoId: this.info.id,
+                        writeOffUserId: this.$store.state.userInfo.id
+                    })
+                    .then(res => {
+                        wx.hideLoading();
+                        wx.showToast({
+                            title: '核销成功'
+                        });
+                        this.onClose();
+                    })
+                    .catch(e => {
+                        wx.showToast({
+                            icon: 'none',
+                            title: e.error
+                        });
+                        this.onClose();
                     });
-                    this.onClose();
-                });
+            }
         }
     }
 };
@@ -187,6 +254,25 @@ export default {
                 line-height: 22px;
                 margin-top: 2px;
             }
+
+            .tag {
+                display: inline-block;
+                padding: 0 4px;
+                font-size: 12px;
+                font-weight: bold;
+                color: #f9692a;
+                line-height: 18px;
+                height: 18px;
+                background: #ffd984;
+                border-radius: 2px;
+            }
+
+            .desc {
+                font-size: 12px;
+                color: #ff7f1f;
+                line-height: 17px;
+                margin-top: 4px;
+            }
         }
     }
 
@@ -209,6 +295,10 @@ export default {
                 color: #000000;
                 line-height: 24px;
             }
+
+            &.order-detail {
+                align-items: flex-start;
+            }
         }
     }
 }
@@ -221,4 +311,24 @@ export default {
         background-color: @text3;
     }
 }
+
+.coupon-img {
+    padding: 0 8px;
+    height: 72px;
+    background: linear-gradient(271deg, #fe9b45 0%, #ffae50 100%);
+    border-radius: 8px;
+    flex-shrink: 0;
+    font-weight: bold;
+    color: #ffffff;
+    font-size: 40px;
+    line-height: 72px;
+    .flex();
+    align-items: flex-end;
+    &::before {
+        content: '¥';
+        font-size: 14px;
+        line-height: 20px;
+        margin-bottom: 20px;
+    }
+}
 </style>

+ 7 - 1
src/pages/my.vue

@@ -137,7 +137,13 @@
                     </div>
                 </div>
 
-                <img class="vip-next" @click="goVipCenter" src="../static/svgs/info_img_jiakezhongxin.svg" alt="" />
+                <img
+                    class="vip-next"
+                    v-if="userInfo && userInfo.vip"
+                    @click="goVipCenter"
+                    src="../static/svgs/info_img_jiakezhongxin.svg"
+                    alt=""
+                />
 
                 <recommend></recommend>
             </div>

+ 128 - 11
src/pages/verify.vue

@@ -31,13 +31,36 @@
                 </div>
                 <div class="item" v-for="(item, i) in list" :key="item.id">
                     <div class="user">
-                        <img :src="item.packageImg" class="avatar" />
-                        <div class="info">
+                        <div class="coupon-img" v-if="brand">
+                            {{ item.coupon.price }}
+                        </div>
+                        <img v-else :src="item.packageImg" class="avatar" />
+                        <div class="info" v-if="brand">
+                            <div class="tag">立减券</div>
+                            <div class="name">{{ item.coupon.name }}</div>
+                            <div class="desc">{{ item.coupon.title }}</div>
+                        </div>
+                        <div class="info" v-else>
                             <div class="name">{{ item.name }}</div>
                             <div class="time">¥{{ item.price }}</div>
                         </div>
                     </div>
-                    <div class="items">
+                    <div class="items" v-if="brand">
+                        <img src="../static/svgs/icon_yihexiao.svg" class="hexiao-img" alt="" />
+                        <div class="row">
+                            <div class="name">核销时间</div>
+                            <div class="num">{{ item.useTime }}</div>
+                        </div>
+                        <div class="row">
+                            <div class="name">使用门店</div>
+                            <div class="num">{{ item.coupon.store }}</div>
+                        </div>
+                        <div class="row row-start">
+                            <div class="name">套餐详情</div>
+                            <div class="num" v-html="item.coupon.content"></div>
+                        </div>
+                    </div>
+                    <div class="items" v-else>
                         <img src="../static/svgs/icon_yihexiao.svg" class="hexiao-img" alt="" />
                         <!-- <div class="row  head">
                             <div class="name">项目名称</div>
@@ -108,7 +131,14 @@
             扫码核销
         </div>
 
-        <order-card :show="showScan" @close="closeScan" :info="orderInfo"></order-card>
+        <order-card
+            :show="showScan"
+            :userCoupon="userCoupon"
+            :couponInfo="couponInfo"
+            @close="closeScan"
+            :info="orderInfo"
+            :isCoupon="isCoupon"
+        ></order-card>
     </scroll-view>
 </template>
 <script>
@@ -129,7 +159,10 @@ export default {
                 img: ''
             },
             showScan: false,
-            brand: false
+            brand: false,
+            couponInfo: {},
+            userCoupon: {},
+            isCoupon: false
         };
     },
     computed: {
@@ -154,29 +187,42 @@ export default {
     },
     onLoad(options) {
         console.log(options);
-        var id = 0;
+        var orderId = 0;
+        var userCouponId = 0;
         if (options.orderId) {
-            id = options.orderId;
+            orderId = options.orderId;
+        }
+
+        if (options.userCouponId) {
+            userCouponId = options.userCouponId;
         }
 
         if (options.q) {
             let query = decodeURIComponent(options.q).split('?orderId=');
             if (query.length > 1) {
                 let q = query[1].split('&time=');
-                id = q[0];
+                orderId = q[0];
+            } else {
+                query = decodeURIComponent(options.q).split('?userCouponId=');
+                if (query.length > 1) {
+                    userCouponId = query[1];
+                }
             }
         }
-        if (id) {
-            this.getOrderInfo(id);
+        if (orderId) {
+            this.getOrderInfo(orderId);
+        } else if (userCouponId) {
+            this.getCouponInfo(userCouponId);
         }
     },
     methods: {
         getData() {
             this.$http.get(`/attractions/get/${this.userInfo.attractionsId}`).then(res => {
                 this.brand = res.brand;
+                console.log('品牌核销员', this.brand);
 
                 this.$http
-                    .postJson(res.brand ? '/userCoupon/all' : '/userPackageFlow/writeOffAll1', {
+                    .postJson(this.brand ? '/userCoupon/all' : '/userPackageFlow/writeOffAll1', {
                         page: this.page,
                         sort: 'createdAt,desc',
                         query: {
@@ -203,6 +249,11 @@ export default {
                         if (q[0]) {
                             this.getOrderInfo(q[0]);
                         }
+                    } else {
+                        query = res.result.split('?userCouponId=');
+                        if (query.length > 1) {
+                            this.getCouponInfo(query[1]);
+                        }
                     }
                     // let id = base64.decode(res.result);
                     // if (!isNaN(Number(id))) {
@@ -249,6 +300,29 @@ export default {
                     });
                 });
         },
+        getCouponInfo(userCouponId) {
+            wx.showLoading({
+                title: '加载中'
+            });
+            this.$mp.page.getTabBar().setData({ show: false });
+            this.$http
+                .get(`/userCoupon/get/${userCouponId}`)
+                .then(res => {
+                    this.userCoupon = res;
+                    this.$http.get(`/coupon/get/${res.couponId}`).then(res => {
+                        this.couponInfo = res;
+                        this.showScan = true;
+                        this.isCoupon = true;
+                    });
+                    wx.hideLoading();
+                })
+                .catch(e => {
+                    wx.showToast({
+                        icon: 'none',
+                        title: e.error
+                    });
+                });
+        },
         closeScan() {
             this.page = 0;
             this.getData();
@@ -311,6 +385,26 @@ page {
             border-radius: 8px;
             flex-shrink: 0;
         }
+
+        .coupon-img {
+            padding: 0 8px;
+            height: 72px;
+            background: linear-gradient(271deg, #fe9b45 0%, #ffae50 100%);
+            border-radius: 8px;
+            flex-shrink: 0;
+            font-weight: bold;
+            color: #ffffff;
+            font-size: 40px;
+            line-height: 72px;
+            .flex();
+            align-items: flex-end;
+            &::before {
+                content: '¥';
+                font-size: 14px;
+                line-height: 20px;
+                margin-bottom: 20px;
+            }
+        }
         .info {
             margin-left: 12px;
             .flex-col();
@@ -330,6 +424,25 @@ page {
                 font-size: 14px;
                 color: @text4;
             }
+
+            .tag {
+                align-self: flex-start;
+                padding: 0 4px;
+                font-size: 12px;
+                font-weight: bold;
+                color: #f9692a;
+                line-height: 18px;
+                height: 18px;
+                background: #ffd984;
+                border-radius: 2px;
+            }
+
+            .desc {
+                font-size: 12px;
+                color: #ff7f1f;
+                line-height: 17px;
+                margin-top: 4px;
+            }
         }
     }
     .items {
@@ -350,6 +463,10 @@ page {
             color: black;
             height: 44px;
             .flex();
+
+            &.row-start {
+                align-items: flex-start;
+            }
             .name {
                 font-size: 14px;
                 color: #939599;

+ 9 - 3
src/pagesMine/city.vue

@@ -3,7 +3,7 @@
     "disableScroll": true,
     "backgroundColor": "#ffffff",
     "navigationBarBackgroundColor": "#ffffff",
-    "navigationBarTitleText": "敬请期待",
+    "navigationBarTitleText": "选择地址",
     "navigationBarTextStyle": "black",
     "backgroundColor": "#ffffff"
 }
@@ -15,7 +15,7 @@
         </div>
 
         <div class="choose">
-            <div class="city">南京站</div>
+            <div class="city" @click="back">南京站</div>
         </div>
         <div class="label">
             全部站点
@@ -29,7 +29,13 @@
 </template>
 
 <script>
-export default {};
+export default {
+    methods: {
+        back() {
+            wx.navigateBack();
+        }
+    }
+};
 </script>
 
 <style lang="less" scoped>

+ 29 - 15
src/pagesMine/counponDetail.vue

@@ -20,6 +20,7 @@
                 <div class="code">
                     <div class="qrcode" :class="{ used: !!userCoupon.use }">
                         <canvas canvas-id="mycanvas" :style="{ width: codeSize + 'px', height: codeSize + 'px' }" />
+                        <img class="qrcode-img" :src="qrcodeImg" />
 
                         <img class="used-img" v-if="!!userCoupon.use" src="../static/svgs/icon_yishiyong.svg" alt="" />
                     </div>
@@ -62,7 +63,8 @@ export default {
     data() {
         return {
             counponInfo: {},
-            userCoupon: {}
+            userCoupon: {},
+            qrcodeImg: ''
         };
     },
     onLoad(options) {
@@ -102,20 +104,29 @@ export default {
             console.log(content, canvasId, cavW, cavH);
             //调用插件中的draw方法,绘制二维码图片
             //this.canvasToTempImage 为绘制完成的回调函数,可根据自己的业务添加
-            qrcode.api.draw(content, canvasId, cavW, cavH, this, this.canvasToTempImage(canvasId));
+            qrcode.api.draw(content, canvasId, cavW, cavH, this, this.canvasToTempImage(canvasId, cavW, cavH));
         },
         //获取临时缓存图片路径,存入data中
-        canvasToTempImage(canvasId) {
-            let that = this;
-            wx.canvasToTempFilePath({
-                canvasId, // 这里canvasId即之前创建的canvas-id
-                success: res => {
-                    let tempFilePath = res.tempFilePath;
-                },
-                fail: function(res) {
-                    console.log(res);
-                }
-            });
+        canvasToTempImage(canvasId, cavW, cavH) {
+            setTimeout(() => {
+                wx.canvasToTempFilePath({
+                    fileType: 'jpg',
+                    x: 0,
+                    y: 0,
+                    width: cavW,
+                    height: cavH,
+                    destWidth: cavW,
+                    destHeight: cavH,
+                    canvasId: canvasId,
+                    success: res => {
+                        console.log(res);
+                        this.qrcodeImg = res.tempFilePath;
+                    },
+                    fail: e => {
+                        console.log(e);
+                    }
+                });
+            }, 1000);
         }
     }
 };
@@ -192,10 +203,13 @@ page,
     .qrcode {
         position: relative;
         border-radius: 12px;
-        border: 1px solid #f5f7fa;
-        padding: 5px;
+        // border: 1px solid #f5f7fa;
+        // padding: 5px;
         margin-top: 27px;
         canvas {
+            position: fixed;
+            top: -300px;
+            left: -300px;
             // width: 200px;
             // height: 200px;
             // padding: 15px;