guhongwei 2 vuotta sitten
vanhempi
commit
10d63f08c4
2 muutettua tiedostoa jossa 259 lisäystä ja 102 poistoa
  1. 56 46
      pages/login/index.vue
  2. 203 56
      pagesMy/order/index.vue

+ 56 - 46
pages/login/index.vue

@@ -23,6 +23,9 @@
 	export default {
 		data() {
 			return {
+				// 平台信息
+				platform: {},
+				openid: '',
 				logoUrl: this.$config.logoUrl,
 				form: {},
 				rules: {
@@ -55,8 +58,39 @@
 		methods: {
 			search() {
 				const that = this;
+				uni.getStorage({
+					key: 'system',
+					success: function(res) {
+						if (res.data) that.$set(that, `platform`, res.data);
+						// 获取openid
+						that.searchOpenid()
+					}
+				})
+			},
+			// 查询openid
+			searchOpenid() {
+				const that = this;
+				if (that.platform.uniPlatform == 'mp-weixin') {
+					uni.login({
+						provider: 'weixin',
+						success: async function(res) {
+							const aee = await that.$api(`/wechat/api/login/app`, 'GET', {
+								js_code: res.code,
+								config: 'pointApp'
+							})
+							if (aee.errcode == '0') {
+								that.$set(that, `openid`, aee.data.openid)
+							}
+						},
+						fail: function(err) {
+							console.log(err);
+						}
+					})
+				} else if (that.platform.uniPlatform == 'app') {
+					console.log('to do');
+				}
 			},
-			// 提交登录
+			// 账号登录
 			toSubmit(ref) {
 				const that = this;
 				that.$refs[ref].validate().then(async params => {
@@ -92,9 +126,22 @@
 					console.log('表单错误信息:', err);
 				})
 			},
-			// 注册账号,去登录
+			// 微信信任登录
+			wxLogin() {
+				const that = this;
+				if (that.platform.uniPlatform == 'mp-weixin') {
+					that.userLogin({
+						openid: that.openid
+					}, '2');
+				} else if (that.platform.uniPlatform == 'app') {
+					console.log('app');
+				}
+			},
+			// 账号登录,无账号,注册账号
 			async createUser(params) {
 				const that = this;
+				const openid = that.openid;
+				if (that.platform.uniPlatform == 'mp-weixin') params.openid = openid;
 				const res = await that.$api(`/user`, 'POST', {
 					...params
 				})
@@ -106,21 +153,23 @@
 					});
 				}
 			},
-			// 注册微信账号,去登录
-			async createwxUser(params) {
+			// 微信登录,无账号,微信注册账号
+			async createwxUser() {
 				const that = this;
 				const res = await that.$api(`/user`, 'POST', {
-					...params
+					openid: that.openid
 				})
 				if (res.errcode == '0') {
-					that.userLogin(params, '2')
+					that.userLogin({
+						openid: that.openid
+					}, '2')
 				} else {
 					uni.showToast({
 						title: res.errmsg,
 					});
 				}
 			},
-			// 账号,微信登录
+			// 用户登录
 			async userLogin(params, type) {
 				const that = this;
 				let res;
@@ -159,45 +208,6 @@
 					}
 				}
 			},
-			// 微信登录
-			wxLogin() {
-				const that = this;
-				uni.login({
-					provider: 'weixin',
-					success: function(res) {
-						// 获取平台信息
-						uni.getSystemInfo({
-							success: async function(arr) {
-								let platForm = arr.uniPlatform;
-								if (platForm == 'app') { //app平台
-									uni.showToast({
-										title: 'app端暂未开通微信登录',
-										icon: 'none'
-									});
-								} else if (platForm == 'mp-weixin') { //微信平台
-									const aee = await that.$api(`/wechat/api/login/app`, 'GET', {
-										js_code: res.code,
-										config: 'pointApp'
-									})
-									if (aee.errcode == '0') {
-										// 微信登录
-										that.userLogin({
-											openid: aee.data.openid
-										}, '2');
-									} else {
-										uni.showToast({
-											title: res.errmsg,
-										});
-									}
-								}
-							}
-						});
-					},
-					fail: function(err) {
-						console.log(err);
-					}
-				})
-			},
 		}
 	}
 </script>

+ 203 - 56
pagesMy/order/index.vue

@@ -9,7 +9,54 @@
 					<view class="tabsList">
 						<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 							<view class="list-scroll-view">
