提交 e9d33106 编写于 作者: DCloud_JSON's avatar DCloud_JSON

添加文件说明注释

上级 b306ac06
<script> <script>
import initApp from '@/common/appInit.js'; import initApp from '@/common/appInit.js';
import checkIsAgree from '@/uni_modules/uni-agree/utils/uni-agree.js'; import checkIsAgree from '@/uni_modules/uni-agree/utils/uni-agree.js';
export default { export default {
globalData: { globalData: {
searchText: '', searchText: '',
appVersion: {} appVersion: {},
config:{}
}, },
onLaunch: function() { onLaunch: function() {
console.log('App Launch') console.log('App Launch')
......
module.exports = { //这是应用的配置页面,App.vue挂载到getApp().globalData.config
"h5": { module.exports = {
"url": "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com", // 前端网页托管的域名 "h5": {
"openApp": { // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改 "url": "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com", // 前端网页托管的域名
"openUrl": 'https://sj.qq.com/myapp/detail.htm?apkName=com.tencent.android.qqdownloader&info=6646FD239A6EBA9E2DEE5DFC7E18D867', // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改
"appname": 'base-app', "openApp": {
"logo": './static/logo.png', //点击悬浮下载栏后打开的网页链接
} "openUrl": 'https://sj.qq.com/myapp/detail.htm?apkName=com.tencent.android.qqdownloader&info=6646FD239A6EBA9E2DEE5DFC7E18D867',
}, //左侧显示的应用名称
"mp": { "appname": 'base-app',
"weixin": { //应用的图标
"id": "gh_33446d7f7a26" "logo": './static/logo.png',
} }
}, },
"router": { "mp": {
"needLogin": [ //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等 "weixin": {
"/pages/ucenter/edit/edit", //微信小程序原始id,微信小程序分享时
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list", "id": "gh_33446d7f7a26"
"/pages/ucenter/edit/uploadCutImageToUnicloud" }
], },
"router": {
//配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等
"needLogin": [
"/pages/ucenter/userinfo/userinfo",
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
"/pages/ucenter/edit/uploadCutImageToUnicloud"
],
"login": [ "smsCode","uniVerify", "username", "weixin", "apple"], "login": [ "smsCode","uniVerify", "username", "weixin", "apple"],
/* /*
根据数组的第0项,决定登陆方式的第一优先级。 根据数组的第0项,决定登陆方式的第一优先级。
为完全列举到的或设备环境不支持的选项,将被隐藏。 未列举到的,或设备环境不支持的选项,将被隐藏。
快捷登陆按钮,在任意一页面都存在。 快捷登陆按钮,在任意一页面都存在。
所以只有三种情况: 所以只有三种情况:
一键登录(uniVerify)、账号(username)、验证码登陆(其他值为第一项都为验证码登陆) 一键登录(uniVerify)、账号(username)、验证码登陆(其他值为第一项都为验证码登陆)
*/ 如果你需要在不同平台有不同的配置,直接用条件编译即可
}, */
"about": { },
"appName": "base-app", "about": {
"logo": "/static/logo.png", "appName": "base-app",
"company": "数字天堂(北京)网络技术有限公司", "logo": "/static/logo.png",
"slogan": "为开发而生", "company": "数字天堂(北京)网络技术有限公司",
"agreements": [{ "slogan": "为开发而生",
"title": "用户服务协议", "agreements": [{
"url": "https://ask.dcloud.net.cn/protocol.html" "title": "用户服务协议",
}, "url": "https://ask.dcloud.net.cn/protocol.html"
{ },
"title": "隐私政策", {
"url": "https://ask.dcloud.net.cn/protocol.html" "title": "隐私政策",
} "url": "https://ask.dcloud.net.cn/protocol.html"
], }
],
"download": "https://m3w.cn/uniapp" "download": "https://m3w.cn/uniapp"
}, },
"marketId":{//用于打开应用市场评分界面 //用于打开应用市场评分界面
"marketId":{
"ios":"id1417078253", "ios":"id1417078253",
"android":"123456" "android":"123456"
} }
} }
//应用初始化页
import baseappConfig from '@/baseapp.config.js'; import baseappConfig from '@/baseapp.config.js';
// #ifdef APP-PLUS // #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
...@@ -6,18 +7,36 @@ import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-ch ...@@ -6,18 +7,36 @@ import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-ch
export default function() { export default function() {
// 初始化appVersion(仅app生效) // 初始化appVersion(仅app生效)
initAppVersion(); initAppVersion();
// baseappConfig挂载到getApp(). // baseappConfig挂载到getApp().
getApp({allowDefault: true}).config = baseappConfig; getApp({allowDefault: true}).globalData.config = baseappConfig;
//自定义路由拦截 /*
const { 这里应用拦截器实现了,路由拦截。当应用无访问摄像头/相册权限,引导跳到设置界面
"router": { 1.添加拦截器说明如下:
needLogin, uni.addInterceptor(item, {
login invoke(e) { // 调用前拦截
} },
success() { // 成功回调拦截
},
fail(err) { // 失败回调拦截
console.log(err);
},
complete(e) { // 完成回调拦截
//console.log(e);
},
returnValue() { // 返回结果拦截
}
})
2.移除拦截器API removeInterceptor('request')
*/
//自定义路由拦截
const {
"router": {
needLogin,
login
}
} = baseappConfig //需要登陆的页面 } = baseappConfig //需要登陆的页面
//uni.addInterceptor的写法
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
list.forEach(item => { list.forEach(item => {
uni.addInterceptor(item, { uni.addInterceptor(item, {
...@@ -60,6 +79,7 @@ export default function() { ...@@ -60,6 +79,7 @@ export default function() {
}, },
}) })
}) })
//当应用无访问摄像头/相册权限,引导跳到设置界面 //当应用无访问摄像头/相册权限,引导跳到设置界面
uni.addInterceptor('chooseImage', { uni.addInterceptor('chooseImage', {
...@@ -96,8 +116,25 @@ export default function() { ...@@ -96,8 +116,25 @@ export default function() {
}) })
// #ifdef APP-PLUS // #ifdef APP-PLUS
// 设备网络状态变化事件 // 监听并提示设备网络状态变化
eventListenerNetwork() uni.onNetworkStatusChange(res=> {
console.log(res.isConnected);
console.log(res.networkType);
if(res.networkType!='none'){
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}else{
showNetworkErrPage()
uni.showToast({
title:'网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
// #endif // #endif
} }
...@@ -131,98 +168,4 @@ function initAppVersion() { ...@@ -131,98 +168,4 @@ function initAppVersion() {
// 检查更新 // 检查更新
checkUpdate(); checkUpdate();
// #endif // #endif
} }
\ No newline at end of file
// 设备网络状态变化事件
function eventListenerNetwork() {
/*
//网络掉线
uni.getNetworkType({
success:res=>{
console.log(res);
if(res.networkType=='none'){
showNetworkErrPage()
}
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
//监听网络变化
uni.onNetworkStatusChange(res=> {
console.log(res.isConnected);
console.log(res.networkType);
if(res.networkType!='none'){
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}else{
showNetworkErrPage()
uni.showToast({
title:'网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
function showNetworkErrPage(){
let pages = getCurrentPages();
console.log('pages.length',pages.length);
if(pages.length===0 || pages[pages.length - 1].route!='/pages/networkErr/networkErr.vue'){
uni.navigateTo({
url:'/pages/networkErr/networkErr'
})
}else{
console.log('已经打开');
}
}
}
function openAppPermissionSetting(){
// 跳转到**应用**的权限页面
if (uni.getSystemInfoSync().platform == "ios") {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
// console.log(plus.device.vendor);
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
*/
}
/*
uni.addInterceptor(item, {
invoke(e) { // 调用前拦截
},
success() { // 成功回调拦截
},
fail(err) { // 失败回调拦截
console.log(err);
},
complete(e) { // 完成回调拦截
//console.log(e);
},
returnValue() { // 返回结果拦截
}
}) // 移除拦截器API removeInterceptor('request')
*/
\ No newline at end of file
/*
创建在h5端全局悬浮引导用户下载app的功能,
如不需要本功能直接移除配置文件baseapp.config.js下的h5/openApp即可
*/
import CONFIG from '../baseapp.config.js'; import CONFIG from '../baseapp.config.js';
const CONFIG_OPEN = CONFIG?.h5?.openApp?.openUrl ? CONFIG.h5.openApp : {}; const CONFIG_OPEN = CONFIG?.h5?.openApp?.openUrl ? CONFIG.h5.openApp : {};
......
<template>
<view :class="[flex?'flex':'null']">
<slot></slot>
</view>
</template>
<script>
export default {
props: {
flex: {
default(){
return false
}
},
},
data() {
return {
}
},
watch: {
},
methods: {
},
}
</script>
<style lang="scss" scoped>
.null{
display: inline-flex;
width: auto;
}
.flex{
display: flex;
}
</style>
此差异已折叠。
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
name:"uni-agreements", name:"uni-agreements",
computed:{ computed:{
agreements(){ agreements(){
return getApp().config.about.agreements return getApp().globalData.config.about.agreements
} }
}, },
methods:{ methods:{
......
<template>
<view class="box" v-if="networkType == 'none'">
<image class="icon-image" src="../../static/uni-network/disconnection.png" mode="widthFix"></image>
<text class="tip-text">网络异常</text>
<view class="btn btn-default" v-if="networkType!='none'" @click="retry">
<text class="btn-text">重试</text>
</view>
<view class="btn btn-default" v-if="networkType=='none'" @click="openSettings">
<text class="btn-text">前往设置</text>
</view>
</view>
</template>
<script>
export default {
name: "uni-network",
data() {
return {
"networkType": ""
};
},
mounted() {
uni.onNetworkStatusChange(({
networkType
}) => {
if(this.networkType == 'none' && networkType != 'none'){
this.change()
}
this.networkType = networkType;
});
uni.getNetworkType({
success: ({
networkType
}) => {
this.networkType = networkType;
}
});
},
methods:{
openSettings(){
if (uni.getSystemInfoSync().platform == "ios") {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-prefs:root=General");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent(Settings.ACTION_SETTINGS);
mainActivity.startActivity(intent);
}
},
change(){
this.$emit('change')
}
}
}
</script>
<style scoped>
.box{
margin:100rpx 0;
flex-direction: column;
align-items: center;
justify-content: center;
}
.icon-image{
width: 300rpx;
}
.tip-text{
color: #999999;
font-size: 32rpx;
margin-bottom: 30rpx;
}
.btn {
padding: 5px 10px;
width: 128px;
flex-direction: row;
align-items: center;
justify-content: center;
text-align: center;
}
.btn-text {
color: #999999;
font-size: 15px;
}
.btn-default {
border-color: #999999;
border-style: solid;
border-width: 1px;
border-radius: 3px;
}
</style>
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
"prompt" : "template", "prompt" : "template",
"template" : { "template" : {
"title" : "服务协议和隐私政策", "title" : "服务协议和隐私政策",
"message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"\">《服务协议》</a>和<a href=\"\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。", "message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"https://ask.dcloud.net.cn/protocol.html\">《服务协议》</a>和<a href=\"https://ask.dcloud.net.cn/protocol.html\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "我知道了", "buttonAccept" : "同意",
"buttonRefuse" : "暂不同意" "buttonRefuse" : "暂不同意"
} }
}, },
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
"es6" : false "es6" : false
}, },
"usingComponents" : true "usingComponents" : true
// "betterScopedSlots" : true
}, },
// "betterScopedSlots" : true
"mp-alipay" : { "mp-alipay" : {
"usingComponents" : true "usingComponents" : true
}, },
......
...@@ -3,23 +3,17 @@ ...@@ -3,23 +3,17 @@
{ {
"path": "pages/list/list", "path": "pages/list/list",
"style": { "style": {
// #ifdef APP-NVUE
"enablePullDownRefresh": false,
// #endif
// #ifdef H5
"navigationStyle":"custom", "navigationStyle":"custom",
// #endif "enablePullDownRefresh": true,
"app-plus":{ "app-plus":{
// #ifdef APP-PLUS // "titleNView":{ /*排除了H5*/
"titleNView":{ /*排除了H5*/ // "searchInput":{
"searchInput":{ // "placeholder":"请输入搜索的内容",
"placeholder":"请输入搜索的内容", // "backgroundColor":"#efefef",
"backgroundColor":"#efefef", // "disabled":true,
"disabled":true, // "borderRadius":"30px"
"borderRadius":"30px" // }
} // }
}
// #endif
} }
} }
}, },
...@@ -73,7 +67,7 @@ ...@@ -73,7 +67,7 @@
"navigationBarTitleText": "文章详情" "navigationBarTitleText": "文章详情"
} }
}, { }, {
"path": "pages/ucenter/edit/bind-mobile/bind-mobile", "path": "pages/ucenter/userinfo/bind-mobile/bind-mobile",
"style": { "style": {
"navigationBarTitleText": "绑定手机号码" "navigationBarTitleText": "绑定手机号码"
} }
...@@ -162,12 +156,12 @@ ...@@ -162,12 +156,12 @@
} }
}, { }, {
"path": "pages/ucenter/edit/edit", "path": "pages/ucenter/userinfo/userinfo",
"style": { "style": {
"navigationBarTitleText": "个人资料" "navigationBarTitleText": "个人资料"
} }
}, { }, {
"path": "pages/ucenter/edit/uploadCutImageToUnicloud", "path": "pages/ucenter/userinfo/uploadCutImageToUnicloud",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
</template> </template>
<script> <script>
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';
const db = uniCloud.database(); const db = uniCloud.database();
...@@ -57,7 +56,7 @@ ...@@ -57,7 +56,7 @@
} from 'vuex'; } from 'vuex';
export default { export default {
data() { data() {
return { return {
// 当前显示 _id // 当前显示 _id
id: "", id: "",
title: 'title', title: 'title',
...@@ -79,7 +78,10 @@ ...@@ -79,7 +78,10 @@
...mapGetters({ ...mapGetters({
'userInfo': 'user/info', 'userInfo': 'user/info',
'hasLogin': 'user/hasLogin' 'hasLogin': 'user/hasLogin'
}) }),
baseappConfig(){
return getApp().globalData.config
}
}, },
onLoad(event) { onLoad(event) {
//获取真实新闻id,通常 id 来自上一个页面 //获取真实新闻id,通常 id 来自上一个页面
...@@ -249,7 +251,7 @@ ...@@ -249,7 +251,7 @@
} }
</script> </script>
<style scoped> <style scoped>
.header-content { .header-content {
flex: 1; flex: 1;
display: flex; display: flex;
...@@ -335,4 +337,4 @@ ...@@ -335,4 +337,4 @@
font-size: 15px; font-size: 15px;
overflow: hidden; overflow: hidden;
} }
</style> </style>
<template> <template>
<view> <view>
<!-- 搜索功能 小程序用绘制的且带原生导航,h5和app用原生自带绘制 --> <!-- #ifdef APP-PLUS -->
<!-- #ifndef APP-PLUS --> <uni-nav-bar :border="false"></uni-nav-bar>
<view class="uni-search-box"> <!-- #endif -->
<uni-search-bar class="uni-search-bar" v-model="keyword" ref="searchBar" radius="100" <!-- 搜索功能 -->
@click.native="searchClick" cancelButton="none" disabled /> <uni-search-bar class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
</view> @click.native="searchClick" cancelButton="none" disabled />
<!-- #endif -->
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @load="handleLoad" @error="onqueryerror"
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @load="handleLoad"
:where="where" collection="opendb-news-articles,uni-id-users" :where="where" collection="opendb-news-articles,uni-id-users"
field="avatar,title,last_modify_date,user_id{username}"> field="avatar,title,last_modify_date,user_id{username}">
<!-- 基于 uni-list 的页面布局 --> <!-- 基于 uni-list 的页面布局 -->
<uni-list class="uni-list" :border="false" :style='{height:windowHeight+"px"}' :bounce="true" <uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
:alwaysScrollableVertical="true">
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<refresh @refresh="refresh" @pullingdown="onpullingdown" :display="!loading ? 'show' : 'hide'"> :style='{height:listHight+"px"}'
<refreshBox :state="refreshState"></refreshBox>
</refresh>
<!-- #endif --> <!-- #endif -->
<cell class="get-data-state" v-if="data.length===0&&pagination.current===1"> >
<!-- 刷新页面后的顶部提示框 当前弹出内容没有实际逻辑 ,可根据当前业务修改弹出提示 --> <cell v-if="error">
<text class="refresh-tip" <template slot="body">
:class="{ 'show-refresh-tip':showRefreshTip }">为您更新了{{data.length}}条内容</text> <!-- 设置网络 -->
<!-- 数据为空 当前页码为1,且正在加载中;这里为了演示,更加直观的表达内部逻辑。商用项目建议将这部分封装为组件,更好的让业务逻辑与功能分离--> <uni-network @change="refresh" @retry="refresh"></uni-network>
<template v-if="loading"> </template>
<image class="get-data-state-img" src="@/static/getDataState/loading.png" mode="widthFix"> </cell>
</image>
<text class="get-data-state-text">加载中...</text> <template v-else>
</template> <cell class="get-data-state" v-if="data.length===0&&pagination.current===1">
<template v-else> <!-- 数据为空 当前页码为1,且正在加载中;这里为了演示,更加直观的表达内部逻辑。商用项目建议将这部分封装为组件,更好的让业务逻辑与功能分离-->
<image class="get-data-state-img" src="@/static/getDataState/nodata.png" mode="widthFix"> <uni-load-more v-if="loading" status="loading"></uni-load-more>
</image> <template v-else>
<text class="get-data-state-text">内容为空</text> <image class="get-data-state-img" src="@/static/getDataState/nodata.png" mode="widthFix">
</template> </image>
</cell> <text class="get-data-state-text">内容为空</text>
<uni-list-item v-if="error">{{error.message}}</uni-list-item> </template>
<uni-list-item v-else :to="'./detail?id='+item._id+'&title='+item.title" </cell>
v-for="(item,index) in testData(data)" :key="index"> <uni-list-item :to="'./detail?id='+item._id+'&title='+item.title"
<!-- 通过header插槽定义列表左侧图片 --> v-for="(item,index) in testData(data)" :key="index">
<template v-slot:header> <!-- 通过header插槽定义列表左侧图片 -->
<image class="avatar" :src="item.avatar" mode="aspectFill"></image> <template v-slot:header>
</template> <image class="avatar" :src="item.avatar" mode="aspectFill"></image>
<!-- 通过body插槽定义布局 --> </template>
<view slot="body" class="main"> <!-- 通过body插槽定义布局 -->
<text class="title">{{ item.title }}</text> <view slot="body" class="main">
<view class="info"> <text class="title">{{ item.title }}</text>
<text class="author">{{item.user_id[0].username}}</text> <view class="info">
<uni-dateformat class="last_modify_date" :date="item.last_modify_date" format="yyyy-MM-dd" <text class="author">{{item.user_id[0].username}}</text>
:threshold="[60000, 2592000000]" /> <uni-dateformat class="last_modify_date" :date="item.last_modify_date"
format="yyyy-MM-dd" :threshold="[60000, 2592000000]" />
</view>
</view> </view>
</view> </uni-list-item>
</uni-list-item>
<!-- 存在下一页数据,且不在加载中 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 -->
<!-- 存在下一页数据,且不在加载中 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 --> <template v-if="!loading">
<cell v-if="hasMore"> <cell v-if="hasMore">
<uni-load-more v-if="!error &&!loading&&hasMore" :status="options.status"></uni-load-more> <uni-load-more :status="options.status"></uni-load-more>
</cell> </cell>
<cell v-else> <cell v-else>
<text class="noMore">- 没有更多数据了 -</text> <text class="noMore">- 没有更多数据了 -</text>
</cell> </cell>
</template>
</template>
</uni-list> </uni-list>
</unicloud-db> </unicloud-db>
</view> </view>
...@@ -70,42 +70,34 @@ ...@@ -70,42 +70,34 @@
export default { export default {
data() { data() {
return { return {
showRefreshTip: true,
where: "", where: "",
keyword: "", keyword: "",
refreshState: 0, refreshState: 0,
windowHeight: 0 //窗口的高 listHight: 0
} }
}, },
onReady() { onReady() {
this.windowHeight = uni.getSystemInfoSync().windowHeight this.listHight = uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 65
this.showRefreshTip = false
cdbRef = this.$refs.udb cdbRef = this.$refs.udb
console.log(cdbRef); console.log(cdbRef);
}, },
onShow() { onShow() {
try{ this.keyword = getApp().globalData.searchText
this.keyword = getApp().globalData.searchText console.log(this.keyword);
console.log(this.keyword); getApp().globalData.searchText = ''
getApp().globalData.searchText = '' if(this.keyword){
this.setInputText() // #ifdef APP-PLUS
}catch(e){ if (!currentWebview) {
console.log(e); let pages = getCurrentPages();
//TODO handle the exception currentWebview = pages[pages.length - 1].$getAppWebview();
}
// 设置 searchInput的 text
currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif
} }
}, },
methods: { methods: {
setInputText() { testData(data) { //复制同一个数据多遍方便测试,正式项目中不要带
// 设置 searchInput的 text
// #ifdef APP-PLUS
if (!currentWebview) {
let pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
}
currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif
},
testData(data) {
var testData = [] var testData = []
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
testData.push(...data) testData.push(...data)
...@@ -116,7 +108,6 @@ ...@@ -116,7 +108,6 @@
// `data` 当前查询结果 `ended` 是否有更多数据 `pagination` 分页信息 HBuilderX 3.1.5+ 支持 // `data` 当前查询结果 `ended` 是否有更多数据 `pagination` 分页信息 HBuilderX 3.1.5+ 支持
console.log(9527, data, ended, pagination); console.log(9527, data, ended, pagination);
//上拉加载成功 //上拉加载成功
this.loadMoreEnd()
}, },
searchClick() { searchClick() {
uni.hideKeyboard(); uni.hideKeyboard();
...@@ -129,66 +120,29 @@ ...@@ -129,66 +120,29 @@
} }
} }
}); });
}, },
refresh() { retry(){
cdbRef.loadData({ this.refresh()
clear: true },
}, () => { refresh(){
this.showRefreshTip = true cdbRef.loadData({
setTimeout(() => { clear: true
this.showRefreshTip = false }, () => {
}, 1000) uni.stopPullDownRefresh()
this.refreshEnd() })
}) console.log('refresh');
}, }
loadMore() {
cdbRef.loadMore({
clear: true
})
},
refreshEnd() {
// #ifdef APP-NVUE
this.refreshState = 0
// #endif
uni.stopPullDownRefresh()
},
loadMoreEnd() {
console.log('loadMoreEnd');
},
// #ifdef APP-NVUE
onpullingdown({
pullingDistance,
viewHeight
}) {
if (pullingDistance > viewHeight) {
this.refreshState = 1
}
},
// #endif
}, },
// #ifndef APP-NVUE
onPullDownRefresh() { onPullDownRefresh() {
this.refresh() this.refresh()
console.log('refresh');
}, },
// #endif
onReachBottom() { onReachBottom() {
this.loadMore() cdbRef.loadMore({clear: true})
console.log('触底了');
},
onNavigationBarSearchInputClicked() {
this.searchClick()
},
onNavigationBarSearchInputChanged(e) {
console.log('变了', e);
if (e.text) {
this.where = 'title == ' + e.text
}
} }
} }
</script> </script>
<style> <style scoped>
.avatar { .avatar {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
...@@ -201,6 +155,7 @@ ...@@ -201,6 +155,7 @@
.title { .title {
width: 480rpx; width: 480rpx;
font-size: 32rpx;
} }
.info { .info {
...@@ -230,10 +185,10 @@ ...@@ -230,10 +185,10 @@
background-color: #FFFFFF; background-color: #FFFFFF;
position: sticky; position: sticky;
top: 0; top: 0;
left: 0; left: 0;
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
z-index:9; z-index: 9;
/* #endif */ /* #endif */
} }
.show-refresh-tip { .show-refresh-tip {
...@@ -260,8 +215,7 @@ ...@@ -260,8 +215,7 @@
text-align: center; text-align: center;
} }
.uni-list { .uni-list {}
}
.noMore { .noMore {
width: 750rpx; width: 750rpx;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
</view> </view>
</template> </template>
<script> <script>
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';
export default { export default {
onLoad() { onLoad() {
...@@ -27,6 +26,12 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ...@@ -27,6 +26,12 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
this.version = plus.runtime.version this.version = plus.runtime.version
// #endif // #endif
}, },
computed:{
baseappConfig(){
console.log(getApp());
return getApp().globalData.config
}
},
data() { data() {
return { return {
version:"V1.0.0", version:"V1.0.0",
...@@ -35,7 +40,8 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ...@@ -35,7 +40,8 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
}; };
}, },
created() { created() {
this.about = baseappConfig.about console.log();
this.about = this.baseappConfig.about
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:'关于'+this.about.appName title:'关于'+this.about.appName
}) })
......
...@@ -18,7 +18,7 @@ var univerify_first,currentWebview;//是否一键登陆优先 ...@@ -18,7 +18,7 @@ var univerify_first,currentWebview;//是否一键登陆优先
export default { export default {
data() { data() {
return { return {
phone:"17769516081" phone:""
} }
}, },
computed: { computed: {
......
<template> <template>
<view class="center"> <view class="center">
<view class="userInfo" @click="toUserInfo"> <view class="userInfo" @click="toUserInfo">
<image class="logo-img" :src="userInfo.avatar||avatarUrl"></image> <image class="logo-img" :src="userInfo.avatar||avatarUrl"></image>
<view class="logo-title"> <view class="logo-title">
<text class="uer-name">{{userInfo.nickname||userInfo.username||userInfo.mobile||'未登录'}}</text> <text class="uer-name">{{userInfo.nickname||userInfo.username||userInfo.mobile||'未登录'}}</text>
<uni-icons class="icon" color="#FFFFFF" type="arrowright" v-if="!login" size="16"></uni-icons> <uni-icons class="icon" color="#FFFFFF" type="arrowright" v-if="!login" size="16"></uni-icons>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<view class="item-footer-badge"></view> <view class="item-footer-badge"></view>
</view> </view>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
</view> </view>
</template> </template>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
] ]
} }
}, },
onLoad() { onLoad() {
//#ifdef APP-PLUS //#ifdef APP-PLUS
this.ucenterList[this.ucenterList.length - 2].unshift({ this.ucenterList[this.ucenterList.length - 2].unshift({
title: '检查更新', title: '检查更新',
...@@ -111,9 +111,9 @@ ...@@ -111,9 +111,9 @@
appVersion() { appVersion() {
return getApp().appVersion return getApp().appVersion
} }
// #endif // #endif
,appConfig(){ ,appConfig(){
return getApp().config return getApp().globalData.config
} }
}, },
methods: { methods: {
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
}, },
toUserInfo() { toUserInfo() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/ucenter/edit/edit' url: '/pages/ucenter/userinfo/userinfo'
}) })
}, },
tapGrid(index) { tapGrid(index) {
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
* 去应用市场评分 * 去应用市场评分
*/ */
gotoMarket() { gotoMarket() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == "ios") { if (uni.getSystemInfoSync().platform == "ios") {
// 这里填写appstore应用id // 这里填写appstore应用id
let appstoreid = this.appConfig.marketId.ios;// 'id1417078253'; let appstoreid = this.appConfig.marketId.ios;// 'id1417078253';
...@@ -299,4 +299,4 @@ ...@@ -299,4 +299,4 @@
/* #endif */ /* #endif */
background-color: #DD524D; background-color: #DD524D;
} }
</style> </style>
static/getDataState/nodata.png

44.7 KB | W: | H:

static/getDataState/nodata.png

33.5 KB | W: | H:

static/getDataState/nodata.png
static/getDataState/nodata.png
static/getDataState/nodata.png
static/getDataState/nodata.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -61,7 +61,7 @@ $uni-spacing-row-lg: 30rpx; ...@@ -61,7 +61,7 @@ $uni-spacing-row-lg: 30rpx;
/* 垂直间距 */ /* 垂直间距 */
$uni-spacing-col-sm: 8rpx; $uni-spacing-col-sm: 8rpx;
$uni-spacing-col-base: 16rpx; $uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 24rpx; $uni-spacing-col-lg: 24rpx;
/* 透明度 */ /* 透明度 */
......
# uni-image-menu # uni-image-menu
\ No newline at end of file
使用示例:
```
import uniImageMenu from 'uni_modules/uni-image-menu/js_sdk/uni-image-menu.js';
uniImageMenu.show({
list:[{
"img": "/static/sharemenu/wechatfriend.png",
"text": "微信好友"
},
{
"img": "/static/sharemenu/wechatmoments.png",
"text": "微信朋友圈"
}],
cancelText:param.cancelText
}, e => {
console.log(e)
})
```
\ No newline at end of file
<template>
<view class="nodata">
<view class="nodata-content">
<view class="text-view a-i-c j-c-c t-a-c">
<text class="title">{{textTypes[networkType]}}</text>
</view>
<view class="icon-view">
<!-- 无数据 icon -->
<image v-if="!isLoading" src="/uni_modules/uni-nodata/static/nodata.png" class="icon-image"></image>
<!-- 加载中 icon -->
<image v-else src="/uni_modules/uni-nodata/static/loading.png" class="icon-loading"></image>
<text class="title">{{isLoading ? '加载中...' : ''}}</text>
</view>
<view class="opera-view" v-if="!isLoading">
<view class="btn btn-default" v-if="networkType!='none'" @click="retry">
<text class="btn-text">重试</text>
</view>
<view class="btn btn-default" v-if="networkType=='none'" @click="openSettings">
<text class="btn-text">设置</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'uni-nodata',
props:{
isLoading:{
type:Boolean,
default:false
}
},
data() {
return {
textTypes: {
none: "暂无网络"
},
isConnected: false,
networkType: "none"
}
},
mounted() {
this.isIOS = (uni.getSystemInfoSync().platform === 'ios');
uni.onNetworkStatusChange((res) => {
this.isConnected = res.isConnected;
this.networkType = res.networkType;
});
uni.getNetworkType({
success: (res) => {
this.networkType = res.networkType;
}
});
},
methods: {
retry() {
this.$emit('retry');
},
async openSettings() {
if (this.networkType == "none") {
this.openSystemSettings();
return;
}
},
openAppSettings() {
this.gotoAppSetting();
},
openSystemSettings() {
if (this.isIOS) {
this.gotoiOSSetting();
} else {
this.gotoAndroidSetting();
}
},
network() {
var result = null;
var cellularData = plus.ios.newObject("CTCellularData");
var state = cellularData.plusGetAttribute("restrictedState");
if (state == 0) {
result = null;
console.log("StateUnknown");
} else if (state == 2) {
result = 1;
console.log("已经开启了互联网权限:NotRestricted");
} else if (state == 1) {
result = 2;
console.log("Restricted");
}
plus.ios.deleteObject(cellularData);
return result;
},
gotoAppSetting() {
if (this.isIOS) {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
},
gotoiOSSetting() {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-prefs:root=General");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
},
gotoAndroidSetting() {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent(Settings.ACTION_SETTINGS);
mainActivity.startActivity(intent);
}
}
}
</script>
<style>
.a-i-c {
align-items: center;
}
.j-c-c {
justify-content: center;
}
.t-a-c {
text-align: center;
}
.nodata {
flex: 1;
flex-direction: column;
/* #ifndef APP-PLUS */
display: flex;
/* #endif */
align-items: center;
justify-content: center;
padding: 30px;
background-color: #f8f8f8;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
/* #ifndef APP-NVUE */
margin: auto;
z-index:9;
/* #endif */
}
.nodata-content {
transform: translateY(-50px);
}
.text-view {
margin-bottom: 40px;
}
.title {
color: #999999;
font-size: 18px;
}
.opera-view {
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn {
padding: 5px 10px;
width: 128px;
flex-direction: row;
align-items: center;
justify-content: center;
text-align: center;
}
.btn-text {
color: #999999;
font-size: 15px;
}
.btn-default {
border-color: #999999;
border-style: solid;
border-width: 1px;
border-radius: 3px;
}
.icon-view{
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
border-width: 1rpx;
border-color: #DD524D;
}
.icon-loading{
width: 500rpx;
height: 300rpx;
}
.icon-image{
width: 640rpx;
height: 640rpx;
}
</style>
{
"id": "uni-nodata",
"displayName": "uni-nodata",
"version": "1.0.0",
"description": "uni-nodata",
"keywords": [
"uni-nodata"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
\ No newline at end of file
# uni-nodata
\ No newline at end of file
...@@ -78,6 +78,4 @@ export default async (param,callback) => { ...@@ -78,6 +78,4 @@ export default async (param,callback) => {
callback(e) callback(e)
}); });
} }
}
\ No newline at end of file
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
"id": "uni-share", "id": "uni-share",
"displayName": "uni-share", "displayName": "uni-share",
"version": "1.0.0", "version": "1.0.0",
"description": "uni-share", "description": "底部弹出宫格图标式的分享菜单,可覆盖原生组件。",
"keywords": [ "keywords": [
"uni-share" "分享菜单"
], ],
"repository": "", "repository": "",
"engines": { "engines": {
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"dcloudext": { "dcloudext": {
"category": [ "category": [
"JS SDK", "JS SDK",
"JS SDK" "通用 SDK"
], ],
"sale": { "sale": {
"regular": { "regular": {
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
"qq": "" "qq": ""
}, },
"declaration": { "declaration": {
"ads": "", "ads": "",
"data": "", "data": "",
"permissions": "" "permissions": ""
}, },
"npmurl": "" "npmurl": ""
}, },
...@@ -38,37 +38,37 @@ ...@@ -38,37 +38,37 @@
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "u", "tcb": "y",
"aliyun": "u" "aliyun": "y"
}, },
"client": { "client": {
"App": { "App": {
"app-vue": "u", "app-vue": "y",
"app-nvue": "u" "app-nvue": "y"
}, },
"H5-mobile": { "H5-mobile": {
"Safari": "u", "Safari": "n",
"Android Browser": "u", "Android Browser": "n",
"微信浏览器(Android)": "u", "微信浏览器(Android)": "n",
"QQ浏览器(Android)": "u" "QQ浏览器(Android)": "n"
}, },
"H5-pc": { "H5-pc": {
"Chrome": "u", "Chrome": "n",
"IE": "u", "IE": "n",
"Edge": "u", "Edge": "n",
"Firefox": "u", "Firefox": "n",
"Safari": "u" "Safari": "n"
}, },
"小程序": { "小程序": {
"微信": "u", "微信": "n",
"阿里": "u", "阿里": "n",
"百度": "u", "百度": "n",
"字节跳动": "u", "字节跳动": "n",
"QQ": "u" "QQ": "n"
}, },
"快应用": { "快应用": {
"华为": "u", "华为": "n",
"联盟": "u" "联盟": "n"
} }
} }
} }
......
# uni-share #### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。
例子 ### 示例代码
import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ```
uniShare({ uniShare({
menus:[ content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图)
{ type: 0,
"img": "/static/sharemenu/wechatfriend.png", href: 'https://uniapp.dcloud.io/',
"text": "微信好友", title: '标题',
"share": { summary: '描述',
"provider": "weixin", imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
"scene": "WXSceneSession" },
} menus: [{
}, "img": "/static/app-plus/sharemenu/wechatfriend.png",
{ "text": "微信好友",
"img": "/static/sharemenu/wechatmoments.png", "share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5
"text": "微信朋友圈", "provider": "weixin",
"share": { "scene": "WXSceneSession"
"provider": "weixin", }
"scene": "WXSceneSession" },
} {
}, "img": "/static/app-plus/sharemenu/wechatmoments.png",
{ "text": "微信朋友圈",
"img": "/static/sharemenu/weibo.png", "share": {
"text": "微博", "provider": "weixin",
"share": { "scene": "WXSenceTimeline"
"provider": "sinaweibo" }
} },
}, {
{ "img": "/static/app-plus/sharemenu/mp_weixin.png",
"img": "/static/sharemenu/qq.png", "text": "微信小程序",
"text": "QQ", "share": {
"share": { provider: "weixin",
"provider": "qq" scene: "WXSceneSession",
} type: 5,
}, miniProgram: {
{ id: baseappConfig.mp.weixin.id,
"img": "/static/sharemenu/copyurl.png", path: `/pages/list/detail?id=${_id}&title=${title}`,
"text": "复制", webUrl: baseappConfig.h5.url +
"share": "copyurl" `/#/pages/list/detail?id=${_id}&title=${title}`,
}, type: 0
{ },
"img": "/static/sharemenu/more.png", }
"text": "更多", },
"share": "shareSystem" {
} "img": "/static/app-plus/sharemenu/weibo.png",
], "text": "微博",
cancelText:"取消分享", "share": {
content:{ "provider": "sinaweibo"
type: 0, }
href: "https://uniapp.dcloud.io/api/plugins/share?id=share", },
title: "主标题", {
summary: "分享内容的摘要", "img": "/static/app-plus/sharemenu/qq.png",
imageUrl: "https://uniapp.dcloud.io/api/plugins/share?id=share", "text": "QQ",
} "share": {
},e=>{ //callback "provider": "qq"
console.log(e); }
}) },
\ No newline at end of file {
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": "复制",
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": "更多",
"share": "shareSystem"
}
],
cancelText: "取消分享",
}, e => { //callback
console.log(e);
})
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册