瀏覽代碼

feat:修改登录bug

wangsisi 1 月之前
父節點
當前提交
b8524d3cda
共有 5 個文件被更改,包括 174 次插入116 次删除
  1. 21 12
      api/user.js
  2. 1 1
      components/checkinPopup/checkinPopup.vue
  3. 1 4
      manifest.json
  4. 83 81
      pages/login/index.vue
  5. 68 18
      pages/tabBar/tree/components/treeAlbumPopup.vue

+ 21 - 12
api/user.js

@@ -1,13 +1,22 @@
-// api/index.js
-import http from '@/utils/http'
-import config from './config'
-
-export default {
-  userInfo() {
-    return http.get('mini/bbs_my/userInfo')
-  },
-  // ! 登录并获取token
-  fetchLogin(data) {
-    return http.post('mini/mini_min_app_user/login',data)
-  },
+// api/index.js
+import http from '@/utils/http'
+import config from './config'
+
+export default {
+	//获取用户信息
+	userInfo() {
+		return http.get('mini/bbs_my/userInfo')
+	},
+	// ! 登录并获取token
+	fetchLogin(data) {
+		return http.post('mini/mini_min_app_user/login', data)
+	},
+	// 修改用户信息
+	updateUser(data) {
+		return http.post('mini/mini_min_app_user/update', data)
+	},
+	// 获取手机号
+	getPhone(data) {
+		return http.get('mini/mini_min_app_user/getPhone', data)
+	},
 }

+ 1 - 1
components/checkinPopup/checkinPopup.vue

@@ -27,7 +27,7 @@
 					:class="['check-day', { active: runningDays == index + 4 },{gary:runningDays > index + 4}]">
 					<view class="leaf-wrap">
 						<image class="leaf"
-							:src="`${config.BASIC_IMG}img/treePage/${runningDays == index + 4 ? 'white-leaf' : runningDays > index + 1 ?'gary-leaf':'leaf-icon'}.png`"
+							:src="`${config.BASIC_IMG}img/treePage/${runningDays == index + 4 ? 'white-leaf' : runningDays > index + 4 ?'gary-leaf':'leaf-icon'}.png`"
 							alt="leaf icon" />
 						<text>x{{ item.energy }}</text>
 					</view>

+ 1 - 4
manifest.json

@@ -61,10 +61,7 @@
 		  "permission": {
 		    "scope.userLocation": {
 		      "desc": "需要获取您的位置以显示地图"
-		    },
-			"scope.userInfo": {
-			  "desc": "用于登录功能"
-			}
+		    }
 		  },
         "usingComponents" : true
     },

+ 83 - 81
pages/login/index.vue

@@ -2,7 +2,8 @@
 	<view class="base-container">
 		<image class="tabbar" src="https://birdseye-img.sysuimars.com/dinggou-mini/tabbar-new.png" mode="" />
 	</view>
-	<up-popup :show="showPopup" mode="center" round="10" :overlay="false" :safeAreaInsetBottom="false" bgColor="transparent">
+	<up-popup :show="showPopup" mode="center" round="10" :overlay="false" :safeAreaInsetBottom="false"
+		bgColor="transparent">
 		<view class="popup">
 			<button class="avatar-none" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
 				<view class="avatar-wrapper">
@@ -13,7 +14,7 @@
 				</view>
 			</button>
 			<view class="tips">设置头像,可以在地图上显示自己守护树的点位哦~</view>
-			<button class="arrow-icon" open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber">
+			<button class="arrow-icon" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
 				<view class="button">微信授权</view>
 			</button>
 		</view>
@@ -23,93 +24,94 @@
 <script setup>
 	import {
 		ref
-	} from 'vue';
-	import { onLoad } from '@dcloudio/uni-app'
+	} from 'vue';
+	import {
+		onLoad
+	} from '@dcloudio/uni-app'
 	import USER from '@/api/user.js'
 
