Browse Source

删掉authLogin hook

ming 3 years ago
parent
commit
78e1c8ffc3

+ 9 - 3
components/fs-avatar/fs-avatar.vue

@@ -17,7 +17,8 @@
 			'margin-left': avatarGroup.margin + 'rpx'
 		}"
 		@click="handleClick"
-	>
+	>
+		<image class="fs-avatar-img" :src="errImg" v-if="errImg" :lazy-load="lazyLoad" :mode="imageMode" @click="handlePreview" />
 		<image class="fs-avatar-img" :src="src" v-if="src" :lazy-load="lazyLoad" :mode="imageMode" @click="handlePreview" />
 		<view v-else class="fs-avatar-slot" :class="['bg-' + bgColorType]" :style="{backgroundColor:bgColor}">
 			<slot></slot>
@@ -26,7 +27,7 @@
 </template>
 
 <script setup>
-import { computed, inject } from 'vue'
+import { computed, inject, ref } from 'vue'
 
 const props = defineProps({
 	src: String,
@@ -103,9 +104,14 @@ const handleClick = () => {
 const handlePreview = () => {
 	if (props.preview) {
 		uni.previewImage({
-			urls: [props.src]
+			urls: [props.src || errImg.value]
 		})
 	}
+}
+
+const errImg = ref('')
+const handleError = e => {
+	errImg.value = props.defaultErrorImg
 }
 </script>
 

+ 6 - 1
components/fs-card/fs-card.vue

@@ -1,5 +1,5 @@
 <template>
-	<view class="fs-card" :class="{'fs-card-full': full, 'fs-card-gutter': gutter}">
+	<view class="fs-card" :class="{'fs-card-full': full, 'fs-card-gutter': gutter}" @click="handleClick">
 		<view class="fs-card-box" :class="{'fs-card-radius': radius, shadow}">
 			<view class="fs-card-title" v-if="slots.title || title" :style="titleStyle">
 				<slot name="title">{{title}}</slot>
@@ -38,6 +38,11 @@ const props = defineProps({
 })
 
 const slots = useSlots()
+const emits = defineEmits(['click'])
+
+const handleClick = () => {
+	emits('click')
+}
 </script>
 
 <style lang="scss" scoped>

+ 2 - 1
components/fs-loadmore/fs-loadmore.vue

@@ -52,8 +52,9 @@ const query = (loadmore) => {
 	}).then(res => {
 		state.hasMore = res.length >= state.pageSize
 		state.dataList = loadmore ? [...state.dataList, ...res] : res
-		state.loading = false
 		emits('update:modelValue', state.dataList)
+	}).finally(() => {
+		state.loading = false
 	})
 }
 

+ 0 - 27
hooks/useAuthLogin/index.js

@@ -1,27 +0,0 @@
-import { computed } from 'vue'
-import { useStore } from 'vuex'
-
-export default () => {
-	return cb => {
-		const store = useStore()
-		const token = computed(() => store.state.token)
-		
-		if (token.value) {
-			cb && cb()
-		} else{
-			uni.showModal({
-				content: '你还未登录,请先登录',
-				confirmText: '去登录',
-				confirmColor: '#0063F5',
-				success: function (res) {
-					if (res.confirm) {
-						uni.navigateTo({
-							url: '/modules/common/login/login'
-						})
-					}
-				}
-			})
-		}
-	}
-}
-

+ 6 - 1
pages/my/my.vue

@@ -86,11 +86,16 @@
 
 <script setup>
 import { computed, ref } from 'vue'
+import { onShow } from '@dcloudio/uni-app'
 import useUser from '@/hooks/useUser'
 import userAvatar from '/static/images/user-avatar.png'
 import wx from '@/business/wx-login.vue'
 
-const userInfo = useUser()
+const userInfo = ref('')
+onShow(() => {
+	userInfo.value = useUser()
+})
+
 const shortcutList = ref([
 	{
 		title: '我的访客',

+ 8 - 0
utils/utils.js

@@ -97,4 +97,12 @@ export default {
 	chooseAndUploadVideo(chooseParam, uploadParam, isCloud) {
 		return this.chooseAndUpload('chooseVideo',chooseParam, uploadParam, isCloud)
 	},
+	authLogin(cb) {
+		if (!uni.getStorageSync('token')) {
+			return uni.navigateTo({
+				url: '/modules/common/login/login'
+			})
+		}
+		cb && cb()
+	}
 }