首次完整推送,

V:1.20240808.006
This commit is contained in:
fm453
2024-08-13 18:32:37 +08:00
parent 15be3e9373
commit c62d15b288
939 changed files with 111777 additions and 0 deletions

View File

@ -0,0 +1,246 @@
<template>
<view class="about">
<view class="box">
<image class="logoImg" :src="about.logo"></image>
<text class="tip appName">{{about.appName}}</text>
<text class="tip">Version {{version}}</text>
<view class="qrcode">
<!--uqrcode 组件来源插件Sansnn-uQRCode 链接地址https://ext.dcloud.net.cn/plugin?id=1287-->
<uqrcode :size="100" canvas-id="qrcode" :value="about.download"></uqrcode>
</view>
<text class="tip">{{$t('about.sacnQR')}} {{about.appName}} {{$t('about.client')}}</text>
</view>
<view class="copyright">
<view class="agreement-box" v-for="(agreement,index) in agreements" :key="index">
<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
<text class="hint" v-if="agreements.length-1>index">{{$t('about.and')}}</text>
</view>
<text class="hint">Copyright © {{year}}</text>
<text class="hint">{{about.company}}</text>
</view>
</view>
</template>
<script>
// #ifdef APP
import UniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
const uniShare = new UniShare()
// #endif
import uniIdPagesConfig from '@/uni_modules/uni-id-pages/config.js';
import uqrcode from "@/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode"
import extConfig from "@/app.config.js";
export default {
components: {
uqrcode
},
// #ifdef APP
onBackPress({
from
}) {
if (from == 'backbutton') {
this.$nextTick(function() {
uniShare.hide()
})
return uniShare.isShow;
}
},
// #endif
onLoad() {
// #ifdef APP-PLUS
this.version = plus.runtime.version
// #endif
},
computed: {
uniStarterConfig() {
let config = getApp().globalData.config;
config.about = extConfig.about;
return config
},
agreements() {
if (!uniIdPagesConfig.agreements) {
return []
}
let {
serviceUrl,
privacyUrl
} = uniIdPagesConfig.agreements
return [{
url: serviceUrl,
title: "用户服务协议"
},
{
url: privacyUrl,
title: "隐私政策条款"
}
]
}
},
data() {
return {
version: "V1.0.0",
year: "2020",
about: {}
};
},
created() {
this.about = this.uniStarterConfig.about
uni.setNavigationBarTitle({
title: this.$t('about.about') + " " + this.about.appName
})
this.year = (new Date).getFullYear()
},
onNavigationBarButtonTap() {
let {
download,
appName,
slogan,
logo
} = this.about
uniShare.show({
content: { //公共的分享类型type、链接herf、标题title、summary描述、imageUrl缩略图
type: 0,
href: download,
title: appName,
summary: slogan,
imageUrl: logo +
'?x-oss-process=image/resize,m_fill,h_100,w_100' //压缩图片解决在ios端分享图过大导致的图片失效问题
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": this.$t('common.wechatFriends'),
"share": {
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": this.$t('common.wechatBbs'),
"share": {
"provider": "weixin",
"scene": "WXSceneTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": this.$t('common.weibo'),
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": this.$t('common.copy'),
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": this.$t('common.more'),
"share": "shareSystem"
}
],
cancelText: this.$t('common.cancelShare'),
}, e => { //callback
console.log(e);
})
},
methods: {
navigateTo({
url,
title
}) {
uni.navigateTo({
url: '/pages/common/webview/index?url=' + url + '&title=' +
title,
success: res => {},
fail: () => {},
complete: () => {}
});
}
}
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
.about {
flex-direction: column;
justify-content: center;
align-items: center;
}
.box {
margin-top: 60px;
flex-direction: column;
justify-content: center;
align-items: center;
}
.logoImg {
margin-bottom: 10rpx;
width: 160rpx;
height: 160rpx;
border-radius: 15px;
}
.tip {
text-align: center;
font-size: 24rpx;
margin-top: 10px;
padding: 10rpx;
}
.appName {
margin-top: 20px;
font-size: 42rpx;
font-weight: 500;
}
.qrcode,
.qrcode .uqrcode {
margin: 10px 0;
width: 100px;
height: 100px;
/* #ifndef APP-NVUE */
display: block;
/* #endif */
}
.copyright {
font-size: 32rpx;
flex-direction: column;
justify-content: center;
align-items: center;
bottom: 20px;
// left: 0;
position: fixed;
}
.agreement-box {
justify-content: center;
}
.agreement {
color: #2285ff;
font-size: 26rpx;
}
.hint {
text-align: center;
color: #999999;
font-size: 26rpx;
}
</style>

View File

@ -0,0 +1,179 @@
<template>
<view class="about">
<view class="box">
<image class="logoImg" :src="about.logo"></image>
<text class="tip appName">{{about.appName}}</text>
<text class="tip">{{about.slogan}}</text>
<view @click="download" id="download">
<image v-if="isIos" class="icon" src="@/static/h5/download-app/ios.png" mode="widthFix"></image>
<image v-else class="icon" src="@/static/h5/download-app/android.png" mode="widthFix"></image>
<text class="download-text">{{$t('invite.download')}}</text>
</view>
<text class="tip">version {{about.version}}</text>
</view>
<view class="copyright">
<text class="hint">{{about.company}}</text>
</view>
<view class="mask" v-if="showMask">
<image src="@/static/h5/download-app/openImg.png" mode="widthFix"></image>
</view>
</view>
</template>
<script>
export default {
computed: {
uniStarterConfig() {
return getApp().globalData.config
}
},
data() {
return {
about: {},
code: "",
isIos: "",
showMask: false,
downloadUrl: {
"ios": "",
"android": ""
}
};
},
created() {
this.about = this.uniStarterConfig.about
this.downloadUrl = this.uniStarterConfig.download
this.year = (new Date).getFullYear()
//判断是否在微信中打开
var userAgent = navigator.userAgent;
var ua = userAgent.toLowerCase();
this.isWeixin = ua.indexOf('micromessenger') != -1;
//判断是否在ios或者安卓打开
this.isIos = !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
},
onLoad({
code
}) {
this.code = code
document.getElementById("openApp").style.display = 'none'
document.getElementsByTagName("body")[0].style = ""
},
methods: {
download() {
if (this.code) {
uni.setClipboardData({
data: this.code,
complete: (e) => {
console.log(e);
uni.hideToast()
/* 以下临时解决setClipboardData h5端样式和键盘弹出端错误解决方案后续会直接内置*/
document.getElementById("#clipboard").style.top = '-999px';
uni.hideKeyboard()
}
})
}
if (this.isIos) {
window.location.href = this.downloadUrl.ios
} else {
if (this.isWeixin) {
//显示浮层
this.showMask = true
} else {
window.location.href = this.downloadUrl.android
}
}
}
}
}
</script>
<style lang="scss">
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
.about {
width: 750rpx;
flex-direction: column;
}
.box {
margin-top: 100px;
flex-direction: column;
justify-content: center;
align-items: center;
}
.logoImg {
margin-bottom: 10upx;
width: 160upx;
height: 160upx;
border-radius: 15px;
}
.tip {
font-size: 24rpx;
margin-top: 10px;
}
.appName {
margin-top: 20px;
font-size: 42rpx;
font-weight: 500;
}
.copyright {
width: 750upx;
font-size: 32rpx;
flex-direction: column;
justify-content: center;
align-items: center;
bottom: 20px;
left: 0;
position: fixed;
}
.hint {
color: #999999;
font-size: 26rpx;
}
.icon {
width: 34rpx;
}
#download {
background-color: #2A9839;
color: #FFFFFF;
margin: 55rpx;
padding: 5px;
height: 30px;
width: 160rpx;
border-radius: 100px;
flex-direction: row;
align-items: center;
justify-content: center;
}
.download-text {
font-size: 32rpx;
}
.mask {
position: fixed;
top: 0;
left: 0;
width: 750rpx;
height: 100vh;
flex-direction: row;
justify-content: flex-end;
background-color: rgba(0, 0, 0, 0.6);
}
.mask image {
width: 600rpx;
}
</style>

View File

@ -0,0 +1,77 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :where="udbWhere"
collection="opendb-news-articles" @load="isLoading == false" @error="isLoading == false"
field="title,_id" :page-size="10">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" :clickable="true"
@click="handleItemClick(item)">
<template v-slot:body>
<view class="item">
<text>{{item.title}}</text>
<uni-dateformat class="article-date" :date="readNewsLog[index].last_time" format="yyyy-MM-dd hh:mm"
:threshold="[0, 0]" />
</view>
</template>
</uni-list-item>
</uni-list>
<uni-load-state @networkResume="refreshData" :state="{data,pagination,hasMore, loading, error}"></uni-load-state>
</unicloud-db>
</view>
</template>
<script>
export default {
data() {
return {
isLoading: true,
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: '',
},
readNewsLog:[],
udbWhere:''
}
},
onLoad() {
this.readNewsLog = uni.getStorageSync('readNewsLog')||[];
let readNewsLogIds = this.readNewsLog.map(({article_id})=>article_id)
console.log(typeof readNewsLogIds,readNewsLogIds);
this.udbWhere = `"_id" in ${JSON.stringify(readNewsLogIds)}`
uni.setNavigationBarTitle({
title: this.$t('newsLog.navigationBarTitle')
})
},
onPullDownRefresh() {
this.refreshData();
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
refreshData() {
this.$refs.udb.loadData({
clear: true
}, (res) => {
uni.stopPullDownRefresh()
})
},
handleItemClick(item) {
uni.navigateTo({
url: '/pages/list/detail?id=' + item._id + '&title=' + item.title
})
}
}
}
</script>
<style>
.item{
display: flex;
flex-direction: column;
}
.article-date {
color: #C8C7CC;
}
</style>

