Kaynağa Gözat

优惠券接口对接

xionghaojie 3 yıl önce
ebeveyn
işleme
7f24519da2

+ 4 - 1
src/App.vue

@@ -422,8 +422,11 @@ export default {
             posObj.bindType = this.bindType
           }
           service.post("/material/library", posObj).then((res) => {
-            if (res.data.data.code)
+            if (res.data.code==0)
               this.$message.success('提交成功')
+            else{
+              this.$message.error(res.data.data.msg)
+            }
           }).catch(function () {
 
           });

+ 12 - 5
src/components/View/editorCoupon.vue

@@ -27,17 +27,17 @@
             <!-- 样式2 -->
             <div class="coupon-box" v-for="item in content.value.couponList" :key="item.id">
                 <div class="coupon-info">
-                    <img src="../../assets/images/l-youhuiquan.png" class="coupon-pic"/>
+                    <img :src="item.couponIcon" class="coupon-pic"/>
                     <div class="coupon-content">
-                        <div class="coupon-content-title">超声波洁牙满减优惠券</div>
-                        <div class="coupon-content-date">2021.07.015-2021.07.31</div>
+                        <div class="coupon-content-title">{{ item.couponTitle }}</div>
+                        <div class="coupon-content-date">{{getDateFormat(item.couponStart)}}-{{ getDateFormat(item.couponEnd) }}</div>
                     </div>
                     <div class="coupon-use">
                         <div style="margin: auto;">
                             <span class="coupon-symbol">¥</span>
-                            <span class="coupon-userMoney">50</span>
+                            <span class="coupon-userMoney">{{ item.couponAmount }}</span>
                         </div>
-                        <div class="coupon-useBreif">满399可用</div>
+                        <div class="coupon-useBreif">{{ item.couponBrief }}</div>
                     </div>
                 </div>
                 <div class="coupon-option">
@@ -102,6 +102,7 @@
 </template>
 
 <script>
+import {dateFormat} from '@/utlis/utli'
 export default {
     name: 'editorCoupon',
     props: ['data', 'className'],
@@ -120,6 +121,12 @@ export default {
             },
         },
     },
+    methods: {
+        // dateFormat时间格式化
+        getDateFormat(date){
+            return dateFormat(new Date(date)).v6
+        }
+    }
 }
 </script>
 

+ 9 - 8
src/components/setting/settingCoupon.vue

@@ -19,7 +19,7 @@
                         <el-option
                             v-for="item in couponList"
                             :key="item.id"
-                            :label="item.title"
+                            :label="item.couponTitle"
                             :value="item.id">
                     </el-option>
                     </el-select>
@@ -37,6 +37,7 @@
 </template>
 
 <script>
+import service from '@/utlis/axios'
 export default {
     name: 'settingCoupon',
     props: ['data', 'className'],
@@ -68,13 +69,13 @@ export default {
     methods: {
         // 获取优惠券列表
         getCouponList() {
-            // service.get("/custom/form/column/list?formId=" + formId).then((res) => {
-            //     if (res.data.code != 0) {
-            //         return that.$message.error(res.data.data.msg);
-            //     }
-            //     this.formColumnList = res.data.data;
-            // }).catch(function () {
-            // });
+            service.get("/coupon/page?page=1&limit=10000").then((res) => {
+                if (res.data.code != 0) {
+                    return that.$message.error(res.data.data.msg);
+                }
+                this.couponList = res.data.data.list;
+            }).catch(function () {
+            });
         },
         couponChange(val){
             console.log('val',val)

+ 44 - 0
src/utlis/utli.js

@@ -20,4 +20,48 @@ export function getCookie (cname) {
 //清除cookie
 export function clearCookie (name) {
     this.setCookie(name, "", -1);
+}
+
+//格式化时间
+export function dateFormat (dat){
+	var dat = new Date(dat)
+    //获取年月日,时间
+    var year = dat.getFullYear();
+    var mon = (dat.getMonth()+1) < 10 ? "0"+(dat.getMonth()+1) : dat.getMonth()+1;
+    var data = dat.getDate()  < 10 ? "0"+(dat.getDate()) : dat.getDate();
+    var hour = dat.getHours()  < 10 ? "0"+(dat.getHours()) : dat.getHours();
+    var min =  dat.getMinutes()  < 10 ? "0"+(dat.getMinutes()) : dat.getMinutes();
+    var seon = dat.getSeconds() < 10 ? "0"+(dat.getSeconds()) : dat.getSeconds();
+	
+	var a = new Array("日", "一", "二", "三", "四", "五", "六");  
+	var week = dat.getDay();  
+	var str = "星期"+ a[week]; 
+	
+	// 获取当前小时
+    var hours = dat.getHours();
+    // 设置默认文字
+    var text = ``;
+	console.log(hours)
+    // 判断当前时间段
+    if (hours >= 0 && hours <= 9) {
+        text = `早上`;
+    } else if (hours > 9 && hours <= 13) {
+        text = `中午`;
+    } else if (hours > 13 && hours <= 17) {
+        text = `下午`;
+    } else if (hours > 17 && hours <= 24) {
+        text = `晚上`;
+    }
+		
+    var newDate = {
+		v1:year +"-"+ mon +"-"+ data +" "+ hour +":"+ min +":"+ seon,
+		v2:year +"/"+ mon +"/"+ data +" "+ hour +":"+ min +":"+ seon,
+		v3:year +"/"+ mon +"/"+ data,
+		v4:year +"年"+ mon +"月"+ data +"日",
+		v5:year +"-"+ mon +"-"+ data,
+        v6:year +"."+ mon +"."+ data,
+		week:str,
+		text:text
+	};
+    return newDate;
 }