洪海涛 8 سال پیش
والد
کامیت
9617e15e92
4فایلهای تغییر یافته به همراه170 افزوده شده و 106 حذف شده
  1. 74 65
      www/vue/src/components/order.vue
  2. 83 18
      www/vue/src/components/pay.vue
  3. 13 20
      www/vue/src/components/placeOrder.vue
  4. 0 3
      www/vue/src/components/recharge.vue

+ 74 - 65
www/vue/src/components/order.vue

@@ -1,20 +1,20 @@
 <template>
 	<div>
-
-		<scroller >
+		
+		<scroller>
 			<div style="padding: 15px;">
 				<button-tab>
 					<button-tab-item selected @on-item-click="consoleIndex(1)">预约中</button-tab-item>
-					<button-tab-item :selected="isComplete" @on-item-click="consoleIndex(3)" >已完成</button-tab-item>
-					<button-tab-item  @on-item-click="consoleIndex(2)">已取消</button-tab-item>
+					<button-tab-item :selected="isComplete" @on-item-click="consoleIndex(3)">已完成</button-tab-item>
+					<button-tab-item @on-item-click="consoleIndex(2)">已取消</button-tab-item>
 				</button-tab>
 			</div>
 			<div style="padding-bottom: 16%;">
 				<div class="order-block" v-for="order in orderList">
 					<div class="row_first order-line">
-						<span >订单时间</span>
-						<span >{{order.booking_time_str}}</span>
-						<span >{{order.status_str}}</span>
+						<span>订单时间</span>
+						<span>{{order.booking_time_str}}</span>
+						<span>{{order.status_str}}</span>
 					</div>
 					<div class="row_second order-left-img" @click="checkOrderDetail(order.id,isShow)">
 						<div>
@@ -34,9 +34,10 @@
 					<div class="order-three" v-if="order.status == 0">
 						<span></span>
 						<span @click="del(order.id)">取消订单</span>
-						<span>立即支付</span>
+						<span @click="newPay(order)">立即支付</span>
 					</div>
-					<div class="order-three order-three-else" v-else-if="order.status == 1 || order.status == 2 || order.status == 3 || order.status == 4 || order.status == 5">
+					<div class="order-three order-three-else"
+					     v-else-if="order.status == 1 || order.status == 2 || order.status == 3 || order.status == 4 || order.status == 5">
 						<span></span>
 						<span @click="completeOrder(false,order.id)">确认完成</span>
 					</div>
@@ -47,19 +48,19 @@
 				</div>
 			</div>
 		</scroller>
-
+		
 		<div v-transfer-dom>
 			<x-dialog v-model="showScrollBox" class="dialog-demo">
 				<span class="dialog-title">确认服务已完成?</span>
 				<span @click="completeOrder(true)" class="vux-confirm">确认</span>
 				<span @click="showScrollBox=false" class="vux-close">取消</span>
-
+			
 			</x-dialog>
 		</div>
 		<div v-transfer-dom>
 			<x-dialog v-model="showScrollBox1" class="dialog-demo">
 				<span class="dialog-title">取消订单成功</span>
-				<span  class="vux-confirm" @click="flush()">完成</span>
+				<span class="vux-confirm" @click="flush()">完成</span>
 			</x-dialog>
 		</div>
 		<navigation></navigation>
@@ -68,7 +69,7 @@
 </template>
 
 <script>
-  import { ButtonTab, ButtonTabItem, Divider, XDialog, TransferDomDirective as TransferDom } from 'vux'
+  import {ButtonTab, ButtonTabItem, Divider, XDialog, TransferDomDirective as TransferDom} from 'vux'
   import axios from 'axios'
   import qs from 'qs'
   import config from '../config/config'