View File

@ -0,0 +1,118 @@
/**
* 判断Push是否开启
*/
function isTurnedOnPush(){
var isOn = undefined;
try{
if('iOS' == plus.os.name){
var types = 0;
var app = plus.ios.invoke('UIApplication', 'sharedApplication');
var settings = plus.ios.invoke(app, 'currentUserNotificationSettings');
if(settings){
types = settings.plusGetAttribute('types');
plus.ios.deleteObject(settings);
}else{
types = plus.ios.invoke(app, 'enabledRemoteNotificationTypes');
}
plus.ios.deleteObject(app);
isOn = (0!=types);
}else{
var main = plus.android.runtimeMainActivity();
var manager = plus.android.invoke('com.igexin.sdk.PushManager', 'getInstance');
isOn = plus.android.invoke(manager, 'isPushTurnedOn', main);
}
}catch(e){
console.error('exception in isTurnedOnPush@dc-push!!');
}
return isOn;
}
/**
* 打开Push
* Android平台 - 打开个推UniPush的推送通道
* iOS平台 - 如果开启通知功能,则打开应用的设置页面引导用户开启通知
*/
function turnOnPush(){
try{
if('iOS' == plus.os.name){
// 如果设置中没有开启通知,则打开应用的设置界面
if(!isTurnedOnPush()){
settingInIos();
}
}else{
var main = plus.android.runtimeMainActivity();
var manager = plus.android.invoke('com.igexin.sdk.PushManager', 'getInstance');
plus.android.invoke(manager, 'turnOnPush', main);
}
}catch(e){
console.error('exception in turnOnPush@dc-push!!');
}
}
/**
* 关闭Push
* Android平台 - 关闭个推UniPush的推送通道
* iOS平台 - 不做任何操作
*/
function trunOffPush(){
try{
if('iOS' == plus.os.name){
// 这里不做任何操作(不引导用户关闭应用的推送能力),应该通知业务服务器不向此用户下发推送消息
}else{
var main = plus.android.runtimeMainActivity();
var manager = plus.android.invoke('com.igexin.sdk.PushManager', 'getInstance');
plus.android.invoke(manager, 'turnOffPush', main);
}
}catch(e){
console.error('exception in trunOffPush@dc-push!!');
}
}
/**
* iOS平台打开应用设置界面
*/
function settingInIos(){
try{
if('iOS' == plus.os.name){
var app = plus.ios.invoke('UIApplication', 'sharedApplication');
var setting = plus.ios.invoke('NSURL', 'URLWithString:', 'app-settings:');
plus.ios.invoke(app, 'openURL:', setting);
plus.ios.deleteObject(setting);
plus.ios.deleteObject(app);
}
}catch(e){
console.error('exception in settingInIos@dc-push!!');
}
}
/**
* android打开应用设置页面
*/
function settingInAndroid(){
if (uni.getSystemInfoSync().platform == "android") {
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var Settings = plus.android.importClass('android.provider.Settings');
var intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// 安卓跳转设置页面详细查看(https://ask.dcloud.net.cn/question/14732)
main.startActivity(intent);
}
}
/**
* 打开应用设置界面
*/
function setting(){
if (uni.getSystemInfoSync().platform == "ios") {
settingInIos();
}
if (uni.getSystemInfoSync().platform == "android") {
settingInAndroid();
}
}
export default {
isOn: isTurnedOnPush,
iosSetting: settingInIos,
on: turnOnPush,
off: trunOffPush,
setting:setting
}

