Преглед на файлове

8/17价格排版&精度&支付成功窗口隐藏

Foystor преди 3 години
родител
ревизия
2b117a7dfc
променени са 6 файла, в които са добавени 219 реда и са изтрити 45 реда
  1. 1 1
      project.private.config.json
  2. 11 0
      src/App.vue
  3. 172 10
      src/components/index/personal.vue
  4. 13 13
      src/pages/coupons/index.vue
  5. 11 12
      src/pages/user_center/confirmPay/index.vue
  6. 11 9
      src/requests/coupons.js

+ 1 - 1
project.private.config.json

@@ -16,7 +16,7 @@
           "name": "pages/index/main",
           "pathName": "pages/index/main",
           "query": "",
-          "scene": null
+          "scene": 1007
         },
         {
           "name": "pages/coupons/main",

+ 11 - 0
src/App.vue

@@ -5,6 +5,17 @@ export default {
       url:'/pages/index/main'
     })
   },
+  //外发
+  onLaunch(options){
+      console.log('启动小程序的场景值:', options.scene)
+      let scene = options.scene
+      if(scene == 1007 || scene == 1008 || scene == 1035 ){
+        console.log('外发给你哦')
+        wx.setStorageSync("is_out", true);
+      }else{
+        wx.setStorageSync("is_out", false);
+      }
+  },
   created() {
 
     // 调用API从本地缓存中获取数据

+ 172 - 10
src/components/index/personal.vue

@@ -70,7 +70,7 @@
       </text>
     </view>
 
-    <!--    领券弹窗-->
+    <!--    会员日注册领券弹窗-->
     <van-popup
       :show="twenty&first"
       :close-on-click-overlay="false"
@@ -92,7 +92,7 @@
             </view>
 
             <view class="flex justify-center margin-top-xl padding-top-xs">
-                <text class="time margin-right-xs">
+                <text class="experience time margin-right-xs">
                 10
               </text>
               <text class="time_text margin-top-xs">
@@ -107,6 +107,94 @@
       </div>
     </van-popup>
 
+    <!--    外发领券弹窗-->
+    <van-popup
+      :show="is_outShow"
+      :close-on-click-overlay="false"
+      custom-class="pop"
+      overlay
+      z-index="99"
+    >
+      <div class="quan_container padding-tb-xl">
+        <view class=" margin-top-xs flex justify-center">
+              <text class="title">
+                {{outCouponData.name}}
+              </text>
+              
+              </view>
+        <view class="flex justify-center">
+                <text class="text-xs" v-if="outCouponData.validity_time.type==1">
+                {{outCouponData.validity_time.time_format}}&nbsp;之前领取有效
+              </text>
+              <text class="text-xs" v-else>
+                {{outCouponData.validity_time.start_time_format}}&nbsp;至&nbsp;{{outCouponData.validity_time.end_time_format}}&nbsp;之前领取有效
+              </text>
+            </view>
+            <!-- 核销 -->
+            <view class="flex justify-center margin-top-xl padding-top-xs" v-if="outCouponData.type==1">
+                <text class="hexiao time margin-right-xs">
+                  {{ outCouponData.discount.time }}
+                </text>
+                <text class="time_text margin-top-xs" v-if="outCouponData.discount.type==0">
+                  分钟
+                </text>
+                <text class="time_text margin-top-xs" v-else>
+                  次
+                </text>
+            </view>
+           <!-- 满减 -->
+            <view class="flex justify-center margin-top-xl padding-top-xs margin-left-xs" v-if="outCouponData.type==2">
+                <text class="time_text margin-top-xs">
+                  满
+                </text>
+                <text class="manjian time margin-lr-xs">
+                   {{ outCouponData.discount.full }}
+                </text>
+                <text class="time_text margin-top-xs">
+                  减
+                </text>
+                <text class="manjian time margin-left-xs">
+                   {{ outCouponData.discount.reduce }}
+                </text>
+            </view>
+            <!-- 折扣 -->
+            <view class="flex justify-center margin-top-xl padding-top-xs margin-left-xs" v-if="outCouponData.type==3">
+                <text class="time_text margin-top-xs">
+                  打
+                </text>
+                <text class="discount time margin-lr-sm">
+                   {{ outCouponData.discount.discount*10 }}
+                </text>
+                <text class="time_text margin-top-xs">
+                  折
+                </text>
+            </view>
+            <!-- 随机 -->
+            <view class="flex justify-center margin-top-xl padding-top-xs margin-left-xs" v-if="outCouponData.type==4">
+                <text class="time_text margin-top-xs">
+                  随机
+                </text>
+                <text class="random time margin-lr-xs">
+                   {{ outCouponData.discount.start }}
+                </text>
+                <text class="time_text margin-top-xs">
+                  至
+                </text>
+                <text class="random time margin-lr-xs">
+                   {{ outCouponData.discount.end }}
+                </text>
+                <text class="time_text margin-top-xs">
+                  元
+                </text>
+            </view>
+            
+            <view class="flex justify-center margin-top-xl">
+              <button class="cu-btn get_btn text-white" @click="get_coupon">领取</button>
+            </view>
+
+      </div>
+    </van-popup>
+
     <!--    窗口弹出-->
     <van-popup :show="pop_show" @close="close_pop" round>
       <div class="err_container flex flex-direction align-center justify-around">
@@ -130,10 +218,11 @@
 </template>
 
 <script>
-import { userUpdateLoginTime } from "../../requests/user";
-import { couponReceiveFirst, couponReceiveFirstID } from "../../requests/coupons";
+import { userUpdateLoginTime} from "../../requests/user";
+import { couponReceiveFirst, couponReceiveFirstID, outputCoupon, couponReceive } from "../../requests/coupons";
 import Toast from "../../../static/vant/toast/toast";
 import { reload_userinfo } from "../../utils/user";
+import { timestampTwoNum } from "../../utils/index";
 import user_store from "@/store/index";
 
 var $this;
@@ -149,18 +238,36 @@ export default {
       receive: 0,
       invite_code: false,
       twenty: false,
+      //外发
+      output: false,
+      is_outShow: false,
+      outCouponData:{
+        type:Number,
+        validity_time:{
+          type:Number
+        },
+        discount:{
+          type:Number
+        }
+      }
     };
   },
   methods: {
+    //会员日注册领取体验卡
     get_ticket() {
       if ($this.receive == 0) {
         $this.receive += 1;
         console.log($this.receive);
         $this.first = false;
-        let ID
+        let params
         couponReceiveFirstID().then((res)=>{
-          ID = res.data.data.coupon_category_id
-          couponReceiveFirst(ID).then((res) => {
+          let resData = res.data.data
+          params={
+            ID: resData.coupon_category_id,
+            start_time: resData.validity_time.start_time,
+            end_time: resData.validity_time.end_time,
+          }
+          couponReceiveFirst(params).then((res) => {
             let $res = res.data;
             if ($res.code == 0) {
                $this.first = false;
@@ -179,6 +286,31 @@ export default {
         })
       }
     },
+    //领取外发卡券
+    get_coupon(){
+       wx.setStorageSync("is_out", false);
+       couponReceive($this.outCouponData).then((res) => {
+        let $res = res.data;
+        if ($res.code == 0) {
+          Toast.success({
+            message: $res.errmsg,
+            duration:800,
+            onClose() {
+              reload_userinfo($this);
+            }
+          })
+          $this.is_outShow = false
+        } else {
+          Toast.fail({
+            message: $res.errmsg,
+            duration:800,
+          })
+          $this.is_outShow = false
+        }
+      }).catch((err)=>{
+        console.log("错误",err)
+      })
+    },
     //修改第一次登录状态
     close_pop() {
       this.pop_show = false;
@@ -207,7 +339,28 @@ export default {
   mounted() {
     $this.first = wx.getStorageSync("is_first");
     $this.invite_code = wx.getStorageSync("code");
+    //外发
+    $this.output = wx.getStorageSync("is_out");
     reload_userinfo($this);
+    
+    //获取外发数据
+    if($this.output == true){
+      outputCoupon().then((res)=>{
+        if(res.data.code == 0){
+          let $newData = res.data.data
+          $newData.validity_time['start_time_format'] = timestampTwoNum($newData.validity_time['start_time'])
+          $newData.validity_time['end_time_format'] = timestampTwoNum($newData.validity_time['end_time'])
+          $newData.validity_time['time_format'] = timestampTwoNum($newData.validity_time['time'])
+
+          $this.outCouponData = $newData
+          console.log('外发数据:',$this.outCouponData)
+          $this.is_outShow = true
+        }else{
+          wx.setStorageSync("is_out", false);
+          $this.output = false
+        }
+      })
+    }
 
     //判断是否每月20号
     let day = new Date().getDate();
@@ -305,12 +458,21 @@ export default {
 
 /*分钟数*/
 .quan_container .time {
-  font-size: 36px;
   font-weight: bold;
   color: #6858C4;
-  line-height: 24px;
 }
-
+.experience{
+  font-size: 36px;
+  line-height: 20px;
+}
+.hexiao,.discount{
+  font-size: 36px;
+  line-height: 7px;
+}
+.manjian,.random{
+  font-size: 28px;
+  line-height: 7px;
+}
 /*分钟二字*/
 .quan_container .time_text {
   font-size: 12px;

+ 13 - 13
src/pages/coupons/index.vue

@@ -23,14 +23,14 @@
                 <van-row gutter="9"> 
                   <van-col span="17" >
                    <!-- 核销券 -->
-                   <view class="padding-tb" v-if="item.type==1">
+                   <view style="margin-top:36rpx" v-if="item.type==1">
                      <text class="time">{{ item.discount.time }}</text>
                      <text class="time_text" v-if="item.discount.type==0">分钟</text>
                      <text class="time_text" v-if="item.discount.type==1">次</text>
                    </view>
 
                    <!-- 满减券 -->
-                   <view class="padding-tb" v-if="item.type==2">
+                   <view style="margin-top:36rpx" v-if="item.type==2">
                      <text class="time_text">满</text>
                      <text class="time">{{ item.discount.full }}</text>
                      <text class="time_text">减</text>
@@ -38,14 +38,14 @@
                    </view>
 
                    <!-- 折扣券 -->
-                   <view class="padding-tb" v-if="item.type==3">
+                   <view style="margin-top:36rpx" v-if="item.type==3">
                      <text class="time_text">打</text>
                      <text class="time">{{ item.discount.discount*10 }}</text>
                      <text class="time_text">折</text>
                    </view>
 
                    <!-- 随机券 -->
-                   <view class="padding-tb" v-if="item.type==4">
+                   <view style="margin-top:36rpx" v-if="item.type==4">
                      <text class="time_text">随机</text>
                      <text class="time">{{ item.discount.start }}</text>
                      <text class="time_text">至</text>
@@ -104,14 +104,14 @@
                 <van-row gutter="9"> 
                   <van-col span="17" >
                     <!-- 核销券 -->
-                    <view class="padding-tb" v-if="item.type==1">
+                    <view style="margin-top:36rpx" v-if="item.type==1">
                       <text class="time">{{ item.time }}</text>
                       <text class="time_text" v-if="item.discount_type==0">分钟</text>
                       <text class="time_text" v-if="item.discount_type==1">次</text>
                     </view>
 
                     <!-- 满减券 -->
-                    <view class="padding-tb" v-if="item.type==2">
+                    <view style="margin-top:36rpx" v-if="item.type==2">
                       <text class="time_text">满</text>
                       <text class="time">{{ item.full }}</text>
                       <text class="time_text">减</text>
@@ -119,14 +119,14 @@
                     </view>
 
                     <!-- 折扣券 -->
-                    <view class="padding-tb" v-if="item.type==3">
+                    <view style="margin-top:36rpx" v-if="item.type==3">
                       <text class="time_text">打</text>
                       <text class="time">{{ item.discount*10 }}</text>
                       <text class="time_text">折</text>
                     </view>
 
                     <!-- 随机券 -->
-                    <view class="padding-tb" v-if="item.type==4">
+                    <view style="margin-top:36rpx" v-if="item.type==4">
                       <text class="time_text">减</text>
                       <text class="time">{{ item.random }}</text>
                       <text class="time_text">元</text>
@@ -184,14 +184,14 @@
                <van-row gutter="9"> 
                   <van-col span="17" >
                     <!-- 核销券 -->
-                    <view class="padding-tb" v-if="item.type==1">
+                    <view style="margin-top:36rpx" v-if="item.type==1">
                       <text class="time">{{ item.time }}</text>
                       <text class="time_text" v-if="item.discount_type==0">分钟</text>
                       <text class="time_text" v-if="item.discount_type==1">次</text>
                     </view>
 
                     <!-- 满减券 -->
-                     <view class="padding-tb" v-if="item.type==2">
+                     <view style="margin-top:36rpx" v-if="item.type==2">
                       <text class="time_text">满</text>
                       <text class="time">{{ item.full }}</text>
                       <text class="time_text">减</text>
@@ -199,14 +199,14 @@
                     </view>
 
                     <!-- 折扣券 -->
-                    <view class="padding-tb" v-if="item.type==3">
+                    <view style="margin-top:36rpx" v-if="item.type==3">
                       <text class="time_text">打</text>
                       <text class="time">{{ item.discount*10 }}</text>
                       <text class="time_text">折</text>
                     </view>
 
                     <!-- 随机券 -->
-                    <view class="padding-tb" v-if="item.type==4">
+                    <view style="margin-top:36rpx" v-if="item.type==4">
                       <text class="time_text">减</text>
                       <text class="time">{{ item.random }}</text>
                       <text class="time_text">元</text>
@@ -399,7 +399,7 @@ export default {
 
 /*分钟数*/
 .time {
-  font-size: 34px;
+  font-size: 24px;
   font-weight: 400;
   color: #030000;
   line-height: 24px;

+ 11 - 12
src/pages/user_center/confirmPay/index.vue

@@ -177,18 +177,16 @@ export default {
 
       if($this.checked==true){
         if($this.data.coupon.discount){        //打折券
-          $this.isAdd = $this.data.add_price*$this.data.coupon.discount
-          $this.add_price = $this.data.add_price
-          $this.isReduce =  $this.isAdd
-        }else if($this.data.discount){         //没有券,活动打折
-          $this.isAdd = $this.data.add_price*$this.data.discount
-          $this.add_price = $this.data.add_price
-          $this.isReduce =  $this.isAdd
-        }else{                                //其它券
+          $this.isAdd = Math.round($this.data.add_price*$this.data.coupon.discount*100)/100
+        }else if($this.data.coupon.coupon_category_id){      //其它券
           $this.isAdd = $this.data.add_price
           $this.add_price = 0
           $this.isReduce =  0
+        }else if($this.data.discount){         //没有券,活动打折
+          $this.isAdd =  Math.round($this.data.add_price*$this.data.discount*100)/100
         }
+        $this.add_price = $this.data.add_price
+        $this.isReduce =  $this.isAdd
       }else{
         $this.isAdd = 0
         $this.add_price = 0
@@ -207,13 +205,13 @@ export default {
       $this.checked = !$this.checked
       if($this.checked==true){
         if($this.data.coupon.discount){        //打折券
-          $this.isAdd = $this.data.add_price*$this.data.coupon.discount
-        }else if($this.data.discount){         //没有券,活动打折
-          $this.isAdd = $this.data.add_price*$this.data.discount
-        }else{                                //其它券
+          $this.isAdd = Math.round($this.data.add_price*$this.data.coupon.discount*100)/100
+        }else if($this.data.coupon.coupon_category_id){                      //其它券
           $this.isAdd = $this.data.add_price
           $this.add_price = 0
           $this.isReduce =  0
+        }else if($this.data.discount){         //没有券,活动打折
+          $this.isAdd = Math.round($this.data.add_price*$this.data.discount*100)/100
         }
         $this.add_price = $this.data.add_price
         $this.isReduce =  $this.isAdd
@@ -353,6 +351,7 @@ export default {
       //  接收回调方法后弹出支付成功
     },
     to_index() {
+      $this.success_show = false;
       mpvue.reLaunch({
         url: "/pages/index/main",
       });

+ 11 - 9
src/requests/coupons.js

@@ -45,10 +45,12 @@ export function couponReceiveFirstID() {
 }
 
 //首次登录领取优惠券
-export function couponReceiveFirst($id) {
+export function couponReceiveFirst($item) {
   let $params = {
     "access_token": wx.getStorageSync('token'),
-    "coupon_category_id": $id,
+    "coupon_category_id": $item.ID,
+    "start_time": $item.start_time,
+    "end_time": $item.end_time,
   }
   return fly.post('coupon/coupon-receive', $params)
 }
@@ -63,10 +65,10 @@ export function payCoupon($item) {
   return fly.get('coupon/choose-coupon', $params)
 }
 
-//外发卡券信息
-// export function outputCoupon() {
-//   let $params = {
-//     "access_token": wx.getStorageSync('token'),
-//   }
-//   return fly.post('coupon/out-list', $params)
-// }
+// 外发卡券信息
+export function outputCoupon() {
+  let $params = {
+    "access_token": wx.getStorageSync('token'),
+  }
+  return fly.post('coupon/out-list', $params)
+}