gcz há 2 anos atrás
pai
commit
1f7367c41a

+ 1 - 1
center/addrlist.vue

@@ -106,7 +106,7 @@
 					let nowPage = pages[ pages.length - 1];    //当前页页面实例
 					let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
 					prevPage.$vm.fromPage = 'addrlist';
-					prevPage.$vm.theAddr = item;         // 修改上一页data里面的content参数值
+					prevPage.$vm.receive.id = item.id;         // 修改上一页data里面的content参数值
 					uni.navigateBack()
 				}
 			}

+ 13 - 1
center/center.vue

@@ -17,7 +17,7 @@
 			<u-icon @click="$u.route('/center/memberinfo',{type:'redirectTo'})" name="setting-fill" color="#333333" size="38rpx"></u-icon>
 		</view>
 		<view class="property page-wrap u-flex u-row-between">
-			<view class="property-item">
+			<view class="property-item" @click="showPayCode = true">
 				<view class="up">
 					<u-icon :name="staticUrl+'/img/paycode.png'" color="#333333" size="42rpx"></u-icon>
 				</view>
@@ -62,6 +62,13 @@
 				</view>
 			</view>
 		</view>
+		<u-overlay :show="showPayCode" @click="showPayCode = false">
+			<view class="pay-code-warp u-flex u-row-center">
+				<view class="rect" @tap.stop>
+					<u--image :showLoading="true" :src="payCodeImg" width="180px" height="180px"></u--image>
+				</view>
+			</view>
+		</u-overlay>
 		<tabbar :tabbarIndexProps="Number(3)" />
 	</view>
 </template>
@@ -76,6 +83,8 @@
 			return {
 				staticUrl:this.$commonConfig.staticUrl,
 				avatar:this.$commonConfig.staticUrl+'/img/avatar.png',
+				showPayCode:false,
+				payCodeImg:'https://cdn.uviewui.com/uview/album/1.jpg',
 				memberInfo:{},
 				orderState:[
 					{name:'全部订单',status:'',ico:this.$commonConfig.staticUrl+'/img/orderstateico-all.png'},
@@ -230,4 +239,7 @@ page{
 		}
 	}
 }
+.pay-code-warp{
+	height: 100vh;
+}
 </style>

+ 16 - 2
components/cartfixed.vue

@@ -1,9 +1,10 @@
 <template>
 	<view class="">
