Prechádzať zdrojové kódy

预览以及渠道计算

wangyong 6 rokov pred
rodič
commit
83e3be417f

+ 21 - 6
pages/buy/buy.js

@@ -250,6 +250,7 @@ Page({
         'Accept': 'application/json'
       },
       success: function (res) {
+        
         console.log(res);
         //有此商品
         if (res.data.total > 0) {
@@ -367,6 +368,7 @@ Page({
       },
       success: function (res) {
         console.log(res);
+        let showPrice = (res.data.maxAndMin.min == res.data.maxAndMin.max) ? res.data.maxAndMin.min : (res.data.maxAndMin.min + '-' + res.data.maxAndMin.max);
         //有此商品
         if (res.data.total > 0) {
           if (res.data.commodity.commodity_flag == '1') {//此商品为下架商品
@@ -722,7 +724,8 @@ Page({
                   var dataContList = {
                     id: groupList[i].id,
                     product_price: groupList[i].product_price,
-                    product_repertory: groupList[i].product_repertory
+                    product_repertory: groupList[i].product_repertory,
+                    product_channel_price: groupList[i].product_channel_price, //添加渠道价格
                   };
                   dataList[dataTit] = dataContList;
                 }
@@ -731,7 +734,8 @@ Page({
                   groupList: groupList,
                   dataList: dataList,
                   showNum: sumTotal,
-                  commodityChannelPrice: res.data.data[0].commodityChannelPrice
+                  commodityChannelPrice: res.data.data[0].product_channel_price,
+                  showPrice: res.data.data[0].product_channel_price,
                 })
                 loadingFlag++;
                 if (loadingFlag == 6) {
@@ -804,8 +808,13 @@ Page({
             }
           }
         })
+        console.log(res, "res,showPrice")
+        
+        // if(that.data.loginStatic){
+        //   showPrice = 
+        // }
         that.setData({
-          showPrice: (res.data.maxAndMin.min == res.data.maxAndMin.max) ? res.data.maxAndMin.min :(res.data.maxAndMin.min + '-' + res.data.maxAndMin.max),
+          showPrice: showPrice,
           minPrice: res.data.maxAndMin.min,//最低价格
           maxPrice: res.data.maxAndMin.max,//最高价格
           minNumber: res.data.commodity.commodity_num,
@@ -885,7 +894,6 @@ Page({
   initSKU: function () {
     var that = this;
     var dataList = that.data.dataList;//已有的规则组合信息
-
     //数据已有组合类
     var i, j, skuKeys = that.getObjKeys(dataList);
 
@@ -915,7 +923,8 @@ Page({
       var SKUResult = that.data.SKUResult;
       SKUResult[skuKeyAttrs.join("-")] = {
         product_repertory: sku.product_repertory,
-        product_price: [sku.product_price]
+        product_price: [sku.product_price],
+        product_channel_price: [sku.product_channel_price], //添加渠道价格
       };
     }
 
@@ -1007,6 +1016,7 @@ Page({
 
   //把组合的key放入结果集SKUResult
   addSKUResult: function ( combArrItem, sku) {
+    console.log(sku,"sku")
     var that = this;
     var key = combArrItem.join("-");
     var SKUResult = that.data.SKUResult;
@@ -1017,7 +1027,8 @@ Page({
     } else {
       SKUResult[key] = {
         product_repertory: sku.product_repertory,
-        product_price: [sku.product_price]
+        product_price: [sku.product_price],
+        product_channel_price:[sku.product_channel_price], //添加渠道价格
       };
     }
     that.setData({
@@ -1143,12 +1154,16 @@ Page({
       console.log("selectedIds.join('-'):"+selectedIds.join('-'));
 
       var prices = SKUResult[selectedIds.join('-')].product_price;
+      console.log(prices,"prices")
       var maxPrice = parseFloat(Math.max.apply(Math, prices)) + + parseFloat(clickBoxPrice);
       var minPrice = parseFloat(Math.min.apply(Math, prices)) + + parseFloat(clickBoxPrice);
 
       
       var showNum = SKUResult[selectedIds.join('-')].product_repertory;//当前规格下的库存
       var showPrice = maxPrice > minPrice ? minPrice + "-" + maxPrice : maxPrice; //当前规格下的价格
+      if(that.data.loginStatic){ // 表示是渠道价格
+        showPrice = SKUResult[selectedIds.join('-')].product_channel_price//当前规格下的渠道价格
+      }
       var num = this.data.minNumber;//当前数量
       if (num >= showNum){
         that.setData({

+ 26 - 4
pages/car/index.js

@@ -31,6 +31,7 @@ Page({
     shixiao_num : 0,//失效商品数量
     firstClick:0, //没有连点购买按钮
     combineList : [],//存放相同规格,不同礼盒和工艺的商品,合并后的数组【仅需 商品id,组合规格id,总数量】
+    loginStatic:false, //是否是渠道登陆
   },
   loadFun: function () {
     //wx.showNavigationBarLoading();
@@ -79,7 +80,8 @@ Page({
     if (un_id != undefined && un_id != '' && un_id != null){
       let data = {
         user_id: un_id,
-        channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId :""
+        channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId :"",
+        channel_id: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
       }
       wx.request({
         url: host + "shoppingcartapi/shoppingcartview",
@@ -262,6 +264,11 @@ Page({
 
   onShow: function (e) {
     var that = this;
+    if (wx.getStorageSync('channelIdObj').channelId) {
+      that.setData({
+        loginStatic: true,
+      })
+    }
     that.loadFun();
   },
 
@@ -1257,11 +1264,26 @@ Page({
   getTotalPrice() {
     let carts = this.data.carts;//获取购物车列表
     let total = 0;
-    for (let i = 0; i < this.data.carts.length; i++) {
-      if (carts[i].flag == 1 && carts[i].commodity_flag == 0) { // 判断选中[flag = 1]并且是上架[commodity_flag = 0]的商品,才会计算价格
-        total += carts[i].num * (parseFloat(carts[i].cost) + parseFloat(carts[i].box_price));   // 所有价格加起来
+    if (this.data.loginStatic) { //判断是否登陆
+      for (let i = 0; i < this.data.carts.length; i++) {
+        if (carts[i].flag == 1 && carts[i].commodity_flag == 0) { // 判断选中[flag = 1]并且是上架[commodity_flag = 0]的商品,才会计算价格
+          //还得检测渠道价格
+          if (carts[i].product_channel_price){
+            total += carts[i].num * (parseFloat(carts[i].product_channel_price) + parseFloat(carts[i].box_price));   // 所有价格加起来
+          }else {
+            total += carts[i].num * (parseFloat(carts[i].cost) + parseFloat(carts[i].box_price));   // 所有价格加起来
+          }
+          
+        }
+      }
+    } else {
+      for (let i = 0; i < this.data.carts.length; i++) {
+        if (carts[i].flag == 1 && carts[i].commodity_flag == 0) { // 判断选中[flag = 1]并且是上架[commodity_flag = 0]的商品,才会计算价格
+          total += carts[i].num * (parseFloat(carts[i].cost) + parseFloat(carts[i].box_price));   // 所有价格加起来
+        }
       }
     }
+    
     this.setData({
       carts: carts,
       totalPrice: total.toFixed(2)

+ 1 - 1
pages/car/index.wxml

@@ -31,7 +31,7 @@
                               <text wx:if="{{item.giftbox_name}}">{{item.giftbox_name}} </text>
                               <text wx:if="{{item.process_name}}">{{item.process_name}}</text>
                           </view>  
-                          <view class="cart-pro-price">¥<text>{{item.new_price}}</text></view> 
+                          <view class="cart-pro-price">¥<text>{{loginStatic && item.product_channel_price ? item.product_channel_price : item.new_price}}</text></view> 
                           <!-- 增加减少数量按钮 -->
                           <view class="cart-count-box">
 

+ 41 - 11
pages/confirmOrder/confirmOrder.js

@@ -66,12 +66,18 @@ Page({
     maskBg: false,//支付提示蒙层
     agrService: true,//同意服务协议
     stateNum:0,//记录定制商品数量
-    allowPay : 0//避免重复点击付款
+    allowPay : 0,//避免重复点击付款
+    loginStatic:false, //判断是否是渠道登陆
   },
 
   onLoad: function (options) {
     wx.showNavigationBarLoading();
     var that = this;
+    if (wx.getStorageSync('channelIdObj').channelId) {
+      that.setData({
+        loginStatic: true,
+      })
+    }
 
     //转义&符
     let cartsOrder = options.carts
@@ -87,20 +93,37 @@ Page({
     })
     var total = 0;
     var total2 = 0;
-    for (var i = 0; i < carts.length; i++) {
+    if(that.data.loginStatic){ // 表示渠道登陆
+      for (var i = 0; i < carts.length; i++) {
+        console.log(carts[i],"购物车")
+        var boxPrice = carts[i].box_price;
+        var goodsPrice = carts[i].product_channel_price ? carts[i].product_channel_price : carts[i].cost;
+  
 
-      var boxPrice = carts[i].box_price;
-      console.log("boxPrice:" + boxPrice);
-      var goodsPrice = carts[i].cost;
-      console.log("goodsPrice:" + goodsPrice);
 
+        if (boxPrice == '' && boxPrice == null) {
+          boxPrice = 0;
+        }
 
-      if (boxPrice == '' && boxPrice == null) {
-        boxPrice = 0;
+        total += ((parseFloat(goodsPrice) + parseFloat(boxPrice)) * parseInt(carts[i].num));
       }
+    } else {
+      for (var i = 0; i < carts.length; i++) {
+
+        var boxPrice = carts[i].box_price;
+        console.log("boxPrice:" + boxPrice);
+        var goodsPrice = carts[i].cost;
+        console.log("goodsPrice:" + goodsPrice);
+
 
-      total += ((parseFloat(goodsPrice) + parseFloat(boxPrice)) * parseInt(carts[i].num));
+        if (boxPrice == '' && boxPrice == null) {
+          boxPrice = 0;
+        }
+
+        total += ((parseFloat(goodsPrice) + parseFloat(boxPrice)) * parseInt(carts[i].num));
+      }
     }
+    
 
     total = total.toFixed(2)
     total2 = total - that.data.minNum;
@@ -231,6 +254,11 @@ Page({
     var that = this;
     var host = getApp().globalData.servsers;
     var un_id = getApp().globalData.un_id;
+    if (wx.getStorageSync('channelIdObj').channelId) {
+      that.setData({
+        loginStatic: true,
+      })
+    }
   },
 
   coupon: function () {//选择优惠劵
@@ -391,7 +419,8 @@ Page({
           invoice_company_title: that.data.invoice_company_title,//纸质单位和增值发票抬头
           invoice_takeName: that.data.invoice_takeName,//收货姓名
           invoice_takeTelphone: that.data.invoice_takeTelphone,//收货人联系方式
-          invoice_takeAddress: that.data.invoice_takeAddress//收货人地址
+          invoice_takeAddress: that.data.invoice_takeAddress,//收货人地址
+          channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId : ""
         },
         method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
         header: {
@@ -650,7 +679,8 @@ Page({
         style4_name: that.data.carts[i].style4_name,
         style5: that.data.carts[i].style5,
         style5_name: that.data.carts[i].style5_name,
-        comGroupId: that.data.carts[i].com_group_id
+        comGroupId: that.data.carts[i].com_group_id,
+        channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId : ""
       },
       method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
       header: {

+ 1 - 1
pages/confirmOrder/confirmOrder.wxml

@@ -7,7 +7,7 @@
       <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_price">¥<text>{{loginStatic && item.product_channel_price ? item.product_channel_price : 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>

+ 6 - 1
pages/index/index.js

@@ -562,8 +562,13 @@ Page({
       method: "get",
       data: data,
       success(res) {
-        let goods = that.data.goodsNewsArray
+        let goods = that.data.goodsNewsArray;
+        console.log(goods)
+        if (that.data.page == 1){
+          goods = [];
+        }
         goods.push(...res.data.rows);
+        console.log(goods)
         that.setData({
           goodsNewsArray: goods,
           requestState: res.data.rows.length === that.data.limit 

+ 1 - 1
pages/mine/mine.wxml

@@ -55,7 +55,7 @@
     <!-- 我的定制订单 -->
  <view class='user-order'>
     <view class="pad-t20 pad-b20 mar-r20 f-s30 mar-l20 order-title f-box f-align-items-center" bindtap='channelInfo'>
-      <view class='f-item'>我的信息</view>
+      <view class='f-item'>{{channIdState ? '渠道信息' :'渠道登入'}}</view>
       <view class='f-s28 f-box f-align-items-center'>
         <icon class='{{madeList.icon}} iconfont'></icon>
       </view>

+ 1 - 2
pages/orderCanvas/orderCanavs.js

@@ -75,8 +75,7 @@ Page({
     }
   },
   returnHome(){
-    // 查看订单
-    wx.navigateTo({
+    wx.switchTab({
       url: '/pages/index/index',
     })
   },

+ 15 - 2
pages/orderList/orderList.js

@@ -148,7 +148,7 @@ Page({
   },
   uploadImg(e){
     // 上传支付凭证
-    let orderId=e.currentTarget.dataset.orderid,that =this;
+    let orderId = e.currentTarget.dataset.orderid, that = this, index = e.currentTarget.dataset.index;
     wx.chooseImage({
       success(res) {
         const tempFilePaths = res.tempFilePaths
@@ -165,11 +165,16 @@ Page({
           },
           success(res) {
             console.log(res, '我上传完了')
-            if(res.data == 'success'){
+            if(res.data){
               wx.showToast({
                 title: '支付凭证上传成功!',
                 icon:'none'
               })
+              let goodsList = that.data.goodsList;
+              goodsList[index].list_order_aff_data[0].pay_order = res.data
+              that.setData({
+                goodsList: goodsList
+              })
             } else {
               wx.showToast({
                 title: res.data,
@@ -181,5 +186,13 @@ Page({
       }
     })
     
+  },
+  seePayOrder(e){
+    let that = this, imgSrc =(host+ e.currentTarget.dataset.src).split(',') 
+   
+    wx.previewImage({
+      current: imgSrc[0],
+      urls: imgSrc
+    })
   }
 })

+ 4 - 3
pages/orderList/orderList.wxml

@@ -17,7 +17,8 @@
       <view class='f-box pad-t20 pad-b20'>
         <view class='f-item'>订单:{{item.order_number}}</view>
         <view wx:if="{{item.order_sta ==1}}">待审核</view>
-         <view wx:if="{{item.order_sta ==3}}">审核通过</view>
+        <view wx:if="{{item.order_sta ==3}}">审核通过</view>
+        <view class='mar-l20' wx:if="{{item.list_order_aff_data[0].pay_order}}" data-src="{{item.list_order_aff_data[0].pay_order}}" bindtap='seePayOrder'>查看凭证</view>
       </view>
       
       <view class='f-box mar-b20' wx:for="{{item.list_order_aff_data}}" wx:for-item="orderItem">
@@ -30,14 +31,14 @@
             <view class='f-item mar-r20'>
               <view>{{orderItem.com_dz}}  {{orderItem.com_lh}}  {{orderItem.com_style1}}</view>
             </view>
-            <view>×{{orderItem.com_num}}</view>
+            <view>×{{orderItem.order_num}}</view>
           </view>
         </view>
       </view>
       <!-- 价格与按钮 -->
       <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' wx:if="{{item.order_sta ==1}}" data-orderId="{{item.order_number}}" bindtap='uploadImg'>上传凭证</view>
+          <view class='btn' wx:if="{{item.order_sta ==1}}" data-index="{{index}}" data-orderId="{{item.order_number}}" bindtap='uploadImg'>{{item.list_order_aff_data[0].pay_order ? "修改凭证" :"上传凭证"}}</view>
           <view class='btn' wx:if="{{item.order_sta ==4}}">查看物流</view>
           <view class='btn' wx:if="{{item.order_sta ==4}}">确认收货</view>
         </view>