lhl 2 лет назад
Родитель
Сommit
da5e18bcfc
6 измененных файлов с 794 добавлено и 4 удалено
  1. 9 0
      api/user.js
  2. 18 0
      pages.json
  3. 4 4
      pages/home/user.vue
  4. 130 0
      pages/public/artDetail.vue
  5. 164 0
      pages/public/artList.vue
  6. 469 0
      pages/user/admin/orderAdmin.vue

+ 9 - 0
api/user.js

@@ -132,4 +132,13 @@ export function getUserList(data) {
 		method: 'get',
 		data
 	})
+}
+
+//配送员订单
+export function GetAdminOrderList(data) {
+	return request({
+		url: '/api/admin/order/list',
+		method: 'get',
+		data
+	});
 }

+ 18 - 0
pages.json

@@ -352,6 +352,12 @@
 					"style": {
 						"navigationBarTitleText": "用户管理"
 					}
+				},
+				{
+					"path": "admin/orderAdmin",
+					"style": {
+						"navigationBarTitleText": "配送订单"
+					}
 				}
 			]
 		}, {
@@ -486,6 +492,18 @@
 					"style": {
 						"navigationBarTitleText": "隐私协议"
 					}
+				},
+				{
+					"path": "artList",
+					"style": {
+						"navigationBarTitleText": "新闻资讯"
+					}
+				},
+				{
+					"path": "artDetail",
+					"style": {
+						"navigationBarTitleText": ""
+					}
 				}
 			]
 		}

+ 4 - 4
pages/home/user.vue

@@ -34,13 +34,13 @@
 				<view class="item-box">
 					<view class="box-title flex">
 						<view class="title"><text>配送员订单</text></view>
-						<view class="link flex" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover">
+						<view class="link flex" @click="navTo('/pages/user/admin/orderAdmin?state=0')" hover-class="common-hover">
 							<text class="margin-r-10">全部</text>
 							<image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
 						</view>
 					</view>
 					<view class="order-section">
-						<view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"
+						<view class="order-item" @click="navTo('/pages/user/admin/orderAdmin?state=0')" hover-class="common-hover"
 							:hover-stay-time="50">
 							<view class=" icon position-relative">
 								<image class="icon-img" src="../../static/icon/userorder1.png" mode="aspectFit">
@@ -51,7 +51,7 @@
 							</view>
 							<text>待付款</text>
 						</view>
-						<view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover"
+						<view class="order-item" @click="navTo('/pages/user/admin/orderAdmin?state=1')" hover-class="common-hover"
 							:hover-stay-time="50">
 							<view class="icon position-relative">
 								<image class="icon-img" src="../../static/icon/userorder2.png" mode="aspectFit">
@@ -62,7 +62,7 @@
 							</view>
 							<text>待核销</text>
 						</view>
-						<view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover"
+						<view class="order-item" @click="navTo('/pages/user/admin/orderAdmin?state=2')" hover-class="common-hover"
 							:hover-stay-time="50">
 							<view class=" icon position-relative">
 								<image class="icon-img" src="../../static/icon/userorder3.png" mode="aspectFit">

+ 130 - 0
pages/public/artDetail.vue

