瀏覽代碼

上传凭证和下单

wangyong 6 年之前
父節點
當前提交
772b2763f8

+ 8 - 7
pages/car/index.js

@@ -824,13 +824,13 @@ Page({
       that.setData({
         buyCarts: []
       })
-      wx.showLoading({
-        title: '',
-        icon: 'loading',
-        mask: true,
-        success: function () {
-        }
-      })
+      // wx.showLoading({
+      //   title: '',
+      //   icon: 'loading',
+      //   mask: true,
+      //   success: function () {
+      //   }
+      // })
       that.selectCartsSta(len);
     }else{
       that.setData({
@@ -864,6 +864,7 @@ Page({
         });
         var newCarts = JSON.stringify(that.data.buyCarts);
         newCarts = newCarts.replace(/&/g, "zss");
+        console.log(newCarts,"newCarts")
         // 立即采购
         wx.navigateTo({
           url: '/pages/confirmOrder/confirmOrder?carts=' + newCarts,

+ 88 - 81
pages/confirmOrder/confirmOrder.js

@@ -7,6 +7,7 @@ Page({
   data: {
     user_phone: '',//绑定的手机号码
     hidden: 'hidden',
+    cartsOrder:null, //给合成订单使用
     addressAll: addressAll,
     addressList: addressList,
 
@@ -73,6 +74,7 @@ Page({
     var that = this;
 
     //转义&符
+    let cartsOrder = options.carts
     var carts = options.carts;
     carts = carts.replace(/zss/g, "&");
     carts = JSON.parse(carts);
@@ -80,7 +82,8 @@ Page({
     console.log(carts);
 
     that.setData({
-      carts: carts
+      carts: carts,
+      cartsOrder: cartsOrder
     })
     var total = 0;
     var total2 = 0;
@@ -348,6 +351,7 @@ Page({
     var timestamp = Date.parse(new Date());
     timestamp = timestamp / 1000;
     var timestamp1 = timestamp;
+    wx.setStorageSync('orderId', timestamp1)
     var host = getApp().globalData.servsers;
     var un_id = getApp().globalData.un_id;
 
@@ -445,11 +449,15 @@ Page({
       }
 
       //调起支付
-      // that.payOrder(timestamp, timestamp1, coupon_id, un_id, formId);
-      wx.showToast({
-        title: '订单已生成,后面待上传支付凭证',
-        icon:'none'
-      })
+      console.log("掉期支付")
+      that.payOrder(timestamp, timestamp1, coupon_id, un_id, formId);
+      // wx.showToast({
+      //   title: '订单已生成,后面待上传支付凭证',
+      //   icon:'none'
+      // })
+      // wx.navigateTo({
+      //   url: '/pages/orderCanvas/orderCanavs',
+      // })
 
     }else{
 
@@ -608,12 +616,6 @@ Page({
         }
       })
     }
-    setTimeout(()=>{
-      wx.hideLoading();
-      wx.navigateTo({
-        url: '/pages/orderCanvas/orderCanavs',
-      })
-    },1000)
    
   },
 
@@ -714,7 +716,7 @@ Page({
 
   //调起付款
   payOrder:function(timestamp, timestamp1, coupon_id, un_id, formId){
-
+   
     console.log("pay");
     console.log("pay-formId:" + formId);
 
@@ -749,6 +751,7 @@ Page({
         }
       }
     })
+    
 
     //获取用户登录状态
     wx.login({
@@ -792,74 +795,74 @@ Page({
                 var paySign = MD5Util.MD5(payDataB).toUpperCase();
 
                 // 发起微信支付
-                wx.requestPayment({
-                  'timeStamp': timestamp,
-                  'nonceStr': nonceStr,
-                  'package': 'prepay_id=' + prepayId,
-                  'signType': 'MD5',
-                  'paySign': paySign,
-                  'success': function (res) {
-                    console.log(111);
-                    console.log(res);
-
-                    wx.request({
-                      url: host + "orderapi/update",
-                      data: {
-                        order_sta: that.data.orderState1,
-                        order_number: timestamp1,
-                        orderState: that.data.orderState1,
-                        order_userid: un_id
-                      },
-                      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
-                      header: {
-                        'Accept': 'application/json'
-                      },
-                      success: function (res) {
-                        console.log("支付");
-                        console.log(res);
-                        that.setData({
-                          maskBg: false,
-                          hiddenmodal: false,
-                          modalCont: '支付成功'
-                        })
-                        setTimeout(function () {
-                          that.setData({
-                            hiddenmodal: true
-                          })
-                          wx.redirectTo({
-                            url: '/pages/orderList/orderList?isSelect=0'
-                          })
-                        }, 2000);
-
-                        if (res == null || res.data == null) {
-                          //删除当前订单
-                          that.deleteOrder(un_id, timestamp, that.data.coupon_id);
-                          that.setData({
-                            maskBg: false,
-                            allowPay: 0,
-                            firstClick: 0
-                          })
-                          return false;
-                        }
-                      }
-                    });
-                  },
-                  'fail': function (res) {
-                    that.setData({
-                      maskBg: false,
-                      hiddenmodal: false,
-                      modalCont: '取消支付'
-                    })
-                    setTimeout(function () {
-                      that.setData({
-                        hiddenmodal: true
-                      })
-                      wx.redirectTo({
-                        url: '/pages/orderList/orderList?isSelect=0'
-                      })
-                    }, 2000);
-                  }
-                })
+                // wx.requestPayment({
+                //   'timeStamp': timestamp,
+                //   'nonceStr': nonceStr,
+                //   'package': 'prepay_id=' + prepayId,
+                //   'signType': 'MD5',
+                //   'paySign': paySign,
+                //   'success': function (res) {
+                //     console.log(111);
+                //     console.log(res);
+
+                //     wx.request({
+                //       url: host + "orderapi/update",
+                //       data: {
+                //         order_sta: that.data.orderState1,
+                //         order_number: timestamp1,
+                //         orderState: that.data.orderState1,
+                //         order_userid: un_id
+                //       },
+                //       method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+                //       header: {
+                //         'Accept': 'application/json'
+                //       },
+                //       success: function (res) {
+                //         console.log("支付");
+                //         console.log(res);
+                //         that.setData({
+                //           maskBg: false,
+                //           hiddenmodal: false,
+                //           modalCont: '支付成功'
+                //         })
+                //         setTimeout(function () {
+                //           that.setData({
+                //             hiddenmodal: true
+                //           })
+                //           wx.redirectTo({
+                //             url: '/pages/orderList/orderList?isSelect=0'
+                //           })
+                //         }, 2000);
+
+                //         if (res == null || res.data == null) {
+                //           //删除当前订单
+                //           that.deleteOrder(un_id, timestamp, that.data.coupon_id);
+                //           that.setData({
+                //             maskBg: false,
+                //             allowPay: 0,
+                //             firstClick: 0
+                //           })
+                //           return false;
+                //         }
+                //       }
+                //     });
+                //   },
+                //   'fail': function (res) {
+                //     that.setData({
+                //       maskBg: false,
+                //       hiddenmodal: false,
+                //       modalCont: '取消支付'
+                //     })
+                //     setTimeout(function () {
+                //       that.setData({
+                //         hiddenmodal: true
+                //       })
+                //       wx.redirectTo({
+                //         url: '/pages/orderList/orderList?isSelect=0'
+                //       })
+                //     }, 2000);
+                //   }
+                // })
 
                 //如果是从购物车进入支付,则清空对应购物车商品
                 if (prevPageUrl == 'pages/car/index' || prevPageUrl == 'pages/carInsert/carInsert') {
@@ -882,6 +885,10 @@ Page({
                     });
                   }
                 }
+                // 生产订单中
+                wx.navigateTo({
+                  url: '/pages/orderCanvas/orderCanavs?carts=' + that.data.cartsOrder,
+                })
 
               } else {
                 that.setData({

+ 1 - 1
pages/confirmOrder/confirmOrder.wxml

@@ -96,7 +96,7 @@
     <view class="footer_left">
       <text class="footer_left_totaltit">¥</text>
       <text class="footer_left_total">{{total2}}</text>
-      <text class='footer_left_coupon'>已优惠¥{{minNum}}</text>
+      <!-- <text class='footer_left_coupon'>已优惠¥{{minNum}}</text> -->
     </view>
     
   </view>

+ 10 - 2
pages/mine/mine.js

@@ -9,7 +9,7 @@ Page({
     orderList:{
       label:'我的采购订单',
       summary:"全部",
-      state:"",
+      state:"0",
       icon:"icon-left",
       data:[
         {
@@ -116,18 +116,20 @@ Page({
     //   })
     // } else {
     that.getPhone(that)
-      userInfo = getApp().globalData.userInfo;
+    userInfo = getApp().globalData.userInfo;
       
       //查询用户身份
     //   getApp().getUserRole(un_id);//获取用户角色
     //   userRole = getApp().globalData.userRole;
     // }
+    console.log(wx.getStorageSync('channelIdObj'),"ffffff")
     that.setData({
       userInfo: userInfo,
       userId: un_id,
       userRole: userRole,
       channIdState: wx.getStorageSync('channelIdObj') ? true : false
     })
+    console.log(that.data.channIdState)
   },
   orderList(e){
     console.log(e,"orderList")
@@ -167,6 +169,12 @@ Page({
         })
       }
     })
+  },
+  outChann(){ // 退出渠道
+    wx.removeStorageSync('channelIdObj');
+    this.setData({
+      channIdState:false
+    })
   }
 
 })

+ 1 - 1
pages/mine/mine.wxml

@@ -53,7 +53,7 @@
   </view>
 
   <!-- 退出渠道 -->
-  <view class='channe-box' wx:if="channIdState">
+  <view class='channe-box' wx:if="{{channIdState}}" bindtap='outChann'>
     <button class='f-s30'>退出渠道</button>
   </view>
   

+ 56 - 2
pages/orderCanvas/orderCanavs.js

@@ -1,18 +1,27 @@
 // pages/orderCanvas/orderCanavs.js
+let app = getApp();
+let host = app.globalData.servsers; // 请求的url
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    carts:null
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    var that = this, carts = options.carts;
+    carts = carts.replace(/zss/g, "&");
+    carts = JSON.parse(carts);
+
 
+    that.setData({
+      carts: carts,
+    })
   },
 
   /**
@@ -60,7 +69,52 @@ Page({
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
+  onShareAppMessage() {
+    return {
+      // title: '',
+      path: '/pages/orderCanvas/orderCanavs'
+    }
+  },
+  orderList(){
+    // 查看订单
+    wx.navigateTo({
+      url: '/pages/orderList/orderList?state=0',
+    })
+  },
+  uploadImg() {
+    // 上传支付凭证
+    let that = this;
+    wx.chooseImage({
+      success(res) {
+        const tempFilePaths = res.tempFilePaths
+        wx.uploadFile({
+          url: host + '/payOrderFile', // 仅为示例,非真实的接口地址
+          filePath: tempFilePaths[0],
+          header: {
+            "Content-Type": "multipart/form-data"
+          },
+          name: 'file',
+          formData: {
+            file: tempFilePaths[0],
+            orderId: wx.getStorageSync('orderId'),
+          },
+          success(res) {
+            console.log(res, '我上传完了')
+            if (res.data == 'success') {
+              wx.showToast({
+                title: '支付凭证上传成功!',
+                icon: 'none'
+              })
+            } else {
+              wx.showToast({
+                title: res.data,
+                icon: 'none'
+              })
+            }
+          }
+        })
+      }
+    })
 
   }
 })

+ 30 - 4
pages/orderCanvas/orderCanavs.wxml

@@ -1,12 +1,38 @@
-<view class='canvas-box'>
+<!-- <view class='canvas-box'>
   <image src='../../images/canvas_order.png' mode='widthFix'></image>
-</view>
+</view> -->
+<view>
+<block wx:for="{{carts}}" wx:key="index"  wx:for-index="{{i}}"> 
+  <view class="goods_infor">
+    <view class="each_goods">
+      <image src="{{item.logo}}" class="goods_img"></image>
+      <view class="goods_cont">
 
+        <view class="goods_price">¥<text>{{item.new_price}}</text></view>
+        <view class="goods_name">{{item.name}}</view>
+        <view class="goods_style"> 
+          <text wx:if="{{item.style1_name}}">{{item.style1_name}} </text>
+          <text wx:if="{{item.style2_name}}">{{item.style2_name}} </text>
+          <text wx:if="{{item.style3_name}}">{{item.style3_name}} </text>
+          <text wx:if="{{item.style4_name}}">{{item.style4_name}} </text>
+          <text wx:if="{{item.style5_name}}">{{item.style5_name}} </text>
+          <text wx:if="{{item.giftbox_name}}">{{item.giftbox_name}} </text>
+          <text wx:if="{{item.process_name}}">{{item.process_name}}</text>
+        </view>
+        <view class="goods_num">x{{item.num}}</view>
+      </view>
+    </view> 
+  </view>
+ </block> 
+</view>
 <view class='footer'>
   <view class='footer-box'>
     <view class='f-box'>
-      <view class='f-item f-box f-justify-content-center c-white bg-orange' style='width:100%' >分享</view>
-      <view class='f-item f-box f-justify-content-center c-white bg-theme' style='width:100%'>上传付款凭证</view>
+      <view class='f-item f-box f-justify-content-center c-white bg-orange' style='width:100%'>
+        <button class='share-box f-item' open-type="share">分享</button>
+      </view>
+      <view class='f-item f-box f-justify-content-center c-white' style='width:100%;background:#eea957' bindtap='uploadImg'>上传付款凭证</view>
+      <view class='f-item f-box f-justify-content-center c-white bg-theme' style='width:100%' bindtap='orderList'>查看订单</view>
     </view>
   </view>
 </view>

+ 96 - 0
pages/orderCanvas/orderCanavs.wxss

@@ -1,4 +1,100 @@
 /* pages/orderCanvas/orderCanavs.wxss */
 .canvas-box image{
   width:100%;
+}
+.share-box{
+  background:none;
+  color:#fff;
+}
+/* 商品信息 */
+.goods_infor{
+  padding:0 32rpx 0 0;
+  background-color: #fff;
+  border-bottom:1px solid #dedede;
+}
+.each_goods{
+  min-height: 212rpx;
+  margin-bottom:14rpx;
+}
+.goods_img{
+  float: left;
+  display: block;
+  width: 214rpx;
+  height: 234rpx;
+}
+.goods_cont{
+  float: left;
+  width: 450rpx;
+  margin:36rpx 0 0 20rpx;
+}
+.goods_name{
+  height: 94rpx;
+  font-size: 24rpx;
+  line-height: 50rpx;
+  color: #262626;
+  text-overflow: ellipsis;
+  overflow: hidden;
+  display: -webkit-box;
+  -webkit-line-clamp: 2;
+  -webkit-box-orient: vertical;
+}
+.goods_style,.goods_num{
+  float: left;
+  font-size: 24rpx;
+  line-height: 30rpx;
+  color: #616161;
+  /* text-overflow: ellipsis;
+  overflow: hidden;
+  white-space: nowrap; */
+}
+.goods_price{
+  font-size: 24rpx;
+  line-height: 30rpx;
+  color: #e60012;
+  text-align: left;
+  padding: 0 0 14rpx 0;
+}
+.goods_price text{
+  font-size: 50rpx;
+}
+.goods_style{
+  width: 340rpx;
+  padding-right:10rpx;
+}
+.goods_num{
+  width: 100rpx;
+  text-align: right;
+}
+.infor_content{
+  background-color: #fff;
+  padding:0 30rpx;
+}
+.each_infor{
+  height: 106rpx;
+  font-size: 28rpx;
+  line-height: 106rpx;
+  color: #636363;
+}
+.checkbox{
+  width: 300rpx;
+}
+checkbox .wx-checkbox-input {
+  border:1px solid #e60012;
+  background-color:#fff;
+}
+checkbox.checkact .wx-checkbox-input{
+  background-color:#e60012;
+}
+
+.infor_title{
+  float: left;
+}
+.infor_num{
+  float: right;
+}
+.infor_num_coupon{
+  color:#f2442d;
+}
+.borderBottom{
+  border-bottom: 1px solid #f0f0f0;
 }

+ 71 - 17
pages/orderList/orderList.js

@@ -5,7 +5,7 @@ Page({
     host: host,
     isSelect: "", //默认全部
     dataStateArray: [{
-        state: '',
+        state: '0',
         label: "全部",
       },
       {
@@ -26,8 +26,9 @@ Page({
       }
     ],
     goodsList: [],
-    dividerState: false, //判断数据是否请求结束了,默认是false
     page: 1, //默认第一页
+    limit:10,//默认就展示10条数据
+    requestStatic:true, //默认可以下拉请求
   },
 
   /**
@@ -82,7 +83,14 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    console.log("到底了")
+    let that = this;
+    if(that.data.requestStatic){
+      that.setData({
+        page:that.data.page +1
+      })
+      that.getOrderList(that)
+    }
   },
 
   /**
@@ -93,36 +101,82 @@ Page({
   },
   tab(e) { // tab切换
     this.setData({
-      isSelect: e.currentTarget.dataset.state
+      isSelect: e.currentTarget.dataset.state,
+      page:1,
+      goodsList:[],
+      requestStatic:true
     })
-    this.getOrderList(this, e.currentTarget.dataset.state)
+    this.getOrderList(this)
   },
-  getOrderList(that, status) {
+  getOrderList(that) {
     wx.request({
       url: host + '/orderapi/orderlist',
       method: 'get',
       data: {
         user_id: app.globalData.user_id,
-        status: status
+        status: that.data.isSelect,
+        offset:that.data.page,
+        limit:that.data.limit
       },
       success(res) {
         console.log(res, "orderItem")
+        let data = res.data,goodsList = that.data.goodsList;
+        data.forEach(res=>{
+          let total = 0;
+          res.list_order_aff_data.forEach(el=>{
+            total += el.order_Price * 1
+          })
+          res.com_price_total = total;
+          res.status = that.data.isSelect
+        })
+        goodsList.push(...data)
         that.setData({
-          goodsList: [...res.data]
+          goodsList: goodsList,
+          requestStatic:res.data.length == that.data.limit
         })
       }
     })
   },
   orderInfor: function (e) { //之前查看详情
-    // var that = this;
-    // var id = e.currentTarget.dataset.id;
-
-    // var newCarts = JSON.stringify(that.data.goosdListnew[id]);
-    // newCarts = newCarts.replace(/&/g, "zss");
-
-    wx.navigateTo({
-      url: '/pages/confirmedList/confirmedList?goosdListnew=' + newCarts
-    })
+    // wx.navigateTo({
+    //   url: '/pages/confirmedList/confirmedList?goosdListnew=' + newCarts
+    // })
 
   },
+  uploadImg(e){
+    // 上传支付凭证
+    let orderId=e.currentTarget.dataset.orderid,that =this;
+    wx.chooseImage({
+      success(res) {
+        const tempFilePaths = res.tempFilePaths
+        wx.uploadFile({
+          url: host + '/payOrderFile', // 仅为示例,非真实的接口地址
+          filePath: tempFilePaths[0],
+          header: {
+            "Content-Type": "multipart/form-data"
+          },
+          name: 'file',
+          formData: {
+            file: tempFilePaths[0],
+            orderId: orderId,
+          },
+          success(res) {
+            console.log(res, '我上传完了')
+            if(res.data == 'success'){
+              wx.showToast({
+                title: '支付凭证上传成功!',
+                icon:'none'
+              })
+            } else {
+              wx.showToast({
+                title: res.data,
+                icon: 'error'
+              })
+            }
+          }
+        })
+      }
+    })
+    
+  }
 })

+ 5 - 5
pages/orderList/orderList.wxml

@@ -32,17 +32,17 @@
       <!-- 价格与按钮 -->
       <view class="f-box f-justify-content-center order-btn">
         <view class='f-item f-box f-justify-content-end mar-r26'>
-          <view class='btn'>上传凭证</view>
-          <view class='btn'>查看物流</view>
-          <view class='btn'>确认收货</view>
+          <view class='btn' wx:if="{{item.status ==1}}" data-orderId="{{item.order_number}}" bindtap='uploadImg'>上传凭证</view>
+          <view class='btn' wx:if="{{item.status ==4}}">查看物流</view>
+          <view class='btn' wx:if="{{item.status ==4}}">确认收货</view>
         </view>
         
-        <view>合计:<text class='c-theme'>¥ {{orderItem.com_price}}</text></view>
+        <view>合计:<text class='c-theme'>¥ {{item.com_price_total}}</text></view>
       </view>
     </view>
   </view>
 
   <data-none wx:if="{{goodsList.length === 0}}"></data-none>
-  <divider wx:if="{{dividerState}}"></divider>
+  <divider wx:if="{{!requestStatic && page !=1}}"></divider>
 </view>
 </view>