Browse Source

未登录、功能页面跳转

zqw601@126.com 2 months ago
parent
commit
f15dc8a060
2 changed files with 105 additions and 34 deletions
  1. 37 11
      mer_uniapp/pages/index/index.vue
  2. 68 23
      mer_uniapp/pages/user/index.vue

+ 37 - 11
mer_uniapp/pages/index/index.vue

@@ -1,5 +1,5 @@
 <template>
-	<view>
+	<view style="overflow-y: scroll;">
 
 		<!-- 状态栏高度 -->
 		<view :style="{ height: `${statusBarHeight}px` }"></view>
@@ -16,12 +16,12 @@
 			<view class="bar-center">校园外卖</view>
 
 			<view style="flex: 1;">
-				<image src="/static/img/ic-search.png"></image>
+				<image @click="goSearch" src="/static/img/ic-search.png"></image>
 			</view>
 		</view>
 
 		<!-- 主体内容 -->
-		<view class="content">
+		<view class="content" :style="{ marginTop: `${navigationBarHeight + 5 }px` }">
 
 			<!-- banner轮播图 -->
 			<view style="margin-top: 10rpx;">
@@ -147,9 +147,7 @@
 			</view>
 
 			<view class="content-goods2" v-for="item in merchantList" :key="item.id">
-				<view>
-					<image :src="item.pcLogo" style="width: 230rpx;height: 230rpx;"></image>
-				</view>
+				<image :src="item.pcLogo" style="width: 230rpx;height: 230rpx;"></image>
 
 				<view style="margin-left: 20rpx;flex: 1;">
 					<view class="">
@@ -164,15 +162,13 @@
 					</view>
 
 					<view style="margin-top: 10rpx;">
-						<text class="goods-info">起送 ¥ {{item.perCapita}}</text>
+						<text class="goods-info">起送 ¥ {{item.freeDeliverFee}}</text>
 						<text v-if="!item.isfreeDeliverfee" class="goods-info"
 							style="color: #E5AD21;margin-left: 16rpx;">免配送费</text>
-						<text v-if="!item.isfreeDeliverfee"
-							style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥
-							{{item.freeDeliverFee}}</text>
+						<text v-if="!item.isfreeDeliverfee" class="goods-info3">¥{{item.freeDeliverFee}}</text>
 						<text v-if="item.isfreeDeliverfee"
 							style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥ {{item.distCosts}}</text>
-						<text class="goods-info" style="margin-left: 38rpx;">10分钟</text>
+						<text class="goods-info" style="margin-left: 38rpx;">{{item.deliverTime}}分钟</text>
 						<text class="goods-info" style="margin-left: 10rpx;">{{item.distance}}</text>
 					</view>
 
@@ -290,6 +286,7 @@
 							longitude: longitude
 						}).then(res => {
 							that.merchantList = res.data.list;
+							console.log('商品信息:', that.merchantList);
 						});
 					},
 					fail: (err) => {
@@ -317,6 +314,25 @@
 					this.offset = -this.currentIndex * 20; // 20px 是单行高度
 				}, 2000); // 2秒切换一次
 			},
+			goSearch() {
+				this.$util.navigateTo('/pages/goods/goods_search/index');
+			},
+			//配送时间转换
+			convertMinutes(minutes) {
+				const mins = Number(minutes);
+				if (isNaN(mins)) return '无效输入';
+
+				if (mins > 60) {
+					const hours = Math.floor(mins / 60);
+					const remaining = mins % 60;
+					let result = [];
+					if (hours > 0) result.push(`${hours}小时`);
+					if (remaining > 0) result.push(`${remaining}分钟`);
+					return result.join('') || '0分钟';
+				} else {
+					return `${mins}分钟`;
+				}
+			},
 		},
 	}
 </script>
@@ -337,6 +353,9 @@
 		background-color: #FF6702;
 		color: #fff;
 		align-items: center;
+		position: fixed;
+		z-index: 100;
+		width: 100%;
 	}
 
 	.navigationbar image {
@@ -539,6 +558,13 @@
 		font-size: 21rpx;
 	}
 
