stanley-king 4 years ago
parent
commit
1379e2f36c

+ 6 - 16
config.js

@@ -20,7 +20,7 @@ function getReq(app,data, callback, method)
   let act = data['act'];
   let act = data['act'];
   if(act.indexOf('member_') == 0)
   if(act.indexOf('member_') == 0)
   {
   {
-    console.log(act + ' must check login status.')
+    // console.log(act + ' must check login status.')
     if (app != null && !app.globalData.userInfo) {
     if (app != null && !app.globalData.userInfo) {
       wx.navigateTo({
       wx.navigateTo({
         url: '/pages/auth/auth',
         url: '/pages/auth/auth',
@@ -28,9 +28,7 @@ function getReq(app,data, callback, method)
       return;
       return;
     }
     }
   } 
   } 
-  else {
-    console.log('act = ' + act);
-  }
+  console.log('act=' + act + '&' + 'op=' + data['op']);
 
 
   let header = {
   let header = {
     'content-type': 'application/json', // 默认值
     'content-type': 'application/json', // 默认值
@@ -43,7 +41,7 @@ function getReq(app,data, callback, method)
       'Cookie': 'MPHPSESSID=' + session_id
       'Cookie': 'MPHPSESSID=' + session_id
     }
     }
   }
   }
-  //const ErrUnLogin = 10014;
+  
   return wx.request({
   return wx.request({
     url: api,
     url: api,
     data,
     data,
@@ -52,7 +50,7 @@ function getReq(app,data, callback, method)
     success(res) 
     success(res) 
     {
     {
       console.log(res) 
       console.log(res) 
-      if(res.data.code == 10014) {
+      if (res.data.code == 10014) { //ErrUnLogin = 10014;
         wx.removeStorage('session_id');
         wx.removeStorage('session_id');
         wx.navigateTo({
         wx.navigateTo({
           url: '/pages/auth/auth',
           url: '/pages/auth/auth',
@@ -114,9 +112,6 @@ function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback)
           successCallback && successCallback(res)
           successCallback && successCallback(res)
         },
         },
         fail: function (res) {
         fail: function (res) {
-          // wx.redirectTo({
-          //   url: `/pages/orderPaySn/orderPaySn?pay_sn=${pay_sn}`
-          // })
           wx.showToast({
           wx.showToast({
             icon: 'none',
             icon: 'none',
             title: '支付失败',
             title: '支付失败',
@@ -132,10 +127,6 @@ function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback)
         title: res.message,
         title: res.message,
         duration: 2000
         duration: 2000
       })
       })
-      // app.globalData.fcodeErr = res.message
-      // setTimeout(() => {
-      //   wx.navigateBack()
-      // }, 2000);
     }
     }
   })
   })
 }
 }
@@ -160,8 +151,7 @@ function payOrder(app, pay_sn) {
           wx.redirectTo({
           wx.redirectTo({
             url: "/pages/order_tabs/orderTabs?state_type=state_pay"
             url: "/pages/order_tabs/orderTabs?state_type=state_pay"
           })
           })
-          console.log("成功:", res);
-          console.log('支付成功')
+          console.log("支付成功:", res);
         },
         },
         fail: function (res) {
         fail: function (res) {
           setTimeout(() => {
           setTimeout(() => {
@@ -171,7 +161,7 @@ function payOrder(app, pay_sn) {
               duration: 2000
               duration: 2000
             })
             })
           }, 200);
           }, 200);
-          console.log("失败", res);
+          console.log("失败:", res);
         }
         }
       });
       });
     }
     }

+ 8 - 3
pages/components/auth/auth.js

@@ -43,10 +43,15 @@ Component({
         this.wxauthen(e)
         this.wxauthen(e)
       }
       }
     },
     },