@@ -93,7 +94,6 @@
     methods: {
       consoleIndex (index) {
         this.isShow = index
-        console.log('click demo01', index)
         let orderList = {user_id: config.userId, type: index, page: 1}
         orderList = qs.stringify(orderList)
         axios.post('o2o/order/list', orderList).then(res => {
@@ -130,6 +130,9 @@
             this.showScrollBox1 = true
           }
         })
+      },
+      newPay (order) {
+        this.$router.push({path: '/pay', query: {orderInfo: order}})
       }
     },
     data () {
@@ -146,34 +149,35 @@
 </script>
 <style lang="less" scoped>
 	.order-block {
-		border-top:1px solid silver;
-		border-bottom:1px solid silver;
+		border-top: 1px solid silver;
+		border-bottom: 1px solid silver;
 		margin-top: 15px;
 	}
+	
 	.row_first {
-
+		
 		font-size: .5rem;
 		display: flex;
-
-
-		span{
-
+		
+		span {
+			
 			display: block;
 			float: left;
 			padding: 20px 0;
 			margin-left: 20px;
-			&:nth-child(1){
-				width:20%;
+			&:nth-child(1) {
+				width: 20%;
 				padding-left: 5px;
 				text-align: left;
 			}
-			&:nth-child(3){
+			&:nth-child(3) {
 				width: 20%;
 				text-align: right;
 				padding-right: 10px;
 			}
 		}
 	}
+	
 	.row_second {
 		font-size: .5rem;
 		text-align: left;
@@ -188,99 +192,104 @@
 				margin-left: 10px;
 			}
 		}
-
+		
 	}
+	
 	.order-line-button-top {
-		border-top:1px #dfdfdf solid;
+		border-top: 1px #dfdfdf solid;
 		width: 90%;
 		margin-left: 5%;
 	}
+	
 	.order-three {
 		font-size: .5rem;
 		display: flex;
-
-		span{
-
+		
+		span {
+			
 			display: block;
 			float: right;
 			padding: 3px 0;
 			margin-left: 20px;
 			margin-bottom: 10px;
 			margin-top: 10px;
-			&:nth-child(1){
-				width:60%;
+			&:nth-child(1) {
+				width: 60%;
 			}
-			&:nth-child(2){
-				width:20%;
+			&:nth-child(2) {
+				width: 20%;
 				padding: 2px;
-				border:1px #D3D3D3 solid;
-				color:#D3D3D3;
+				border: 1px #D3D3D3 solid;
+				color: #D3D3D3;
 				text-align: center;
 			}
-			&:nth-child(3){
+			&:nth-child(3) {
 				width: 20%;
 				text-align: center;
-				border:1px #E16E00 solid;
-				color:#E16E00;
+				border: 1px #E16E00 solid;
+				color: #E16E00;
 				margin-right: 8px;
 				padding: 2px 2px 2px 2px;
 			}
 		}
 	}
+	
 	.order-three-else {
-		span{
-
+		span {
+			
 			display: block;
 			float: right;
 			padding: 3px 0;
 			margin-left: 20px;
 			margin-bottom: 10px;
-
-			&:nth-child(1){
-				width:80%;
+			
+			&:nth-child(1) {
+				width: 80%;
 			}
-
-			&:nth-child(2){
+			
+			&:nth-child(2) {
 				width: 20%;
 				text-align: right;
-				color:#E16E00;
-				border:1px #E16E00 solid;
+				color: #E16E00;
+				border: 1px #E16E00 solid;
 				margin-right: 8px;
 				padding: 2px 5px 2px 2px;
 			}
 		}
 	}
+	
 	.order-three-else-color {
-		span{
-
+		span {
+			
 			display: block;
 			float: right;
 			padding: 3px 0;
 			margin-left: 20px;
 			margin-bottom: 10px;
-
-			&:nth-child(1){
-				width:80%;
+			
+			&:nth-child(1) {
+				width: 80%;
 			}
-
-			&:nth-child(2){
+			
+			&:nth-child(2) {
 				width: 20%;
 				text-align: right;
-				color:#e3ddc4;
-				border:1px #8F7625 solid;
+				color: #e3ddc4;
+				border: 1px #8F7625 solid;
 				background-color: #8F7625;
 				margin-right: 8px;
 				padding: 2px 5px 2px 2px;
 			}
 		}
 	}
-
+	
 	.order-line {
 		background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90%' height='1'><rect fill='#c8c7cc' x='0' y='0' width='90%' height='0.5'/></svg>");
 		background-repeat: no-repeat;
 		background-position: 20px 50px;
 		border-bottom: 0;
 	}
+	
 	.order-left-img {
 		width: 90%;
 		/*height: 100px;*/
@@ -289,16 +298,16 @@
 		background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMjAxNy4zLjXW1e4OAAAA7klEQVRYhc2XwQ3CMAxFXxADsAmHegA2gRHKJDACbMIAyYFNukG5VKhCCkmKXeNboqj/yU6/nTCOI56xcVX/B4CtxkdCCMQYewARuZbOz8seNO5ASqkHLtPyCRxEZKgBsCjBHnjEGHc1h1UyMJXgBhxn29lMmGRARE7AfbZVlQnVEiyBUL8DrRAmPtACYWZEtRCmTpiDSCm9IcytuASh5gOlyPnEagAZiLN7N3QvwSoZyIl3XTeYA3wTB+PfsCRuClDbnk0AWmYDdYAWcXWAVnFVgCXiagDTSN4srgbwEdXioDsV+z1Mfgn3bugO8AJZSqO192KiLQAAAABJRU5ErkJggg==') no-repeat 100% 5%;
 		background-size: .8rem;
 	}
-
+	
 	.dialog-demo {
 		font-size: .5rem;
 		.vux-confirm {
 			background-color: #2c7cf6;
 			display: inline-block;
 			color: white;
-			border:1px solid;
-			padding: 10px 0 ;
-			margin: 10px 0 ;
+			border: 1px solid;
+			padding: 10px 0;
+			margin: 10px 0;
 			border-radius: 5px;
 			width: 40%;
 		}
@@ -306,13 +315,13 @@
 			background-color: #f7f7f7;
 			display: inline-block;
 			color: #939393;
-			border:1px solid #c9c9c9;
-			padding: 10px 0 ;
-			margin: 10px 0 ;
+			border: 1px solid #c9c9c9;
+			padding: 10px 0;
+			margin: 10px 0;
 			border-radius: 5px;
 			width: 40%;
 		}
-		.weui-dialog{
+		.weui-dialog {
 			border-radius: 8px;
 			padding-bottom: 8px;
 		}

+ 83 - 18
www/vue/src/components/pay.vue

@@ -1,17 +1,20 @@
 <template>
 	<div class="brand">
-		<h2>收银台</h2>
-		<group>
-			<div class="order-info">订单类型:<span>{{orderType}}</span></div>
-			<div class="order-info">微信支付:<span>{{payType}}</span></div>
-		</group>
-		<group>
-			<div class="pay-type">支付方式</div>
-		</group>
-		<group>
-			<a href="javascript:void(0)" class="pay-option checked" data-value="wx_pub"> <i class="icon-weixin"></i> 微信支付 </a>
-		</group>
-		<div class="btn" @click="btnPay">确认支付</div>
+		<scroller>
+			<h2>收银台</h2>
+			<group>
+				<div class="order-info">订单类型:<span>{{orderType}}</span></div>
+				<div class="order-info">微信支付:<span>{{orderPayValue}}</span></div>
+			</group>
+			<group>
+				<div class="pay-type">支付方式</div>
+			</group>
+			<group>
+				<a href="javascript:void(0)" class="pay-option checked" data-value="wx_pub"> <i class="icon-weixin"></i>
+					微信支付 </a>
+			</group>
+			<div class="btn" @click="btnPay">确认支付</div>
+		</scroller>
 	</div>
 </template>
 
@@ -24,8 +27,10 @@
   export default {
     data () {
       return {
-        orderType: '',
-        payType: ''
+        orderType: '', // 订单类型
+        orderCoupon: '', // 代金券支付
+        orderBalance: '', // 余额支付
+        orderPayValue: '' // 微信支付
       }
     },
     components: {
@@ -33,10 +38,34 @@
       Group
     },
     created () {
-      console.log(this.$route.query.payRecharge !== {})
-      if (this.$route.query.payRecharge !== {}) {
+      if (this.$route.query.payRecharge !== undefined) {
+        // 订单类型
         this.orderType = this.$route.query.payRecharge.products
-        this.payType = this.$route.query.payRecharge.final_price
+        // 微信支付
+        this.orderPayValue = this.$route.query.payRecharge.final_price
+      } else if (this.$route.query.orderInfo !== undefined) {
+        // 订单类型 orderType
+        this.orderType = this.$route.query.orderInfo.products_str
+        // 代金券支付 orderCoupon
+        this.orderCoupon = this.$route.query.orderInfo.final_price
+        // 余额支付 orderBalance
+        this.orderBalance = this.$route.query.orderInfo.final_price
+        // 微信支付 orderPayValue
+        this.orderPayValue = this.$route.query.orderInfo.final_price
+        console.log(this.$route.query.orderInfo)
+        if (this.$route.query.orderInfo.coupons && this.$route.query.orderInfo.coupons.length) {
+          for (let i in this.$route.query.orderInfo.coupons) {
+            this.orderCoupon += parseInt(this.$route.query.orderInfo.coupons[i].coupon.value)
+          }
+        }
+        if (this.$route.query.orderInfo.pay_price && this.$route.query.orderInfo.pay_price !== 0) {
+          this.orderBalance = this.$route.query.orderInfo.final_price - this.$route.query.orderInfo.pay_price
+        }
+        if (this.$route.query.orderInfo.pay_price && this.$route.query.orderInfo.pay_price !== 0) {
+          this.orderPayValue = this.$route.query.orderInfo.pay_price
+        } else {
+          this.orderPayValue = this.$route.query.orderInfo.final_price
+        }
       }
     },
     methods: {
@@ -48,7 +77,17 @@
             pay_channel: 'wx_pub'
           }
           axios.post('o2o/recharge/payRecharge', qs.stringify(payRecharge)).then(res => {
-            console.log(res.data.data.credential.wx_pub)
+            this.pay(res.data, payRecharge.order_id)
+          })
+        } else if (config.orderInfo.length !== 0) {
+          axios.post('o2o/order/pay', qs.stringify(config.orderInfo)).then(res => {
+            this.pay(res.data)
+          })
+        }
+      },
+      pay (res, orderId, charge) {
+        let orderInfo = {}
+        console.log(orderId)
 //            window.location.href = 'http://common.yiguanjia.me/webapp/o2o/module/pay/index.html?appId=' +
 //              option.appId + '&nonceStr=' + option.nonceStr +
 //              '&package=' + prepay + '&signType=' +
@@ -57,7 +96,33 @@
 //              option.paySign + '&amount=' + wxPay.amount +
 //              '&created=' + wxPay.created + '&body=' +
 //              wxPay.body + '&bookingTime=' + bookingTime
+        if (res.success) {
+          let orderList = {user_id: config.userId, type: 1}
+          axios.post('o2o/order/list', qs.stringify(orderList)).then(res => {
+            for (let i in res.data.data) {
+              if (orderId === res.data.data[i].id) {
+                orderInfo = res.data.data[i]
+              }
+            }
           })
+          console.log(orderInfo)
+//          var orderInfo = user.getOrderInfo(orderID);
+//          var params = {
+//            orderInfo: orderInfo,
+//            charge: res.data
+//          }
+          // 调用native中pay方法,传值orderInfo,charge并做回调,返回充值结果
+//          native.pay(params, function (resA) {
+//            if (resA.success) {
+//              $doc.trigger('spa:navigate', {
+//                hash: 'paySuccess'
+//              });
+//            } else {
+//              $doc.trigger('spa:openpanel', ['simpleAlert', {
+//                message: resA.message
+//              }]);
+//            }
+//          });
         }
       }
     }

+ 13 - 20
www/vue/src/components/placeOrder.vue

@@ -66,7 +66,9 @@
   import selectTime from '../config/selectTime'
   import {Group, DatetimeRange, TransferDom, Datetime, XNumber, Cell, CellBox, XTextarea, Alert} from 'vux'
   import {mapState, mapActions} from 'vuex'
-  import api from '../config/api'
+  import axios from 'axios'
+  import qs from 'qs'
+  //    import api from '../config/api'
   export default {
     name: 'placeOrder',
     data () {
@@ -113,7 +115,6 @@
       if (config.orderInfo.coupons) {
         this.couponName = config.orderInfo.coupons.coupon.name
         this.couponValue = parseInt(config.orderInfo.coupons.coupon.value)
-        console.log(this.orderPrice)
       }
       if (config.station === '') {
         config.station = '57db39709f5160bb048b456a'
@@ -131,7 +132,6 @@
         this.addressContent = config.addressContent
       }
       config.order.extra = JSON.stringify(config.productInfo.extra[0])
-      console.log(config.order.extra)
     },
     computed: {
       ...mapState({
@@ -145,15 +145,12 @@
         this.orderPrice = config.orderPrice = payCharge(parseInt(config.productInfo.extra[val].price), config.xNumberValue, this.couponValue)
       },
       'couponValue' (val, oldVal) {
-        console.log('val' + val)
-        console.log('val' + oldVal)
       }
     },
     methods: {
       // 监听时间插件值得变化
       clearConfig () {
         this.$router.push({path: '/addressList'})
-//        console.log(config)
       },
       ...mapActions([
         'PAYCHANGE'
@@ -181,7 +178,6 @@
         config.order.time = val
       },
       btnOrder: function () {
-        console.log(config.order.extra)
         // 判断服务是否选择
         if (localStorage.getItem('extra') === null && config.productInfo.extra.length !== 0) {
 //          config.order.extra = ''
@@ -189,8 +185,6 @@
           this.alertContent = '你还没有选择服务类型'
           this.showAlert = true
         }
-        // 判断时间
-        // 判断地址
         config.order.userId = config.userId
         config.order.memo = this.remarks
         config.order.id = config.productInfo.id
@@ -198,10 +192,8 @@
           product_id: config.productInfo.id, // 产品ID
           count: this.xNumberValue // 产品数量
         })
-        console.log(this.$store.state.user.userInfo.balance)
 
         // 获得余额支付的金额
-        console.log(config.xNumberValue)
         // 判断用户余额大于等于订单金额,满足条件走余额支付
         if (this.$store.state.user.userInfo.balance >= this.orderPrice) {
           config.order.balance = this.orderPrice
@@ -213,7 +205,6 @@
         }
         let productParamJson = [{'product_id': config.productInfo.id, 'count': config.xNumberValue}]
         productParamJson = JSON.stringify(productParamJson)
-        console.log(config.order)
         config.order.extra = '[' + config.order.extra + ']'
         let tmp = {
           balance: config.order.balance,
@@ -231,9 +222,16 @@
           tech_id: '',
           user_id: config.userId
         }
-        config.orderInfo = tmp
-        console.log(config.orderInfo)
-        api.addOrder()
+//        config.orderInfo = tmp
+        axios.post('o2o/order/add', qs.stringify(tmp)).then(res => {
+          if (res.data.success) {
+//            config.orderInfo = res.data.data
+            this.$router.push({path: '/pay', query: {orderInfo: res.data.data}})
+          }
+//          console.log(res.data)
+        })
+//        this.$router.push({path: '/pay'})
+//        api.addOrder()
       },
       btnAction: function (index, event) {
         this.xNumberValue = config.xNumberValue = 0
@@ -242,7 +240,6 @@
         config.orderInfo.coupons = []
         this.couponName = '暂无优惠券'
         this.couponValue = 0
-        console.log(config.order.extra)
         this.isActive = index
         config.isActive = index
       }
@@ -251,10 +248,6 @@
   function payCharge (price, count, couponValue) {
     let p = ''
     p = price * count - couponValue
-    console.log(price)
-    console.log(count)
-    console.log(couponValue)
-    console.log(p)
     return p
   }
 </script>

+ 0 - 3
www/vue/src/components/recharge.vue

@@ -127,7 +127,6 @@
         let payRecharge = {}
         axios.post('o2o/recharge/addRechargeorder', qs.stringify(addRechargeOrder)).then(res => {
           if (res.data.success) {
-            console.log(res.data.data.price)
             let payValue = ''
             if (this.otherAmount === '' && this.isShow !== 4) {
               payValue = this.rechargeItem.denomination
@@ -143,8 +142,6 @@
             this.$router.push({path: '/pay', query: {payRecharge: payRecharge}})
           }
         })
-        // axios     1.创建充值卡订单  user_id: user.id,        value:inputVal,
-        // 第二步
       },
       show (e) {
         if (this.index !== e) {