Browse Source

add directbuyvorder

stanley-king 4 years ago
parent
commit
834e8232c5

+ 3 - 1
app.json

@@ -1,6 +1,9 @@
 {
   "pages": [
     "pages/postage/postage",
+    "pages/postageManage/postageManage",
+    "pages/address/address",
+    "pages/postageDetail/postageDetail",
     "pages/index/index",
     "pages/discover/discover",
     "pages/shopCart/shopCart",
@@ -14,7 +17,6 @@
     "pages/confirmOrder/confirmOrder",
     "pages/confirmVOrder/confirmVOrder",
     "pages/order_tabs/orderTabs",
-    "pages/address/address",
     "pages/addAddress/addAddress",
     "pages/orderPaySn/orderPaySn",
     "pages/fcode/fcode",

+ 54 - 1
config.js

@@ -53,7 +53,60 @@ function getReq(data, callback, method)
   })
 }
 
+function buyVGoods(goods_id,goods_num) 
+{
+  let ifcart = 0
+  let cartids = goods_id + '|' + goods_num;
+  let params = {
+    act: 'member_buy',
+    op: 'step_vsecond',
+    payment: 'minipay',
+    usebonus: 0,
+    ifcart : 0,
+    cart_id: cartids,
+    invoice_id: 0
+  }
+
+  params = Object.assign({}, params);
+  getReq(params, function (res) {
+    wx.hideLoading()
+    if (res.code == 200) {
+      let param = res.datas.param.data
+      let pay_sn = res.datas.pay_sn
+      wx.requestPayment({
+        timeStamp: param.timeStamp, //时间戳,自1970年以来的秒数
+        nonceStr: param.nonceStr,   //随机串
+        package: param.package,
+        signType: param.signType, //微信签名方式:
+        paySign: param.paySign,   //微信签名
+        success: function (res) {
+          wx.reLaunch({
+            url: "/pages/index/index"
+          })
+        },
+        fail: function (res) {
+          wx.redirectTo({
+            url: `/pages/orderPaySn/orderPaySn?pay_sn=${pay_sn}`
+          })
+        }
+      });
+    }
+    else {
+      wx.showToast({
+        icon: 'none',
+        title: res.message,
+        duration: 2000
+      })
+      app.globalData.fcodeErr = res.message
+      setTimeout(() => {
+        wx.navigateBack()
+      }, 2000);
+    }
+  })
+}
+
 module.exports = {
   getReq,
-  host: api
+  host: api,
+  buyVGoods:buyVGoods
 }

+ 1 - 1
pages/address/address.wxss

@@ -23,7 +23,7 @@
   left: 0;
   right: 0;
   color: #fff;
-  background: #2b2b2b;
+  background: #fe7124;
   line-height: 92rpx;
   text-align: center;
   font-size: 30rpx;

+ 15 - 1
pages/components/blockItem/blockItem.js

@@ -1,5 +1,8 @@
 // pages/components/blockItem/blockItem.js
