提交 8f0945e8 编写于 作者: L linju

23

上级 57405b69
...@@ -12,19 +12,13 @@ ...@@ -12,19 +12,13 @@
uni.preloadPage({ uni.preloadPage({
url: "/pages/ucenter/settings/settings", url: "/pages/ucenter/settings/settings",
complete:e=>{ complete:e=>{
console.log(e); // console.log(e);
}
});
uni.preloadPage({
url: "uni_modules/uni-login-page/pages/index/index",
complete:e=>{
console.log(e);
} }
}); });
// #ifdef APP-PLUS // #ifdef APP-PLUS
//预加载一键登录 //预加载一键登录
plus.oauth.getServices(oauthServices=>{ plus.oauth.getServices(oauthServices=>{
console.log(oauthServices); // console.log(oauthServices);
oauthServices.forEach(({_id},item)=>{ oauthServices.forEach(({_id},item)=>{
if(_id=='provider'){ if(_id=='provider'){
uni.preLogin({ uni.preLogin({
......
...@@ -33,9 +33,9 @@ export default function() { ...@@ -33,9 +33,9 @@ export default function() {
list.forEach(item=>{ list.forEach(item=>{
uni.addInterceptor(item,{ uni.addInterceptor(item,{
invoke(e){// 调用前拦截 invoke(e){// 调用前拦截
console.log(e); //console.log(e);
const token = uni.getStorageSync('uni_id_token') const token = uni.getStorageSync('uni_id_token')
console.log(token); // console.log(token);
const url = e.url.split('?')[0] const url = e.url.split('?')[0]
//拦截强制登陆页面 //拦截强制登陆页面
if (needLogin.includes(url) && token == '') { if (needLogin.includes(url) && token == '') {
...@@ -68,7 +68,7 @@ export default function() { ...@@ -68,7 +68,7 @@ export default function() {
}, },
complete(e){ // 完成回调拦截 complete(e){ // 完成回调拦截
console.log(e); //console.log(e);
}, },
returnValue(){// 返回结果拦截 returnValue(){// 返回结果拦截
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
"transformPx" : false, "transformPx" : false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus" : {
"compatible": {
"ignoreVersion": true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持
},
"usingComponents" : true, "usingComponents" : true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3, "compilerVersion" : 3,
......
...@@ -215,20 +215,20 @@ ...@@ -215,20 +215,20 @@
"navigationBarBackgroundColor": "#FFFFFF", "navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
}, },
"condition": { // "condition": {
"list": [ // "list": [
{ // {
"path": "uni_modules/uni-login-page/pages/index/index" // "path": "uni_modules/uni-login-page/pages/index/index"
}, // },
{ // {
"path": "pages/test/test" // "path": "pages/test/test"
}, // },
{ // {
"path":"pages/ucenter/settings/settings" // "path":"pages/ucenter/settings/settings"
} // }
], // ],
"current":2 // "current":1
}, // },
"tabBar": { "tabBar": {
"color": "#7A7E83", "color": "#7A7E83",
"selectedColor": "#007AFF", "selectedColor": "#007AFF",
......
...@@ -8,77 +8,92 @@ ...@@ -8,77 +8,92 @@
<text>应用相关权限</text> <text>应用相关权限</text>
<button type="default" @click="openAppPermissionSetting">打开</button> <button type="default" @click="openAppPermissionSetting">打开</button>
<button type="default" @click="iosSetting">iosSetting</button> --> <button type="default" @click="iosSetting">iosSetting</button> -->
<button type="default" @click="openCamera">打开相机</button> <!-- <button type="default" @click="openCamera">打开相机</button> -->
<button type="default" @click="openGridPage">打开一个需要登陆的页面</button> <!-- <button type="default" @click="openGridPage">打开一个需要登陆的页面</button> -->
<button type="default" @click="showShare">打开分享</button>
<!-- <uni-bottom-menu ref="bottomMenu" @clickItem="clickItem" :list="menus"></uni-bottom-menu> -->
</view> </view>
</template> </template>
<script> <script>
import permision from '@/js_sdk/wa-permission/permission.js'; // import permision from '@/js_sdk/wa-permission/permission.js';
import uniShare from 'uni_modules/uni-share/js_sdk/main.js';
export default { export default {
data() { data() {
return { return {
} }
}, },
onLoad() { onLoad() {
uni.addInterceptor('showToast',{ /*
invoke(e){// 调用前拦截
console.log(e)
e.title = "645"
},
success(e){// 成功回调拦截
console.log(e)
},
fail(e){// 失败回调拦截
console.log(e)
},
complete(e){
console.log(e)
},
returnValue(e){// 返回结果拦截
console.log(e)
}
})
return // uni.addInterceptor('showToast',{
/* // invoke(e){// 调用前拦截
当某个权限调用失败 // console.log(e)
1.先检测手机的该模块是否打开 // e.title = "645"
2.检测当前应用是否被授权了该模块对应的权限 // },
提示,并点击跳转到设置 // success(e){// 成功回调拦截
*/ // console.log(e)
this.changeAction('chooseImage', { // },
after_action: e => { // fail(e){// 失败回调拦截
console.log('changeAction', e); // console.log(e)
if(e.errCode === 11){ // },
uni.showModal({ // complete(e){
content: '无权限', // console.log(e)
confirmText:"前往设置", // },
success(e) { // returnValue(e){// 返回结果拦截
if(e.confirm){ // console.log(e)
permision.gotoAppPermissionSetting() // }
} // })
}
});
}
}
})
this.changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], { // return
before_action: e => { //
let needLoginUrls = ['/pages/grid/grid']//需要登陆的页面 // 当某个权限调用失败
let token = uni.getStorageSync('uni-id-token') // 1.先检测手机的该模块是否打开
if (needLoginUrls.includes(e.url) && token == '') { // 2.检测当前应用是否被授权了该模块对应的权限
console.log('该页面需要登陆,即将跳转到login页面'); // 提示,并点击跳转到设置
uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'}) //
return false // this.changeAction('chooseImage', {
} // after_action: e => {
return true // console.log('changeAction', e);
} // if(e.errCode === 11){
}) // uni.showModal({
// content: '无权限',
// confirmText:"前往设置",
// success(e) {
// if(e.confirm){
// permision.gotoAppPermissionSetting()
// }
// }
// });
// }
// }
// })
// this.changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], {
// before_action: e => {
// let needLoginUrls = ['/pages/grid/grid']//需要登陆的页面
// let token = uni.getStorageSync('uni-id-token')
// if (needLoginUrls.includes(e.url) && token == '') {
// console.log('该页面需要登陆,即将跳转到login页面');
// uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
// return false
// }
// return true
// }
// })
*/
}, },
methods: { methods: {
showShare(){
uniShare()
},
clickItem(e){
console.log(e);
uni.showToast({
title: e
});
},
openCamera(){ openCamera(){
uni.chooseImage({ uni.chooseImage({
sourceType: ["camera"], sourceType: ["camera"],
......
var nvMask,nvImageMenu;
export default {
show(list,callback){
if(!list){
list = [{
"img":"/static/sharemenu/wechatfriend.png",
"text":"图标文字"
}]
}
//以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
var screenWidth = plus.screen.resolutionWidth
//以360px宽度屏幕为例,上下左右边距及2排按钮边距留25像素,图标宽度55像素,同行图标间的间距在360宽的屏幕是30px,但需要动态计算,以此原则计算4列图标分别的left位置
//图标下的按钮文字距离图标5像素,文字大小12像素
//底部取消按钮高度固定为44px
//TODO 未处理横屏和pad,这些情况6个图标应该一排即可
var margin = 25,
iconWidth = 55,
icontextSpace = 5,
textHeight = 12
var left1 = margin / 360 * screenWidth
var iconSpace = (screenWidth - (left1 * 2) - (iconWidth * 4)) / 3 //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距
if (iconSpace <= 5) { //屏幕过窄时,缩小边距和图标大小,再算一次
margin = 15
iconWidth = 40
left1 = margin / 360 * screenWidth
iconSpace = (screenWidth - (left1 * 2) - (iconWidth * 4)) / 3 //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距
}
var left2 = left1 + iconWidth + iconSpace
var left3 = left1 + (iconWidth + iconSpace) * 2
var left4 = left1 + (iconWidth + iconSpace) * 3
var top1 = left1
var top2 = top1 + iconWidth + icontextSpace + textHeight + left1
nvMask = new plus.nativeObj.View("nvMask", { //先创建遮罩层
top: '0px',
left: '0px',
height: '100%',
width: '100%',
backgroundColor: 'rgba(0,0,0,0.2)'
});
nvMask.addEventListener("click", function() { //处理遮罩层点击
nvMask.hide();
nvImageMenu.hide();
})
nvImageMenu = new plus.nativeObj.View("nvImageMenu", { //创建底部图标菜单
bottom: '0px',
left: '0px',
height: (iconWidth + textHeight + 2 * margin)*(parseInt(list.length/4)+1) +44+'px',//'264px',
width: '100%',
backgroundColor: 'rgb(255,255,255)'
});
let myList = []
list.forEach((item,i)=>{
myList.push({
tag: 'img',
src: item.img,
position: {
top: eval('top'+( parseInt(i/4) +1)),
left: eval('left'+(1+i%4)),
width: iconWidth,
height: iconWidth
}
})
myList.push({
tag: 'font',
text: item.text,
textStyles: {
size: textHeight
},
position: {
top: eval('top'+(parseInt(i/4)+1)) + iconWidth + icontextSpace,
left: eval('left'+(1+i%4)),
width: iconWidth,
height: textHeight
}
})
})
//绘制底部图标菜单的内容
nvImageMenu.draw([
{
tag: 'rect',//菜单顶部的分割灰线
color: '#e7e7e7',
position: {
top: '0px',
height: '1px'
}
},
{
tag: 'font',
id: 'sharecancel',//底部取消按钮的文字
text: '取消分享',
textStyles: {
size: '14px'
},
position: {
bottom: '0px',
height: '44px'
}
},
{
tag: 'rect',//底部取消按钮的顶部边线
color: '#e7e7e7',
position: {
bottom: '45px',
height: '1px'
}
},
...myList
])
nvMask.show()
nvImageMenu.show() //5+应支持从底部向上弹出的动画
nvImageMenu.addEventListener("click",e=>{ //处理底部图标菜单的点击事件,根据点击位置触发不同的逻辑
// console.log("click menu"+JSON.stringify(e));
if (e.screenY > plus.screen.resolutionHeight - 44) { //点击了底部取消按钮
nvMask.hide();
nvImageMenu.hide();
} else if (e.clientX < 5 || e.clientX > screenWidth - 5 || e.clientY < 5) {
//屏幕左右边缘5像素及菜单顶部5像素不处理点击
} else { //点击了图标按钮
var iClickIndex = -1 //点击的图标按钮序号,第一个图标按钮的index为0
var iRow = e.clientY < (top2 - (left1 / 2)) ? 0 : 1
var iCol = -1
if (e.clientX < (left2 - (iconSpace / 2))) {
iCol = 0
} else if (e.clientX < (left3 - (iconSpace / 2))) {
iCol = 1
} else if (e.clientX < (left4 - (iconSpace / 2))) {
iCol = 2
} else {
iCol = 3
}
if (iRow == 0) {
iClickIndex = iCol
} else {
iClickIndex = iCol + 4
}
// console.log("点击按钮的序号: " + iClickIndex);
if (iClickIndex >= 0 && iClickIndex <= 5) { //处理具体的点击逻辑,此处也可以自行定义逻辑。如果增减了按钮,此处也需要跟着修改
callback(iClickIndex)
}
}
})
/* nvImageMenu.addEventListener("touchstart", function(e) {
if (e.screenY > (plus.screen.resolutionHeight - 44)) {
//TODO 这里可以处理按下背景变灰的效果
}
})
nvImageMenu.addEventListener("touchmove", function(e) {
//TODO 这里可以处理按下背景变灰的效果
if (e.screenY > plus.screen.resolutionHeight - 44) {}
})
nvImageMenu.addEventListener("touchend", function(e) {
//TODO 这里可以处理释放背景恢复的效果
})
*/
},
hide(){
nvMask.hide()
nvImageMenu.hide()
}
}
\ No newline at end of file
{
"id": "uni-image-menu",
"displayName": "uni-image-menu",
"version": "1.0.0",
"description": "uni-image-menu",
"keywords": [
"uni-image-menu"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"JS SDK",
"JS SDK"
],
"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-image-menu
\ No newline at end of file
const helpPage = '/pages/ucenter/help/help'; // 帮助页面 const helpPage = '/pages/ucenter/help/help'; // 帮助页面
import { import {mapMutations} from 'vuex';
mapGetters,
mapMutations
} from 'vuex';
let mixin = { let mixin = {
// // 监听帮助按钮 // // 监听帮助按钮
// onNavigationBarButtonTap(event) { // onNavigationBarButtonTap(event) {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<text class="tip-text">未注册的手机号验证通过后将自动注册</text> <text class="tip-text">未注册的手机号验证通过后将自动注册</text>
<!-- 其他登录方式 --> <!-- 其他登录方式 -->
<view class="auth-box"> <view class="auth-box" v-if="loginList.includes('password')">
<text class="login-text" hover-class="hover" @click="toPwdLogin">密码登录</text> <text class="login-text" hover-class="hover" @click="toPwdLogin">密码登录</text>
<!-- <text class="login-text" hover-class="hover" @click="openLoginList">其他登录方式</text> --> <!-- <text class="login-text" hover-class="hover" @click="openLoginList">其他登录方式</text> -->
</view> </view>
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
</template> </template>
<script> <script>
var univerify_first,currentWebview;//是否一键登陆优先 var univerify_first,currentWebview;//是否一键登陆优先
import baseappConfig from '@/baseapp.config.json';
import mixin from '../../common/loginPage.mixin.js'; import mixin from '../../common/loginPage.mixin.js';
var currentPage; var currentPage;
export default { export default {
...@@ -49,9 +50,11 @@ var univerify_first,currentWebview;//是否一键登陆优先 ...@@ -49,9 +50,11 @@ var univerify_first,currentWebview;//是否一键登陆优先
return { return {
phoneArea: ['+86'], phoneArea: ['+86'],
currenPhoneArea: '+86', currenPhoneArea: '+86',
loginList:[]
} }
}, },
onLoad(e) { onLoad(e) {
this.loginList = baseappConfig.router.login
univerify_first = e.univerify_first univerify_first = e.univerify_first
//#ifdef APP-PLUS //#ifdef APP-PLUS
if(univerify_first){ if(univerify_first){
...@@ -64,6 +67,7 @@ var univerify_first,currentWebview;//是否一键登陆优先 ...@@ -64,6 +67,7 @@ var univerify_first,currentWebview;//是否一键登陆优先
onReady() { onReady() {
//#ifdef APP-PLUS //#ifdef APP-PLUS
if(univerify_first){ if(univerify_first){
console.log('开始一键登陆');
this.$refs.uniQuickLogin.login('univerify') this.$refs.uniQuickLogin.login('univerify')
setTimeout(() => { setTimeout(() => {
currentWebview.setStyle({ currentWebview.setStyle({
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
<text class="login-text" @click="toRetrievePwd">找回密码</text> <text class="login-text" @click="toRetrievePwd">找回密码</text>
</view> </view>
</view> </view>
</view> </view>
<uni-quick-login ref="uniQuickLogin"></uni-quick-login>
</view> </view>
</template> </template>
......
...@@ -58,10 +58,9 @@ ...@@ -58,10 +58,9 @@
mounted() { mounted() {
//获取当前环境能用的快捷登陆方式 //获取当前环境能用的快捷登陆方式
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.showLoading();
plus.oauth.getServices(oauthServices=>{ plus.oauth.getServices(oauthServices=>{
this.oauthServices = oauthServices this.oauthServices = oauthServices
console.log(oauthServices); // console.log(oauthServices);
},err=>{ },err=>{
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
......
import uniImageMenu from 'uni_modules/uni-image-menu/js_sdk/uni-image-menu.js';
let old_menus = [{
"img": "/static/sharemenu/wechatfriend.png",
"text": "微信好友",
"share":{
"provider":"weixin",
"scene":"WXSceneSession"
}
},
{
"img": "/static/sharemenu/wechatmoments.png",
"text": "微信朋友圈",
"share":{
"provider":"weixin",
"scene":"WXSceneSession"
}
},
{
"img": "/static/sharemenu/weibo.png",
"text": "微博",
"share":{
"provider":"sinaweibo"
}
},
{
"img": "/static/sharemenu/qq.png",
"text": "QQ",
"share":{
"provider":"qq"
}
},
{
"img": "/static/sharemenu/copyurl.png",
"text": "复制",
"share":false
},
{
"img": "/static/sharemenu/more.png",
"text": "更多",
"share":"more"
}
]
let menus = []
plus.oauth.getServices(services=>{ //只显示有服务的项目
let servicesList = services.map(e=>e.id)
console.log(servicesList);
old_menus.forEach(item=>{
console.log(item.share.provider);
if(servicesList.includes(item.share.provider)){
menus.push(item)
}
})
},err=>{
uni.showModal({
title: '获取服务供应商失败:' +JSON.stringify(err),
showCancel: false,
confirmText: '知道了'
});
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
let shareContent = {
type: 0,
href: "https://uniapp.dcloud.io/api/plugins/share?id=share",
title: "主标题",
summary: "分享内容的摘要",
imageUrl: "https://uniapp.dcloud.io/api/plugins/share?id=share",
}
export default (callback) => {
uniImageMenu.show(menus,e=>{
console.log(e);
if(e<4){
uni.share({
...menus[e].share,
...shareContent,
success: function(res) {
console.log("success:" + JSON.stringify(res));
},
fail: function(err) {
console.log("fail:" + JSON.stringify(err));
},
complete() {
uniImageMenu.hide()
}
})
}
})
}
{
"id": "uni-share",
"displayName": "uni-share",
"version": "1.0.0",
"description": "uni-share",
"keywords": [
"uni-share"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"JS SDK",
"JS SDK"
],
"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-share
\ No newline at end of file
...@@ -3,7 +3,9 @@ import callCheckVersion from './call-check-version' ...@@ -3,7 +3,9 @@ import callCheckVersion from './call-check-version'
// 推荐再App.vue中使用 // 推荐再App.vue中使用
const PACKAGE_INFO_KEY = '__package_info__' const PACKAGE_INFO_KEY = '__package_info__'
export default function() { export default function() {
return
// #ifdef APP-PLUS // #ifdef APP-PLUS
callCheckVersion().then(async (e) => { callCheckVersion().then(async (e) => {
if (!e.result) return; if (!e.result) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册