邪性 3 anos atrás
pai
commit
0cf8fdc733

+ 1 - 1
app.js

@@ -110,7 +110,7 @@ App({
           icon: "warn-o"
         })
       };
-      // globalurl = "https://lsr.zzly.vip";
+      globalurl = "https://lsr.zzly.vip";
       let header_token = {};
       if (_token) header_token = { 'Authorization': !wx.getStorageSync('token') ? '' : wx.getStorageSync('token') };
       return new Promise(resolve => {

+ 3 - 1
components/l-notify/index.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "van-transition": "@vant/weapp/transition/index"
+  }
 }

+ 1 - 0
pages/detail/detail.js

@@ -30,6 +30,7 @@ Page({
         return false
       }
       let { id, shopdetail } = this.data;
+      console.log(id)
       wx.navigateTo({
         url: `/pages/pay/pay?data=${JSON.stringify({ id, shopdetail })}`,
       })

+ 9 - 2
pages/leaveadd/leaveadd.js

@@ -9,7 +9,8 @@ Page({
   data: {
     active: 0,
     submitobj: {},
-    orderarr: []
+    orderarr: [],
+    msg: '',//暂无可请假的内容
   },
   // 挑选
   CheckboxonChange (e) {
@@ -48,7 +49,7 @@ Page({
       return false;
     }
     delete submitobj["key"];
-    if (submitobj == {}) {
+    if (JSON.stringify(submitobj) == "{}") {
       wx.showToast({
         title: '请选择请假日期',
         icon: "error"
@@ -90,6 +91,12 @@ Page({
         method: "get",
         success (res) {
           let { data } = res.data, { lead_dates, orders } = data, datas = {}, orderarr = [], submitobj = {};
+          if (orders.length == 0) {
+            that.setData({
+              msg: "暂无可请假的内容!"
+            })
+            return false;
+          }
           type = orders;
           for (let key in lead_dates) {
             let arr = [];

+ 6 - 0
pages/leaveadd/leaveadd.less

@@ -30,4 +30,10 @@
     box-sizing: border-box;
     padding: 10rpx 50rpx ;
   }
+  .msg{
+    background-color: #fff;
+    padding: 10px 16px;
+    color: #f03;
+    text-align: center;
+  }
 }

+ 1 - 0
pages/leaveadd/leaveadd.wxml

@@ -24,6 +24,7 @@
         </van-checkbox-group>
       </van-tab>
     </van-tabs>
+    <view wx:if="{{msg!=''}}" class="msg">{{msg}}</view>
     <view class="btn">
       <van-button round bind:click="submit" type="primary" block>提交</van-button>
     </view>

+ 6 - 0
pages/leaveadd/leaveadd.wxss

@@ -27,3 +27,9 @@
   box-sizing: border-box;
   padding: 10rpx 50rpx ;
 }
+.leaveadd .msg {
+  background-color: #fff;
+  padding: 10px 16px;
+  color: #f03;
+  text-align: center;
+}

+ 44 - 8
pages/pay/pay.js

@@ -10,11 +10,34 @@ Page({
     loadding: false,//正在支付中 true
     disabled: false,//支付完毕 true
     message: '',//订单备注
-    paytype: "1",// 支付方式
+    paytype: "1",// 支付方式 单选
+    balance: null,//余额
+    result: [],//复选框
+  },
+  // 请求余额
+  Request () {
+    let that = this;
+    axios({
+      url: '/option/balance/',
+      method: 'get',
+      success (res) {
+        let { data } = res.data;
+        that.setData({
+          ...data[0]
+        })
+      }
+    })
+  },
+  // 复选框
+  checkboxonchange (e) {
+    let { detail } = e;
+    this.setData({
+      result: detail
+    })
   },
   // 提交支付
   onSubmit () {
-    let { id: commodity, message: notes, useraddress } = this.data, { id: student } = useraddress, that = this;
+    let { commodity, message: notes, useraddress, paytype, result } = this.data, { id: student } = useraddress, that = this, balance = '';
     if (!student) {
       wx.showToast({
         title: '请选择学生',
@@ -22,6 +45,9 @@ Page({
       })
       return false;
     }
+    if (result.indexOf('1') > -1) {
+      balance = 2;
+    }
     let { appid, user } = app.globalData, { openid } = user;
     function pay () {
       return new Promise(resolve => {
@@ -29,11 +55,15 @@ Page({
           url: `/order/`,
           method: 'post',
           data: {
-            appid, openid, notes, commodity, student
+            appid, openid, notes, commodity, student, balance
           },
           success (res) {
             that.setData({ loadding: true })
             let { data } = res.data;
+            if (!data) {
+              resolve({ type: 1, value: "支付成功" });
+              return false;
+            }
             wx.requestPayment({
               timeStamp: data.timeStamp,
               nonceStr: data.nonceStr,
@@ -54,10 +84,14 @@ Page({
     }
     pay().then(
       res => {
-        that.setData({ loadding: false, disabled: true })
-        wx.redirectTo({
-          url: '/pages/order/order',
-        })
+        that.setData({ loadding: false, disabled: true });
+        wx.lxd.Notify({ type: res.type == 1 ? 'success' : '', message: res.value })
+        const time = setTimeout(() => {
+          wx.redirectTo({
+            url: '/pages/order/order',
+          })
+          clearTimeout(time)
+        }, 3000)
       }
     );
   },
@@ -85,7 +119,8 @@ Page({
     if (!!data) {
       data = JSON.parse(data);
       this.setData({
-        ...data
+        ...data,
+        commodity: data.id
       })
     }
   },
@@ -101,6 +136,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
+    this.Request()
     let { useraddress } = app.globalData;
     this.setData({ useraddress })
   },

+ 3 - 1
pages/pay/pay.json

@@ -5,6 +5,8 @@
     "van-tag": "@vant/weapp/tag/index",
     "van-radio": "@vant/weapp/radio/index",
     "van-radio-group": "@vant/weapp/radio-group/index",
-    "van-field": "@vant/weapp/field/index"
+    "van-field": "@vant/weapp/field/index",
+    "van-checkbox": "@vant/weapp/checkbox/index",
+    "van-checkbox-group": "@vant/weapp/checkbox-group/index"
   }
 }

+ 4 - 0
pages/pay/pay.less

@@ -55,4 +55,8 @@
       align-items: center;
     };
   }
+  .balance{
+    padding: 10px 16px;background-color: #fff;
+    .txt{color: #f03;}
+  }
 }

+ 13 - 0
pages/pay/pay.wxml

@@ -46,6 +46,19 @@
           </view>
         </van-cell>
       </van-radio-group>
+      <van-checkbox-group value="{{ result }}" bind:change="checkboxonchange">
+        <van-cell border="{{false}}">
+          <view class="type" slot="title">
+            <view class="str">
+              <van-icon name="gold-coin" color="gold" size="16" />
+              余额抵扣:<text class="txt">¥{{balance}}</text>
+            </view>
+            <view class="radio">
+              <van-checkbox name="1" />
+            </view>
+          </view>
+        </van-cell>
+      </van-checkbox-group>
     </view>
     <!-- 提交支付 -->
     <van-submit-bar disabled="{{disabled}}" loading="{{loadding}}" price="{{ shopdetail.amount*100 }}"

+ 7 - 0
pages/pay/pay.wxss

@@ -50,3 +50,10 @@
   justify-content: space-between;
   align-items: center;
 }
+.pay .balance {
+  padding: 10px 16px;
+  background-color: #fff;
+}
+.pay .balance .txt {
+  color: #f03;
+}