View File

@ -0,0 +1,325 @@
<template>
<view class="content">
<!-- 功能列表 -->
<uni-list class="mt10" :border="false">
<uni-list-item :title="$t('settings.userInfo')" to="/uni_modules/uni-id-pages/pages/userinfo/userinfo"
link="navigateTo"></uni-list-item>
<uni-list-item v-if="userInfo.mobile" :title="$t('settings.changePassword')"
:to="'/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='+ userInfo.mobile"
link="navigateTo"></uni-list-item>
</uni-list>
<uni-list class="mt10" :border="false">
<!-- #ifndef H5 -->
<!-- #ifdef APP-PLUS -->
<!-- 检查push过程未结束不显示push设置项 -->
<uni-list-item :title="$t('settings.clearTmp')" @click="clearTmp" link></uni-list-item>
<uni-list-item v-show="pushIsOn != 'wait'" :title="$t('settings.pushServer')"
@click.native="pushIsOn?pushServer.off():pushServer.on()" showSwitch
:switchChecked="pushIsOn"></uni-list-item>
<!-- #endif -->
<uni-list-item v-if="supportMode.includes('fingerPrint')" :title="$t('settings.fingerPrint')"
@click.native="startSoterAuthentication('fingerPrint')" link></uni-list-item>
<uni-list-item v-if="supportMode.includes('facial')" :title="$t('settings.facial')"
@click="startSoterAuthentication('facial')" link></uni-list-item>
<!-- #endif -->
<uni-list-item v-if="i18nEnable" :title="$t('settings.changeLanguage')" @click="changeLanguage"
:rightText="currentLanguage" link></uni-list-item>
</uni-list>
<!-- 退出/登录 按钮 -->
<view class="bottom-back" @click="changeLoginState">
<text class="bottom-back-text" v-if="hasLogin">{{$t('settings.logOut')}}</text>
<text class="bottom-back-text" v-else>{{$t('settings.login')}}</text>
</view>
</view>
</template>
<script>
import pushServer from './dc-push/push.js';
import {
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
export default {
data() {
return {
pushServer: pushServer,
supportMode: [],
pushIsOn: "wait",
currentLanguage: "",
userInfo: {}
}
},
computed: {
hasLogin() {
return store.hasLogin
},
i18nEnable() {
return getApp().globalData.config.i18n.enable
}
},
onLoad() {
this.currentLanguage = uni.getStorageSync('CURRENT_LANG') == "en" ? 'English' : '简体中文'
uni.setNavigationBarTitle({
title: this.$t('settings.navigationBarTitle')
})
// #ifdef APP-PLUS || MP-WEIXIN
uni.checkIsSupportSoterAuthentication({
success: (res) => {
this.supportMode = res.supportMode
},
fail: (err) => {
console.log(err);
}
})
// #endif
},
onShow() {
// 检查手机端获取推送是否开启
//#ifdef APP-PLUS
setTimeout(() => {
this.pushIsOn = pushServer.isOn();
}, 300)
//#endif
},
methods: {
async changeLoginState() {
if (this.hasLogin) {
await mutations.logout()
} else {
uni.redirectTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
});
}
},
/**
* 开始生物认证
*/
startSoterAuthentication(checkAuthMode) {
console.log(checkAuthMode);
let title = {
"fingerPrint": this.$t('settings.fingerPrint'),
"facial": this.$t('settings.facial')
} [checkAuthMode]
// 检查是否开启认证
this.checkIsSoterEnrolledInDevice({
checkAuthMode,
title
})
.then(() => {
console.log(checkAuthMode, title);
// 开始认证
uni.startSoterAuthentication({
requestAuthModes: [checkAuthMode],
challenge: '123456', // 微信端挑战因子
authContent: this.$t('settings.please') + " " + `${title}`,
complete: (res) => {
console.log(res);
},
success: (res) => {
console.log(res);
if (res.errCode == 0) {
/**
* 验证成功后开启自己的业务逻辑
*
* app端以此为依据 验证成功
*
* 微信小程序需要再次通过后台验证resultJSON与resultJSONSignature获取最终结果
*/
return uni.showToast({
title: `${title}` + this.$t('settings.successText'),
icon: 'none'
});
}
uni.showToast({
title: this.$t('settings.failTip'),
icon: 'none'
});
},
fail: (err) => {
console.log(err);
console.log(`认证失败:${err.errCode}`);
uni.showToast({
title: this.$t('settings.authFailed'),
// title: `认证失败`,
icon: 'none'
});
}
})
})
},
checkIsSoterEnrolledInDevice({
checkAuthMode,
title
}) {
return new Promise((resolve, reject) => {
uni.checkIsSoterEnrolledInDevice({
checkAuthMode,
success: (res) => {
console.log(res);
if (res.isEnrolled) {
return resolve(res);
}
uni.showToast({
title: this.$t('settings.deviceNoOpen') + `${title}`,
icon: 'none'
});
reject(res);
},
fail: (err) => {
console.log(err);
uni.showToast({
title: `${title}` + this.$t('settings.fail'),
icon: 'none'
});
reject(err);
}
})
})
},
clearTmp() {
uni.showLoading({
title: this.$t('settings.clearing'),
mask: true
});
/*
任何临时存储或删除不直接影响程序运行逻辑清除缓存必定造成业务逻辑的变化打开页面的图片不从缓存中读取而从网络请求的内容都可以视为缓存。主要有storage、和file写入。
缓存分为三部分
原生层webview、x5播放器的、第三方sdk的、地图组件等
前端框架(重启就会自动清除)
开发者自己的逻辑(如:
本示例的 检测更新功能下载了apk安装包
其他逻辑需要根据开发者自己的业务设计
比如:有聊天功能的应用,聊天记录是否视为缓存,还是单独提供清除聊天记录的功能由开发者自己设计
*/
uni.getSavedFileList({
success: res => {
if (res.fileList.length > 0) {
uni.removeSavedFile({
filePath: res.fileList[0].filePath,
complete: res => {
console.log(res);
uni.hideLoading()
uni.showToast({
title: this.$t('settings.clearedSuccessed'),
icon: 'none'
});
}
});
} else {
uni.hideLoading()
uni.showToast({
title: this.$t('settings.clearedSuccessed'),
icon: 'none'
});
}
},
complete: e => {
console.log(e);
}
});
},
changeLanguage() {
console.log('语言切换')
uni.showActionSheet({
itemList: ["English", "简体中文"],
success: res => {
console.log(res.tapIndex);
let language = uni.getStorageSync('CURRENT_LANG')
if (
!res.tapIndex && language == 'zh-Hans' || res.tapIndex && language == 'en'
) {
const globalData = getApp().globalData
if (language === 'en') {
language = globalData.locale = 'zh-Hans'
} else {
language = globalData.locale = 'en'
}
uni.setStorageSync('CURRENT_LANG', language)
getApp().globalData.$i18n.locale = language
this.currentLanguage = res.tapIndex ? '简体中文' : 'English'
if (uni.setLocale) {
uni.setLocale(language)
}
uni.reLaunch({
url: '/pages/index/index',
complete: () => {
uni.$emit("changeLanguage", language)
}
})
}
},
fail: () => {},
complete: () => {}
});
}
}
}
</script>
<style>
/* #ifndef APP-NVUE */
page {
flex: 1;
width: 100%;
height: 100%;
}
uni-button:after {
border: none;
border-radius: 0;
}
/* #endif */
.content {
/* #ifndef APP-NVUE */
display: flex;
width: 750rpx;
height: 100vh;
/* #endif */
flex-direction: column;
flex: 1;
background-color: #F9F9F9;
}
.bottom-back {
margin-top: 10px;
width: 750rpx;
height: 44px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
/* #ifndef APP-NVUE */
border: none;
/* #endif */
border-width: 0;
border-radius: 0;
background-color: #FFFFFF;
}
.bottom-back-text {
font-size: 33rpx;
}
.mt10 {
margin-top: 10px;
}
/* #ifndef APP-NVUE || VUE3 */
.content ::v-deep .uni-list {
background-color: #F9F9F9;
}
.content ::v-deep .uni-list-item--disabled,
.list-item {
height: 50px;
margin-bottom: 1px;
}
/* #endif */
</style>