-const getTypeSn = require('../../../utils/util.js').getTypeSn;
+const getTypeSn    = require('../../../utils/util.js').getTypeSn;
+const parseAppjump = require('../../../utils/util.js').parseAppjump;
+const buyVGoods = require('../../../config.js').buyVGoods;
+
 Component({
   /**
    * 组件的属性列表
@@ -157,6 +160,17 @@ Component({
           })
           break;
         }
+        case "appjump": {
+          //let url = 'xyzshop://www.xyzshops.com/DirectBuy?goods_id=6217&num=1';
+          let url = target_data;
+          const [prefix, params] = parseAppjump(url);
+
+          if(prefix == 'xyzshop://www.xyzshops.com/DirectBuyVGoods') {
+            let goods_id = params['goods_id'];
+            let num = params['num'];    
+            buyVGoods(goods_id,num);        
+          }
+        }
         default: {
           console.log(type + '类型找不到');
         }

+ 20 - 20
pages/components/select/select.wxss

@@ -2,58 +2,58 @@
   width: 100%;
 }
 .com-sContent{
-  border-bottom: 1px solid #e2e2e2;
+  border-bottom: 1rpx solid #e2e2e2;
   background: white;
-  font-size: 16px;
+  font-size: 26rpx;
   position: relative;
-  height: 45px;
-  line-height: 45px;
+  height: 90rpx;
+  line-height: 90rpx;
 }
 .com-sImg{
   position: absolute;
   right: 0;
-  top: 12px;
-  width: 20px;
-  height: 20px;
+  top: 24rpx;
+  width: 40rpx;
+  height: 40rpx;
   transition: all .3s ease;
 }
 .com-sTxt{
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
-  padding:0 20px 0 0;
-  font-size: 22px;
+  padding:0 40rpx 0 0;
+  font-size: 42rpx;
   color: #2b2b2b;
 }
 
 .com-sTxt.noText{
-  font-size: 14px;
+  font-size: 26rpx;
   color: #848799;
 }
 
 .com-sList{
   background: white;
-  width: 85%;
+  width: 660rpx;
   position: absolute;
-  border-bottom: 1px dotted #e2e2e2;
+  border-bottom: 1rpx dotted #e2e2e2;
   /* border-top: none; */
   box-sizing: border-box;
   z-index: 3;
-  max-height: 120px;
+  max-height: 300rpx;
   overflow: auto;
 }
 .com-sItem{
-  /* left: 15px;
-  right: 15px; */
-  height: 45px;
-  line-height: 45px;
-  border-top: 1px solid #e2e2e2;
-  padding: 0 6px;
+  /* left: 15rpx;
+  right: 15rpx; */
+  height: 90rpx;
+  line-height: 90rpx;
+  border-top: 1rpx solid #e2e2e2;
+  padding: 0 12rpx;
   text-align: left;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
-  font-size: 14px;
+  font-size: 26rpx;
 }
 .com-sItem:first-child{
   border-top: none;

+ 153 - 30
pages/postage/postage.js

@@ -1,59 +1,173 @@
-// pages/postage/postage.js
+import recordSource from '../../utils/recordSource';
 const getReq = require('../../config.js').getReq
-let appInstance = getApp()
+
+let app = getApp();
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    currentIndex: 0,
-    rechargeGearActiveIndex: 0,
+    currentIndex: 0,  //页签索引
+    rechargeGearActiveIndex: 0, //挡位项目索引
+    tips:'',  //顶部tips
+    goods:[], //挡位数据
+    goods_id:'', //当前选中挡位的goods_id
+    card_type: '', //油卡类型 (中石化/中石油)
+    card_no: '', //油卡号
+    firstLoad: true,
     tabsData: [
-      { id: 0, icon: '/image/postage/sinopec.png', title: '中国石化', tips: '选择油卡:(一人最多十张油卡)' },
-      { id: 1, icon: '/image/postage/petrochina.png', title: '中国石油', tips: '选择油卡:(一人最多八张油卡)' }
+      { id: 0, icon: '/image/postage/sinopec.png', title: '中国石化', tips: '选择油卡:(一人最多十张油卡)', card_no: '15853434113521' },
+      { id: 1, icon: '/image/postage/petrochina.png', title: '中国石油', tips: '选择油卡:(一人最多八张油卡)', card_no: '41865461251351' }
     ],
-    selectArray: [{
-        "id": "10",
-        "text": "9066666888"
-    }, {
-        "id": "21",
-        "text": "25288888556"
-    }],
-    gearData: [
-      { faceValue: 100,  price: 95  },
-      { faceValue: 200,  price: 190 },
-      { faceValue: 500,  price: 475 },
-      { faceValue: 1000, price: 950 }
-    ]
+// <<<<<<< HEAD
+//     selectArray: [{
+//         "id": "10",
+//         "text": "9066666888"
+//     }, {
+//         "id": "21",
+//         "text": "25288888556"
+//     }],
+//     gearData: [
+//       { faceValue: 100,  price: 95  },
+//       { faceValue: 200,  price: 190 },
+//       { faceValue: 500,  price: 475 },
+//       { faceValue: 1000, price: 950 }
+//     ]
+// =======
+    fromSource: ''
+// >>>>>>> 259bb9c31cb59d1d11de38b7b18920184eefb6c9
   },
 
+  // 页签切换
   handlerClickTabItem(e) {
+    var dataset = e.currentTarget.dataset
     this.setData({
-      currentIndex: e.currentTarget.dataset.activeindex
+      currentIndex: dataset.activeindex,
+      card_no: dataset.cardno
     });
   },
 
+  //充值档位切换
   handlerClickRechargeGear(e) {
+    var dataset = e.currentTarget.dataset
     this.setData({
-      rechargeGearActiveIndex: e.currentTarget.dataset.activeindex
+      rechargeGearActiveIndex: dataset.activeindex,
+      goods_id: dataset.currentvalue
     });
   },
 
-  handlerClickAdd(e){
-    wx.showToast({
-      title: '尚未实现',
-      icon: 'none',
-      duration: 2000,
-      mask: true
-    });
+  //跳转到油卡管理页面
+  handlerAddCard(){
+    wx.navigateTo({
+      url: '/pages/postageManage/postageManage',
+    })
   },
 
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    
+    let fromSource = recordSource(app, `act=index&op=card_goods`)
+    this.setData({
+      fromSource: app.globalData.fromSource,
+      card_no: this.data.tabsData[0].card_no
+    });
+    var self = this;
+    getReq({
+      act: 'index',
+      op: 'card_goods',
+      card_type: 'oil',
+      from: fromSource
+    }, function (res) {
+      self.setData({
+        firstLoad: false
+      });
+      if (res.code == 200) {
+        if(res.datas && res.datas.goods){
+          var datas = res.datas
+          self.setData({
+            tips: datas.tips,
+            goods: datas.goods,
+            goods_id: datas.goods[0].goods_id
+          });
+        }
+      }else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+      }
+    })
+  },
+
+  // 立即充值
+  handlerRecharge(){
+    wx.showToast({
+      icon: 'none',
+      title: `goods_id: ${this.data.goods_id}, card_no: ${this.data.card_no}`,
+      duration: 2000
+    })
+    console.table({'goods_id': this.data.goods_id, 'card_no': this.data.card_no})
+
+    this.toPay()
+  },
+
+  toPay() {
+    let goods_id = this.data.goods_id
+    let goods_num = 1
+    let iscart = this.data.ifcart
+    let cart_id = this.data.cart_id
+
+    let ifcart = cart_id ? 1 : 0
+    let cartids = cart_id ? cart_id : (goods_id + '|' + goods_num)
+    let params = {
+      act: 'member_buy',
+      op: 'step_vsecond',
+      payment: 'minipay',
+      usebonus: 1,
+      ifcart:1,
+      cart_id: 1,
+      invoice_id: 0
+    }
+    params = Object.assign({}, params);
+    getReq(params, function (res) {
+      wx.hideLoading()
+      if (res.code == 200) {
+        let param = res.datas.param.data
+        let pay_sn = res.datas.pay_sn
+        wx.requestPayment({
+          timeStamp: param.timeStamp, //时间戳,自1970年以来的秒数
+          nonceStr: param.nonceStr, //随机串
+          package: param.package,
+          signType: param.signType, //微信签名方式:
+          paySign: param.paySign, //微信签名
+          success: function (res) {
+            wx.reLaunch({
+              url: "/pages/index/index"
+            })
+          },
+          fail: function (res) {
+            // wx.redirectTo({
+            //   url: `/pages/orderPaySn/orderPaySn?pay_sn=${pay_sn}`
+            // })
+          }
+        });
+      }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+        app.globalData.fcodeErr = res.message
+        setTimeout(() => {
+          wx.navigateBack()
+        }, 2000);
+      }
+    })
   },
 
   /**
@@ -67,7 +181,16 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    
+    if(!this.data.firstLoad) {
+      let defaultAddress = app.globalData.defaultAddress
+      console.log('defaultAddress',defaultAddress)
+      app.setFromSource(this.data.fromSource)
+      if (defaultAddress) {
+        this.setData({
+          defaultAddress
+        })
+      }
+    }
   },
 
   /**

+ 1 - 4
pages/postage/postage.json

@@ -1,7 +1,4 @@
 {
   "navigationBarTitleText": "油卡充值",
-  "navigationBarBackgroundColor": "#fe7124",
-  "usingComponents": {
-    "Select": "../components/select/select"
-  }
+  "navigationBarBackgroundColor": "#fe7124"
 }

+ 13 - 12
pages/postage/postage.wxml

@@ -1,11 +1,10 @@
-<!--pages/address/address.wxml-->
 <view class="postage">
-  <view class="tips">您好!尊敬的会员,您正享受商城促销活动9.6折</view>
+  <view class="tips" wx:if="{{tips}}">{{tips}}</view>
   <!-- 选择油卡 -->
   <view class="tabs" wx:if="{{tabsData.length}}">
     <view class="tabs-title">
       <view class="tabs-title-item {{currentIndex == index ? 'active' : ''}}" wx:for="{{tabsData}}" wx:key="index" 
-      bindtap="handlerClickTabItem" data-activeindex="{{index}}">
+      bindtap="handlerClickTabItem" data-activeindex="{{index}}" data-cardno="{{item.card_no}}">
         <image class="tabs-title-item__icon" src="{{item.icon}}"></image>
         <text class="tabs-title-item__text">{{item.title}}</text>
       </view>
@@ -13,26 +12,28 @@
     <view class="tabs-content" wx:for="{{tabsData}}" wx:key="index"  style='display:{{currentIndex !== index ? "none" : "block"}}'>
       <view class="tabs-content__tips" catchtap="handlerClickAdd">
         <text class="tabs-content__tips-text">{{item.tips}}</text>
-        <image class="tabs-content__tips-add" src="/image/postage/add.png"></image>
+        <!-- <image class="tabs-content__tips-add" src="/image/postage/add.png"></image> -->
+      </view>
+      <view class="card-no vux-1px-b" bindtap="handlerAddCard">
+        {{ defaultAddress.mob_phone || item.card_no}}
       </view>
-      <Select prop-array='{{selectArray}}'></Select>
     </view>
   </view>
   
   <!-- 充值挡位 -->
-  <view class="rechargeGear" wx:if="{{gearData.length}}">
+  <view class="rechargeGear" wx:if="{{goods.length}}">
     <view class="rechargeGear-title">充值挡位</view>
     <view class="rechargeGear-content">
-      <view class="rechargeGear-content__item {{rechargeGearActiveIndex == index ? 'active' : ''}}" wx:for="{{gearData}}" wx:key="index" 
-      bindtap="handlerClickRechargeGear" data-activeindex="{{index}}">
-        <view class="faceValue">{{item.faceValue}}元</view>
-        <view class="price">售价 {{item.price}} 元</view>
+      <view class="rechargeGear-content__item {{rechargeGearActiveIndex == index ? 'active' : ''}}" wx:for="{{goods}}" wx:key="index" 
+      bindtap="handlerClickRechargeGear" data-activeindex="{{index}}" data-currentvalue="{{item.goods_id}}">
+        <view class="faceValue">{{item.goods_spec}}</view>
+        <view class="price">售价 {{item.goods_price}} 元</view>
       </view>
     </view>
     <view class="rechargeGear-footer">
-      <navigator class="btn-rechargeNow" url="/pages/addAddress/addAddress">
+      <view class="btn-rechargeNow" bindtap="handlerRecharge">
         <text>立即充值</text>
-      </navigator>
+      </view>
       <view class="rechargeNow-tips">充值后,即时到账</view>
     </view>
   </view>

+ 48 - 37
pages/postage/postage.wxss

@@ -1,6 +1,6 @@
 .postage{
   position: relative;
-  padding: 10px 0;
+  padding: 20rpx 0;
   color: #848799;
 }
 
@@ -10,36 +10,36 @@
   top: 0;
   left: 0;
   width: 100%;
-  height: 165px;
+  height: 165rpx;
   background: linear-gradient(to bottom, #fd7428 0%,#fc8f4a 100%);
   z-index: -1;
 }
 
 .tips{
-  padding: 5px 10px;
+  padding: 15rpx 20rpx;
   width: 92%;
   margin: 0 auto;
   background-color: #ffd900;
   color: #786700;
-  border-radius: 10px;
+  border-radius: 10rpx;
   box-sizing: border-box;
-  font-size: 14px;
+  font-size: 26rpx;
 }
 
 .tabs, .rechargeGear{
   width: 92%;
-  margin: 10px auto;
+  margin: 20rpx auto;
 }
 
 .tabs-title{
   display: flex;
   justify-content: space-between;
   align-items: center;
-  height: 42px;
-  line-height: 42px;
+  height: 90rpx;
+  line-height: 90rpx;
   background-color: #fff;
-  border-top-left-radius: 10px;
-  border-top-right-radius: 10px;
+  border-top-left-radius: 10rpx;
+  border-top-right-radius: 10rpx;
 }
 
 .tabs-title-item{
@@ -50,9 +50,9 @@
 }
 
 .tabs-title-item__icon{
-  width: 20px;
-  height: 20px;
-  margin-right: 5px;
+  width: 40rpx;
+  height: 40rpx;
+  margin-right: 10rpx;
 }
 
 .tabs-title-item__text{}
@@ -68,57 +68,62 @@
   bottom: 0;
   left: 15%;
   right: 10%;
-  height: 2px;
+  height: 6rpx;
   background-color: #fe7124;
 }
 
 .tabs-content__tips{
   display: flex;
-  height: 40px;
+  height: 80rpx;
   align-items: center;
 }
 
 .tabs-content__tips-text{
-  font-size: 14px;  
+  font-size: 26rpx;  
 }
 
 .tabs-content__tips-add{
-  width: 20px;
-  height: 20px;
-  margin-left: 25px;
+  width: 40rpx;
+  height: 40rpx;
+  margin-left: 50rpx;
 }
 
 .tabs-content,.rechargeGear-footer{
-  padding: 15px 15px 25px 15px;
+  padding: 30rpx 30rpx 50rpx 30rpx;
   background-color: #fff;
-  border-bottom-left-radius: 10px;
-  border-bottom-right-radius: 10px;
+  border-bottom-left-radius: 10rpx;
+  border-bottom-right-radius: 10rpx;
 }
 
 .btn-rechargeNow{
   width: 85%;
-  padding: 13px;
-  margin: 0 auto 15px;
+  padding: 22rpx;
+  margin: 0 auto 30rpx;
   background-color: #fe7124;
   background: linear-gradient(to right, #ff7a21 0%,#feb25a 100%);
   text-align: center;
   color: #fff;
-  border-radius: 10px;
+  border-radius: 10rpx;
+}
+
+.btn-rechargeNow:active{
+  opacity: .8;
 }
 
 .rechargeNow-tips{
   text-align: center;
+  font-size: 26rpx;
 }
 
 /* 充值挡位 */
 .rechargeGear-title{
-  height: 42px;
-  line-height: 42px;
+  height: 84rpx;
+  line-height: 84rpx;
   background-color: #fff;
   color: #1e242e;
-  padding-left: 15px;
-  border-top-left-radius: 10px;
-  border-top-right-radius: 10px;
+  padding-left: 30rpx;
+  border-top-left-radius: 10rpx;
+  border-top-right-radius: 10rpx;
 }
 
 .rechargeGear-content{
@@ -127,7 +132,7 @@
   justify-content: space-between;
   background-color: #fff;
   box-sizing: border-box;
-  padding: 0 15px;
+  padding: 0 30rpx;
 }
 
 .rechargeGear-content__item{
@@ -136,12 +141,12 @@
   flex-direction: column;
   align-items: center;
   justify-content: center;
-  padding: 10px 0;
-  border: 1px solid #fe7124;
-  border-radius: 10px;
+  padding: 20rpx 0;
+  border: 1rpx solid #fe7124;
+  border-radius: 10rpx;
   color: #fe7124;
   background-color: #fff;
-  margin-bottom: 15px;
+  margin-bottom: 30rpx;
 }
 
 .rechargeGear-content__item.active{
@@ -150,9 +155,15 @@
 }
 
 .faceValue{
-  margin-bottom: 5px;
+  margin-bottom: 10rpx;
 }
 
 .price{
-  font-size: 12px;
+  font-size: 24rpx;
+}
+
+.card-no{
+  padding: 20rpx 0;
+  font-size: 40rpx;
+  color: #2b2b2b;
 }