-		<view class="cart u-flex u-row-center" @click="$u.route('/shopping/cart',{type:'redirectTo'})">
+		<view class="cart u-flex u-row-center" @click="$u.route('/shopping/cart',{type:'reLaunch'})">
 			<u-icon size="52rpx" class="icon" :name="staticUrl+'/img/cartico.png'"></u-icon>
 			<u-badge type="error" max="99" :value="cartTotal" :absolute="true" :offset="[0,5]"></u-badge>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -24,8 +25,21 @@
 			this.getCartList()
 		},
 		methods: {
-			getCartList(){
+			getCartList(isAdd){
 				this.$u.api.cartList().then(res=>{
+					if(isAdd){
+						if(res.data.total==this.cartTotal){
+							this.$refs.uToast.show({
+								type:"success",
+								message:'已在购物车'
+							});
+						}else{
+							this.$refs.uToast.show({
+								type:"success",
+								message:'加入成功'
+							});
+						}
+					}
 					this.cartTotal = res.data.total;
 					console.log('getCartList',res);
 					}).catch(err=>{

+ 6 - 3
components/tabbar.vue

@@ -92,6 +92,8 @@ export default {
 	watch:{
 		'tabbarIndexProps': {
 			handler(newVal, oldVal) {
+				// let pages = getCurrentPages();
+				// console.log('pages============',pages);
 				this.tabbarValue = newVal
 			},
 			immediate: true
@@ -112,7 +114,7 @@ export default {
 			1: {
 			  url: '/shopping/producTypetList',
 			  query: {
-				type: 'redirect'
+				type: 'reLaunch'
 			  }
 			},
 			2: '/xushuo/xushuo',
@@ -123,9 +125,10 @@ export default {
 		  const targetRoute = tabBarRoutes[name];
 		  
 		  if (typeof targetRoute === 'string') {
-			uni.$u.route(targetRoute,{type: 'redirect'});
+			uni.reLaunch({url: targetRoute});
 		  } else if (typeof targetRoute === 'object') {
-			uni.$u.route(targetRoute.url, targetRoute.query);
+			let queryParams = uni.$u.queryParams(targetRoute.query);
+			uni.reLaunch({url: targetRoute.url+queryParams});
 		  }
 			// this.tabbarValue = name
 		}

+ 15 - 0
pages.json

@@ -84,6 +84,7 @@
 					"path": "productdetails",
 					"style": {
 						"navigationBarTitleText": "产品详情",
+						"enableShareAppMessage": true, // 允许分享
 						"navigationStyle": "custom"
 					}
 				},
@@ -108,6 +109,13 @@
 						"navigationStyle": "custom"
 					}
 				},
+				{
+					"path": "pay",
+					"style": {
+						"navigationBarTitleText": "收银台",
+						"navigationStyle": "custom"
+					}
+				},
 				{
 					"path": "order",
 					"style": {
@@ -121,6 +129,13 @@
 						"navigationBarTitleText": "订单详情",
 						"navigationStyle": "custom"
 					}
+				},
+				{
+					"path": "distribution",
+					"style": {
+						"navigationBarTitleText": "物流详情",
+						"navigationStyle": "custom"
+					}
 				}
 			]
 		},

+ 9 - 8
pages/index/index.vue

@@ -38,15 +38,15 @@
 			</view>
 			
 			<view class="icon-nav u-flex u-row-around">
-				<view class="nav-item" @click="$u.route('/shopping/productList',{typeId:1,typeName:'特价专区',type:'redirectTo'})">
+				<view class="nav-item" @click="$u.route('/shopping/productList',{typeId:1,typeName:'特价专区',type:'reLaunch'})">
 					<u--image class="image" :src="staticUrl+'/img/index-nav-1.png'" width="101rpx" height="101rpx"></u--image>
 					特价专区
 				</view>
-				<view class="nav-item" @click="$u.route('/shopping/productList',{typeId:2,typeName:'爆款专区',type:'redirectTo'})">
+				<view class="nav-item" @click="$u.route('/shopping/productList',{typeId:2,typeName:'爆款专区',type:'reLaunch'})">
 					<u--image class="image" :src="staticUrl+'/img/index-nav-2.png'" width="101rpx" height="101rpx"></u--image>
 					爆款专区
 				</view>
-				<view class="nav-item" @click="$u.route('/credits/credits',{type:'redirectTo'})">
+				<view class="nav-item" @click="$u.route('/credits/credits',{type:'reLaunch'})">
 					<u--image class="image" :src="staticUrl+'/img/index-nav-3.png'" width="101rpx" height="101rpx"></u--image>
 					积分商城
 				</view>
@@ -179,11 +179,7 @@
 			addCart(id){
 				// console.log('addCart',id);
 				this.$u.api.addCart({goodsId:id}).then(res=>{
-					this.$refs.uToast.show({
-						type:"success",
-						message:res.msg
-					});
-					this.$refs.cartfixed.getCartList();
+					this.$refs.cartfixed.getCartList('isAdd');
 					console.log('res',res);
 					}).catch(err=>{
 					console.log('addCart',err.data);
@@ -204,6 +200,11 @@ page{
 }
 </style>
 <style lang="scss" scoped>
+.page-bg{
+	.img{
+		height: 100vh;
+	}
+}
 .search-out{
 	background-color: rgba(0,0,0,0.04);
 	border-radius: 100rpx;

+ 24 - 4
shopping/cart.vue

@@ -98,6 +98,8 @@
 		mixins: [MescrollMixin], // 使用mixin
         data() {
             return {
+				buyNowId:null,//立即购买id
+				buyNowName:'',//立即购买商品
 				staticUrl:this.$commonConfig.staticUrl,
 				allCheckbox:{name: '全选'},
 				options:[
@@ -154,6 +156,10 @@
 			  }, 0).toFixed(2);
 			}
         },
+		onLoad(page) {
+			this.buyNowId = page.buyNowId;
+			this.buyNowName = page.buyNowName;
+		},
         methods: {
 			/*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
 			downCallback(){
@@ -179,6 +185,10 @@
 					pageNum : page.num,
 					pageSize :  page.size,
 				}
+				//如果从立即购买中过来
+				if(this.buyNowName){
+					params.goodsName = this.buyNowName
+				}
 				// console.log('this.params',params);
 				this.$u.api.cartList(params).then(data => {
 					console.log('data',JSON.parse(JSON.stringify(data)));
@@ -279,10 +289,20 @@
 				})
 			},
 			submitorder(){
-				console.log('submitorder',this.selectGoods);
-				uni.$u.route('/shopping/submitorder', {
-					selectGoods: JSON.stringify(this.selectGoods),
-				});
+				// console.log('submitorder',this.selectGoods);
+				let param = {};
+				param.goodsList = this.selectGoods.map(item=>{
+					return {goodsId:item.goodsId,quantity:item.quantity}
+				})
+				// console.log('param',param);
+				this.$u.api.getSettlement(param).then(res=>{
+					uni.$u.route('/shopping/submitorder', {
+						selectGoods: JSON.stringify(res.data),
+					});
+					// console.log('submitorder',res.data);
+				}).catch(err=>{
+					console.log('getSettlement',err.data);
+				})
 			},
 			delSelect(){
 				let that = this;

+ 2 - 2
shopping/comment.vue

@@ -6,14 +6,14 @@
 			 :safeAreaInsetTop="true"
 		>
 		</u-navbar>
-		<view class="sort u-flex">
+		<!-- <view class="sort u-flex">
 			<view class="sort-item" 
 				:class="{active:index==activeIndex}" 
 				@click="sortClick(index)"
 				v-for="(item,index) in sortArr" :key="index">
 				{{item.name}}
 			</view>
-		</view>
+		</view> -->
 		<mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
 			<view class="page-wrap" >
 				<view class="comment" v-for="item in dataList" :key="item.id">

+ 101 - 0
shopping/distribution.vue

@@ -0,0 +1,101 @@
+<template>
+	<view class="">
+		<u-navbar
+			title="物流详情"
+			:autoBack="true"
+			 :safeAreaInsetTop="true"
+		>
+		</u-navbar>
+		<view class="map-wrap">
+			<map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers"></map>
+		</view>
+
+		<view class="base-info page-wrap">
+			<view class="company base-item u-flex">
+				<u--image :showLoading="false" :src="companylogo" width="60rpx" height="60rpx"></u--image>
+				<text>顺丰快递:34535664987</text>
+			</view>
+			<view class="orderNo base-item">订单号:6754364543553545</view>
+			<view class="addr base-item">收货地址:广东省广州市越秀区顶峰路334号腾讯大厦32楼3002号</view>
+		</view>
+		<view class="distribution page-wrap">
+			<u-steps current="0" activeColor="#00A447" dot direction="column">
+				<u-steps-item title="已下单" desc="10:30">
+				</u-steps-item>
+				<u-steps-item title="已出库" desc="10:35">
+				</u-steps-item>
+				<u-steps-item title="运输中" desc="11:40"></u-steps-item>
+			</u-steps>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default{
+		data(){
+			return {
+				staticUrl:this.$commonConfig.staticUrl,
+				latitude: 30.659462,
+				longitude: 104.065735,
+				covers: [], //存放标记点数组
+				companylogo:'',
+			}
+		},
+		onLoad(page) {
+			this.setCovers(this.latitude, this.longitude)
+		},
+		methods:{
+			//设置点位
+			setCovers(latitude, longitude) {
+				let location = {
+					id: 0,
+					latitude: Number(latitude),
+					longitude: Number(longitude),
+					width: uni.upx2px(50),
+					height: uni.upx2px(55),
+					iconPath:this.$commonConfig.staticUrl+ '/img/index-nav-2.png'
+					// iconPath: './../../static/location.png'
+				}
+				this.covers = [location]
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+.base-info{
+	background-color: #fff;
+	font-size: 32rpx;
+	font-weight: 400;
+	color: #333333;
+	line-height: 45rpx;
+	.base-item{
+		padding: 20rpx;
+		border-bottom: 0.5px solid #eee;
+	}
+	.company{
+		font-weight: 600;
+		color: #00A447;
+	}
+	.orderNo{
+		
+	}
+}
+.distribution{
+	/deep/.u-steps{
+		font-weight: 400;
+		.u-text__value{
+			font-size: 32rpx;
+			color: #999999;
+			line-height: 45rpx;
+		}
+		.u-text__value--main{
+			color: #00A447;
+		}
+		.u-text__value--tips{
+			font-size: 24rpx;
+			line-height: 33rpx;
+		}
+	}
+}
+</style>

+ 45 - 21
shopping/order.vue

@@ -3,6 +3,7 @@
 		<u-navbar
 			title="我的订单"
 			:autoBack="true"
+			 @leftClick="leftClick"
 			 :safeAreaInsetTop="true"
 		>
 		</u-navbar>
@@ -22,29 +23,31 @@
 						:class="item.class"
 						@click="goOrderDetails(item.id)" :key="item.id">
 						<view class="top u-flex u-row-between">
-							<text>订单号:887784332234423</text>
+							<text>订单号:{{item.orderNum||''}}</text>
 							<text class="status">{{item.status|filterOrderState}}</text>
 						</view>
-						<view class="center u-flex u-row-between">
-							<view class="left u-flex">
-								<u--image :showLoading="true" :src="item.mainImg" width="128rpx" height="128rpx"></u--image>
-								<view class="text">
-									<view class="name ellipsis-2">goodsName{{item.goodsName}}</view>
-									<view class="specification ellipsis-1">规格:{{item.specification}}</view>
+						<view class="center">
+							<view v-for="goods in item.detailList" class="goods u-flex u-row-between">
+								<view class="left u-flex">
+									<u--image :showLoading="true" :src="goods.mainImg" width="128rpx" height="128rpx"></u--image>
+									<view class="text">
+										<view class="name ellipsis-2">{{goods.goodsName}}</view>
+										<view class="specification ellipsis-1">规格:{{goods.specification}}</view>
+									</view>
+								</view>
+								<view class="right">
+									<u-icon name="arrow-right" color="#999" size="24"></u-icon>
+									<text class="price red">¥ <text class="price-num">{{goods.price}}</text></text>
 								</view>
-							</view>
-							<view class="right">
-								<u-icon name="arrow-right" color="#999" size="24"></u-icon>
-								<text class="price red">¥ <text class="price-num">{{item.price||'1600'}}</text></text>
 							</view>
 						</view>
 						<view class="bottom u-flex u-row-between">
-							<view class="left">更多</view>
+							<view class="left"></view>
 							<view class="right u-flex">
 								<view 
 									class="btn"
 									:class="btn.class"
-									@click.stop="clickEven(btn.fun)"
+									@click.stop="clickEven(btn.fun,item)"
 									v-for="(btn,index) in statusBtn[item.status]" :key="index">
 									{{btn.name}}
 								</view>
@@ -78,7 +81,7 @@
 				status:'',
 				dataList:[{status:0},{status:1},{status:2},{status:3},{status:4}],
 				statusBtn:{
-					0:[{name:'取消订单',fun:'cancel ',class:''},{name:'去支付',fun:'pay',class:'red'}],
+					0:[{name:'查看物流',fun:'logistics',class:''},{name:'取消订单',fun:'cancel ',class:''},{name:'去支付',fun:'pay',class:'red'}],
 					1:[{name:'申请退款',fun:'refund',class:'green'}],
 					2:[{name:'查看物流',fun:'logistics',class:''},{name:'确认收货',fun:'confirmReceipt',class:'green'}],
 					3:[{name:'查看物流',fun:'logistics',class:''},{name:'评价',fun:'evaluate',class:'green'}],
@@ -113,13 +116,17 @@
 			this.tabsCurrent = page.current || 0;
 		},
 		methods: {
+			leftClick(){
+				// uni.$u.route('/center/center', {
+				// 	type: 'reLaunch'
+				// });
+			},
 			/*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
 			downCallback(){
 				this.mescroll.resetUpScroll();
 			},
 			/*上拉加载的回调*/
 			upCallback(page) {
-				return
 				// 此处可以继续请求其他接口
 				// if(page.num == 1){
 				// 	// 请求其他接口...
@@ -173,7 +180,8 @@
 				this.mescroll.resetUpScroll();
 			},
 			tabsClick(item){
-				this.status = item.status;
+				// this.status = item.status;
+				this.tabsCurrent = item.index;
 				this.reloadList()
 				// console.log('item',item);
 			},
@@ -182,17 +190,27 @@
 					id: id
 				});
 			},
-			pay(){
-				console.log('pay');
+			pay(item){
+				console.log('pay',item);
 			},
-			clickEven(fun){
+			clickEven(fun,item){
 				// console.log('fun',fun);
 				let funObj = {
-				  'pay': this.pay
+				  pay: this.pay,
+				  logistics:this.logistics
 				};
 				if (fun in funObj) {
-				  funObj[fun]();
+				  funObj[fun](item);
 				}
+			},
+			pay(item){
+				console.log('pay',item);
+			},
+			logistics(item){
+				console.log('logistics',item);
+				uni.$u.route('/shopping/distribution', {
+					name: 'lisa'
+				});
 			}
 		}
 	}
@@ -234,6 +252,12 @@ page{
 		margin-bottom: 20rpx;
 		padding-bottom: 20rpx;
 		border-bottom: 0.5px solid #eee;
+		.goods{
+			padding: 20rpx 0;
+			&:not(:last-child){
+				border-bottom: 0.5px solid #eee;
+			}
+		}
 		.text{
 			margin-left: 20rpx;
 			.specification{

+ 81 - 33
shopping/orderdetails.vue

@@ -10,12 +10,12 @@
         <view class="addr page-wrap u-flex u-row-between">
         	<view class="left">
         		<view class="top">
-        			<text class="label" v-if="isDefaultAddr">默认</text>{{theAddr.address}}
+        			<text class="label" v-if="orderDetails.ifDefault">默认</text>{{orderDetails.address||''}}
         		</view>
-				<view class="center">{{theAddr.receiveAdress}}</view>
-				<view class="bottom">{{theAddr.receiveName}} {{theAddr.receivePhone}}</view>
+        		<view class="center">{{orderDetails.receiveAdress}}</view>
+        		<view class="bottom">{{orderDetails.receiveName}} {{orderDetails.receivePhone}}</view>
         	</view>
-			<!-- <u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon> -->
+        	<!-- <u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon> -->
         </view>
 		<!-- <view class="payway page-wrap u-flex u-row-between">
 			<view class="left">支付方式</view>
@@ -25,7 +25,7 @@
 			</view>
 		</view> -->
 		<view class="order-product page-wrap">
-			<view class="product u-flex" v-for="(item,index) in dataList" :key="item.id">
+			<view class="product u-flex" v-for="(item,index) in orderDetails.detailList" :key="item.id">
 				<u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
 				<view class="text">
 					<view class="up">
@@ -37,21 +37,14 @@
 					</view>
 					<view class="down u-flex u-row-between">
 						<view class="left">
-							<view class="" v-if="vuex_member_info.levelType>1">
-								<text class="price">¥ <text class="price-num">{{item.vipPrice}}</text></text>
-								<text class="vip-icon">VIP</text>
-								<text class="original-price gray line-through">¥ {{item.salePrice}}</text>
-							</view>
-							<view class="" v-else>
-								<text class="price">¥ <text class="price-num">{{item.salePrice}}</text></text>
-							</view>
+							<text class="price">¥ <text class="price-num">{{item.price}}</text></text>
 						</view>
-						<u-number-box v-model="item.quantity" @change="changeQuantity(index, $event)" integer></u-number-box>
+						<u-number-box v-model="item.quantity" :disabled="true" @change="changeQuantity(index, $event)" integer></u-number-box>
 					</view>
 				</view>
 			</view>
 		</view>
-		<view class="page-wrap order-reduced">
+<!-- 		<view class="page-wrap order-reduced">
 			<view class="reduced-item u-flex u-row-between u-border-bottom">
 				<view class="left">
 					<text>优惠券</text>
@@ -59,7 +52,7 @@
 				</view>
 				<view class="right u-flex">
 					<text class="price red">-¥ <text class="price-num">1000</text></text>
-					<!-- <u-icon name="arrow-right" color="#676767" size="20"></u-icon> -->
+					<u-icon name="arrow-right" color="#676767" size="20"></u-icon>
 				</view>
 			</view>
 			<view class="reduced-item integral u-flex u-row-between">
@@ -75,34 +68,44 @@
 					</u-checkbox-group>
 				</view>
 			</view>
-		</view>
+		</view> -->
 		<view class="page-wrap total">
 			<view class="total-item u-flex u-row-between u-border-bottom">
 				<view class="left">
 					商品金额
 				</view>
-				<view class="right">
-					¥2399.00
+				<view class="right red">
+					¥ {{orderDetails.originalOrderPrice}}
 				</view>
 			</view>
 			<view class="total-item u-flex u-row-between">
 				<view class="left">
 					运费
-					<text class="gray">总重:40kg</text>
+					<!-- <text class="gray">总重:{{totalWeight}}</text> -->
 				</view>
-				<view class="right">
-					+ ¥2399.00
+				<view class="right red">
+					<text v-if="orderDetails.originalFreightPrice">+ ¥ {{orderDetails.originalFreightPrice}}</text>
+					<text v-else>免运费</text>
 				</view>
 			</view>
 		</view>
 		<view class="cart-bottom">
 			<view class="inner u-flex u-row-between">
 				<view class="left u-flex">
-					<view class="total-price">
-						待支付:<text class="red">¥4322.00</text>
+					<view class="total-price" v-if="orderDetails.status==0">
+						待支付:<text class="red">¥ {{orderDetails.orderPrice}}</text>
+					</view>
+				</view>
+				<!-- <view class="btn" @click="submitOrder">去结算</view> -->
+				<view class="btn-wrap u-flex">
+					<view
+						class="btn"
+						:class="btn.class"
+						@click.stop="clickEven(btn.fun,orderDetails)"
+						v-for="(btn,index) in statusBtn[orderDetails.status]" :key="index">
+						{{btn.name}}
 					</view>
 				</view>
-				<view class="btn">去结算</view>
 			</view>
 		</view>
     </view>
@@ -113,22 +116,59 @@
             return {
 				id:'',
 				title:'订单详情',
+				orderDetails:{},
 				fromPage:'',
 				useIntegral:false,
 				dataList:[],
 				theAddr:{},
 				isDefaultAddr:false,
+				statusBtn:{
+					0:[{name:'取消订单',fun:'cancel ',class:'cancel'},{name:'去支付',fun:'pay',class:'red'}],
+					1:[{name:'申请退款',fun:'refund',class:'green'}],
+					2:[{name:'查看物流',fun:'logistics',class:''},{name:'确认收货',fun:'confirmReceipt',class:'green'}],
+					3:[{name:'查看物流',fun:'logistics',class:''},{name:'评价',fun:'evaluate',class:'green'}],
+					// 4:[{name:'查看物流',fun:'logistics',class:''},{name:'评价',fun:'evaluate',class:'green'}],
+					5:[{name:'查看退款',fun:'viewRefund',class:'green'}],
+					// 6:[{name:'查看退款',fun:'viewRefund',class:'green'}],
+					// 7:[{name:'查看退款',fun:'viewRefund',class:'green'}]
+				}
             }
         },
 		onLoad(page) {
-			// console.log('page',page);
+			console.log('page',page);
 			this.id = page.id;
+			this.getOrderDetails(this.id);
 		},
 		onShow() {
 		},
         methods: {
-			leftClick(e){
-				console.log('leftClick',e);
+			leftClick(){
+				console.log('orderdetails leftClick');
+			},
+			getOrderDetails(id){
+				this.$u.api.orderDetails({id:id}).then(res=>{
+					this.orderDetails = res.data
+					console.log('orderDetails',JSON.parse(JSON.stringify(res.data)));
+				}).catch(err=>{
+					console.log('getOrderDetails',err);
+				})
+			},
+			clickEven(fun,item){
+				// console.log('fun',fun);
+				let funObj = {
+				  'pay': this.pay
+				};
+				if (fun in funObj) {
+				  funObj[fun](item);
+				}
+			},
+			pay(item){
+				console.log('pay',item);
+				uni.$u.route('/shopping/pay', {
+					orderId: this.orderDetails.id,
+					// openid: that.vuex_wechatOpenid,
+					payAmount:this.orderDetails.orderPrice
+				});
 			},
         }
     }
@@ -234,13 +274,21 @@
 			margin-left: 30rpx;
 		}
 		.btn{
-			height: 80rpx;
-			line-height: 80rpx;
+			font-size: 26rpx;
+			height: 64rpx;
+			line-height: 64rpx;
 			border-radius: 50rpx;
-			padding: 0 50rpx;
-			background-color: #FF3C3F;
-			color: #fff;
+			padding: 0 40rpx;
+			border: 1px solid #333;
+			color: #333;
 			text-align: center;
+			background-color: transparent;
+			margin-left: 10rpx;
+			&.red{
+				border-color: #FF3C3F;
+				background-color: #FF3C3F;
+				color: #fff;
+			}
 		}
 	}
 }

+ 126 - 0
shopping/pay.vue

@@ -0,0 +1,126 @@
+<template>
+	<view class="">
+		<u-navbar
+			title="收银台"
+			@leftClick="leftClick"
+			:autoBack="true"
+			 :safeAreaInsetTop="true"
+		>
+		</u-navbar>
+		<view class="page-wrap">
+			<view class="pay-way page-wrap">
+				  <u-radio-group  v-model="params.paymentMode" placement="column" @change="groupChange">
+				    <view class="pay-way-item u-flex u-row-between">
+				    	<view class="left">微信支付</view>
+				    	<u-radio :name="1" activeColor="#00A447" size="36rpx"></u-radio>
+				    </view>
+					<view :class="{disabled:customBalance<params.payAmount}" class="pay-way-item u-flex u-row-between">
+						<view class="left">旭烁余额支付(¥ {{customBalance}})</view>
+						<u-radio :name="2" :disabled="customBalance<params.payAmount" activeColor="#00A447" size="36rpx"></u-radio>
+					</view>
+				  </u-radio-group>
+			</view>
+			<view class="full-btn" @click="gotoPay">去支付<text>¥ {{params.payAmount}}</text></view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				customBalance:'',
+				params:{
+					paymentMode:'',
+					orderId:'',
+					openid:'',
+					payAmount:'',
+				}
+				
+			}
+		},
+		onShow() {	
+			this.getMemberInfo();
+		},
+		onLoad(page) {
+			this.params.orderId = page.orderId;
+			this.params.openid = this.vuex_wechatOpenid;
+			this.params.payAmount = page.payAmount;
+			this.params.paymentMode = page.paymentMode || 1;
+		},
+		methods: {
+			leftClick(){
+				
+			},
+			getMemberInfo(){
+				this.$u.api.memberInfo({id:this.vuex_user_info.userid}).then(res=>{
+					this.customBalance= res.data.balance;
+				}).catch(err=>{
+					console.log('memberInfo',err.data);
+				})
+			},
+			gotoPay(){
+				console.log('gotoPay',this.params);
+				this.$u.api.gotoPay(this.params).then(res=>{
+					if(this.params.paymentMode==1){
+						this.wxPay()
+					}
+					console.log('res',res.data);
+				}).catch(err=>{
+					console.log('gotoPay',err);
+				})				
+			},
+			wxPay(){
+				uni.requestPayment({
+				    "provider": "wxpay", 
+				    "orderInfo": {
+				        "appid": "wx499********7c70e",  // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
+				        "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串
+				        "package": "Sign=WXPay",        // 固定值
+				        "partnerid": "148*****52",      // 微信支付商户号
+				        "prepayid": "wx202254********************fbe90000", // 统一下单订单号 
+				        "timestamp": 1597935292,        // 时间戳(单位:秒)
+				        "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名
+				    },
+				    success(res) {},
+				    fail(e) {}
+				})				
+			},
+			groupChange(e){
+				console.log('groupChange',e);
+			}
+			
+		}
+	}
+</script>
+<style>
+	page{
+		background-color: #F5F5F5;
+	}
+</style>
+<style lang="scss" scoped>
+.pay-way{
+	background-color: #fff;
+	border-radius: 8rpx;
+	.pay-way-item {
+		padding: 30rpx;
+		&:not(:last-child){
+			border-bottom: 0.5px solid #eee;
+		}
+		&.disabled{
+			.left{
+				color: #D8D8D8;
+			}
+		}
+	}
+	.left{
+		font-size: 30rpx;
+		font-weight: 500;
+		color: #333333;
+		line-height: 42rpx;
+	}
+}
+.full-btn{
+	margin-top: 100rpx;
+}
+</style>

+ 5 - 7
shopping/producTypetList.vue

@@ -90,6 +90,7 @@
 		</view>
 		<tabbar :tabbarIndexProps="Number(1)" />
 		<cartfixed ref="cartfixed" @getCartList="getCartList" />
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -141,6 +142,7 @@
 			typesIndex:{
 				handler(val){
 					console.log('typesIndex',val);
+					this.params.goodsName = '' ;
 					let data =  uni.$u.deepClone(this.goodsTypeTree[val]);
 					this.subTypeList = data.child.splice(0,3);
 					this.subTypeListMore= data.child;
@@ -257,14 +259,10 @@
 			addCart(id){
 				// console.log('addCart',id);
 				this.$u.api.addCart({goodsId:id}).then(res=>{
-					this.$refs.uToast.show({
-						type:"success",
-						message:res.msg
-					});
-					this.$refs.cartfixed.getCartList();
-					console.log('res',res);
+					this.$refs.cartfixed.getCartList('isAdd');
+					console.log('res',res.data);
 					}).catch(err=>{
-					console.log('addCart',err.data);
+					console.log('addCart',err);
 				})
 			}
 		}

+ 1 - 5
shopping/productList.vue

@@ -162,11 +162,7 @@
 			addCart(id){
 				// console.log('addCart',id);
 				this.$u.api.addCart({goodsId:id}).then(res=>{
-					this.$refs.uToast.show({
-						type:"success",
-						message:res.msg
-					});
-					this.$refs.cartfixed.getCartList();
+					this.$refs.cartfixed.getCartList('isAdd');
 					console.log('res',res);
 					}).catch(err=>{
 					console.log('addCart',err.data);

+ 111 - 14
shopping/productdetails.vue

@@ -7,10 +7,11 @@
 		>
 		</u-navbar>
 		 <u-swiper
-				:list="details.slideImgList"
-				@change="e => currentNum = e.current"
-				:autoplay="false"
-				indicatorStyle="right: 20px"
+			v-if="details.slideImgList.length>0"
+			:list="details.slideImgList"
+			@change="e => currentNum = e.current"
+			:autoplay="false"
+			indicatorStyle="right: 20px"
 		>
 			<view
 				slot="indicator"
@@ -42,7 +43,7 @@
 					包邮
 				</view>
 			</view>
-			<view class="addr-line u-flex">
+			<!-- <view class="addr-line u-flex">
 				<text class="addr-til">送至</text>
 				<view class="addr-con u-flex u-flex-1">
 					<view class="u-flex u-row-between u-flex-1">
@@ -50,7 +51,7 @@
 						<u-icon name="arrow-right" color="#676767" size="20"></u-icon>
 					</view>
 				</view>
-			</view>
+			</view> -->
 		</view>
 		<view class="comment view-wrap u-flex u-row-between">
 			<view class="left">
@@ -72,21 +73,24 @@
 			<view class="details-tool u-flex u-row-between">
 				<view class="left u-flex">
 					<view class="icon-wrap">
-						<u-icon name="share" color="#676767" size="30"></u-icon>
-						分享
+						<button class="share-btn" data-name="shareBtn" open-type="share">
+							<u-icon name="share" color="#676767" size="30"></u-icon>
+							分享
+						</button>
 					</view>
 					<view class="icon-wrap"  @click="$u.route('/shopping/cart')">
 						<u-icon name="shopping-cart" color="#676767" size="30"></u-icon>
 						购物车
-						<u-badge class="badge" numberType="overflow" type="error " max="99" value="9" :absolute="true" :offset="[0,0]"></u-badge>
+						<u-badge class="badge" numberType="overflow" type="error " max="99" :value="cartTotal" :absolute="true" :offset="[0,0]"></u-badge>
 					</view>
 				</view>
 				<view class="right u-flex">
-					<view class="btn add-btn">加入购物车</view>
-					<view class="btn buy-btn">立即购买</view>
+					<view class="btn add-btn" @click="addCart(details.id)">加入购物车</view>
+					<view class="btn buy-btn" @click="buyNow(details.id)">立即购买</view>
 				</view>
 			</view>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -95,6 +99,7 @@
 		data() {
 			return {
 				id:'',
+				cartTotal:0,
 				currentNum:0,
 				swiperList: [],
 				details:{
@@ -110,14 +115,93 @@
 			// console.log('this.id',this.id);
 			this.getDetails(this.id);
 		},
+		onShow(){
+			this.getCartList()
+		},
 		methods: {
+			getCartList(isAdd){
+				this.$u.api.cartList().then(res=>{
+					if(isAdd){
+						if(res.data.total==this.cartTotal){
+							this.$refs.uToast.show({
+								type:"success",
+								message:'已在购物车'
+							});
+						}						
+					}
+					this.cartTotal = res.data.total;
+					console.log('getCartList',res);
+					}).catch(err=>{
+					console.log('getCartList',err.data);
+				})
+			},
 			getDetails(id){
 				this.$u.api.memberGoodDetails({id:id}).then(res=>{
 					console.log('res',res.data);
-					this.details = res.data
-					}).catch(err=>{
+					this.details = res.data;
+					if(!res.data.slideImgList&&res.data.mainImg){
+						this.details.slideImgList = [];
+						this.details.slideImgList.push(res.data.mainImg)
+					}
+				}).catch(err=>{
 					console.log('getDetails',err.data);
 				})
+			},
+			addCart(id,buyNow){
+				this.$u.api.addCart({goodsId:id}).then(res=>{
+					this.$refs.uToast.show({
+						type:"success",
+						message:res.msg
+					});
+					if(buyNow){
+						uni.$u.route('/shopping/cart', {
+							buyNowId: id,
+							buyNowName:this.details.goodsName
+						});
+					}
+					this.getCartList('isAdd');
+					console.log('res',res.data);
+					}).catch(err=>{
+					console.log('addCart',err);
+				})
+			},
+			buyNow(id){
+				this.addCart(id,'buyNow')
+			},
+			onShareAppMessage: function( options ){
+			  var that = this;
+			  // 设置菜单中的转发按钮触发转发事件时的转发内容
+			  var shareObj = {
+			    title: this.details.goodsName,    // 默认是小程序的名称(可以写slogan等)
+			    path: '/shopping/productdetails',    // 默认是当前页面,必须是以‘/'开头的完整路径
+			    imageUrl: '',   //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
+			    success: function(res){
+			      // 转发成功之后的回调
+			      if(res.errMsg == 'shareAppMessage:ok'){
+			      }
+			    },
+			    fail: function(){
+			      // 转发失败之后的回调
+			      if(res.errMsg == 'shareAppMessage:fail cancel'){
+			        // 用户取消转发
+			      }else if(res.errMsg == 'shareAppMessage:fail'){
+			        // 转发失败,其中 detail message 为详细失败信息
+			      }
+			    },
+				complete:function(){
+					 // 转发结束之后的回调(转发成不成功都会执行)
+				}
+			  };
+			  // 来自页面内的按钮的转发
+			  if( options.from == 'button' ){
+			    var eData = options.target.dataset;
+				console.log('options.target.dataset',options.target.dataset);
+			    console.log('id' ,this.details.id);   // shareBtn
+			    // 此处可以修改 shareObj 中的内容
+			    shareObj.path = '/shopping/productdetails?id='+this.details.id;
+			  }
+			  // 返回shareObj
+			  return shareObj;
 			}
 		}
 	}
@@ -150,7 +234,7 @@
 }
 .addr{
 	font-size: 30rpx;
-	.addr-line{
+	.addr-line:not(:last-child){
 		margin-bottom: 20rpx;
 	}
 	.addr-til{
@@ -214,5 +298,18 @@
 			background-color: #FF3C3F;
 		}
 	}
+	.share-btn{
+		padding: 0;
+		margin: 0;
+		border: 0;
+		font-size: 24rpx;
+		color: #666;
+		line-height: 1;
+		background-color: transparent;
+		outline: none;
+		&::after{
+		  border: none;
+		}
+	}
 }
 </style>

+ 1 - 5
shopping/productsearch.vue

@@ -188,11 +188,7 @@
 			addCart(id){
 				// console.log('addCart',id);
 				this.$u.api.addCart({goodsId:id}).then(res=>{
-					this.$refs.uToast.show({
-						type:"success",
-						message:res.msg
-					});
-					this.$refs.cartfixed.getCartList();
+					this.$refs.cartfixed.getCartList('isAdd');
 					console.log('res',res);
 					}).catch(err=>{
 					console.log('addCart',err.data);

+ 126 - 44
shopping/submitorder.vue

@@ -10,10 +10,10 @@
         <view class="addr page-wrap u-flex u-row-between">
         	<view class="left">
         		<view class="top">
-        			<text class="label" v-if="isDefaultAddr">默认</text>{{theAddr.address}}
+        			<text class="label" v-if="orderInfo.receive.ifDefault">默认</text>{{receive.address}}
         		</view>
-				<view class="center">{{theAddr.receiveAdress}}</view>
-				<view class="bottom">{{theAddr.receiveName}} {{theAddr.receivePhone}}</view>
+				<view class="center">{{receive.receiveAdress}}</view>
+				<view class="bottom">{{receive.receiveName}} {{receive.receivePhone}}</view>
         	</view>
 			<u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon>
         </view>
@@ -25,7 +25,7 @@
 			</view>
 		</view> -->
 		<view class="order-product page-wrap">
-			<view class="product u-flex" v-for="(item,index) in dataList" :key="item.id">
+			<view class="product u-flex" v-for="(item,index) in orderInfo.goodsList" :key="item.id">
 				<u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
 				<view class="text">
 					<view class="up">
@@ -51,7 +51,7 @@
 				</view>
 			</view>
 		</view>
-		<view class="page-wrap order-reduced">
+<!-- 		<view class="page-wrap order-reduced">
 			<view class="reduced-item u-flex u-row-between u-border-bottom">
 				<view class="left">
 					<text>优惠券</text>
@@ -75,23 +75,23 @@
 					</u-checkbox-group>
 				</view>
 			</view>
-		</view>
+		</view> -->
 		<view class="page-wrap total">
 			<view class="total-item u-flex u-row-between u-border-bottom">
 				<view class="left">
 					商品金额
 				</view>
-				<view class="right">
-					¥2399.00
+				<view class="right red">
+					¥ {{totalAmount}}
 				</view>
 			</view>
 			<view class="total-item u-flex u-row-between">
 				<view class="left">
 					运费
-					<text class="gray">总重:40kg</text>
+					<text class="gray">总重:{{totalWeight}}</text>
 				</view>
-				<view class="right">
-					+ ¥2399.00
+				<view class="right red">
+					<text>+ ¥ {{distribution.distributionPrice}}</text>
 				</view>
 			</view>
 		</view>
@@ -99,10 +99,10 @@
 			<view class="inner u-flex u-row-between">
 				<view class="left u-flex">
 					<view class="total-price">
-						待支付:<text class="red">¥4322.00</text>
+						待支付:<text class="red">¥ {{payAmount + distribution.distributionPrice}}</text>
 					</view>
 				</view>
-				<view class="btn">去结算</view>
+				<view class="btn" @click="submitOrder">去结算</view>
 			</view>
 		</view>
     </view>
@@ -114,18 +114,36 @@
 				fromPage:'',
 				useIntegral:false,
 				dataList:[],
-				theAddr:{},
+				receiveId:'',
+				receive:{},
 				isDefaultAddr:false,
+				orderInfo:{goodsList:[]},
+				distribution:{},//物流信息
+				totalAmount:null,//订单总金额
+				payAmount:null,//订单支付金额
+				userTotalBalance:null,//用户总余额
+				userTotalCredit:null,//用户总积分
+				orderTotalCredit:null,//订单需要的总积分
             }
         },
 		onLoad(page) {
 			// console.log('page',page);
-			// console.log('selectGoods',JSON.parse(page.selectGoods));
-			this.dataList = JSON.parse(page.selectGoods);
+			this.setData(page.selectGoods,true)
 		},
 		onShow() {
-			if(this.fromPage!='addrlist'){
-				this.getAddrList()
+			if(this.fromPage=='addrlist'){
+				this.settlement()
+			}
+		},
+		computed: {
+			totalWeight() {
+			  let that = this;
+			  return this.orderInfo.goodsList.reduce((total, item) => {
+					let weight = null;
+					weight = item.weight
+				  total += weight * item.quantity;
+				return total;
+			  }, 0);
 			}
 		},
         methods: {
@@ -137,42 +155,106 @@
 			},
 			selectAddr(){
 				uni.$u.route('/center/addrlist', {
-					from: 'submitorder'
+					from: 'settlement'
 				});
 			},
-			getAddrList(){
-				this.$u.api.addrList().then(res=>{
-					this.theAddr = res.data.rows;
-					let defaultAddress;
-					let firstAddress = res.data.rows[0];
-					 res.data.rows.forEach(address => {
-					  if (address.ifDefault) { // 如果有默认地址标识
-						defaultAddress = address;
-						this.isDefaultAddr = true;
-					  }
-					});
+			// getAddrList(){
+			// 	this.$u.api.addrList().then(res=>{
+			// 		this.theAddr = res.data.rows;
+			// 		let defaultAddress;
+			// 		let firstAddress = res.data.rows[0];
+			// 		 res.data.rows.forEach(address => {
+			// 		  if (address.ifDefault) { // 如果有默认地址标识
+			// 			defaultAddress = address;
+			// 			this.isDefaultAddr = true;
+			// 		  }
+			// 		});
 				
-					if (!defaultAddress) { // 如果没有默认地址标识
-					  defaultAddress = firstAddress;
-					}
-					this.theAddr = defaultAddress;
-				}).catch(err=>{
-					console.log('getAddrList',err.data);
-				})
-			},
+			// 		if (!defaultAddress) { // 如果没有默认地址标识
+			// 		  defaultAddress = firstAddress;
+			// 		}
+			// 		this.theAddr = defaultAddress;
+			// 	}).catch(err=>{
+			// 		console.log('getAddrList',err.data);
+			// 	})
+			// },
 			// 改变商品数量
 			changeQuantity(index, value) {
+				console.log('goodsList',this.orderInfo.goodsList);
+				this.$nextTick(()=>{
+					this.settlement();
+				})
 				
-				this.changeQuantityApi(this.dataList[index].id,value.value)
 			},
-			changeQuantityApi(id,num){
-				this.$u.api.updateQuantity({id:id,quantity:num}).then(res=>{
-					// this.dataList[index].quantity = num
+			settlement(){
+				// console.log('settlement',this.selectGoods);
+				let param = {
+					receiveId:this.receive.id
+				};
+				param.goodsList = this.orderInfo.goodsList.map(item=>{
+					return {goodsId:item.id,quantity:item.quantity}
+				});
+				console.log('param',param);
+				this.$u.api.getSettlement(param).then(res=>{
 					console.log('res',res.data);
-					}).catch(err=>{
-					console.log('changeQuantityApi',err.data);
+					this.setData(res.data,false)
+					
+				}).catch(err=>{
+					console.log('getSettlement',err);
 				})
 			},
+			setData(originData,isString){
+				let jsonData;
+				if(isString){
+					jsonData = JSON.parse(originData);
+				}else{
+					jsonData = originData
+				}
+				let {
+					receive, 
+					distribution, 
+					totalAmount, 
+					payAmount, 
+					userTotalBalance, 
+					userTotalCredit, 
+					orderTotalCredit } = jsonData || {};
+				this.orderInfo = jsonData;
+				this.receive = receive;
+				this.distribution = distribution;//物流信息
+				this.totalAmount = totalAmount;//订单总金额
+				this.payAmount = payAmount;//	订单支付金额
+				this.userTotalBalance = userTotalBalance;//	用户总余额
+				this.userTotalCredit = userTotalCredit;//	用户总积分
+				this.orderTotalCredit = orderTotalCredit;//订单需要的总积分
+			},
+			submitOrder(){
+				let that = this;
+				let param = {
+					receiveId:this.receive.id,
+					distribution:this.distribution,
+				};
+				param.goodsList = this.orderInfo.goodsList.map(item=>{
+					return {goodsId:item.id,quantity:item.quantity}
+				})
+				//获取经纬度
+				uni.getLocation({
+					type: 'gcj02',
+					success: (res) => {
+						param.latitude = res.latitude;
+						param.longitude = res.longitude;
+						that.$u.api.submitOrder(param).then(res=>{
+							console.log('res',res.data);
+							uni.$u.route('/shopping/pay', {
+								orderId: res.data.orderId,
+								// openid: that.vuex_wechatOpenid,
+								payAmount:res.data.payAmount
+							});
+						}).catch(err=>{
+							console.log('submitOrder',err);
+						})
+					},
+				});
+			}
         }
     }
 </script>

+ 0 - 1
uni.scss

@@ -298,6 +298,5 @@ page{
 	right: 0;
 	.img{
 		width: 100%;
-		height: 100vh;
 	}
 }