Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦想橡皮擦
uni-starter
提交
da48954e
U
uni-starter
项目概览
梦想橡皮擦
/
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看板
提交
da48954e
编写于
4月 30, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新文章阅读记录的数据表为read-news-log
上级
d8a3338e
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
68 addition
and
437 deletion
+68
-437
pages.json
pages.json
+1
-1
pages/list/detail.vue
pages/list/detail.vue
+21
-30
pages/ucenter/read-news-log/read-news-log.vue
pages/ucenter/read-news-log/read-news-log.vue
+9
-5
pages/ucenter/ucenter.vue
pages/ucenter/ucenter.vue
+1
-1
uniCloud-aliyun/cloudfunctions/user-center/index.js
uniCloud-aliyun/cloudfunctions/user-center/index.js
+1
-2
uniCloud-aliyun/database/read-news-log.schema.json
uniCloud-aliyun/database/read-news-log.schema.json
+35
-0
uni_modules/read-news-log/changelog.md
uni_modules/read-news-log/changelog.md
+0
-0
uni_modules/read-news-log/js_sdk/validator/opendb-news-favorite.js
...es/read-news-log/js_sdk/validator/opendb-news-favorite.js
+0
-0
uni_modules/read-news-log/package.json
uni_modules/read-news-log/package.json
+0
-0
uni_modules/read-news-log/readme.md
uni_modules/read-news-log/readme.md
+0
-0
uni_modules/uni-id-users/js_sdk/validator/uni-id-users.js
uni_modules/uni-id-users/js_sdk/validator/uni-id-users.js
+0
-73
uni_modules/uni-id-users/package.json
uni_modules/uni-id-users/package.json
+0
-91
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
+0
-234
未找到文件。
pages.json
浏览文件 @
da48954e
...
...
@@ -180,7 +180,7 @@
},
{
"path"
:
"
uni_modules/uni-news-favorite/pages/uni-news-favorite/list
"
,
"path"
:
"
pages/ucenter/read-news-log/read-news-log
"
,
"style"
:
{
"navigationBarTitleText"
:
"阅读记录"
,
"enablePullDownRefresh"
:
false
...
...
pages/list/detail.vue
浏览文件 @
da48954e
...
...
@@ -50,7 +50,7 @@
import
uniShare
from
'
uni_modules/uni-share/js_sdk/uni-share.js
'
;
const
db
=
uniCloud
.
database
();
const
newsFavoriteTable
=
db
.
collection
(
'
opendb-news-favorite
'
)
const
readNewsLog
=
db
.
collection
(
'
read-news-log
'
)
import
{
mapGetters
}
from
'
vuex
'
;
...
...
@@ -114,35 +114,26 @@
},
methods
:
{
setFavorite
()
{
if
(
!
this
.
hasLogin
)
return
newsFavoriteTable
.
where
({
article_id
:
this
.
id
,
user_id
:
this
.
userInfo
.
_id
})
.
get
()
.
then
(
res
=>
{
let
value
=
{
article_id
:
this
.
id
,
article_title
:
this
.
title
,
user_id
:
this
.
userInfo
.
_id
,
update_date
:
Date
.
now
()
}
if
(
res
.
result
.
data
.
length
==
0
)
{
return
newsFavoriteTable
.
add
(
value
)
}
else
{
return
newsFavoriteTable
.
where
({
article_id
:
this
.
id
,
user_id
:
this
.
userInfo
.
_id
})
.
update
(
value
)
}
})
.
then
(
res
=>
{
// console.log(res);
})
.
catch
(
err
=>
{
console
.
log
(
err
);
})
if
(
!
this
.
hasLogin
){
return
console
.
log
(
'
未登陆用户
'
);
}
let
article_id
=
this
.
id
,
last_time
=
Date
.
now
();
console
.
log
({
article_id
,
last_time
});
readNewsLog
.
where
(
`"article_id" == "
${
article_id
}
" && "user_id"==$env.uid`
)
.
update
({
last_time
})
.
then
(({
result
:{
updated
}})
=>
{
console
.
log
(
'
updated
'
,
updated
);
if
(
!
updated
)
{
readNewsLog
.
add
({
article_id
}).
then
(
e
=>
{
console
.
log
(
e
);
}).
catch
(
err
=>
{
console
.
log
(
err
);
})
}
}).
catch
(
err
=>
{
console
.
log
(
err
);
})
},
loadData
(
data
)
{
//如果上一页未传递标题过来(如搜索直达详情),则从新闻详情中读取标题
...
...
uni_modules/uni-news-favorite/pages/uni-news-favorite/list
.vue
→
pages/ucenter/read-news-log/read-news-log
.vue
浏览文件 @
da48954e
<
template
>
<view
class=
"container"
>
<unicloud-db
ref=
"udb"
v-slot:default=
"
{data, pagination, loading, hasMore, error}" where="user_id == $env.uid"
orderby="update_date desc" collection="opendb-news-favorite" @load="isLoading == false" @error="isLoading == false" :page-size="10">
orderby="last_time desc" collection="read-news-log,opendb-news-articles" @load="isLoading == false" @error="isLoading == false"
field="article_id.title,article_id._id,last_time" :page-size="10">
<view
v-if=
"data && data.length"
>
<uni-list>
<uni-list-item
v-for=
"(item, index) in data"
:key=
"index"
:clickable=
"true"
@
click=
"handleItemClick(item)"
>
<view
slot=
"body"
>
<text>
{{
item
.
article_
title
||
item
.
article_id
}}
</text>
<uni-dateformat
class=
"article-date"
:date=
"item.
update_dat
e"
format=
"yyyy-MM-dd hh:mm"
<view
slot=
"body"
>
<text>
{{
item
.
article_
id
[
0
].
title
}}
</text>
<uni-dateformat
class=
"article-date"
:date=
"item.
last_tim
e"
format=
"yyyy-MM-dd hh:mm"
:threshold=
"[0, 0]"
/>
</view>
</uni-list-item>
</uni-list>
</view>
<view
v-else
>
<uni-load-more
v-if=
"!loading"
status=
"noMore"
></uni-load-more>
</view>
<uni-load-more
v-if=
"data.length>10"
:status=
"loading?'loading':(hasMore ? 'more' : 'noMore')"
></uni-load-more>
</unicloud-db>
...
...
@@ -48,7 +52,7 @@
},
handleItemClick
(
item
)
{
uni
.
navigateTo
({
url
:
'
/pages/list/detail?id=
'
+
item
.
article_id
+
'
&title=
'
+
(
item
.
article_title
||
''
)
url
:
'
/pages/list/detail?id=
'
+
item
.
article_id
[
0
].
_id
+
'
&title=
'
+
item
.
article_id
[
0
].
title
})
}
}
...
...
pages/ucenter/ucenter.vue
浏览文件 @
da48954e
...
...
@@ -70,7 +70,7 @@
//#endif
{
title
:
'
阅读过的文章
'
,
to
:
'
/
uni_modules/uni-news-favorite/pages/uni-news-favorite/list
'
,
to
:
'
/
pages/ucenter/read-news-log/read-news-log
'
,
},
{
title
:
'
我的积分
'
,
...
...
uniCloud-aliyun/cloudfunctions/user-center/index.js
浏览文件 @
da48954e
...
...
@@ -133,7 +133,7 @@ exports.main = async (event, context) => {
break
;
case
'
register
'
:
let
{
username
,
password
,
gender
,
nickname
username
,
password
,
nickname
}
=
params
if
(
/^1
\d{10}
$/
.
test
(
username
))
{
return
{
...
...
@@ -150,7 +150,6 @@ exports.main = async (event, context) => {
res
=
await
uniID
.
register
({
username
,
password
,
gender
,
nickname
});
if
(
res
.
code
===
0
)
{
...
...
uniCloud-aliyun/database/read-news-log.schema.json
0 → 100644
浏览文件 @
da48954e
{
"bsonType"
:
"object"
,
"required"
:
[
"user_id"
,
"article_id"
],
"permission"
:
{
"read"
:
"doc.uid == auth.uid"
,
"create"
:
"auth.uid != null"
,
"update"
:
"doc.uid == auth.uid"
//
"delete"
:
"doc.uid == auth.uid"
},
"properties"
:
{
"_id"
:
{
"description"
:
"ID,系统自动生成"
},
"article_id"
:
{
"bsonType"
:
"string"
,
"description"
:
"文章id,参考opendb-news-articles表"
,
"foreignKey"
:
"opendb-news-articles._id"
},
"user_id"
:
{
"bsonType"
:
"string"
,
"description"
:
"收藏者id,参考uni-id-users表"
,
"forceDefaultValue"
:
{
"$env"
:
"uid"
},
"foreignKey"
:
"uni-id-users._id"
},
"last_time"
:
{
//设计策略是多次看同一个文章只做一次记录,重复看的文章时间更新为当前时间
"bsonType"
:
"timestamp"
,
"description"
:
"最后一次看的时间"
,
"defaultValue"
:
{
"$env"
:
"now"
}
}
}
}
\ No newline at end of file
uni_modules/
uni-news-favorite
/changelog.md
→
uni_modules/
read-news-log
/changelog.md
浏览文件 @
da48954e
文件已移动
uni_modules/
uni-news-favorite
/js_sdk/validator/opendb-news-favorite.js
→
uni_modules/
read-news-log
/js_sdk/validator/opendb-news-favorite.js
浏览文件 @
da48954e
文件已移动
uni_modules/
uni-news-favorite
/package.json
→
uni_modules/
read-news-log
/package.json
浏览文件 @
da48954e
文件已移动
uni_modules/
uni-news-favorite
/readme.md
→
uni_modules/
read-news-log
/readme.md
浏览文件 @
da48954e
文件已移动
uni_modules/uni-id-users/js_sdk/validator/uni-id-users.js
已删除
100644 → 0
浏览文件 @
d8a3338e
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const
validator
=
{
"
avatar
"
:
{
"
rules
"
:
[{
"
format
"
:
"
string
"
}],
"
label
"
:
"
头像地址
"
},
"
gender
"
:
{
"
rules
"
:
[{
"
format
"
:
"
int
"
},
{
"
range
"
:
[{
"
text
"
:
"
未知
"
,
"
value
"
:
0
},
{
"
text
"
:
"
男
"
,
"
value
"
:
1
},
{
"
text
"
:
"
女
"
,
"
value
"
:
2
}
]
}
],
"
defaultValue
"
:
0
,
"
label
"
:
"
性别
"
},
// "mobile": {
// "rules": [{
// "format": "string"
// },
// {
// "pattern": "^\\+?[0-9-]{3,20}$"
// }
// ],
// "label": "手机号码"
// },
"
nickname
"
:
{
"
rules
"
:
[{
required
:
true
,
errorMessage
:
'
请输入昵称
'
,
},
{
minLength
:
3
,
maxLength
:
10
,
errorMessage
:
'
昵称长度在 {minLength} 到 {maxLength} 个字符
'
,
}
],
"
label
"
:
"
昵称
"
}
}
const
enumConverter
=
{
"
gender_valuetotext
"
:
{
"
0
"
:
"
未知
"
,
"
1
"
:
"
男
"
,
"
2
"
:
"
女
"
}
}
export
{
validator
,
enumConverter
}
uni_modules/uni-id-users/package.json
已删除
100644 → 0
浏览文件 @
d8a3338e
{
"id"
:
"uni-id-users"
,
"displayName"
:
"uni-id-users"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"keywords"
:
[
"uni-id-users"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.1.0"
},
"dcloudext"
:
{
"category"
:
[
"uniCloud"
,
"Admin插件"
],
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[
"uni-dateformat"
,
"uni-badge"
,
"uni-icons"
,
"uni-load-more"
,
"uni-link"
,
"uni-forms"
,
"uni-group"
,
"uni-list"
,
"uni-fab"
,
"uni-datetime-picker"
,
"uni-data-picker"
,
"uni-file-picker"
,
"uni-easyinput"
,
"uni-data-checkbox"
],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"y"
,
"aliyun"
:
"y"
},
"client"
:
{
"App"
:
{
"app-vue"
:
"y"
,
"app-nvue"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"y"
,
"Android Browser"
:
"y"
,
"微信浏览器(Android)"
:
"y"
,
"QQ浏览器(Android)"
:
"y"
},
"H5-pc"
:
{
"Chrome"
:
"y"
,
"IE"
:
"u"
,
"Edge"
:
"y"
,
"Firefox"
:
"y"
,
"Safari"
:
"y"
},
"小程序"
:
{
"微信"
:
"y"
,
"阿里"
:
"y"
,
"百度"
:
"y"
,
"字节跳动"
:
"y"
,
"QQ"
:
"y"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
已删除
100644 → 0
浏览文件 @
d8a3338e
<
template
>
<view
class=
"uni-container"
>
<uni-forms
ref=
"form"
:value=
"formData"
:rules=
"rules"
validate-trigger=
"submit"
err-show-type=
"toast"
>
<uni-forms-item
name=
"avatar"
>
<template>
<view
class=
"avatar-box"
>
<image
class=
"avatar-img"
:src=
"formData.avatar || '/static/uni-center/logo.png'"
@
click=
"chooseImg"
mode=
"aspectFill"
></image>
</view>
</
template
>
</uni-forms-item>
<!-- <uni-forms-item name="gender" label="性别" required>
<uni-data-checkbox v-model="formData.gender" :localdata="formOptions.gender_localdata" />
</uni-forms-item> -->
<uni-forms-item
name=
"mobile"
label=
"手机号码"
v-if=
"formData.mobile"
>
<uni-easyinput
placeholder=
"手机号码"
:disabled=
"true"
v-model=
"formData.mobile"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"nickname"
label=
"昵称"
required
>
<uni-easyinput
placeholder=
"用户昵称"
v-model=
"formData.nickname"
trim=
"both"
/>
</uni-forms-item>
<view
class=
"uni-button-group"
>
<button
type=
"primary"
class=
"uni-button"
@
click=
"submit"
>
修改
</button>
</view>
</uni-forms>
</view>
</template>
<
script
>
import
{
validator
}
from
'
../../js_sdk/validator/uni-id-users.js
'
;
import
{
mapMutations
,
mapGetters
}
from
'
vuex
'
;
const
db
=
uniCloud
.
database
();
const
dbCollectionName
=
'
uni-id-users
'
;
function
getValidator
(
fields
)
{
let
reuslt
=
{}
for
(
let
key
in
validator
)
{
if
(
fields
.
indexOf
(
key
)
>
-
1
)
{
reuslt
[
key
]
=
validator
[
key
]
}
}
return
reuslt
}
export
default
{
data
()
{
return
{
formData
:
{
"
avatar
"
:
""
,
"
gender
"
:
''
,
"
mobile
"
:
""
,
"
nickname
"
:
""
},
formOptions
:
{
"
gender_localdata
"
:
[{
"
text
"
:
"
未知
"
,
"
value
"
:
0
},{
"
text
"
:
"
男
"
,
"
value
"
:
1
},
{
"
text
"
:
"
女
"
,
"
value
"
:
2
}
]
},
rules
:
{
...
getValidator
([
"
avatar
"
,
"
gender
"
,
"
nickname
"
])
}
}
},
computed
:{
...
mapGetters
({
userInfo
:
'
user/info
'
})
},
onLoad
(
e
)
{
let
id
=
uni
.
getStorageSync
(
'
uni_id_uid
'
)
||
this
.
userInfo
.
_id
;
this
.
formDataId
=
id
this
.
getDetail
(
id
)
},
onReady
()
{
this
.
$refs
.
form
.
setRules
(
this
.
rules
)
},
methods
:
{
...
mapMutations
({
setUserInfo
:
'
user/login
'
}),
// 选择图片
chooseImg
(){
uni
.
chooseImage
({
count
:
1
,
success
:(
res
)
=>
{
// 头像剪裁尺寸
let
options
=
{
width
:
600
,
height
:
600
}
// 剪裁并上传头像
uni
.
navigateTo
({
url
:
'
/pages/ucenter/userinfo/uploadCutImageToUnicloud?path=
'
+
res
.
tempFilePaths
[
0
]
+
`&options=
${
JSON
.
stringify
(
options
)}
`
,
animationType
:
"
fade-in
"
,
events
:{
uploadAvatarAfter
:({
url
})
=>
{
this
.
formData
.
avatar
=
url
;
this
.
submitForm
({
avatar
:
url
});
}
}
});
}
})
},
/**
* 触发表单提交
*/
submit
()
{
uni
.
showLoading
({
mask
:
true
})
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
console
.
log
(
res
);
this
.
submitForm
(
res
)
}).
catch
((
errors
)
=>
{
uni
.
hideLoading
()
})
},
submitForm
(
value
)
{
// 使用 clientDB 提交数据
db
.
collection
(
dbCollectionName
).
doc
(
this
.
formDataId
).
update
(
value
).
then
((
res
)
=>
{
uni
.
showToast
({
icon
:
'
none
'
,
title
:
'
修改成功
'
})
this
.
setUserInfo
(
value
);
setTimeout
(()
=>
uni
.
navigateBack
(),
500
)
}).
catch
((
err
)
=>
{
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail
(
id
)
{
uni
.
showLoading
({
mask
:
true
})
db
.
collection
(
dbCollectionName
).
doc
(
id
).
field
(
'
avatar,gender,mobile,nickname
'
).
get
().
then
((
res
)
=>
{
const
data
=
res
.
result
.
data
[
0
]
if
(
data
)
{
this
.
formData
=
data
}
}).
catch
((
err
)
=>
{
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
})
}
}
}
</
script
>
<
style
>
.uni-container
{
padding
:
15px
;
}
.uni-input-border
,
.uni-textarea-border
{
width
:
100%
;
font-size
:
14px
;
color
:
#666
;
border
:
1px
#e5e5e5
solid
;
border-radius
:
5px
;
box-sizing
:
border-box
;
}
.uni-input-border
{
padding
:
0
10px
;
height
:
35px
;
}
.uni-textarea-border
{
padding
:
10px
;
height
:
80px
;
}
.uni-button-group
{
margin-top
:
50px
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
}
.uni-button
{
width
:
184px
;
padding
:
12px
20px
;
font-size
:
14px
;
border-radius
:
4px
;
line-height
:
1
;
margin
:
0
;
}
.avatar-box
{
width
:
700
rpx
;
height
:
200
rpx
;
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
justify-content
:
center
;
align-items
:
center
;
}
.avatar-img
{
width
:
150
rpx
;
height
:
150
rpx
;
border-radius
:
75
rpx
;
border
:
#F8F8F8
solid
3px
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录