-								<view class="list" v-for="(item,index) in list" :key="index">
+								<view class="list_1" v-if="tabs.active=='-0'">
+									全部订单
+								</view>
+								<view class="list_2" v-for="(item,index) in list" :key="index" v-else-if="tabs.active=='0'">
+									<view class="status">
+										{{item.status=='0'?'待付款':'已付款'}}
+									</view>
+									<view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
+										<view class="goods_1">
+											<view class="shopname">
+												<text class="iconfont icon-shangdian"></text>
+												<text>{{tag.shop_name}}</text>
+											</view>
+										</view>
+										<view class="goods_2">
+											<view class="market" v-for="(tags,indexss) in tag.goods" :key="indexss">
+												<view class="url">
+													<image class="image" :src="tags.goods.file&&tags.goods.file.length>0?tags.goods.file[0].url:''" mode=""></image>
+												</view>
+												<view class="goodsname">
+													{{tags.name}}
+												</view>
+												<view class="goodsother">
+													<view class="price">
+														¥{{tags.sell_money}}
+													</view>
+													<view class="num">
+														×{{tags.buy_num}}
+													</view>
+												</view>
+											</view>
+										</view>
+									</view>
+									<view class="other">
+										<text>共{{item.total_detail.freight_total}}件商品</text>
+										<text>总价¥{{item.total_detail.goods_total}}</text>
+									</view>
+									<view class="btn">
+										<button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
+										<button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
+										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
+										<button class="toRefund" v-if="item.status=='3'" type="default" size="mini" @click="toRefund(item)">申请退款</button>
+									</view>
+								</view>
+								<view class="list_3" v-else>
+									其他情况
+								</view>
+								<!-- 	<view class="list" v-for="(item,index) in list" :key="index">
 									<view class="list_1">
 										<view class="l">
 											<text class="iconfont icon-shangdian"></text>
@@ -21,8 +68,7 @@
 									</view>
 									<view class="list_2">
 										<view class="l">
-											<image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''"
-												mode=""></image>
+											<image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode=""></image>
 										</view>
 										<view class="c">
 											<view class="name">
@@ -40,19 +86,15 @@
 									</view>
 									<view class="other">
 										<text>共{{item.market_num}}件商品</text>
-										<text>总价¥{{item.money}}</text>
+										<text>总价¥{{item.total_detail.goods_total}}</text>
 									</view>
 									<view class="btn">
-										<button v-if="item.status=='0'" type="default" @click="toCancel(item)"
-											size="mini">取消订单</button>
-										<button v-if="item.status=='0'" type="default" @click="toPay(item)"
-											size="mini">付款</button>
-										<button v-if="item.status=='3'" type="default" @click="toAfter(item)"
-											size="mini">申请售后</button>
-										<button v-if="item.status=='3'" type="default" @click="toRefund(item)"
-											size="mini">申请退款</button>
+										<button v-if="item.status=='0'" type="default" @click="toCancel(item)" size="mini">取消订单</button>
+										<button v-if="item.status=='0'" type="default" @click="toPay(item)" size="mini">付款</button>
+										<button v-if="item.status=='3'" type="default" @click="toAfter(item)" size="mini">申请售后</button>
+										<button v-if="item.status=='3'" type="default" @click="toRefund(item)" size="mini">申请退款</button>
 									</view>
-								</view>
+								</view> -->
 							</view>
 						</scroll-view>
 					</view>
@@ -98,23 +140,11 @@
 						}
 					]
 				},