+ 353 - 0
pages/postageDetail/postageDetail.js

@@ -0,0 +1,353 @@
+// pages/addAddress/addAddress.js
+const getReq = require('../../config.js').getReq
+import trees from '../../areas.js'
+let appInstance = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    checked: false,
+    areas: [],
+    tree: [],
+    value: [0, 0, 0],
+    oldval: [0, 0, 0],
+    citys: [],
+    districts: [],
+    animation_flag: false,
+    name: '',
+    mob_phone: '',
+    address: '',
+    area_info: '',
+    area_id: '',
+    isEdit: false,
+    address_id: '',
+    city_id: '',
+    bindName: '',
+    bindPhone: '',
+    bindAddress: '',
+    show: true
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    if (options.true_name) {
+      this.setData({
+        name: options.true_name,
+        bindName: options.true_name,
+        mob_phone: options.mob_phone,
+        bindPhone: options.mob_phone,
+        address: options.address,
+        bindAddress: options.address,
+        area_info: options.area_info,
+        area_id: options.area_id,
+        isEdit: true,
+        address_id: options.address_id,
+        city_id: options.city_id
+      })
+    }
+    this.setData({
+      show: false,
+      tree: trees,
+      citys: trees[0].children,
+      districts: trees[0].children[0].children
+    })
+    // this.getDatas()
+    
+  },
+  toggleChecked() {
+    this.setData({
+      checked: !this.data.checked
+    })
+  },
+  bindChange: function (e) {
+    const val = e.detail.value
+    if (this.data.value[0] != val[0]) {
+      val[1] = 0
+      val[2] = 0
+    } else {    //若省份column未做滑动,地级市做了滑动则定位区县第一位
+      if (this.data.value[1] != val[1]) {
+        val[2] = 0
+      }
+    }
+    this.setData({
+      value: val,
+      citys: this.data.tree[val[0]].children,
+      districts: this.data.tree[val[0]].children[val[1]].children
+    })
+  },
+  getDatas() {
+    var self = this
+    getReq({
+      act: 'app_update',
+      op: 'area',
+      curpage: 1
+    }, function (res) {
+      if (res.code == 200) {
+        self.setData({
+          show: false,
+        })
+      }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+      }
+    })
+  },
+  arrayToTree(array) {
+    let result = [], hash = {}, children = 'children'
+    array.forEach((item, index) => {
+      hash[item.aid] = item
+    })
+
+    array.forEach((item, index) => {
+      let pid = item.pid
+      if (pid == 0) {
+        result.push(item)
+      }
+      else {
+        let hashvp = hash[item.pid]
+        if (!hashvp[children]) {
+          hashvp[children] = []
+        }
+        hashvp[children].push(item)
+      }
+    })
+    return result
+  },
+  animation_flag(e) {
+    let flag = e.currentTarget.dataset.flag
+    let animation_flag = flag == 'true' ? true : false
+    let val = this.data.oldval
+
+    this.setData({
+      animation_flag,
+      value: val,
+      citys: this.data.tree[val[0]].children,
+      districts: this.data.tree[val[0]].children[val[1]].children
+    })
+  },
+  setAddress() {
+    let val = this.data.value
+    let province = this.data.tree[val[0]]
+    let city = province.children[val[1]]
+    let district = province.children[val[1]].children[val[2]]
+
+    let area_info = province.n + city.n + district.n
+    let area_id = district.aid
+    this.setData({
+      animation_flag: false,
+      oldval: val,
+      area_info,
+      area_id
+    })
+  },
+  commmitAddress() {
+    let self = this
+    let name = this.trim(this.data.name)
+    if (!name) {
+      wx.showToast({
+        icon: 'none',
+        title: "请填写您的收货人名称",
+        duration: 1500
+      })
+      return
+    }
+
+    let phone = this.trim(this.data.mob_phone)
+    if (!(/^1(3|4|5|7|8)\d{9}$/.test(phone))) {
+      wx.showToast({
+        icon: 'none',
+        title: "请填写您的手机号",
+        duration: 1500
+      })
+      return
+    }
+
+    let area_info = this.data.area_info
+    if (!area_info) {
+      wx.showToast({
+        icon: 'none',
+        title: "请选择您的收货地址",
+        duration: 1500
+      })
+      return
+    }
+
+    let address = this.trim(this.data.address)
+    if (!address) {
+      wx.showToast({
+        icon: 'none',
+        title: "请填写的您的详细收货地址",
+        duration: 1500
+      })
+      return
+    }
+
+    wx.showLoading({
+      title: '加载中',
+    })
+    if (this.data.isEdit) {
+      this.editAddress(name, this.data.address_id, this.data.city_id, this.data.area_id, this.data.area_info, address, phone)
+    }
+    else {
+      this.addArress(name, address, phone, area_info);
+    }
+  },
+  addArress(name, address, phone, area_info) {
+    let self = this;
+    getReq({
+      act: 'member_address',
+      op: 'address_add',
+      area_info,
+      true_name: name,
+      address,
+      mob_phone: phone,
+      area_id: this.data.area_id
+    }, function (res) {
+      wx.hideLoading()
+      if (res.code == 200) {
+        let address_id = res.datas.address_id
+        let {area_id, city_id} = self.data
+        self.setDefault(res, name, phone, area_info, address, address_id, area_id, city_id)
+      }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+      }
+    })
+  },
+
+  editAddress(true_name, address_id, city_id, area_id, area_info, address, mob_phone) {
+    let self = this;
+    let params = {
+      act: 'member_address',
+      op: 'address_edit',
+      true_name,
+      address_id,
+      city_id,
+      area_id,
+      area_info,
+      address,
+      mob_phone,
+    }
+    getReq(params, function (res) {
+      if (res.code == 200) {
+        self.setDefault(res, true_name, mob_phone, area_info, address, address_id, area_id, city_id)
+      }
+    });
+  },
+  setDefault(res, true_name, mob_phone, area_info, address, address_id, area_id, city_id) {
+    let self = this;
+    let is_default = self.data.checked ? 1 : 0
+    if (is_default) {
+      let area_info = self.data.area_info
+      appInstance.checkDefaultAddress({
+        true_name,
+        mob_phone,
+        area_info,
+        address,
+        address_id,
+        area_id,
+        city_id
+      })
+    }
+    let params = {
+      act: 'member_address',
+      op: 'set_default',
+      is_default,
+      address_id
+    }
+    getReq(params, function (response) {
+      wx.hideLoading()
+      if (response.code == 200) {
+        wx.navigateBack()
+      }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: response.message,
+          duration: 2000
+        })
+      }
+    })
+  },
+  trim(str) {
+    str = str.replace(/\s+/g, "")
+    return str
+  },
+  bindKeyInput(e) {
+    let valueType = e.currentTarget.dataset.value
+    let value = e.detail.value
+    switch (valueType) {
+      case 'name':
+        this.setData({
+          name: value
+        })
+        break;
+      case 'phone':
+        this.setData({
+          mob_phone: value
+        })
+        break;
+      case 'address':
+        this.setData({
+          address: value
+        })
+        break;
+      default:
+        break;
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  }
+})