+	.goods-info3 {
+		color: #999999;
+		font-size: 21rpx;
+		margin-left: 10rpx;
+		text-decoration: line-through;
+	}
+
 	.goods-sales {
 		background-color: #FEEFE5;
 		color: #FF6702;

+ 68 - 23
mer_uniapp/pages/user/index.vue

@@ -12,15 +12,23 @@
 
 		<view class="card">
 			<view class="card-left">
-				<img class="avatar" src="/static/img/ic-buy.png" alt="用户头像">
-				<view class="username">老番茄333 <image src="/static/img/ic-code.png" class="code"></image>
+				<view class="name" v-if="!isLogin" @tap="openAuto">
+					<img class="avatar" src="/static/img/ic-buy.png" alt="默认头像">
+					<view class="username">请点击登录</view>
 				</view>
 
-				<view class="phone-info">
-					<text>绑定手机号:185-7033-6037</text>
-					<image src="/static/img/ic-copy.png">
-					</image>
-				</view>
+				<template v-else>
+					<img class="avatar" src="/static/img/ic-buy.png" alt="用户头像">
+					<view class="username">老番茄333 <image src="/static/img/ic-code.png" class="code"></image>
+					</view>
+
+					<view class="phone-info">
+						<text>绑定手机号:185-7033-6037</text>
+						<image src="/static/img/ic-copy.png">
+						</image>
+					</view>
+				</template>
+
 			</view>
 
 			<view class="card-right">
@@ -29,7 +37,7 @@
 						<img class="content-icon" src="/static/img/ic-tickets.png" alt="我的票劵">
 						<view class="content-text1">我的票劵</view>
 					</view>
-					<view class="content-item">
+					<view class="content-item" @click="menusTap('/pages/goods/order_list/index')">
 						<img class="content-icon" src="/static/img/ic-order.png" alt="我的订单">
 						<view class="content-text2">我的订单</view>
 					</view>
@@ -47,18 +55,20 @@
 		</view>
 
 		<view class="item-settled">
-			<image src="/static/img/ic-settled-left.png" style="width: 350rpx;height: 116rpx;"></image>
+			<image @tap="menusTap('/pages/users/settled/index')" src="/static/img/ic-settled-left.png"
+				style="width: 350rpx;height: 116rpx;"></image>
 
 			<image src="/static/img/ic-bg-line.png" style="width: 4rpx;height: 154rpx;margin: 0 20rpx;"></image>
 
-			<image src="/static/img/ic-settled-right.png" style="width: 350rpx;height: 116rpx;"></image>
+			<image @tap="menusTap('')" src="/static/img/ic-settled-right.png"
+				style="width: 350rpx;height: 116rpx;"></image>
 		</view>
 
-		<view class="item-features">
+		<view class="item-features" v-if="isLogin">
 			<view class="item-features-title">我的功能</view>
 			<div class="grid-container">
 				<!-- 示例:12 个格子(3行x4列) -->
-				<div class="grid-item" v-for="item in featuresList" :key="item.id">
+				<div class="grid-item" v-for="item in featuresList" :key="item.id" @click="menusTap(item.url)">
 					<img class="grid-img" :src="item.icon">
 					<div class="grid-text">{{item.text}}</div>
 				</div>
@@ -73,7 +83,18 @@
 <script>
 	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
 	let app = getApp();
+	import Cache from '@/utils/cache';
+	import {
+		toLogin
+	} from '@/libs/login.js';
+	import {
+		mapGetters
+	} from "vuex";
+	import {
+		BACK_URL
+	} from '@/config/cache';
 	export default {
+		computed: mapGetters(['isLogin']),
 		data() {
 			return {
 				statusBarHeight: app.globalData.statusBarHeight,
@@ -81,52 +102,62 @@
 				featuresList: [{
 						id: 1,
 						icon: '/static/img/ic-express.png',
-						text: '我的快递'
+						text: '我的快递',
+						url: ''
 					},
 					{
 						id: 2,
 						icon: '/static/img/ic-address.png',
-						text: '通用地址'
+						text: '通用地址',
+						url: '/pages/address/user_address_list/index'
 					},
 					{
 						id: 3,
 						icon: '/static/img/ic-comments.png',
-						text: '我的评论'
+						text: '我的评论',
+						url: ''
 					},
 					{
 						id: 4,
 						icon: '/static/img/ic-collection.png',
-						text: '我的收藏'
+						text: '我的收藏',
+						url: '/pages/goods/user_goods_collection/index'
 					},
 					{
 						id: 5,
 						icon: '/static/img/ic-buy.png',
-						text: '我的团购'
+						text: '我的团购',
+						url: ''
 					},
 					{
 						id: 6,
 						icon: '/static/img/ic-vouchers.png',
-						text: '我的卡券'
+						text: '我的卡券',
+						url: '/pages/users/user_coupon/index'
 					},
 					{
 						id: 7,
 						icon: '/static/img/ic-distribution.png',
-						text: '我的分销'
+						text: '我的分销',
+						url: '/pages/users/user_spread_user/index'
 					},
 					{
 						id: 8,
 						icon: '/static/img/ic-friend.png',
-						text: '邀请好友'
+						text: '邀请好友',
+						url: ''
 					},
 					{
 						id: 9,
 						icon: '/static/img/ic-feedback.png',
-						text: '帮助反馈'
+						text: '帮助反馈',
+						url: ''
 					},
 					{
 						id: 10,
 						icon: '/static/img/ic-security-settings.png',
-						text: '安全设置'
+						text: '安全设置',
+						url: ''
 					}
 				],
 			}
@@ -144,7 +175,21 @@
 			// #endif
 
 		},
-		methods: {},
+		methods: {
+			menusTap(url) {
+				if (!this.isLogin) {
+					this.openAuto();
+				} else {
+					if (url === '') return
+					this.$util.navigateTo(url);
+				}
+			},
+			// 打开授权
+			openAuto() {
+				Cache.set(BACK_URL, '')
+				toLogin();
+			},
+		},
 	}
 </script>