-	const showPopup = ref(true);
-	const userData = ref({})
-	const pageUrl = ref('')
-	const pageParams = ref(null)
-	
-	onLoad(({route_path,params = "{}"}) =>{
-		pageUrl.value = route_path
-		pageParams.value = params
-		getUserData()
-	})
-
-	
-	const getUserData = () =>{
-	    USER.userInfo().then(res =>{
-	      const timestamp = res.data.birthDate && Date.parse(res.data.birthDate); // 返回毫秒级时间戳
-		  userData.value = res.data
-	    })
-	}
-	
-	const onChooseAvatar = (e) =>{
-	    const { avatarUrl } = e.detail 
-	    // wx.showLoading({title: '上传中'})
-	    // upload(this.data.userInfo.id + "/" + new Date().getTime() + ".png", avatarUrl, (res) => {
-	    //   that.setData({
-	    //     'userInfo.icon':BASE_IMG_DIR+res.key,
-	    //   })
-	    //   wx.hideLoading()
-	    // })
-	}
-	
-	const onGetPhoneNumber = (e) =>{
-	    if (e.detail.code) {
-	      // getPhone({code:e.detail.code}).then(res =>{
-	      //   if(res.success){
-	      //     this.setData({'userInfo.tel':res.data})
-	      //     that.saveUserInfo(that.data.userInfo)
-	      //   }
-	      // })
-		  uni.navigateTo({
-		  	url: `/pages/tabBar/home/subPages/allGardenMap?enterSelectTree=true`
-		  });
-	    }else{
-	      console.log("用户拒绝了授权");
-	    }
-	}
-	
-	const saveUserInfo = (params) =>{
-	    // saveUser(params).then(response =>{
-	    //   wx.hideLoading()
-	    //   if(response.success){
-	    //     wx.showToast({
-	    //       title: '保存成功',
-	    //       icon: 'none',
-	    //       duration: 2000,
-	    //       mask:true
-	    //     })
-	    //     const params = {
-	    //       showPopup:true
-	    //     }
-	    //     wx.reLaunch({
-	    //       url: `/pages/tabBar/home/index?route_path=lj_home&params=${JSON.stringify(params)}`
-	    //     })
-	    //   }else{
-	    //     wx.showToast({
-	    //       title: '保存失败',
-	    //       icon: 'none',
-	    //       duration: 2000,
-	    //       mask:true
-	    //     })
-	    //   }
-	    // })
+	const showPopup = ref(true);
+	const userData = ref({})
+	const pageUrl = ref('')
+	const pageParams = ref(null)
+
+	onLoad(({
+		route_path,
+		params = "{}"
+	}) => {
+		pageUrl.value = route_path
+		pageParams.value = params
+		getUserData()
+	})
+
+
+	const getUserData = () => {
+		USER.userInfo().then(res => {
+			const timestamp = res.data.birthDate && Date.parse(res.data.birthDate); // 返回毫秒级时间戳
+			userData.value = res.data
+		})
+	}
+
+	const onChooseAvatar = (e) => {
+		const {
+			avatarUrl
+		} = e.detail
+		// wx.showLoading({title: '上传中'})
+		// upload(this.data.userInfo.id + "/" + new Date().getTime() + ".png", avatarUrl, (res) => {
+		//   that.setData({
+		//     'userInfo.icon':BASE_IMG_DIR+res.key,
+		//   })
+		//   wx.hideLoading()
+		// })
+	}
+
+	const onGetPhoneNumber = (e) => {
+		if (e.detail.code) {
+			USER.getPhone({
+				code: e.detail.code
+			}).then(res => {
+				if (res.success) {
+					userData.value.tel = res.data
+					saveUserInfo(userData.value)
+				}
+			})
+		} else {
+			console.log("用户拒绝了授权");
+		}
+	}
+
+	const saveUserInfo = (params) => {
+		USER.updateUser(params).then(response => {
+			uni.hideLoading()
+			if (response.success) {
+				uni.showToast({
+					title: '保存成功',
+					icon: 'none',
+					duration: 2000,
+					mask: true
+				})
+				uni.navigateTo({
+					url: `/pages/tabBar/home/subPages/gardenMap?enterSelectTree=true`
+				});
+			} else {
+				uni.showToast({
+					title: '保存失败',
+					icon: 'none',
+					duration: 2000,
+					mask: true
+				})
+			}
+		})
 	}
 </script>
 
 <style lang="scss" scoped>
 	@import "@/static/style/mixin.scss";
-
 	.base-container {
 		background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/login-new.png');
 		background-size: 100% 100%;
 		background-repeat: no-repeat;
 		background-position: center center;
-
 		.tabbar {
 			width: 100%;
 			height: 112rpx;
@@ -121,11 +123,11 @@
 
 	.popup {
 		width: 86vw;
-		padding: 40rpx;
+		padding: 40rpx;
 		box-sizing: border-box;
-		background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/popup-bg.png');
-		background-size: 100% 100%;
-		background-repeat: no-repeat;
+		background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/popup-bg.png');
+		background-size: 100% 100%;
+		background-repeat: no-repeat;
 		background-position: center center;
 
 		.avatar-none {

+ 68 - 18
pages/tabBar/tree/components/treeAlbumPopup.vue

@@ -9,16 +9,20 @@
 				<image class="icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon-popup.png`"></image>
 			</view>
             <view class="album-cont">
-                <scroll-view class="time-line-scroll" scroll-x :scroll-into-view="scrollIntoViewId" scroll-with-animation>
-                    <view class="time-line">
-                        <view class="time-item" v-for="(item,index) in dateList" :key="index" :id="`d-${item.dateStr}`" @click="handleDateClick(item.dateStr)">
-                            <text v-if="item.showYear" class="year-flag">{{ item.year }}</text>
-                            <text :style="{color:(selectedDateStr===item.dateStr)?'#2199F8':'#777777'}">{{item.display}}</text>
-                            <view class="dot" :style="{background:(selectedDateStr===item.dateStr)?'#2199F8':'#777777'}"></view>
-                            <text class="today" v-if="item.isToday">今</text>
+                <view class="time-line-scroll">
+                    <scroll-view class="time-line-container" scroll-x :scroll-into-view="scrollIntoViewId" scroll-with-animation>
+                        <view class="time-line">
+                            <view class="time-item" v-for="(item,index) in dateList" :key="index" :id="`d-${item.dateStr}`" @click="handleDateClick(item.dateStr)">
+                                <text :style="{color:(selectedDateStr===item.dateStr)?'#2199F8':'#777777'}">{{item.display}}</text>
+                                <view class="dot" :style="{background:(selectedDateStr===item.dateStr)?'#2199F8':'#777777'}"></view>
+                                <text class="today" v-if="item.isToday">今</text>
+                                <text v-if="item.showYear" class="year-flag">{{ item.year }}</text>
+                            </view>
                         </view>
-                    </view>
-                </scroll-view>
+                    </scroll-view>
+                    <!-- 中间竖线标志 -->
+                    <view class="center-line"></view>
+                </view>
 				<view class="swiper-wrap">
 					<swiper class="swiper">
 						<swiper-item v-for="(item,index) in photoList" :key="index">
@@ -90,18 +94,44 @@
             const mapped = arr.map(ds=>{
                 const dateStr = (typeof ds === 'string') ? ds.split(' ')[0] : ''
                 const isToday = dateStr === today
+                const [y,m,d] = dateStr.split('-')
                 return {
                     dateStr,
                     display: dateStr ? formatToDisplay(dateStr) : '',
                     isToday,
-                    year: dateStr ? dateStr.slice(0,4) : ''
+                    year: y,
+                    month: m,
+                    day: d
                 }
             }).filter(i=>i.dateStr)
             mapped.sort((a,b)=> a.dateStr.localeCompare(b.dateStr))
+            
+            // 只显示月份第一天和中间/下月第一天
+            const filteredDates = []
+            let currentMonth = ''
+            let currentYear = ''
+            
             for(let i=0;i<mapped.length;i++){
-                mapped[i].showYear = i===0 || mapped[i].year !== mapped[i-1].year
+                const item = mapped[i]
+                const monthKey = `${item.year}-${item.month}`
+                
+                if(monthKey !== currentMonth){
+                    // 新月份的第一天
+                    item.showYear = monthKey.split('-')[0] !== currentYear
+                    filteredDates.push(item)
+                    currentMonth = monthKey
+                    currentYear = item.year
+                } else {
+                    // 检查是否是当前月份的中间日期或下个月第一天
+                    const day = parseInt(item.day)
+                    if(day === 15 || day === 1){
+                        item.showYear = false
+                        filteredDates.push(item)
+                    }
+                }
             }
-            dateList.value = mapped
+            
+            dateList.value = filteredDates
             if(dateList.value.length){
                 const last = dateList.value[dateList.value.length-1]
                 selectedDateStr.value = last.dateStr
@@ -207,14 +237,30 @@
             .time-line-scroll{
                 margin-bottom: 16rpx;
                 width: 100%;
+                position: relative;
+            }
+            .time-line-container{
+                width: 100%;
                 white-space: nowrap;
             }
             .time-line{
                 display: flex;
                 padding: 0 20rpx;
+                position: relative;
+            }
+            .center-line{
+                position: absolute;
+                left: 50%;
+                top: 0;
+                bottom: 0;
+                width: 2rpx;
+                background: #2199F8;
+                z-index: 10;
+                transform: translateX(-50%);
+                pointer-events: none;
             }
             .time-item{
-                min-width: 100rpx;
+                min-width: 120rpx;
                 font-size: 24rpx;
                 color: #777777;
                 display: flex;
@@ -222,6 +268,8 @@
                 align-items: center;
                 position: relative;
                 padding: 0 12rpx;
+                cursor: pointer;
+                
                 &::before{
                     content: '';
                     position: absolute;
@@ -231,21 +279,23 @@
                     height: 2rpx;
                     background: rgba(136, 136, 136, 0.1);
                 }
-                .year-flag{
-                    font-size: 20rpx;
-                    color: #999;
-                    margin-bottom: 6rpx;
-                }
                 .dot{
                     width: 14rpx;
                     height: 14rpx;
                     background: #777777;
                     border-radius: 50%;
+                    position: relative;
+                    z-index: 5;
                 }
                 .today{
                     color: #2199F8;
                     margin-top: 8rpx;
                 }
+                .year-flag{
+                    font-size: 18rpx;
+                    color: #999;
+                    margin-top: 6rpx;
+                }
             }
 			.swiper-wrap{
 				position: relative;