+ 4 - 0
pages/postageDetail/postageDetail.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "添加油卡",
+  "navigationBarBackgroundColor": "#fe7124"
+}

+ 32 - 0
pages/postageDetail/postageDetail.wxml

@@ -0,0 +1,32 @@
+<view>
+    <view class="info_cell-wrap bacfff">
+      <view class="info_cell vux-1px-b">
+        <view class="info_cell_lable">手机号:</view>
+        <view class="info_cell_content">
+          <input class="postage_input" placeholder="请输入办卡时的手机号" maxlength="11" type="number" bindinput="bindKeyInput" data-value="phone" value="{{bindPhone}}"/> 
+        </view>
+      </view>
+    </view>
+
+    <view class="info_cell-wrap bacfff">
+      <view class="info_cell vux-1px-b">
+        <view class="info_cell_lable">卡号:</view>
+        <view class="info_cell_content">
+          <input class="postage_input" placeholder="请输入资产名称" bindinput="bindKeyInput" data-value="card_no" value="{{bindCardNo}}"/>
+        </view>
+      </view>
+    </view>
+
+    <view class="info_cell-wrap bacfff">
+      <view class="info_cell">
+        <view class="info_cell_lable">确认卡号:</view>
+        <view class="info_cell_content">
+          <input class="postage_input" placeholder="二次输入卡号" bindinput="bindKeyInput" data-value="confirm_ard_no" value="{{bindConfirmCardNo}}"/>
+        </view>
+      </view>
+    </view>
+
+    <view class="add_postage_btn" bindtap="commmitAddress">
+      确认
+    </view>
+</view>

