Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Devin_Coder1024
uni-starter
提交
85af1fc5
U
uni-starter
项目概览
Devin_Coder1024
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
85af1fc5
编写于
12月 21, 2023
作者:
D
Devin_Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
合并变更
上级
499b9596
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
182 addition
and
182 deletion
+182
-182
pages/list/list.nvue
pages/list/list.nvue
+44
-44
uni_modules/uni-id-pages/components/uni-id-pages-avatar/uni-id-pages-avatar.vue
...es/components/uni-id-pages-avatar/uni-id-pages-avatar.vue
+138
-138
未找到文件。
pages/list/list.nvue
浏览文件 @
85af1fc5
...
...
@@ -12,16 +12,16 @@
</view>
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:collection="colList" :page-size="10"
:collection="colList" :page-size="10"
>
<!-- 基于 uni-list 的页面布局 field="user_id.nickname"-->
<uni-list class="uni-list" :border="false" :style="{height:listHight}">
<!-- 作用于app端nvue页面的下拉加载 -->
<!-- #ifdef APP-NVUE -->
<refreshBox @refresh="refresh" :loading="loading"></refreshBox>
<!-- 作用于app端nvue页面的下拉加载 -->
<!-- #ifdef APP-NVUE -->
<refreshBox @refresh="refresh" :loading="loading"></refreshBox>
<!-- #endif -->
<!-- 列表渲染 -->
<uni-list-item :to="'/pages/list/detail?id='+item._id+'&title='+item.title" v-for="(item,index) in data" :key="index">
<!-- 通过header插槽定义列表左侧图片 -->
...
...
@@ -39,22 +39,22 @@
</view>
</view>
</template>
</uni-list-item>
<!-- 加载状态:上拉加载更多,加载中,没有更多数据了,加载错误 -->
<!-- #ifdef APP-PLUS -->
<uni-list-item>
<template v-slot:body>
</uni-list-item>
<!-- 加载状态:上拉加载更多,加载中,没有更多数据了,加载错误 -->
<!-- #ifdef APP-PLUS -->
<uni-list-item>
<template v-slot:body>
<!-- #endif -->
<uni-load-state @networkResume="refresh" :state="{data,pagination,hasMore, loading, error}"
@loadMore="loadMore">
</uni-load-state>
<!-- #ifdef APP-PLUS -->
</template>
</uni-list-item>
</uni-load-state>
<!-- #ifdef APP-PLUS -->
</template>
</uni-list-item>
<!-- #endif -->
</uni-list>
</unicloud-db>
</unicloud-db>
</view>
</template>
...
...
@@ -63,7 +63,7 @@
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
import Gps from '@/uni_modules/json-gps/js_sdk/gps.js';
const gps = new Gps(),db = uniCloud.database();
const gps = new Gps(),db = uniCloud.database();
export default {
components: {
...
...
@@ -76,16 +76,16 @@
} else {
return '请输入搜索内容'
}
},
colList(){
return [
db.collection('opendb-news-articles').where(this.where).field('avatar,title,last_modify_date,user_id').getTemp(),
db.collection('uni-id-users').field('_id,nickname').getTemp()
]
},
colList(){
return [
db.collection('opendb-news-articles').where(this.where).field('avatar,title,last_modify_date,user_id').getTemp(),
db.collection('uni-id-users').field('_id,nickname').getTemp()
]
}
},
data() {
return {
return {
where: '"article_status" == 1',
keyword: "",
showRefresh: false,
...
...
@@ -102,7 +102,7 @@
}
}
},
async onReady() {
async onReady() {
// #ifdef APP-NVUE
/* 可用窗口高度 - 搜索框高 - 状态栏高 */
this.listHight = uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50 + 'px';
...
...
@@ -150,10 +150,10 @@
cdbRef.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
// #ifdef APP-NVUE
this.showRefresh = false
// #endif
uni.stopPullDownRefresh()
// #ifdef APP-NVUE
this.showRefresh = false
// #endif
console.log('end');
})
console.log('refresh');
...
...
@@ -165,20 +165,20 @@
console.error(e);
},
onpullingdown(e) {
console.log(e);
this.showRefresh = true
if(e.pullingDistance>100){
this.refresh()
console.log(e);
this.showRefresh = true
if(e.pullingDistance>100){
this.refresh()
}
}
},
// #ifndef APP-NVUE
onPullDownRefresh() {
this.refresh()
},
onReachBottom() {
this.loadMore()
}
// #ifndef APP-NVUE
onPullDownRefresh() {
this.refresh()
},
onReachBottom() {
this.loadMore()
}
// #endif
}
</script>
...
...
@@ -201,8 +201,8 @@
margin-right: 10rpx;
}
.main {
justify-content: space-between;
.main {
justify-content: space-between;
flex: 1;
}
...
...
@@ -243,4 +243,4 @@
z-index: 999;
/* #endif */
}
</style>
</style>
uni_modules/uni-id-pages/components/uni-id-pages-avatar/uni-id-pages-avatar.vue
浏览文件 @
85af1fc5
<
template
>
<button
open-type=
"chooseAvatar"
@
chooseavatar=
"bindchooseavatar"
@
click=
"uploadAvatarImg"
class=
"box"
:class=
"
{'showBorder':border}" :style="{width,height,lineHeight:height}">
<button
open-type=
"chooseAvatar"
@
chooseavatar=
"bindchooseavatar"
@
click=
"uploadAvatarImg"
class=
"box"
:class=
"
{'showBorder':border}" :style="{width,height,lineHeight:height}">
<cloud-image
v-if=
"avatar_file"
:src=
"avatar_file.url"
:width=
"width"
:height=
"height"
></cloud-image>
<uni-icons
v-else
:style=
"
{width,height,lineHeight:height}" class="chooseAvatar" type="plusempty" size="30"
color="#dddddd">
</uni-icons>
...
...
@@ -7,9 +7,9 @@
</
template
>
<
script
>
import
{
store
,
mutations
import
{
store
,
mutations
}
from
'
@/uni_modules/uni-id-pages/common/store.js
'
/**
* uni-id-pages-avatar
...
...
@@ -17,7 +17,7 @@
* @property {String} width 图片的宽,默认为:50px
* @property {String} height 图片的高,默认为:50px
*/
export
default
{
export
default
{
data
()
{
return
{
isPC
:
false
...
...
@@ -37,12 +37,12 @@
default
()
{
return
"
50px
"
}
},
border
:{
type
:
Boolean
,
default
()
{
return
false
}
},
border
:{
type
:
Boolean
,
default
()
{
return
false
}
}
},
async
mounted
()
{
...
...
@@ -51,150 +51,150 @@
// #endif
},
computed
:
{
hasLogin
()
{
return
store
.
hasLogin
},
userInfo
()
{
return
store
.
userInfo
},
avatar_file
()
{
hasLogin
()
{
return
store
.
hasLogin
},
userInfo
()
{
return
store
.
userInfo
},
avatar_file
()
{
return
store
.
userInfo
.
avatar_file
}
},
methods
:
{
setAvatarFile
(
avatar_file
)
{
// 使用 clientDB 提交数据
// 使用 clientDB 提交数据
mutations
.
updateUserInfo
({
avatar_file
})
},
async
bindchooseavatar
(
res
){
let
avatarUrl
=
res
.
detail
.
avatarUrl
let
avatar_file
=
{
extname
:
avatarUrl
.
split
(
'
.
'
)[
avatarUrl
.
split
(
'
.
'
).
length
-
1
],
name
:
''
,
url
:
''
}
//上传到服务器
let
cloudPath
=
this
.
userInfo
.
_id
+
''
+
Date
.
now
()
avatar_file
.
name
=
cloudPath
try
{
uni
.
showLoading
({
title
:
"
更新中
"
,
mask
:
true
});
let
{
fileID
}
=
await
uniCloud
.
uploadFile
({
filePath
:
avatarUrl
,
cloudPath
,
fileType
:
"
image
"
});
avatar_file
.
url
=
fileID
uni
.
hideLoading
()
}
catch
(
e
){
console
.
error
(
e
);
}
console
.
log
(
'
avatar_file
'
,
avatar_file
);
this
.
setAvatarFile
(
avatar_file
)
},
uploadAvatarImg
(
res
)
{
// #ifdef MP-WEIXIN
return
false
// 微信小程序走 bindchooseavatar方法
// #endif
// #ifndef MP-WEIXIN
if
(
!
this
.
hasLogin
){
return
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/login/login-withoutpwd
'
})
}
const
crop
=
{
quality
:
100
,
width
:
600
,
height
:
600
,
resize
:
true
};
uni
.
chooseImage
({
count
:
1
,
crop
,
success
:
async
(
res
)
=>
{
let
tempFile
=
res
.
tempFiles
[
0
],
avatar_file
=
{
// #ifdef H5
extname
:
tempFile
.
name
.
split
(
'
.
'
)[
tempFile
.
name
.
split
(
'
.
'
).
length
-
1
],
// #endif
// #ifndef H5
extname
:
tempFile
.
path
.
split
(
'
.
'
)[
tempFile
.
path
.
split
(
'
.
'
).
length
-
1
]
// #endif
},
filePath
=
res
.
tempFilePaths
[
0
]
//非app端剪裁头像,app端用内置的原生裁剪
// #ifndef APP-PLUS
filePath
=
await
new
Promise
((
callback
)
=>
{
// #ifdef H5
if
(
!
this
.
isPC
)
{
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage?path=
'
+
filePath
+
`&options=
${
JSON
.
stringify
(
crop
)}
`
,
animationType
:
"
fade-in
"
,
events
:
{
success
:
url
=>
{
callback
(
url
)
}
},
complete
(
e
)
{
// console.log(e);
}
});
}
// #endif
})
// #endif
let
cloudPath
=
this
.
userInfo
.
_id
+
''
+
Date
.
now
()
avatar_file
.
name
=
cloudPath
uni
.
showLoading
({
title
:
"
更新中
"
,
mask
:
true
});
let
{
fileID
}
=
await
uniCloud
.
uploadFile
({
filePath
,
cloudPath
,
fileType
:
"
image
"
});
avatar_file
.
url
=
fileID
uni
.
hideLoading
()
this
.
setAvatarFile
(
avatar_file
)
}
})
// #endif
async
bindchooseavatar
(
res
){
let
avatarUrl
=
res
.
detail
.
avatarUrl
let
avatar_file
=
{
extname
:
avatarUrl
.
split
(
'
.
'
)[
avatarUrl
.
split
(
'
.
'
).
length
-
1
],
name
:
''
,
url
:
''
}
//上传到服务器
let
cloudPath
=
this
.
userInfo
.
_id
+
''
+
Date
.
now
()
avatar_file
.
name
=
cloudPath
try
{
uni
.
showLoading
({
title
:
"
更新中
"
,
mask
:
true
});
let
{
fileID
}
=
await
uniCloud
.
uploadFile
({
filePath
:
avatarUrl
,
cloudPath
,
fileType
:
"
image
"
});
avatar_file
.
url
=
fileID
uni
.
hideLoading
()
}
catch
(
e
){
console
.
error
(
e
);
}
console
.
log
(
'
avatar_file
'
,
avatar_file
);
this
.
setAvatarFile
(
avatar_file
)
},
uploadAvatarImg
(
res
)
{
// #ifdef MP-WEIXIN
return
false
// 微信小程序走 bindchooseavatar方法
// #endif
// #ifndef MP-WEIXIN
if
(
!
this
.
hasLogin
){
return
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/login/login-withoutpwd
'
})
}
const
crop
=
{
quality
:
100
,
width
:
600
,
height
:
600
,
resize
:
true
};
uni
.
chooseImage
({
count
:
1
,
crop
,
success
:
async
(
res
)
=>
{
let
tempFile
=
res
.
tempFiles
[
0
],
avatar_file
=
{
// #ifdef H5
extname
:
tempFile
.
name
.
split
(
'
.
'
)[
tempFile
.
name
.
split
(
'
.
'
).
length
-
1
],
// #endif
// #ifndef H5
extname
:
tempFile
.
path
.
split
(
'
.
'
)[
tempFile
.
path
.
split
(
'
.
'
).
length
-
1
]
// #endif
},
filePath
=
res
.
tempFilePaths
[
0
]
//非app端剪裁头像,app端用内置的原生裁剪
// #ifndef APP-PLUS
filePath
=
await
new
Promise
((
callback
)
=>
{
// #ifdef H5
if
(
!
this
.
isPC
)
{
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage?path=
'
+
filePath
+
`&options=
${
JSON
.
stringify
(
crop
)}
`
,
animationType
:
"
fade-in
"
,
events
:
{
success
:
url
=>
{
callback
(
url
)
}
},
complete
(
e
)
{
// console.log(e);
}
});
}
// #endif
})
// #endif
let
cloudPath
=
this
.
userInfo
.
_id
+
''
+
Date
.
now
()
avatar_file
.
name
=
cloudPath
uni
.
showLoading
({
title
:
"
更新中
"
,
mask
:
true
});
let
{
fileID
}
=
await
uniCloud
.
uploadFile
({
filePath
,
cloudPath
,
fileType
:
"
image
"
});
avatar_file
.
url
=
fileID
uni
.
hideLoading
()
this
.
setAvatarFile
(
avatar_file
)
}
})
// #endif
}
}
}
</
script
>
<
style
>
/* #ifndef APP-NVUE */
.box
{
overflow
:
hidden
;
}
/* #endif */
.box
{
padding
:
0
;
}
<
style
>
/* #ifndef APP-NVUE */
.box
{
overflow
:
hidden
;
}
/* #endif */
.box
{
padding
:
0
;
}
.chooseAvatar
{
/* #ifndef APP-NVUE */
display
:
inline-block
;
display
:
inline-block
;
box-sizing
:
border-box
;
/* #endif */
border-radius
:
10px
;
text-align
:
center
;
padding
:
1px
;
}
.showBorder
{
border
:
solid
1px
#ddd
;
text-align
:
center
;
padding
:
1px
;
}
.showBorder
{
border
:
solid
1px
#ddd
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录