View File

@ -0,0 +1,506 @@
<template>
<view class="center">
<uni-sign-in ref="signIn"></uni-sign-in>
<view class="userInfo" @click.capture="toUserInfo">
<cloud-image width="150rpx" height="150rpx" v-if="hasLogin&&userInfo.avatar_file&&userInfo.avatar_file.url"
:src="userInfo.avatar_file.url"></cloud-image>
<view v-else class="defaultAvatarUrl">
<uni-icons color="#ffffff" size="50" type="person-filled" />
</view>
<view class="logo-title">
<text class="uer-name" v-if="hasLogin">{{userInfo.nickname||userInfo.username||userInfo.mobile}}</text>
<text class="uer-name" v-else>{{$t('mine.notLogged')}}</text>
</view>
</view>
<uni-grid class="grid" :column="4" :showBorder="false" :square="true">
<uni-grid-item class="item" v-for="(item,index) in gridList" @click.native="tapGrid(index)" :key="index">
<uni-icons class="icon" color="#007AFF" :type="item.icon" size="26"></uni-icons>
<text class="text">{{item.text}}</text>
</uni-grid-item>
</uni-grid>
<uni-list class="center-list" v-for="(sublist , index) in ucenterList" :key="index">
<uni-list-item v-for="(item,i) in sublist" :title="item.title" link :rightText="item.rightText" :key="i"
:clickable="true" :to="item.to" @click="ucenterListClick(item)" :show-extra-icon="true"
:extraIcon="{type:item.icon,color:'#999'}">
<template v-slot:footer>
<view v-if="item.showBadge" class="item-footer">
<text class="item-footer-text">{{item.rightText}}</text>
<view class="item-footer-badge"></view>
</view>
</template>
</uni-list-item>
</uni-list>
</view>
</template>
<script>
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
// #ifdef APP
import UniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
const uniShare = new UniShare()
// #endif
const db = uniCloud.database();
import {
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
export default {
// #ifdef APP
onBackPress({
from
}) {
if (from == 'backbutton') {
this.$nextTick(function() {
uniShare.hide()
})
return uniShare.isShow;
}
},
// #endif
data() {
return {
gridList: [{
"text": this.$t('mine.noticeText'),
"icon": "email"
},
{
"text": this.$t('mine.appsText'),
"icon": "cloud-upload"
},
{
"text": this.$t('mine.scanText'),
"event": "toScan",
"icon": "scan"
},
{
"text": this.$t('mine.scoreText'),
"icon": "shop"
}
],
ucenterList: [
[
// #ifdef APP-PLUS
{
"title": this.$t('mine.signInByAd'),
"event": 'signInByAd',
"icon": "compose"
},
// #endif
{
"title": this.$t('mine.signIn'),
"event": 'signIn',
"icon": "compose"
},
// #ifdef APP-PLUS
{
"title": this.$t('mine.toEvaluate'),
"event": 'gotoMarket',
"icon": "star"
},
//#endif
{
"title": this.$t('mine.readArticles'),
"to": './read-news-log/read-news-log',
"icon": "flag"
},
{
"title": this.$t('mine.myScore'),
"to": '',
"event": 'getScore',
"icon": "paperplane"
}
// #ifdef APP-PLUS
, {
"title": this.$t('mine.invite'),
"event": 'share',
"icon": "redo"
}
// #endif
],
[{
"title": this.$t('mine.feedback'),
"to": '/uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback',
"icon": "help"
}, {
"title": this.$t('mine.newsList'),
"to": '/uni_modules/uni-cms-article/pages/list/list',
"icon": "list"
}, {
"title": this.$t('mine.articleList'),
"to": '/pages/uni-starter/list/list',
"icon": "settings"
}, {
"title": this.$t('mine.settings'),
"to": './settings/settings',
"icon": "gear"
}]
// #ifdef APP-PLUS
,
[{
"title": this.$t('mine.about'),
"to": './about/about',
"icon": "info"
}]
// #endif
],
listStyles: {
"height": "150rpx", // 边框高度
"width": "150rpx", // 边框宽度
"border": { // 如果为 Boolean 值,可以控制边框显示与否
"color": "#eee", // 边框颜色
"width": "1px", // 边框宽度
"style": "solid", // 边框样式
"radius": "100%" // 边框圆角,支持百分比
}
}
}
},
onLoad() {
//#ifdef APP-PLUS
this.ucenterList[this.ucenterList.length - 2].unshift({
title: this.$t('mine.checkUpdate'), // this.this.$t('mine.checkUpdate')"检查更新"
rightText: this.appVersion.version + '-' + this.appVersion.versionCode,
event: 'checkVersion',
icon: 'loop',
showBadge: this.appVersion.hasNew
})
//#endif
},
onShow() {},
computed: {
userInfo() {
return store.userInfo
},
hasLogin() {
return store.hasLogin
},
// #ifdef APP-PLUS
appVersion() {
return getApp().appVersion
},
// #endif
appConfig() {
return getApp().globalData.config
}
},
methods: {
toSettings() {
uni.navigateTo({
url: "./settings/settings"
})
},
signIn() { //普通签到
this.$refs.signIn.open()
},
signInByAd() { //看激励视频广告签到
this.$refs.signIn.showRewardedVideoAd()
},
/**
* 个人中心项目列表点击事件
*/
ucenterListClick(item) {
if (!item.to && item.event) {
this[item.event]();
}
},
async checkVersion() {
let res = await callCheckVersion()
console.log(res);
if (res.result.code > 0) {
checkUpdate()
} else {
uni.showToast({
title: res.result.message,
icon: 'none'
});
}
},
toUserInfo() {
uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
})
},
//TODO,扫码识别后的相应操作
toScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ["qrCode"],
success: (e) => {
console.log(e.result)
},
fail: (e) => {
console.error(e)
}
})
},
tapGrid(index) {
if (!this.gridList[index].event) {
uni.showToast({
// title: '你点击了,第' + (index + 1) + '个',
title: this.$t('mine.clicked') + " " + (index + 1),
icon: 'none'
});
} else {
// console.log(this.gridList[index]);
this[this.gridList[index].event]();
}
},
/**
* 去应用市场评分
*/
gotoMarket() {
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == "ios") {
// 这里填写appstore应用id
let appstoreid = this.appConfig.marketId.ios; // 'id1417078253';
console.log({
appstoreid
});
plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/' + appstoreid + '?mt=8',
err => {
console.log('plus.runtime.openURL err:' + JSON.stringify(err));
});
}
if (uni.getSystemInfoSync().platform == "android") {
var Uri = plus.android.importClass("android.net.Uri");
var uri = Uri.parse("market://details?id=" + this.appConfig.marketId.android);
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent(Intent.ACTION_VIEW, uri);
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
}
// #endif
},
/**
* 获取积分信息
*/
getScore() {
if (!this.userInfo) return uni.showToast({
title: this.$t('mine.checkScore'),
icon: 'none'
});
uni.showLoading({
mask: true
})
db.collection("uni-id-scores")
.where('"user_id" == $env.uid')
.field('score,balance')
.orderBy("create_date", "desc")
.limit(1)
.get()
.then((res) => {
console.log(res);
const data = res.result.data[0];
let msg = '';
msg = data ? (this.$t('mine.currentScore') + data.balance) : this.$t('mine.noScore');
uni.showToast({
title: msg,
icon: 'none'
});
}).finally(() => {
uni.hideLoading()
})
},
async share() {
let {
result
} = await db.collection('uni-id-users').where("'_id' == $cloudEnv_uid").field('my_invite_code')
.get()
let myInviteCode = result.data[0].my_invite_code
if (!myInviteCode) {
return uni.showToast({
title: '请检查uni-config-center中uni-id配置是否已启用 autoSetInviteCode',
icon: 'none'
});
}
console.log({
myInviteCode
});
let {
appName,
logo,
company,
slogan
} = this.appConfig.about
// #ifdef APP-PLUS
uniShare.show({
content: { //公共的分享类型type、链接herf、标题title、summary描述、imageUrl缩略图
type: 0,
href: this.appConfig.h5.url +
`/#/pages/ucenter/invite/invite?code=uniInvitationCode:${myInviteCode}`,
title: appName,
summary: slogan,
imageUrl: logo +
'?x-oss-process=image/resize,m_fill,h_100,w_100' //压缩图片解决在ios端分享图过大导致的图片失效问题
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": this.$t('common.wechatFriends'),
"share": {
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": this.$t('common.wechatBbs'),
"share": {
"provider": "weixin",
"scene": "WXSceneTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": this.$t('common.weibo'),
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": this.$t('common.copy'),
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": this.$t('common.more'),
"share": "shareSystem"
}
],
cancelText: this.$t('common.cancelShare'),
}, e => { //callback
console.log(e);
})
// #endif
}
}
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
page {
background-color: #f8f8f8;
}
/* #endif*/
.center {
flex: 1;
flex-direction: column;
background-color: #f8f8f8;
}
.userInfo {
// padding: 20rpx;
padding-top: 60px;
background-image: url(@/static/uni-center/headers.png);
flex-direction: column;
align-items: center;
}
.defaultAvatarUrl {
width: 150rpx;
height: 150rpx;
background-color: #007aff;
border-radius: 100%;
justify-content: center;
align-items: center;
}
.logo-title {
flex: 1;
align-items: center;
justify-content: space-between;
flex-direction: row;
}
.uer-name {
height: 100rpx;
line-height: 100rpx;
font-size: 38rpx;
color: #FFFFFF;
}
.center-list {
margin-bottom: 30rpx;
background-color: #f9f9f9;
}
.center-list-cell {
width: 750rpx;
background-color: #007AFF;
height: 40rpx;
}
.grid {
background-color: #FFFFFF;
margin-bottom: 6px;
}
.uni-grid .text {
font-size: 16px;
height: 25px;
line-height: 25px;
color: #817f82;
}
.uni-grid .item ::v-deep .uni-grid-item__box {
justify-content: center;
align-items: center;
}
/*修改边线粗细示例*/
/* #ifndef APP-NVUE */
.center-list ::v-deep .uni-list--border:after {
-webkit-transform: scaleY(0.2);
transform: scaleY(0.2);
margin-left: 80rpx;
}
.center-list ::v-deep .uni-list--border-top,
.center-list ::v-deep .uni-list--border-bottom {
display: none;
}
/* #endif */
.item-footer {
flex-direction: row;
align-items: center;
}
.item-footer-text {
color: #999;
font-size: 24rpx;
padding-right: 10rpx;
}
.item-footer-badge {
width: 20rpx;
height: 20rpx;
/* #ifndef APP-NVUE */
border-radius: 50%;
/* #endif */
/* #ifdef APP-NVUE */
border-radius: 10rpx;
/* #endif */
background-color: #DD524D;
}
</style>