+ 171 - 0
pages/postageDetail/postageDetail.wxss

@@ -0,0 +1,171 @@
+/* pages/addAddress/addAddress.wxss */
+@import "../address/address.wxss";
+@import "../components/template/loadAnimation/loadAnimation.wxss";
+.info_cell-wrap {
+  padding-left: 40rpx;
+}
+
+.info_cell {
+  display: -webkit-flex;
+  display: flex;
+  align-items: center;
+  line-height: 112rpx;
+  font-size: 28rpx;
+}
+
+.info_cell_lable {
+  width: 154rpx;
+}
+
+.info_cell_content {
+  -webkit-flex: 1;
+  flex: 1;
+}
+
+.checkbtn {
+  display: -webkit-flex;
+  display: flex;
+  align-items: center;
+  padding: 40rpx;
+  font-size: 24rpx;
+}
+
+.no_checked_icon {
+  width: 36rpx;
+  height: 36rpx;
+  border-radius: 50%;
+  border: 1rpx solid #666;
+}
+
+.check_icon-box {
+  display: -webkit-flex;
+  display: flex;
+  align-items: center;
+  width: 42rpx;
+  height: 42rpx;
+  margin-right: 4rpx;
+}
+
+.common_cell_arrow {
+  position: relative;
+}
+
+.common_cell_arrow::after {
+  content: " ";
+  display: inline-block;
+  height: 12rpx;
+  width: 12rpx;
+  border-width: 2rpx 2rpx 0 0;
+  border-color: #c8c8cd;
+  border-style: solid;
+  -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
+  transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
+  position: absolute;
+  top: 50%;
+  margin-top: -8rpx;
+  right: 40rpx;
+}
+.area_flex {
+  display: inline-block;
+  width: 33%;
+}
+
+
+
+.picker_mask { 
+  position: fixed;
+  left: 0;
+  top:0;
+  height: 100%;
+  width: 100%;
+  background-color: rgba(0, 0, 0, 0.6);
+  z-index: -1;
+  opacity: 0;
+}
+.picker_mask.show_popup {
+  z-index: 99;
+  opacity: 1;
+}
+
+.picker_container {
+  position: fixed;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  z-index: 100;
+   -webkit-transition: all 0.1s;
+  transition: all 0.1s;
+  -webkit-transform: translateY(110%);
+  transform: translateY(110%);
+}
+.show_animation {
+  -webkit-transform: translateY(0);
+  transform: translateY(0);
+}
+.picker_header {
+  display: -webkit-flex;  
+  display: flex;
+  justify-content: space-between;
+  padding: 0 30rpx;
+  line-height: 88rpx;
+  font-size: 32rpx;
+  color: #333;
+  background: #fbf9fe;
+}
+.picker_header .picker_cancel {
+  color: #828282;
+}
+
+
+
+
+.animation-element {
+  display: flex;
+  position: fixed;
+  width: 100%;
+  height: 470rpx;
+  bottom: 0;
+  background-color: rgba(255, 255, 255, 1);
+}
+
+.animation-button {
+  top:20rpx;
+  width: 290rpx;
+  height: 100rpx;  
+  align-items:center;
+}
+
+
+.left-bt{
+  left: 30rpx;
+}
+.right-bt {
+  right: 30rpx;
+}
+
+.line{
+  display: block;
+  position: fixed;
+  height: 1rpx;
+  width: 100%;
+  margin-top: 89rpx; 
+  background-color: #eeeeee;
+}
+.postage_input {
+  width: 440rpx;
+}
+
+.add_postage_btn{
+  width: 80%;
+  padding: 22rpx;
+  margin: 45rpx auto ;
+  background-color: #fe7124;
+  background: linear-gradient(to right, #ff7a21 0%,#feb25a 100%);
+  text-align: center;
+  color: #fff;
+  border-radius: 10rpx;
+}
+
+.add_postage_btn:active{
+  opacity: .8;
+}

+ 161 - 0
pages/postageManage/postageManage.js

@@ -0,0 +1,161 @@
+// pages/address/address.js
+const getReq = require('../../config.js').getReq
+let appInstance = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    address_list: [],
+    firstLoad: true,
+    fromPerson: false
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.getDatas()
+    let len = getCurrentPages().length
+    let prev = getCurrentPages()[len - 2] 
+    if(prev['route'].indexOf('/person/person') != -1) {
+      this.setData({
+        fromPerson: true
+      })
+    }
+  },
+  getDatas() {
+    wx.showLoading({
+      title: '加载中',
+    })
+    var self = this
+    getReq({
+      act: 'member_address',
+      op: 'address_list'
+    }, function (res) {
+      wx.hideLoading()
+      if (res.code == 200) {
+        let address_list = res.datas.address_list
+        if(!address_list.length) {
+          appInstance.clearAddress()
+        }
+        self.setData({
+          address_list,
+          firstLoad: false
+        })
+
+      }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+      }
+    })
+  },
+  check_address(e) {
+    if(this.data.fromPerson)return;
+    let dataset = e.currentTarget.dataset
+    let { address } = dataset
+    let true_name = dataset.truename
+    let mob_phone = dataset.mobphone
+    let area_info = dataset.areainfo
+    let address_id = dataset.addressid
+    let area_id = dataset.areaid
+    let city_id = dataset.cityid
+    
+    appInstance.checkDefaultAddress({
+      true_name,
+      mob_phone,
+      area_info,
+      address,
+      address_id,
+      area_id,
+      city_id
+    })
+    wx.navigateBack()
+
+  },
+  modify_address(e) {
+    let dataset = e.currentTarget.dataset
+    let { address } = dataset
+    let true_name = dataset.truename
+    let mob_phone = dataset.mobphone
+    let area_info = dataset.areainfo
+    let address_id = dataset.addressid
+    let area_id = dataset.areaid
+    let city_id = dataset.cityid
+ 
+    wx.navigateTo({
+      url: `/pages/postageDetail/postageDetail?true_name=${true_name}&mob_phone=${mob_phone}&area_info=${area_info}&address=${address}&area_id=${area_id}&address_id=${address_id}&city_id=${city_id}`
+    })
+  },
+  del_address(e) {
+    let self = this;
+    let address_id = e.currentTarget.dataset.addressid
+    wx.showModal({
+      content: "确认删除此收货地址",
+      confirmText: "确定",
+      cancelText: "取消",
+      success: function(res) {
+        if (res.confirm) {
+          getReq({
+            act: 'member_address',
+            op: 'address_del',
+            address_id
+          }, function (res) {
+            if (res.code == 200) {
+              self.getDatas()
+            }
+          })
+        } else if (res.cancel) {
+        }
+      }
+    })
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    if (!this.data.firstLoad) {
+      this.getDatas()
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  }
+})