-				list: [ //订单列表
-					{
-						shop: '官方自营店',
-						status: '3',
-						url: [{
-							name: "20220928155634.jpg",
-							uri: "/files/point/20220928155634.jpg",
-							url: "https://broadcast.waityou24.cn/files/point/20220928155634.jpg"
-						}],
-						name: '饮用水',
-						price: 58,
-						buy_num: 1,
-						market_num: 1,
-						money: 58
-					}
-				]
-
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 5,
+				page: 0
 			};
 		},
 		onLoad: function(e) {
@@ -148,11 +178,45 @@
 				const that = this;
 				let user = that.user;
 				let status = that.status;
-				console.log(status);
+				if (status == '-0') {
+
+				} else if (status == '0') {
+					const res = await that.$api(`/order`, 'GET', {
+						status: '0',
+						customer: user._id
+					});
+					if (res.errcode == '0') {
+						let list = [...that.list, ...res.data];
+						that.$set(that, `list`, list)
+						that.$set(that, `total`, res.total)
+					} else {
+						uni.showToast({
+							title: res.errmsg,
+						});
+					}
+				} else {
+
+				}
 			},
 			// 分页
 			toPage(e) {
-
+				const that = this;
+				let list = that.list;
+				let limit = that.limit;
+				if (that.total > list.length) {
+					uni.showLoading({
+						title: '加载中',
+						mask: true
+					})
+					let page = that.page + 1;
+					that.$set(that, `page`, page)
+					let skip = page * limit;
+					that.$set(that, `skip`, skip)
+					that.search();
+					uni.hideLoading();
+				} else uni.showToast({
+					title: '没有更多数据了'
+				});
 			},
 			// 输入框
 			toInput(e) {
@@ -189,11 +253,12 @@
 			},
 			// 付款
 			toPay(e) {
+				const that = this;
 				uni.getStorage({
 					key: 'system',
 					success: async function(res) {
 						// 微信小程序支付
-				 	if (res.data.uniPlatform == "mp-weixin") {
+						if (res.data.uniPlatform == "mp-weixin") {
 							const res = await that.$api('/pay/toPayOrder', 'POST', {
 								order_id: e,
 								type: '0'
@@ -204,9 +269,9 @@
 								...res.data,
 								success(res) {
 									console.log('in success');
-				  			console.log(res)
+									console.log(res)
 								},
-				 			fail(e) {
+								fail(e) {
 									console.log('in fail');
 									console.log(e)
 								}
@@ -290,41 +355,58 @@
 				width: 100vw;
 				height: 82vh;
 
-				.list {
+				.list_2 {
 					background-color: #fff;
 					margin: 0 2vw 2vw 2vw;
 					padding: 2vw;
 
-					.list_1 {
+					.status {
+						text-align: right;
 						margin: 0 0 1vw 0;
-						display: flex;
-						flex-direction: row;
-						justify-content: space-between;
 					}
 
-					.list_2 {
+					.goods {
 						margin: 0 0 1vw 0;
-						display: flex;
-
-						.l {
-							width: 20vw;
+						padding: 2vw;
+						border-bottom: 1px solid #f5f5f5;
 
-							.image {
-								width: 100%;
-								height: 20vw;
-								border-radius: 5px;
+						.goods_1 {
+							margin: 0 0 2vw 0;
 
+							.shopname {
+								text:last-child {
+									padding: 0 0 0 2vw;
+								}
 							}
 						}
 
-						.c {
-							width: 60vw;
-							padding: 0 2vw;
-						}
+						.goods_2 {
+							margin: 0 0 1vw 0;
+
+							.market {
+								display: flex;
+
+								.url {
+									width: 20vw;
+
+									.image {
+										width: 100%;
+										height: 20vw;
+										border-radius: 5px;
 
-						.r {
-							width: 15vw;
-							text-align: right;
+									}
+								}
+
+								.goodsname {
+									width: 60vw;
+									padding: 0 2vw;
+								}
+
+								.goodsother {
+									width: 15vw;
+									text-align: right;
+								}
+							}
 						}
 					}
 
@@ -347,8 +429,73 @@
 						button {
 							margin: 2vw 0 0 2vw;
 						}
+
+						.toPay {
+							border: 1px solid #ff0000;
+							color: #ff0000;
+						}
 					}
 				}
+
+				// .list {
+				// 	background-color: #fff;
+				// 	margin: 0 2vw 2vw 2vw;
+				// 	padding: 2vw;
+
+				// 	.list_1 {
+				// 		margin: 0 0 1vw 0;
+				// 		display: flex;
+				// 		flex-direction: row;
+				// 		justify-content: space-between;
+				// 	}
+
+				// 	.list_2 {
+				// 		margin: 0 0 1vw 0;
+				// 		display: flex;
+
+				// 		.l {
+				// 			width: 20vw;
+
+				// 			.image {
+				// 				width: 100%;
+				// 				height: 20vw;
+				// 				border-radius: 5px;
+
+				// 			}
+				// 		}
+
+				// 		.c {
+				// 			width: 60vw;
+				// 			padding: 0 2vw;
+				// 		}
+
+				// 		.r {
+				// 			width: 15vw;
+				// 			text-align: right;
+				// 		}
+				// 	}
+
+				// 	.other {
+				// 		margin: 0 0 2vw 0;
+				// 		text-align: right;
+
+				// 		text {
+				// 			font-size: 14px;
+
+				// 			padding: 0 0 0 2vw;
+				// 		}
+				// 	}
+
+				// 	.btn {
+				// 		text-align: right;
+				// 		margin: 2vw 0 0 0;
+				// 		border-top: 1px solid #f1fff1;
+
+				// 		button {
+				// 			margin: 2vw 0 0 2vw;
+				// 		}
+				// 	}
+				// }
 			}
 		}
 	}