-    wxauthen: function (eInfo) {
+    wxauthen: function (eInfo) {      
       let userInfo = eInfo.detail.userInfo;
       let userInfo = eInfo.detail.userInfo;
-      let { encryptedData, iv, signature } = eInfo.detail
-      userInfo = Object.assign({}, { encryptedData }, { signature }, { iv }, userInfo)
+      if (app.globalData.userId.unionid) {
+        userInfo = Object.assign({}, app.globalData.userId, app.globalData.userInfo);
+      }
+      else {
+        let { encryptedData, iv, signature } = e.detail
+        userInfo = Object.assign({}, { encryptedData }, { signature }, { iv }, userInfo)
+      }
       
       
       let phoneInfo = { iv: this.phone_iv, encryptedData: this.phone_encryptedData }
       let phoneInfo = { iv: this.phone_iv, encryptedData: this.phone_encryptedData }
       let params = {
       let params = {

+ 0 - 2
pages/phoneCharges/phoneCharges.js

@@ -95,9 +95,7 @@ Page({
       return
       return
     }
     }
     buyVGoods(app,goods_id,1,{ card_no }, (res) => {
     buyVGoods(app,goods_id,1,{ card_no }, (res) => {
-      // console.log('res',res)  成功回调
     }, (err) => {
     }, (err) => {
-      // 失败回调
     })
     })
   },
   },
 
 

+ 342 - 0
pages/vorderList/orderTabs.js

@@ -0,0 +1,342 @@
+// pages/order_tabs/orderTabs.js
+const getReq = require('../../config.js').getReq
+const payOrder = require('../../config.js').payOrder
+
+import recordSource from '../../utils/recordSource'
+let app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    hasmore: false,
+    orders: [],
+    addTimes: [],
+    curpage: 1,
+    tabs: [
+      {
+        name: "全部",
+        type: ""
+      },
+      {
+        name: "待付款",
+        type: 'state_new'
+      },
+      {
+        name: "充值中",
+        type: 'state_pay'
+      },
+      // {
+      //   name: "待收货",
+      //   type: 'state_send'
+      // },
+      {
+        name: "已完成",
+        type: 'state_success'
+      }
+    ],
+    selectedIndex: 0,
+    state_type: '',
+    tabs_title: '',
+    loading: false,
+    fromSource: '',
+    firstLoad: true
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    let state_type = options.state_type || this.data.state_type;
+    switch (state_type) {
+      case '': {
+        this.setData({
+          selectedIndex: 0,
+          state_type,
+          tabs_title: '全部'
+        })
+        break;
+      }
+      case 'state_new': {
+        this.setData({
+          selectedIndex: 1,
+          state_type,
+          tabs_title: '待付款'
+        })
+        break;
+      }
+      case 'state_pay': {
+        this.setData({
+          selectedIndex: 2,
+          state_type,
+          tabs_title: '待发货'
+        })
+        break;
+      }
+      case 'state_send': {
+        this.setData({
+          selectedIndex: 3,
+          state_type,
+          tabs_title: '待收货'
+        })
+        break;
+      }
+      case 'state_success': {
+        this.setData({
+          selectedIndex: 4,
+          state_type,
+          tabs_title: '已收货'
+        })
+        break;
+      }
+    }
+    this.req_datas(state_type);
+  },
+
+  req_datas(type) {
+    let fromSource = recordSource(app, `act=member_order&op=list&page=15&curpage=${this.data.curpage}&state_type=${type}&client_type=mini`)
+    this.setData({
+      loading: true,
+      fromSource: app.globalData.fromSource
+    });
+    wx.showLoading({
+      title: '加载中',
+    });
+    if (type != this.data.state_type) {
+      this.setData({
+        hasmore: false,
+        orders: [],
+        addTimes: [],
+        curpage: 1,
+        state_type: type
+      });
+    }
+    let self = this;
+    getReq(app,{
+      act: 'member_vorder',
+      op: 'list',
+      page: 15,
+      curpage: this.data.curpage,
+      state_type: type,
+      from: fromSource
+    }, function (res) {
+      let vorders = res.datas.vorders;
+      let addTimes = [];
+      let hasmore = false;
+      let curpage = self.data.curpage
+      for (let item of vorders) {
+        addTimes.push(self.timeFormat(item.vorder_info.add_time));
+      }
+      if (res.datas.mobile_page.hasmore) {
+        hasmore = true;
+        curpage = self.data.curpage + 1;
+      }
+      else {
+        hasmore = false;
+      }
+      self.setData({
+        hasmore,
+        curpage,
+        orders: self.data.orders.concat(vorders),
+        addTimes: self.data.addTimes.concat(addTimes),
+        loading: false,
+        firstLoad: false
+      });
+
+      wx.hideLoading();
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    if(!this.data.firstLoad) {
+      app.setFromSource(this.data.fromSource)
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    if (this.data.hasmore) {
+      this.req_datas(this.data.state_type);
+    }
+  },
+
+  timeFormat(time) {
+    let date = new Date(time * 1000);
+    let year = date.getFullYear();
+    let month = date.getMonth() + 1;
+    let day = date.getDate();
+    return `${year}-${month}-${day}`;
+  },
+
+  selectTab(e) {
+    let index = e.target.dataset.index;
+    let type = e.target.dataset.type;
+    if (type == this.data.state_type) {
+      return;
+    }
+    else {
+      switch (type) {
+        case '': {
+          this.setData({
+            selectedIndex: index,
+            tabs_title: '全部'
+          })
+          break;
+        }
+        case 'state_new': {
+          this.setData({
+            selectedIndex: index,
+            tabs_title: '待付款'
+          })
+          break;
+        }
+        case 'state_pay': {
+          this.setData({
+            selectedIndex: index,
+            tabs_title: '待发货'
+          })
+          break;
+        }
+        case 'state_send': {
+          this.setData({
+            selectedIndex: index,
+            tabs_title: '待收货'
+          })
+          break;
+        }
+        case 'state_success': {
+          this.setData({
+            selectedIndex: index,
+            tabs_title: '已收货'
+          })
+          break;
+        }
+      }
+      this.req_datas(type);
+    }
+  },
+  change_order_state(action, order_id, index) {
+    let self = this;
+    getReq(app,{
+      act: 'member_vorder',
+      op: 'change_state',
+      act_type: action,
+      order_id: order_id
+    }, function (res) {
+      if (res.code != 200) {
+        wx.showToast({
+          title: res.message,
+          icon: 'none'
+        })
+      }
+      else {
+        let orders = self.data.orders;
+        let addTimes = self.data.addTimes;
+        orders.splice(index, 1);
+        addTimes.splice(index, 1);
+        self.setData({
+          orders,
+          addTimes
+        })
+      }
+    })
+  },
+  order_action(e) {
+    const action = e.target.dataset.action;
+    const order_id = e.target.dataset.orderid;
+    const order_sn = e.target.dataset.ordersn;
+    const pay_sn = e.target.dataset.paysn;
+    const index = e.target.dataset.index;
+    let self = this;
+    switch (action) {
+      case "if_delete": {
+        wx.showModal({
+          title: "提示",
+          content: "您确定要删除该订单吗?",
+          success: function (res) {
+            if (res.confirm) {
+              self.change_order_state(action, order_id, index);
+            }
+            else if (res.cancel) {
+              return;
+            }
+          }
+        })
+        break;
+      }
+      case "if_deliver": {
+        let url = encodeURIComponent("https://passport.lrlz.com/mobile/index.php?act=member_order&op=search_deliver&order_id=");
+        app.navigateto(`/pages/webView/webView?url=${url}${order_id}`)
+        break;
+      }
+      case "if_cancel": {
+        wx.showModal({
+          title: "提示",
+          content: "您确定要取消该订单吗?",
+          success: function (res) {
+            if (res.confirm) {
+              self.change_order_state(action, order_id, index);
+            }
+            else if (res.cancel) {
+              return;
+            }
+          }
+        })
+        break;
+      }
+      case "if_receive": {
+        wx.showModal({
+          title: "提示",
+          content: "您确定收货吗?",
+          success: function (res) {
+            if (res.confirm) {
+              self.change_order_state(action, order_id, index);
+            }
+            else if (res.cancel) {
+              return;
+            }
+          }
+        })
+        break;
+      }
+      case "if_payment": {
+        payOrder(app, pay_sn)
+        // app.navigateto(`/pages/orderPaySn/orderPaySn?pay_sn=${pay_sn}`)
+      }
+    }
+  }
+})

+ 6 - 0
pages/vorderList/orderTabs.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "我的订单",
+  "usingComponents": {
+    
+  }
+}

+ 57 - 0
pages/vorderList/orderTabs.wxml

@@ -0,0 +1,57 @@
+<view class='tabs vux-1px-b'>
+  <block wx:key="index" wx:for="{{tabs}}">
+    <view class='tabs_item {{selectedIndex == index?"selected":""}}' 
+          data-type="{{item.type}}" 
+          data-index="{{index}}" 
+          bindtap='selectTab'>{{item.name}}</view>
+  </block>
+</view>
+<view style='height:88rpx;'></view>
+<view class="order_list" wx:if="{{orders.length > 0}}">
+  <block wx:key="index" wx:for-index="idx" wx:for="{{orders}}">
+    <view class='order_item'>
+      <view class='order_time'>
+          <text class='add_time'>{{addTimes[idx]}}</text>
+          <rich-text nodes="{{item.vorder_info.state_desc}}"></rich-text>
+      </view>
+      <block wx:key="index" wx:for-item="goods_list"  wx:for="{{item.vorder_goods}}">
+        <view class='order_content align_center'>
+        <view class='order_image'>
+          <image style='width:140rpx;height: 140rpx;' src='{{goods_list.goods_image}}'></image>
+        </view>
+        <view class='order_info'>
+          <view>
+            <text class='goods_name'>{{goods_list.goods_name}}</text>
+          </view>
+          <view>
+            <text class='goods_spec'>{{goods_list.goods_spec}}</text>
+          </view>
+        </view>
+        <view class='order_price'>
+          <view>¥{{goods_list.goods_price}}</view>
+        </view>
+      </view>
+      </block>
+      <view class='order_total'>
+        <text>合计:<text class='order_amount mr6'>¥{{item.vorder_info.pay_cash}}</text> 
+      </text>
+      </view>
+      <view class='order_handle'>
+        <block wx:key="index" wx:for="{{item.actions}}" wx:for-item="action">
+          <text wx:if="{{(action.action != 'if_evaluation') && (action.action != 'if_refund_cancel')}}" 
+                data-action="{{action.action}}" 
+                data-orderid="{{item.vorder_info.order_id}}" 
+                data-ordersn="{{item.vorder_info.order_sn}}" 
+                data-index="{{idx}}" 
+                data-paysn="{{item.vorder_info.pay_sn}}" 
+                bindtap='order_action'>{{action.title}}</text>  
+        </block> 
+      </view>
+    </view>
+  </block>    
+</view>
+<view class='empty_order' wx:if="{{orders.length <= 0 && loading == false}}">
+  <image class="empty_order_icon" src="../../image/empty_order.png"></image>
+  <view class="emoty_order_title">您还没有相关的订单</view>
+  <view class="emoty_order_subtitle">可以去看看有哪些想买的</view>
+</view>

+ 134 - 0
pages/vorderList/orderTabs.wxss

@@ -0,0 +1,134 @@
+.order_item {
+  font-size: 24rpx;
+  margin-top: 15rpx;
+  background: #fff;
+}
+
+.order_time {
+  position: relative;
+  display: flex;
+  padding: 10rpx 15rpx;
+}
+
+.order_time::after {
+  content: "";
+  position: absolute;
+  bottom: 0;
+  right: 0;
+  width: 100%;
+  height: 2rpx;
+  background: #d9d9d9;
+  -webkit-transform: scaleY(0.5);
+  transform: scaleY(0.5);
+}
+
+.order_time text {
+  flex: 1;
+}
+
+.order_time text.state_desc, .order_price, .order_total, .order_handle {
+  text-align: right;
+}
+
+.order_content {
+  display: flex;
+  position: relative;
+  padding: 5rpx 15rpx;
+}
+
+.order_content::after {
+  content: "";
+  position: absolute;
+  bottom: 0;
+  right: 0;
+  width: 100%;
+  height: 2rpx;
+  background: #d9d9d9;
+  -webkit-transform: scaleY(0.5);
+  transform: scaleY(0.5);
+}
+
+.order_info {
+  width: 500rpx;
+  padding-left: 15rpx;
+}
+
+.order_handle {
+  margin-top: 8rpx;
+}
+
+.order_total {
+  padding-right: 15rpx;
+  padding-top: 15rpx;
+  padding-bottom: 15rpx;
+}
+
+.order_handle text {
+  display: inline-block;
+  color: grey;
+  border: 1rpx solid grey;
+  border-radius: 5rpx;
+  padding: 10rpx 16rpx;
+  
+  margin: 15rpx;
+  font-size: 22rpx;
+}
+.goods_spec {
+  font-size:20rpx;
+  color:grey;
+  margin-top:20rpx;
+  display:inline-block;
+}
+.order_amount {
+  color: #333;
+}
+
+.tabs {
+  display: flex;
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 88rpx;
+  line-height: 88rpx;
+  background: #ffffff;
+  font-size: 28rpx;
+  text-align: center;
+  z-index: 10;
+}
+
+.tabs view {
+  flex: 1;
+}
+
+.selected {
+  color: #333;
+  border-bottom: 3px solid #2b2b2b; 
+}
+
+.empty_order {
+  text-align: center;
+  font-size: 30rpx;
+}
+
+.empty_order text {
+  display: block;
+  height: 300rpx;
+  line-height: 300rpx;
+}
+.empty_order_icon {
+  width: 523rpx;
+  height: 300rpx;
+  margin: 120rpx auto 50rpx;
+}
+.emoty_order_title {
+  font-size: 36rpx;
+  font-weight: bold;
+  color: #333;
+  text-align: center;
+}
+.emoty_order_subtitle {
+  font-size: 24rpx;
+  color: #666;
+  text-align: center;
+}