+ 4 - 0
pages/postageManage/postageManage.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "油卡管理",
+  "navigationBarBackgroundColor": "#fe7124"
+}

+ 21 - 0
pages/postageManage/postageManage.wxml

@@ -0,0 +1,21 @@
+<!--pages/address/address.wxml-->
+<view class="address_container">
+  <view class="adress_wrap vux-1px-b" wx:for="{{address_list}}" wx:for-index="idx" wx:key="idx" bindlongpress="del_address" bindtap='check_address' data-truename="{{item.true_name}}" data-mobphone="{{item.mob_phone}}" data-areainfo="{{item.area_info}}" data-address="{{item.address}}" data-addressid="{{item.address_id}}" data-areaid="{{item.area_id}}" data-cityid="{{item.city_id}}">
+    
+    <view class="address_line">
+      <text>{{item.true_name}}</text>
+      <text class="ml8">{{item.mob_phone}}</text>
+    </view>
+    <view class="address_line mt8">
+      <text class="col333 mr16" wx:if="{{item.is_default == 1}}">[默认地址]</text>
+      <text>{{item.area_info}}</text>
+      <view style="word-wrap:break-word;max-width: 100%;">{{item.address}}</view>
+    </view>
+    <view class="modify_address_wrap" catchtap="modify_address" data-truename="{{item.true_name}}" data-mobphone="{{item.mob_phone}}" data-areainfo="{{item.area_info}}" data-address="{{item.address}}" data-areaid="{{item.area_id}}" data-addressid="{{item.address_id}}" data-cityid="{{item.city_id}}">
+      <image src="../../image/person/evaluated_icon.png" class="modify_address"></image>
+    </view>
+  </view>
+  <navigator url="/pages/postageDetail/postageDetail">
+    <view class="add_address_btn">添加卡号</view>
+  </navigator>
+</view>

