Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
萌新之路
uni-starter
提交
085b1384
U
uni-starter
项目概览
萌新之路
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
1
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,发现更多精彩内容 >>
提交
085b1384
编写于
4月 21, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/dcloud/base-app
上级
5be43ca2
8673038e
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
677 addition
and
62 deletion
+677
-62
pages.json
pages.json
+7
-0
pages/list/detail.vue
pages/list/detail.vue
+26
-5
pages/ucenter/ucenter.vue
pages/ucenter/ucenter.vue
+59
-51
uniCloud-aliyun/database/opendb-news-favorite.schema.json
uniCloud-aliyun/database/opendb-news-favorite.schema.json
+6
-2
uniCloud-aliyun/database/uni-id-scores.schema.json
uniCloud-aliyun/database/uni-id-scores.schema.json
+7
-4
uni_modules/uni-news-favorite/changelog.md
uni_modules/uni-news-favorite/changelog.md
+0
-0
uni_modules/uni-news-favorite/js_sdk/validator/opendb-news-favorite.js
...ni-news-favorite/js_sdk/validator/opendb-news-favorite.js
+28
-0
uni_modules/uni-news-favorite/package.json
uni_modules/uni-news-favorite/package.json
+89
-0
uni_modules/uni-news-favorite/pages/uni-news-favorite/add.vue
...modules/uni-news-favorite/pages/uni-news-favorite/add.vue
+129
-0
uni_modules/uni-news-favorite/pages/uni-news-favorite/detail.vue
...ules/uni-news-favorite/pages/uni-news-favorite/detail.vue
+101
-0
uni_modules/uni-news-favorite/pages/uni-news-favorite/edit.vue
...odules/uni-news-favorite/pages/uni-news-favorite/edit.vue
+156
-0
uni_modules/uni-news-favorite/pages/uni-news-favorite/list.vue
...odules/uni-news-favorite/pages/uni-news-favorite/list.vue
+68
-0
uni_modules/uni-news-favorite/readme.md
uni_modules/uni-news-favorite/readme.md
+1
-0
未找到文件。
pages.json
浏览文件 @
085b1384
...
@@ -209,6 +209,13 @@
...
@@ -209,6 +209,13 @@
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
},
{
"path"
:
"uni_modules/uni-news-favorite/pages/uni-news-favorite/list"
,
"style"
:{
"navigationBarTitleText"
:
"阅读记录"
,
"enablePullDownRefresh"
:
false
}
}
}
],
],
"globalStyle"
:
{
"globalStyle"
:
{
...
...
pages/list/detail.vue
浏览文件 @
085b1384
...
@@ -49,6 +49,10 @@
...
@@ -49,6 +49,10 @@
import
baseappConfig
from
'
@/baseapp.config.js
'
;
import
baseappConfig
from
'
@/baseapp.config.js
'
;
import
uniShare
from
'
uni_modules/uni-share/js_sdk/uni-share.js
'
;
import
uniShare
from
'
uni_modules/uni-share/js_sdk/uni-share.js
'
;
import
uParse
from
'
@/components/u-parse/parse.vue
'
;
import
uParse
from
'
@/components/u-parse/parse.vue
'
;
const
db
=
uniCloud
.
database
();
const
dbCollectionName
=
'
opendb-news-favorite
'
;
import
{
mapGetters
}
from
'
vuex
'
;
export
default
{
export
default
{
components
:
{
components
:
{
uParse
uParse
...
@@ -72,7 +76,10 @@
...
@@ -72,7 +76,10 @@
//查询条件 ,更多详见 :https://uniapp.dcloud.net.cn/uniCloud/unicloud-db?id=jsquery
//查询条件 ,更多详见 :https://uniapp.dcloud.net.cn/uniCloud/unicloud-db?id=jsquery
where
()
{
where
()
{
return
`_id =="
${
this
.
id
}
"`
return
`_id =="
${
this
.
id
}
"`
}
},
...
mapGetters
({
'
userInfo
'
:
'
user/info
'
})
},
},
onLoad
(
event
)
{
onLoad
(
event
)
{
//获取真实新闻id,通常 id 来自上一个页面
//获取真实新闻id,通常 id 来自上一个页面
...
@@ -104,13 +111,27 @@
...
@@ -104,13 +111,27 @@
}
}
},
},
methods
:
{
methods
:
{
setFavorite
(){
if
(
!
this
.
userInfo
)
return
db
.
collection
(
dbCollectionName
).
add
({
article_id
:
this
.
id
,
article_title
:
this
.
title
,
user_id
:
this
.
userInfo
.
_id
}).
then
((
res
)
=>
{
console
.
log
(
res
);
}).
catch
(
err
=>
{
console
.
log
(
err
);
})
},
loadData
(
data
)
{
loadData
(
data
)
{
//如果上一页未传递标题过来(如搜索直达详情),则从新闻详情中读取标题
//如果上一页未传递标题过来(如搜索直达详情),则从新闻详情中读取标题
if
(
this
.
title
==
''
&&
data
[
0
].
title
)
{
if
(
this
.
title
==
''
&&
data
[
0
].
title
)
{
this
.
title
=
data
[
0
].
title
this
.
title
=
data
[
0
].
title
uni
.
setNavigationBarTitle
({
uni
.
setNavigationBarTitle
({
title
:
data
[
0
].
title
title
:
data
[
0
].
title
})
});
this
.
setFavorite
();
}
}
},
},
/**
/**
...
...
pages/ucenter/ucenter.vue
浏览文件 @
085b1384
...
@@ -70,12 +70,13 @@
...
@@ -70,12 +70,13 @@
// #endif
// #endif
{
{
title
:
'
阅读过的文章
'
,
title
:
'
阅读过的文章
'
,
to
:
'
'
to
:
'
/uni_modules/uni-news-favorite/pages/uni-news-favorite/list
'
,
},
{
},
{
title
:
'
我的积分
'
,
title
:
'
我的积分
'
,
to
:
''
,
to
:
''
,
event
:
'
getScore
'
event
:
'
getScore
'
}],
}
],
[{
[{
title
:
'
问题与反馈
'
,
title
:
'
问题与反馈
'
,
to
:
'
/uni_modules/uni-feedback/pages/opendb-feedback/list
'
// /pages/ucenter/uni-feedback/uni-feedback uni_modules/uni-feedback/pages/opendb-feedback/list
to
:
'
/uni_modules/uni-feedback/pages/opendb-feedback/list
'
// /pages/ucenter/uni-feedback/uni-feedback uni_modules/uni-feedback/pages/opendb-feedback/list
...
@@ -88,14 +89,12 @@
...
@@ -88,14 +89,12 @@
},
},
onLoad
()
{
onLoad
()
{
//#ifdef APP-PLUS
//#ifdef APP-PLUS
this
.
ucenterList
[
this
.
ucenterList
.
length
-
1
].
unshift
(
this
.
ucenterList
[
this
.
ucenterList
.
length
-
1
].
unshift
({
{
title
:
'
检查更新
'
,
title
:
'
检查更新
'
,
rightText
:
this
.
appVersion
.
version
+
'
-
'
+
this
.
appVersion
.
versionCode
,
rightText
:
this
.
appVersion
.
version
+
'
-
'
+
this
.
appVersion
.
versionCode
,
event
:
'
checkVersion
'
,
event
:
'
checkVersion
'
,
showBadge
:
this
.
appVersion
.
hasNew
showBadge
:
this
.
appVersion
.
hasNew
}
})
)
//#endif
//#endif
},
},
computed
:
{
computed
:
{
...
@@ -104,7 +103,8 @@
...
@@ -104,7 +103,8 @@
login
:
'
user/hasLogin
'
login
:
'
user/hasLogin
'
})
})
// #ifdef APP-PLUS
// #ifdef APP-PLUS
,
appVersion
()
{
,
appVersion
()
{
return
getApp
().
appVersion
return
getApp
().
appVersion
}
}
// #endif
// #endif
...
@@ -173,12 +173,20 @@
...
@@ -173,12 +173,20 @@
* 获取积分信息
* 获取积分信息
*/
*/
getScore
()
{
getScore
()
{
if
(
!
this
.
userInfo
)
return
uni
.
showToast
({
title
:
'
请登录后查看积分
'
,
icon
:
'
none
'
});
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
})
})
db
.
collection
(
dbCollectionName
).
field
(
'
score,balance
'
).
get
().
then
((
res
)
=>
{
db
.
collection
(
dbCollectionName
).
field
(
'
score,balance
'
).
get
().
then
((
res
)
=>
{
const
data
=
res
.
result
.
data
[
0
]
const
data
=
res
.
result
.
data
[
0
];
console
.
log
(
data
);
uni
.
showToast
({
title
:
'
当前积分为
'
+
data
.
balance
,
icon
:
'
none
'
});
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
showModal
({
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
content
:
err
.
message
||
'
请求服务失败
'
,
...
...
uniCloud-aliyun/database/opendb-news-favorite.schema.json
浏览文件 @
085b1384
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"bsonType"
:
"object"
,
"bsonType"
:
"object"
,
"required"
:
[
"user_id"
,
"article_id"
],
"required"
:
[
"user_id"
,
"article_id"
],
"permission"
:
{
"permission"
:
{
"read"
:
true
,
"read"
:
"doc.uid == auth.uid"
,
"create"
:
"auth.uid != null"
,
"create"
:
"auth.uid != null"
,
"update"
:
false
,
"update"
:
false
,
"delete"
:
"doc.uid == auth.uid"
"delete"
:
"doc.uid == auth.uid"
...
@@ -16,6 +16,10 @@
...
@@ -16,6 +16,10 @@
"description"
:
"文章id,参考opendb-news-articles表"
,
"description"
:
"文章id,参考opendb-news-articles表"
,
"foreignKey"
:
"opendb-news-articles._id"
"foreignKey"
:
"opendb-news-articles._id"
},
},
"article_title"
:{
"bsonType"
:
"string"
,
"description"
:
"文章标题"
},
"user_id"
:
{
"user_id"
:
{
"bsonType"
:
"string"
,
"bsonType"
:
"string"
,
"description"
:
"收藏者id,参考uni-id-users表"
,
"description"
:
"收藏者id,参考uni-id-users表"
,
...
...
uniCloud-aliyun/database/uni-id-scores.schema.json
浏览文件 @
085b1384
{
{
"bsonType"
:
"object"
,
"bsonType"
:
"object"
,
"required"
:
[
"user_id"
,
"score"
,
"balance"
],
"required"
:
[
"user_id"
,
"score"
,
"balance"
],
"permission"
:{
"permission"
:
{
"read"
:
true
"read"
:
true
,
"create"
:
true
,
"update"
:
"doc._id == auth.uid"
,
"delete"
:
false
},
},
"properties"
:
{
"properties"
:
{
"_id"
:
{
"_id"
:
{
...
...
uni_modules/uni-news-favorite/changelog.md
0 → 100644
浏览文件 @
085b1384
uni_modules/uni-news-favorite/js_sdk/validator/opendb-news-favorite.js
0 → 100644
浏览文件 @
085b1384
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const
validator
=
{
"
article_id
"
:
{
"
rules
"
:
[
{
"
required
"
:
true
},
{
"
format
"
:
"
string
"
}
]
},
"
create_date
"
:
{
"
rules
"
:
[
{
"
format
"
:
"
timestamp
"
}
]
}
}
const
enumConverter
=
{}
export
{
validator
,
enumConverter
}
uni_modules/uni-news-favorite/package.json
0 → 100644
浏览文件 @
085b1384
{
"id"
:
"opendb-news-favorite"
,
"displayName"
:
"opendb-news-favorite"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"keywords"
:
[
"opendb-news-favorite"
],
"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-link"
,
"uni-load-more"
,
"uni-forms"
,
"uni-group"
,
"uni-list"
,
"uni-fab"
,
"uni-datetime-picker"
,
"uni-file-picker"
,
"uni-easyinput"
],
"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-news-favorite/pages/uni-news-favorite/add.vue
0 → 100644
浏览文件 @
085b1384
<
template
>
<view
class=
"uni-container"
>
<uni-forms
ref=
"form"
:value=
"formData"
validate-trigger=
"submit"
err-show-type=
"toast"
>
<uni-forms-item
name=
"article_id"
label=
""
required
>
<uni-easyinput
placeholder=
"文章id,参考opendb-news-articles表"
v-model=
"formData.article_id"
/>
</uni-forms-item>
<uni-forms-item
name=
"create_date"
label=
""
>
<uni-datetime-picker
return-type=
"timestamp"
:value=
"formData.create_date"
/>
</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/opendb-news-favorite.js
'
;
const
db
=
uniCloud
.
database
();
const
dbCollectionName
=
'
opendb-news-favorite
'
;
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
:
{
"
article_id
"
:
""
,
"
create_date
"
:
null
},
formOptions
:
{},
rules
:
{
...
getValidator
([
"
article_id
"
,
"
create_date
"
])
}
}
},
onReady
()
{
this
.
$refs
.
form
.
setRules
(
this
.
rules
)
},
methods
:
{
/**
* 触发表单提交
*/
submit
()
{
uni
.
showLoading
({
mask
:
true
})
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
this
.
submitForm
(
res
)
}).
catch
((
errors
)
=>
{
uni
.
hideLoading
()
})
},
submitForm
(
value
)
{
// 使用 clientDB 提交数据
db
.
collection
(
dbCollectionName
).
add
(
value
).
then
((
res
)
=>
{
uni
.
showToast
({
icon
:
'
none
'
,
title
:
'
新增成功
'
})
this
.
getOpenerEventChannel
().
emit
(
'
refreshData
'
)
setTimeout
(()
=>
uni
.
navigateBack
(),
500
)
}).
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
;
}
.uni-button
{
width
:
184px
;
padding
:
12px
20px
;
font-size
:
14px
;
border-radius
:
4px
;
line-height
:
1
;
margin
:
0
;
}
</
style
>
uni_modules/uni-news-favorite/pages/uni-news-favorite/detail.vue
0 → 100644
浏览文件 @
085b1384
<
template
>
<view
class=
"container"
>
<unicloud-db
ref=
"udb"
v-slot:default=
"
{data, loading, error, options}" :options="options" collection="opendb-news-favorite" field="article_id,create_date" :where="queryWhere" :getone="true" :manual="true">
<view
v-if=
"error"
>
{{
error
.
message
}}
</view>
<view
v-else-if=
"loading"
>
<uni-load-more
:contentText=
"loadMore"
status=
"loading"
></uni-load-more>
</view>
<view
v-else-if=
"data"
>
<view>
<text>
article_id:
</text>
<text>
{{
data
.
article_id
}}
</text>
</view>
<view>
<text>
create_date:
</text>
<uni-dateformat
:date=
"data.create_date"
:threshold=
"[0, 0]"
/>
</view>
</view>
</unicloud-db>
<view
class=
"btns"
>
<button
type=
"primary"
@
click=
"handleUpdate"
>
修改
</button>
<button
type=
"warn"
class=
"btn-delete"
@
click=
"handleDelete"
>
删除
</button>
</view>
</view>
</
template
>
<
script
>
// 由schema2code生成,包含校验规则和enum静态数据
import
{
enumConverter
}
from
'
../../js_sdk/validator/opendb-news-favorite.js
'
;
export
default
{
data
()
{
return
{
queryWhere
:
''
,
loadMore
:
{
contentdown
:
''
,
contentrefresh
:
''
,
contentnomore
:
''
},
options
:
{
// 将scheme enum 属性静态数据中的value转成text
...
enumConverter
}
}
},
onLoad
(
e
)
{
this
.
_id
=
e
.
id
},
onReady
()
{
if
(
this
.
_id
)
{
this
.
queryWhere
=
'
_id=="
'
+
this
.
_id
+
'
"
'
}
},
methods
:
{
handleUpdate
()
{
// 打开修改页面
uni
.
navigateTo
({
url
:
'
./edit?id=
'
+
this
.
_id
,
events
:
{
// 监听修改页面成功修改数据后, 刷新当前页面数据
refreshData
:
()
=>
{
this
.
$refs
.
udb
.
loadData
({
clear
:
true
})
}
}
})
},
handleDelete
()
{
this
.
$refs
.
udb
.
remove
(
this
.
_id
,
{
success
:
(
res
)
=>
{
// 删除数据成功后跳转到list页面
uni
.
navigateTo
({
url
:
'
./list
'
})
}
})
}
}
}
</
script
>
<
style
>
.container
{
padding
:
10px
;
}
.btns
{
margin-top
:
10px
;
display
:
flex
;
flex-direction
:
row
;
}
.btns
button
{
flex
:
1
;
}
.btn-delete
{
margin-left
:
10px
;
}
</
style
>
uni_modules/uni-news-favorite/pages/uni-news-favorite/edit.vue
0 → 100644
浏览文件 @
085b1384
<
template
>
<view
class=
"uni-container"
>
<uni-forms
ref=
"form"
:value=
"formData"
validate-trigger=
"submit"
err-show-type=
"toast"
>
<uni-forms-item
name=
"article_id"
label=
""
required
>
<uni-easyinput
placeholder=
"文章id,参考opendb-news-articles表"
v-model=
"formData.article_id"
/>
</uni-forms-item>
<uni-forms-item
name=
"create_date"
label=
""
>
<uni-datetime-picker
return-type=
"timestamp"
:value=
"formData.create_date"
/>
</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/opendb-news-favorite.js
'
;
const
db
=
uniCloud
.
database
();
const
dbCollectionName
=
'
opendb-news-favorite
'
;
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
:
{
"
article_id
"
:
""
,
"
create_date
"
:
null
},
formOptions
:
{},
rules
:
{
...
getValidator
([
"
article_id
"
,
"
create_date
"
])
}
}
},
onLoad
(
e
)
{
const
id
=
e
.
id
this
.
formDataId
=
id
this
.
getDetail
(
id
)
},
onReady
()
{
this
.
$refs
.
form
.
setRules
(
this
.
rules
)
},
methods
:
{
/**
* 触发表单提交
*/
submit
()
{
uni
.
showLoading
({
mask
:
true
})
this
.
$refs
.
form
.
submit
().
then
((
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
.
getOpenerEventChannel
().
emit
(
'
refreshData
'
)
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
(
'
article_id
'
).
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
;
}
.uni-button
{
width
:
184px
;
padding
:
12px
20px
;
font-size
:
14px
;
border-radius
:
4px
;
line-height
:
1
;
margin
:
0
;
}
</
style
>
uni_modules/uni-news-favorite/pages/uni-news-favorite/list.vue
0 → 100644
浏览文件 @
085b1384
<
template
>
<view
class=
"container"
>
<unicloud-db
ref=
"udb"
v-slot:default=
"
{data, pagination, loading, hasMore, error}" collection="opendb-news-favorite" field="article_id">
<view
v-if=
"error"
>
{{
error
.
message
}}
</view>
<view
v-else-if=
"data"
>
<uni-list>
<uni-list-item
v-for=
"(item, index) in data"
:key=
"index"
showArrow
:clickable=
"true"
@
click=
"handleItemClick(item)"
>
<view
slot=
"body"
>
<text>
{{
item
.
article_title
||
item
.
article_id
}}
</text>
<uni-dateformat
:date=
"item.create_date"
format=
"yyyy-MM-dd hh:mm"
:threshold=
"[0, 0]"
/>
</view>
</uni-list-item>
</uni-list>
</view>
<uni-load-more
:status=
"loading?'loading':(hasMore ? 'more' : 'noMore')"
></uni-load-more>
</unicloud-db>
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
loadMore
:
{
contentdown
:
''
,
contentrefresh
:
''
,
contentnomore
:
''
}
}
},
onPullDownRefresh
()
{
this
.
$refs
.
udb
.
loadData
({
clear
:
true
},
()
=>
{
uni
.
stopPullDownRefresh
()
})
},
onReachBottom
()
{
this
.
$refs
.
udb
.
loadMore
()
},
methods
:
{
handleItemClick
(
item
)
{
console
.
log
(
item
);
uni
.
navigateTo
({
url
:
'
/pages/list/detail?id=
'
+
item
.
article_id
+
'
&title=
'
+
(
item
.
article_title
||
''
)
})
},
fabClick
()
{
// 打开新增页面
uni
.
navigateTo
({
url
:
'
./add
'
,
events
:
{
// 监听新增数据成功后, 刷新当前页面数据
refreshData
:
()
=>
{
this
.
$refs
.
udb
.
loadData
({
clear
:
true
})
}
}
})
}
}
}
</
script
>
<
style
>
</
style
>
uni_modules/uni-news-favorite/readme.md
0 → 100644
浏览文件 @
085b1384
# opendb-news-favorite
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录