소스 검색

添加抵扣卷逻辑

xiaohaizhao 1 년 전
부모
커밋
5f02e00bc1
3개의 변경된 파일142개의 추가작업 그리고 15개의 파일을 삭제
  1. 60 13
      pages/teams/addOrder.js
  2. 66 1
      pages/teams/addOrder.scss
  3. 16 1
      pages/teams/addOrder.wxml

+ 60 - 13
pages/teams/addOrder.js

@@ -15,7 +15,8 @@ Page({
         users: [],
         remarks: "",
         showAmount: "¥0.00",
-        isDelete: true
+        isDelete: true,
+        useDiscount: 0
     },
     onLoad(options) {
         this.setData({
@@ -24,8 +25,22 @@ Page({
             opUsers: options.users ? JSON.parse(options.users) : []
         })
         sys_payorderid = options.sys_payorderid;
-        console.log(options)
         this.getVersions(options.vid || "");
+        this.getDiscounts();
+    },
+    /* 获取优惠卷 */
+    getDiscounts() {
+        _Http.basic({
+            "id": 20230801162402,
+            "content": {
+                nocache: true
+            }
+        }).then(res => {
+            console.log("获取优惠卷", res)
+            this.setData({
+                discounts: res.data
+            })
+        })
     },
     /* 保存订单进度 */
     changeOrder() {
@@ -172,6 +187,9 @@ Page({
                     // if (formatTime(new Date(), '-').split(" ")[0] >= date) users.push(v[idname] + '');
                 } else {
                     if (!users.some(v => v == v[idname])) users.push(v[idname] + '');
+                    if (v.isleader == 0) this.setData({
+                        useDiscount: this.data.useDiscount += 1
+                    })
                 }
             }
         });
@@ -185,21 +203,44 @@ Page({
     },
     onChange(e) {
         const {
-            id
+            id,
+            isleader
         } = e.currentTarget.dataset;
-        let users = this.data.users;
+        let users = this.data.users,
+            useDiscount = this.data.useDiscount;
         if (users.some(v => v == id)) {
             users = users.filter(s => s != id)
+            if (isleader == 0) useDiscount -= 1;
         } else {
             users.push(id + "")
+            if (isleader == 0) useDiscount += 1;
         }
         this.setData({
-            users
+            users,
+            useDiscount
         });
         this.changeOrder();
     },
+    examine() {
+        return new Promise((resolve, reject) => {
+            if (currency(this.data.showAmount).value == 0) {
+                wx.showModal({
+                    title: '提示',
+                    content: '优惠后金额为0,是否确认',
+                    complete: (res) => {
+                        if (res.cancel) resolve(false)
+                        if (res.confirm) resolve(true)
+                    }
+                })
+            } else {
+                resolve(true)
+            }
+        })
+    },
     /* 支付 */
-    payment() {
+    async payment() {
+        let isPayment = await this.examine();
+        if (!isPayment) return;
         let that = this;
         that.data.isDelete = false;
         wx.login({
@@ -213,7 +254,6 @@ Page({
                         "trade_type": "JSAPI"
                     }
                 }).then(res => {
-                    console.log(res)
                     wx.requestPayment({
                         timeStamp: res.data.timeStamp,
                         nonceStr: res.data.nonceStr,
@@ -227,12 +267,19 @@ Page({
                             })
                         },
                         fail(err) {
-                            wx.showToast({
-                                title: '支付失败',
-                                icon: "error",
-                                mask: true
-                            })
-                            console.error(err)
+                            if (res.msg == '成功' && currency(that.data.showAmount).value == 0) {
+                                wx.showToast({
+                                    title: '支付成功',
+                                    mask: true
+                                })
+                            } else {
+                                wx.showToast({
+                                    title: '支付失败',
+                                    icon: "error",
+                                    mask: true
+                                })
+                                console.error(err)
+                            }
                         },
                         complete(e) {
                             console.log(e)

+ 66 - 1
pages/teams/addOrder.scss

@@ -77,7 +77,7 @@
             color: #333333;
             margin-top: 0;
 
-            .tag1{
+            .tag1 {
                 font-weight: normal !important;
                 margin-right: 10rpx;
             }
@@ -108,6 +108,71 @@
     }
 }
 
+scroll-view {
+    min-width: 100vw;
+    background-color: #fff;
+
+    .discounts {
+        display: flex;
+        align-items: center;
+        height: 150rpx;
+        box-sizing: border-box;
+
+        .card {
+            display: flex;
+            align-items: center;
+            width: 410rpx;
+            height: 130rpx;
+            padding: 10rpx 0;
+            border-radius: 16rpx;
+            mask-composite: subtract;
+            -webkit-mask-image: radial-gradient(circle at 130rpx 4px, transparent 4px, red 4.5px), radial-gradient(closest-side circle at 50%, red 99%, transparent 100%);
+            -webkit-mask-size: 100%, 2rpx 4rpx;
+            -webkit-mask-repeat: repeat, repeat-y;
+            -webkit-mask-position: 0 -4rpx, 130rpx;
+            -webkit-mask-composite: source-out;
+            box-sizing: border-box;
+            margin-left: 15rpx;
+            flex-shrink: 0;
+
+            .card-left {
+                width: 130rpx;
+                text-align: center;
+                font-size: 24rpx;
+                font-weight: bold;
+                color: #fff;
+            }
+
+            .card-right {
+                padding: 16px 12px;
+                display: flex;
+                flex: 1;
+                flex-direction: column;
+
+                .card-info {
+                    margin: 0 0 10px 0;
+                    font-size: 14px;
+                    line-height: 20px;
+                    color: #fff;
+                }
+
+                .card-time {
+                    font-size: 12px;
+                    line-height: 16px;
+                    font-weight: normal;
+                    color: #fff;
+                    margin-top: 4px;
+                }
+            }
+        }
+    }
+
+}
+
+
+
+
+
 .footer {
     display: flex;
     justify-content: space-between;

+ 16 - 1
pages/teams/addOrder.wxml

@@ -14,9 +14,24 @@
         </view>
     </navigator>
 </van-radio-group>
+<block wx:if="{{discounts.length}}">
+    <view class="tips">使用抵扣劵</view>
+    <scroll-view scroll-x>
+        <view class="discounts">
+            <view class="card" wx:for="{{discounts}}" style="background: {{(index-0+1)<=useDiscount?'linear-gradient(45deg, orange, red)':'linear-gradient(45deg, grey, grey)'}};" wx:key="index">
+                <view class="card-left">抵扣一年</view>
+                <view class="card-right">
+                    <view class="card-info">{{item.type}}折扣券</view>
+                    <view class="card-time">有效期至{{item.enddate}}</view>
+                </view>
+            </view>
+        </view>
+    </scroll-view>
+</block>
+
 <view class="tips">请选择付费{{sys_payincidence==1?'账号':'主体'}}</view>
 <van-checkbox-group wx:if="{{sys_payincidence==1}}" value="{{ users }}">
-    <view class="user-item" wx:for="{{userList}}" wx:key="userid" data-id="{{item.userid}}" bindtap="{{(item.isleader && per.query(users,item.userid) && !item.enddate[sys_site_systempartitionid])?'':'onChange'}}">
+    <view class="user-item" wx:for="{{userList}}" wx:key="userid" data-id="{{item.userid}}" data-isleader="{{item.isleader}}" bindtap="{{(item.isleader && per.query(users,item.userid) && !item.enddate[sys_site_systempartitionid])?'':'onChange'}}">
         <van-checkbox shape='square' icon-size='14' disabled="{{item.isleader && per.query(users,item.userid) && !item.enddate[sys_site_systempartitionid]}}" name="{{item.userid}}" />
         <view class="content">
             <view class="label">