+ 46 - 0
pages/postageManage/postageManage.wxss

@@ -0,0 +1,46 @@
+/* pages/address/address.wxss */
+.address_container {
+  padding-bottom: 130rpx;
+}
+.adress_wrap {
+  padding: 20rpx;
+  font-size: 24rpx;
+  background: #fff;
+}
+
+.address_line {
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  line-height: 38rpx;
+  padding-right: 50rpx;
+  box-sizing: border-box;
+}
+
+.add_address_btn {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  color: #fff;
+  background: #fe7124;
+  line-height: 92rpx;
+  text-align: center;
+  font-size: 30rpx;
+  z-index: 9;
+}
+.modify_address_wrap {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  position: absolute;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  z-index: 2;
+  width: 100rpx;
+}
+.modify_address {
+  width: 38rpx;
+  height: 44rpx;
+}

+ 63 - 1
utils/util.js

@@ -28,7 +28,69 @@ const getTypeSn = url => {
   return type_sn
 }
 
+function getUrlPrefixAndParams(url) {
+  // 用JS拿到URL,如果函数接收了URL,那就用函数的参数。如果没传参,就使用当前页面的URL
+
+  let params = url.split('?');
+  let prefix = params[0];
+  if(params.length < 2) {    
+    return [prefix, {}];
+  }
+  
+  var queryString = params[1];
+  // 用来存储我们所有的参数
+  var obj = {};
+  // 如果没有传参,返回一个空对象
+  if (!queryString) {
+      return obj;
+  }
+  // stuff after # is not part of query string, so get rid of it
+  queryString = queryString.split('#')[0];
+  // 将参数分成数组
+  var arr = queryString.split('&');
+  for (var i = 0; i < arr.length; i++) {
+      // 分离成key:value的形式
+      var a = arr[i].split('=');
+      // 将undefined标记为true
+      var paramName = a[0];
+      var paramValue = typeof (a[1]) === 'undefined' ? true : a[1];
+      // 如果调用对象时要求大小写区分,可删除这两行代码
+      paramName = paramName.toLowerCase();
+      if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase();
+      // 如果paramName以方括号结束, e.g. colors[] or colors[2]
+      if (paramName.match(/\[(\d+)?\]$/)) {
+          // 如果paramName不存在,则创建key
+          var key = paramName.replace(/\[(\d+)?\]/, '');
+          if (!obj[key]) obj[key] = [];
+          // 如果是索引数组 e.g. colors[2]
+          if (paramName.match(/\[\d+\]$/)) {
+              // 获取索引值并在对应的位置添加值
+              var index = /\[(\d+)\]/.exec(paramName)[1];
+              obj[key][index] = paramValue;
+          } else {
+              // 如果是其它的类型,也放到数组中
+              obj[key].push(paramValue);
+          }
+      } else {
+          // 处理字符串类型
+          if (!obj[paramName]) {
+              // 如果如果paramName不存在,则创建对象的属性
+              obj[paramName] = paramValue;
+          } else if (obj[paramName] && typeof obj[paramName] === 'string') {
+              // 如果属性存在,并且是个字符串,那么就转换为数组
+              obj[paramName] = [obj[paramName]];
+              obj[paramName].push(paramValue);
+          } else {
+              // 如果是其它的类型,还是往数组里丢
+              obj[paramName].push(paramValue);
+          }
+      }
+  }
+  return [prefix,obj];
+}
+
 module.exports = {
   getTypeSn: getTypeSn,
-  formatTime: formatTime
+  formatTime: formatTime,
+  parseAppjump: getUrlPrefixAndParams
 }