@@ -0,0 +1,130 @@
+<template>
+	<view class="center">
+		<view class="title clamp">{{ item.title }}</view>
+		<view class="time">{{ item.add_time }}</view>
+		<view class="main" v-for="(ls, index) in item.content" :key="index">
+			<view v-if="ls.type == 'rich-text'" v-html="ls.value" class="main"></view>
+			<video v-if="ls.type == 'video' && ls.value" :src="ls.value" style="width:100%;height: 300px" frameborder="0"></video>
+		</view>
+	</view>
+</template>
+
+<script>
+import { details } from '@/api/user.js';
+export default {
+	data() {
+		return {
+			id: '',
+			item: ''
+		};
+	},
+	onLoad(option) {
+		this.id = option.id;
+		this.loadData();
+	},
+	onShareAppMessage(options) {
+		// 设置菜单中的转发按钮触发转发事件时的转发内容
+		let pages = getCurrentPages(); //获取加载的页面
+		let currentPage = pages[pages.length - 1]; //获取当前页面的对象
+		let url = currentPage.route; //当前页面url
+		let item = currentPage.options; //如果要获取url中所带的参数可以查看options
+		let shareObj = {
+			title: '水箱计算', // 默认是小程序的名称(可以写slogan等)
+			path: url + '?id=' + item.id, // 默认是当前页面,必须是以‘/’开头的完整路径
+			imageUrl: '',
+			success: function(res) {
+				// 转发成功之后的回调
+				if (res.errMsg == 'shareAppMessage:ok') {}
+			},
+			fail: function() {
+				// 转发失败之后的回调
+				if (res.errMsg == 'shareAppMessage:fail cancel') {
+					// 用户取消转发
+				} else if (res.errMsg == 'shareAppMessage:fail') {
+					// 转发失败,其中 detail message 为详细失败信息
+				}
+			}
+		};
+		return shareObj;
+	},
+	methods: {
+		loadData() {
+			details({}, this.id).then(({ data }) => {
+				console.log(data);
+				data.content = data.content.replace(/<img/g, '<img class="rich-img"').replace(/<p>\s*<img/g, '<p class="pHeight"><img').replace(/<div/g, '<div style="max-width: 50% !important;"');
+				data.content = this.getVideo(data.content);
+				this.item = data;
+			});
+		},
+		// 富文本视频解析
+		getVideo(data) {
+			let videoList = [];
+			let videoReg = /<video.*?(?:>|\/>)/gi; //匹配到字符串中的 video 标签
+			let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; //匹配到字符串中的 video 标签 的路径
+			let arr = data.match(videoReg) || []; // arr 为包含所有video标签的数组
+			let articleList = data.split('</video>'); // 把字符串  从视频标签分成数组
+			arr.forEach((item, index) => {
+				var src = item.match(srcReg);
+				videoList.push(src[1]); //所要显示的字符串中 所有的video 标签 的路径
+			});
+			let needArticleList = [];
+			articleList.forEach((item, index) => {
+				if (item != '' && item != undefined) {
+					//  常见的标签渲染
+					needArticleList.push({
+						type: 'rich-text',
+						value: item + '</video>'
+					});
+				}
+				let articleListLength = articleList.length; // 插入到原有video 标签位置
+				if (index < articleListLength && videoList[index] != undefined) {
+					needArticleList.push({
+						type: 'video',
+						value: videoList[index]
+					});
+				}
+			});
+			return needArticleList;
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+	page {
+		background-color: #fff;
+		min-height: 100%;
+		height: auto;
+	}
+.center {
+	min-height: 100%;
+	height: auto;
+	background: #ffffff;
+	padding: 30rpx 24rpx 0;
+}
+.title {
+	font-size: 32rpx;
+	font-family: PingFang SC;
+	font-weight: bold;
+	color: #333333;
+}
+.time {
+	font-size: 24rpx;
+	font-family: PingFangSC;
+	font-weight: 500;
+	color: #999999;
+	margin-top: 40rpx;
+}
+.main {
+	margin-top: 60rpx;
+}
+/deep/ .main {
+	.rich-img {
+		width: 100% !important;
+		height: auto;
+	}
+	* {
+		max-width: 100% !important;
+	}
+}
+</style>

+ 164 - 0
pages/public/artList.vue

@@ -0,0 +1,164 @@
+<template>
+	<view class="content">
+		<view class="main">
+			<view v-for="(item, index) in list">
+				<view class="first" v-if="index == 0" @click="navToList(item.id)">
+					<view class="title">{{item.title}}</view>
+					<view class="image"><image :src="item.image_input[0]" mode=""></image></view>
+					<view class="time">{{item.add_time}}</view>
+				</view>
+				<view class="item flex" @click="navToList(item.id)" v-else>
+					<view class="item-left"><image :src="item.image_input[0]" mode=""></image></view>
+					<view class="item-right">
+						<view class="item-font clamp">{{item.title}}</view>
+						<view class="item-time">{{item.add_time}}</view>
+					</view>
+				</view>
+			</view>
+		</view>
+		<uni-load-more :status="loadingType"></uni-load-more>
+	</view>
+</template>
+
+<script>
+import { article } from '@/api/user.js';
+export default {
+	data() {
+		return {
+			list: [],
+			page: 1.,
+			limit: 10,
+			loadingType: 'more'
+		};
+	},
+	onLoad() {
+		this.loadData();
+	},
+	onShareAppMessage(options) {
+		// 设置菜单中的转发按钮触发转发事件时的转发内容
+		let pages = getCurrentPages(); //获取加载的页面
+		let currentPage = pages[pages.length - 1]; //获取当前页面的对象
+		let url = currentPage.route; //当前页面url
+		let item = currentPage.options; //如果要获取url中所带的参数可以查看options
+		let shareObj = {
+			title: '水箱计算', // 默认是小程序的名称(可以写slogan等)
+			path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
+			imageUrl: '',
+			success: function(res) {
+				// 转发成功之后的回调
+				if (res.errMsg == 'shareAppMessage:ok') {}
+			},
+			fail: function() {
+				// 转发失败之后的回调
+				if (res.errMsg == 'shareAppMessage:fail cancel') {
+					// 用户取消转发
+				} else if (res.errMsg == 'shareAppMessage:fail') {
+					// 转发失败,其中 detail message 为详细失败信息
+				}
+			}
+		};
+		return shareObj;
+	},
+	methods: {
+		// 载入数据
+		async loadData() {
+			let obj = this;
+			if(obj.loadingType == 'noMore' || obj.loadingType == 'loading' ) {
+				return
+			}
+			obj.loadingType = 'loading'
+			article({page:obj.page,limit:obj.limit},1).then(({data}) =>{
+				obj.list = obj.list.concat(data)
+				obj.page++
+				if(data.length == obj.limit) {
+					obj.loadingType = 'more'
+				}else {
+					obj.loadingType = 'noMore'
+				}
+			})
+		},
+		navToList(id) {
+			uni.navigateTo({
+				url: '/pages/index/artDetail?id=' + id
+			});
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+page,
+.content {
+	height: auto;
+	min-height: 100%;
+	background: #f5f5f5;
+}
+.main {
+	// margin-top: 20rpx;
+	background: #ffffff;
+	.first {
+		padding: 50rpx 0 18rpx;
+		margin: 0 22rpx;
+		border-bottom: 1px solid #e0e0e0;
+		.title {
+			font-size: 32rpx;
+			font-family: PingFang SC;
+			font-weight: bold;
+			color: #333333;
+		}
+		.image {
+			width: 710rpx;
+			height: 400rpx;
+			background: #eee;
+			margin-top: 20rpx;
+			image {
+				width: 100%;
+				height: 100%;
+			}
+		}
+		.time {
+			margin-top: 20rpx;
+			font-size: 26rpx;
+			font-family: PingFang SC;
+			font-weight: 500;
+			color: #666666;
+		}
+	}
+	.item {
+		padding: 26rpx 0 18rpx;
+		margin: 0 22rpx;
+		justify-content: flex-start;
+		align-items: flex-start;
+		border-bottom: 1px solid #e0e0e0;
+		.item-left {
+			width: 224rpx;
+			height: 160rpx;
+			image {
+				width: 100%;
+				height: 100%;
+			}
+		}
+		.item-right {
+			width: 458rpx;
+			height: 160rpx;
+			margin-left: 24rpx;
+			padding: 18rpx 0;
+			display: flex;
+			flex-direction: column;
+			justify-content: space-between;
+			.item-font {
+				font-size: 32rpx;
+				font-family: PingFang SC;
+				font-weight: bold;
+				color: #333333;
+			}
+			.item-time {
+				font-size: 28rpx;
+				font-family: PingFang SC;
+				font-weight: 500;
+				color: #666666;
+			}
+		}
+	}
+}
+</style>

+ 469 - 0
pages/user/admin/orderAdmin.vue

@@ -0,0 +1,469 @@
+<template>
+	<view class="content">
+		<view class="navbar">
+			<view v-for="(item, index) in navList" :key="index" class="nav-item"
+				:class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
+		</view>
+
+		<swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
+			<swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
+				<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
+					<!-- 空白页 -->
+					<empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
+
+					<!-- 订单列表 -->
+					<view @click="goToOrderDetail(item)" v-for="(item, index) in tabItem.orderList" :key="index"
+						class="order-item">
+						<view class="i-top b-b">
+							<text class="time">订单编号:{{ item.order_id }}</text>
+							<text class="state" :style="{ color: item.stateTipColor }">{{ item.status_name }}</text>
+							<!-- <text v-if="item.status === 4" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text> -->
+						</view>
+
+						<scroll-view v-if="item._info.length > 0" class="goods-box" scroll-x>
+							<view v-for="(goodsItem, goodsIndex) in item._info" :key="goodsIndex" class="goods-item">
+								<image class="goods-img" :src="goodsItem.cart_info.productInfo.image" mode="aspectFill">
+								</image>
+								<view class="good-name clamp">
+									{{goodsItem.cart_info.productInfo.suk}}*{{goodsItem.cart_info.cart_num}}
+								</view>
+							</view>
+						</scroll-view>
+						<view class="info-info">
+							<view class="js">
+								共{{item._info.length}}件
+							</view>
+							<view class="hj">
+								合计:¥{{item.pay_price}}
+							</view>
+						</view>
+						<!-- 客户信息 -->
+						<view class="kh-info">
+							<view class="">
+								客户信息:<text>李丹丹 13757625302</text>
+							</view>
+							<view class="">
+								配送地址:<text>浙江省台州市东海大道100号402室</text>
+							</view>
+						</view>
+						<!-- 底部操作栏 -->
+						<view class="btm-btn-wrap flex">
+							<view class="btm-left">
+								下单时间:{{item.add_time.split(' ')[0].replace(/-/g,'/')}}
+							</view>
+							<view class="btm-right flex">
+								<view class="btm-btn">
+									联系客户
+								</view>
+								<view class="btm-btn ksps">
+									开始配送
+								</view>
+							</view>
+						</view>
+					</view>
+
+					<uni-load-more :status="tabItem.loadingType"></uni-load-more>
+				</scroll-view>
+			</swiper-item>
+		</swiper>
+	</view>
+</template>
+
+<script>
+	import {
+		orderList,
+		orderCancel,
+		orderDel,
+		orderTake
+	} from '@/api/order.js';
+	import {
+		GetAdminOrderList
+	} from '@/api/user.js'
+	export default {
+		data() {
+			return {
+				tabCurrentIndex: 0,
+				navList: [{
+						state: 0,
+						text: '待付款',
+						loadingType: 'more',
+						orderList: [],
+						page: 1, //当前页数
+						limit: 10 //每次信息条数
+					},
+					{
+						state: 1,
+						text: '待发货',
+						loadingType: 'more',
+						orderList: [],
+						page: 1, //当前页数
+						limit: 10 //每次信息条数
+					},
+					{
+						state: 2,
+						text: '待收货',
+						loadingType: 'more',
+						orderList: [],
+						page: 1, //当前页数
+						limit: 10 //每次信息条数
+					},
+					{
+						state: 3,
+						text: '待评价',
+						loadingType: 'more',
+						orderList: [],
+						page: 1, //当前页数
+						limit: 10 //每次信息条数
+					},
+					{
+						state: 4,
+						text: '已完成',
+						loadingType: 'more',
+						orderList: [],
+						page: 1, //当前页数
+						limit: 10 //每次信息条数
+					}
+				]
+			};
+		},
+
+		onLoad(options) {
+			/**
+			 * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
+			 * 替换onLoad下代码即可
+			 */
+			this.tabCurrentIndex = +options.state;
+			// #ifndef MP
+			this.loadData();
+			// #endif
+			// #ifdef MP
+			if (options.state == 0) {
+				this.loadData();
+			}
+			// #endif
+		},
+		// #ifdef APP-PLUS || H5
+		onBackPress(e) {
+			uni.switchTab({
+				url: '/pages/home/user',
+			});
+			return true;
+		},
+		// #endif
+		methods: {
+			toCall(phone) {
+				uni.makePhoneCall({
+					phoneNumber:phone
+				})
+			},
+			// 转换金额为数字
+			moneyNum(value) {
+				return +value;
+			},
+			//跳转到订单详情
+			goToOrderDetail(e) {
+				uni.navigateTo({
+					url: '/pages/order/orderDetail?id=' + e.order_id
+				});
+			},
+			//获取订单列表
+			loadData(source) {
+				//这里是将订单挂载到tab列表下
+				let index = this.tabCurrentIndex;
+				let navItem = this.navList[index];
+				let state = navItem.state;
+				if (source === 'tabChange' && navItem.loaded === true) {
+					//tab切换只有第一次需要加载数据
+					return;
+				}
+				if (navItem.loadingType === 'loading') {
+					//防止重复加载
+					return;
+				}
+				if (navItem.loadingType === 'noMore') {
+					//防止重复加载
+					return;
+				}
+				// 修改当前对象状态为加载中
+				navItem.loadingType = 'loading';
+
+				GetAdminOrderList({
+						status: state,
+						page: navItem.page,
+						limit: navItem.limit,
+						shopping_type: 1 //1-送货,2自提
+					})
+					.then(({
+						data
+					}) => {
+						let arr = data.map(e => {
+							let b = this.orderStateExp(e.status);
+							e.stateTip = b.stateTip;
+							e.stateTipColor = b.stateTipColor;
+							return e;
+						});
+						navItem.orderList = navItem.orderList.concat(arr);
+						// console.log(navItem.orderList);
+						navItem.page++;
+						if (navItem.limit == data.length) {
+							//判断是否还有数据, 有改为 more, 没有改为noMore
+							navItem.loadingType = 'more';
+							return;
+						} else {
+							//判断是否还有数据, 有改为 more, 没有改为noMore
+							navItem.loadingType = 'noMore';
+						}
+						uni.hideLoading();
+						this.$set(navItem, 'loaded', true);
+					})
+					.catch(e => {
+						console.log(e);
+					});
+			},
+			//swiper 切换
+			changeTab(e) {
+				this.tabCurrentIndex = e.target.current;
+				this.loadData('tabChange');
+			},
+			//顶部tab点击
+			tabClick(index) {
+				this.tabCurrentIndex = index;
+			},
+			//订单状态文字和颜色
+			orderStateExp(state) {
+				let stateTip = '',
+					stateTipColor = '#fa436a';
+				switch (+state) {
+					case 0:
+						stateTip = '待付款';
+						break;
+					case 1:
+						stateTip = '待发货';
+						break;
+					case 2:
+						stateTip = '待收货';
+						break;
+					case 3:
+						stateTip = '待评价';
+						break;
+					case 4:
+						stateTip = '已完成';
+						stateTipColor = '#5dbc7c';
+						break;
+					case 9:
+						stateTip = '订单已关闭';
+						stateTipColor = '#909399';
+						break;
+
+						//更多自定义
+				}
+				return {
+					stateTip,
+					stateTipColor
+				};
+			}
+		}
+	};
+</script>
+
+<style lang="scss">
+	page,
+	.content {
+		background: $page-color-base;
+		height: 100%;
+	}
+
+	.swiper-box {
+		height: calc(100% - 40px);
+	}
+
+	.list-scroll-content {
+		height: 100%;
+	}
+
+	.navbar {
+		display: flex;
+		height: 40px;
+		padding: 0 5px;
+		background: #fff;
+		box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
+		position: relative;
+		z-index: 10;
+
+		.nav-item {
+			flex: 1;
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			height: 100%;
+			font-size: 15px;
+			color: $font-color-dark;
+			position: relative;
+
+			&.current {
+				color: $base-color;
+
+				&:after {
+					content: '';
+					position: absolute;
+					left: 50%;
+					bottom: 0;
+					transform: translateX(-50%);
+					width: 44px;
+					height: 0;
+					border-bottom: 2px solid $base-color;
+				}
+			}
+		}
+	}
+
+	.uni-swiper-item {
+		height: auto;
+	}
+
+	.order-item {
+		display: flex;
+		flex-direction: column;
+		padding-left: 30rpx;
+		padding-right: 30rpx;
+		background: #fff;
+		margin-top: 16rpx;
+		position: relative;
+
+		.i-top {
+			display: flex;
+			align-items: center;
+			height: 80rpx;
+			font-size: $font-base;
+			color: $font-color-dark;
+			position: relative;
+
+			.time {
+				flex: 1;
+			}
+
+			.state {
+				color: $base-color;
+			}
+
+			.del-btn {
+				padding: 10rpx 0 10rpx 36rpx;
+				font-size: $font-lg;
+				color: $font-color-light;
+				position: relative;
+
+				&:after {
+					content: '';
+					width: 0;
+					height: 30rpx;
+					border-left: 1px solid $border-color-dark;
+					position: absolute;
+					left: 20rpx;
+					top: 50%;
+					transform: translateY(-50%);
+				}
+			}
+		}
+
+		.info-info {
+			width: 215rpx;
+			height: 200rpx;
+			position: absolute;
+			top: 80rpx;
+			right: 35rpx;
+			display: flex;
+			flex-direction: column;
+			justify-content: flex-end;
+			align-items: flex-end;
+			font-size: 30rpx;
+			font-weight: 500;
+
+			.hj {
+				padding-top: 40rpx;
+				color: #000000;
+				padding-bottom: 20rpx;
+			}
+
+			.js {
+				color: #A8ADBF;
+			}
+		}
+
+		.kh-info {
+			font-size: 24rpx;
+			font-weight: 500;
+			color: #666666;
+			padding: 20rpx 0;
+			border-top: 1px solid #F8F8F8;
+
+			view {
+				padding: 5rpx 0;
+			}
+
+			text {
+				font-weight: bold;
+				color: #333333;
+			}
+
+		}
+
+		/* 多条商品 */
+		.goods-box {
+			height: 200rpx;
+			padding: 20rpx 0;
+			white-space: nowrap;
+			padding-right: 250rpx;
+
+			.goods-item {
+				width: 120rpx;
+				height: 180rpx;
+				display: inline-block;
+				margin-right: 24rpx;
+			}
+
+			.goods-img {
+				display: block;
+				width: 120rpx;
+				height: 120rpx;
+			}
+
+			.good-name {
+				font-size: 24rpx;
+				text-align: center;
+				width: 120rpx;
+				padding-top: 10rpx;
+				margin-right: 0;
+			}
+		}
+
+		.btm-btn-wrap {
+			height: 90rpx;
+			width: 100%;
+			font-size: 24rpx;
+			font-weight: 500;
+			color: #A3A8BB;
+
+			.btm-right {
+				justify-content: flex-end;
+			}
+
+			.btm-btn {
+				width: 144rpx;
+				height: 55rpx;
+				border: 2px solid #ededed;
+				border-radius: 28rpx;
+				font-size: 26rpx;
+				font-weight: 500;
+				text-align: center;
+				line-height: 55rpx;
+				margin-left: 10rpx;
+				color: #999999;
+			}
+
+			.ksps {
+				border-color: #4589ec;
+				color: #4589ec;
+			}
+		}
+	}
+</style>