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

优化删除冗余文件,规范文件命名

上级 e9d33106
<template>
<view class="login-iknow-wrap">
<text class="text-sub" v-for="(t, i) in innerText" :key="i" :class="t.to?'link-color':''"
@click="clickLink(t)">{{t.text || t}}</text>
</view>
</template>
<script>
/**
* text 政策描述文字
* link 高亮关键字及其链接
*/
export default {
name: "login-ikonw",
props: {
text: {
type: String,
default: ''
},
link: {
type: Array,
default: ()=>[]
}
},
data() {
return {
};
},
computed: {
innerText() {
if (this.link.length == 0) return this.text;
let textList = String(this.text);
this.link.forEach(item => {
textList = textList.replace(item.text, '$');
});
textList = textList.split('');
let list = [],
linkList = JSON.parse(JSON.stringify(this.link));
textList.forEach((text, tIndex) => {
if (text == '$') {
let currLink = linkList.shift();
currLink.text.split('').forEach(item => {
list.push({
text: item,
to: currLink.to
});
})
} else {
list.push({
text
})
}
});
return list;
}
},
methods: {
/**
* 点击跳转到协议页面
* @param {Object} link
*/
clickLink(link) {
uni.navigateTo({
url: link.to
})
}
}
}
</script>
<style scoped>
.login-iknow-wrap{
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: wrap;
}
.text-sub{
color: #8a8f8b;
font-size: 26rpx;
}
.link-color {
color: #04498c;
}
</style>
<template>
<view class="quick-login-box">
<view class="item" v-for="(item,index) in servicesList" :key="index"
@click="item.path?to(item.path):login(item.id,false)">
@click="item.path?to(item.path):login_before(item.id,false)">
<image class="logo" :src="item.logo" mode="widthFix"></image>
<text class="login-title">{{item.text}}</text>
</view>
......@@ -136,7 +136,7 @@
})
}
},
login(type, navigateBack = true) {
login_before(type, navigateBack = true) {
console.log(arguments);
console.log('services', services);
let oauthService = this.oauthServices.find((service) => service.id == type)
......@@ -149,7 +149,7 @@
code
}) => {
console.log(code);
this.quickLogin({
this.login({
code
}, type)
},
......@@ -171,7 +171,7 @@
})
Object.assign(e.authResult, res.userInfo)
}
this.quickLogin(e.authResult, type)
this.login(e.authResult, type)
},
fail: (err) => {
uni.hideLoading()
......@@ -209,7 +209,7 @@
}
})
},
quickLogin(params, type) { //联网验证登陆
login(params, type) { //联网验证登陆
console.log(params, type);
this.request('user-center/login_by_' + type, params, result => {
console.log(result);
......
......@@ -20,7 +20,7 @@
}
}
export default {
name: "send-sms-code",
name: "uni-send-sms-code",
props: {
/**
* 倒计时时长 s
......@@ -35,15 +35,15 @@
phone: {
type: [String, Number],
default: ''
},
/*
验证码类型,用于防止不同功能的验证码混用,目前支持的类型login登录、register注册、bind绑定手机、unbind解绑手机
*/
codeType:{
type: String,
default(){
return 'login'
}
},
/*
验证码类型,用于防止不同功能的验证码混用,目前支持的类型login登录、register注册、bind绑定手机、unbind解绑手机
*/
codeType:{
type: String,
default(){
return 'login'
}
}
},
data() {
......@@ -68,28 +68,28 @@
this.sendMsg();
})
},
sendMsg() {
let reg_phone = /^1\d{10}$/;
if(!reg_phone.test(this.phone))return uni.showToast({
title: '手机号格式错误',
icon: 'none'
});
this.request('user-center/sendSmsCode',
sendMsg() {
let reg_phone = /^1\d{10}$/;
if(!reg_phone.test(this.phone))return uni.showToast({
title: '手机号格式错误',
icon: 'none'
});
this.request('user-center/sendSmsCode',
{
"mobile": this.phone,
"type": this.codeType
},result=>{
console.log(result);
uni.showToast({
title: "短信验证码发送成功",
icon: 'none'
});
this.reverseNumber = Number(this.count);
this.getCode();
this.$emit('getCode');
}
)
},result=>{
console.log(result);
uni.showToast({
title: "短信验证码发送成功",
icon: 'none'
});
this.reverseNumber = Number(this.count);
this.getCode();
this.$emit('getCode');
}
)
},
getCode() {
if (this.reverseNumber == 0) {
......@@ -116,11 +116,11 @@
justify-content: center;
align-items: center;
}
.inner-text {
font-size: 28rpx;
color: #AAAAAA;
.inner-text {
font-size: 28rpx;
color: #AAAAAA;
}
.inner-text-active {
color: #007aff;
}
</style>
</style>
/**
* 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启
*/
var isIos
// #ifdef APP-PLUS
isIos = (plus.os.name == "iOS")
// #endif
// 判断推送权限是否开启
function judgeIosPermissionPush() {
var result = false;
var UIApplication = plus.ios.import("UIApplication");
var app = UIApplication.sharedApplication();
var enabledTypes = 0;
if (app.currentUserNotificationSettings) {
var settings = app.currentUserNotificationSettings();
enabledTypes = settings.plusGetAttribute("types");
console.log("enabledTypes1:" + enabledTypes);
if (enabledTypes == 0) {
console.log("推送权限没有开启");
} else {
result = true;
console.log("已经开启推送功能!")
}
plus.ios.deleteObject(settings);
} else {
enabledTypes = app.enabledRemoteNotificationTypes();
if (enabledTypes == 0) {
console.log("推送权限没有开启!");
} else {
result = true;
console.log("已经开启推送功能!")
}
console.log("enabledTypes2:" + enabledTypes);
}
plus.ios.deleteObject(app);
plus.ios.deleteObject(UIApplication);
return result;
}
// 判断定位权限是否开启
function judgeIosPermissionLocation() {
var result = false;
var cllocationManger = plus.ios.import("CLLocationManager");
var status = cllocationManger.authorizationStatus();
result = (status != 2)
console.log("定位权限开启:" + result);
// 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation
/* var enable = cllocationManger.locationServicesEnabled();
var status = cllocationManger.authorizationStatus();
console.log("enable:" + enable);
console.log("status:" + status);
if (enable && status != 2) {
result = true;
console.log("手机定位服务已开启且已授予定位权限");
} else {
console.log("手机系统的定位没有打开或未给予定位权限");
} */
plus.ios.deleteObject(cllocationManger);
return result;
}
// 判断麦克风权限是否开启
function judgeIosPermissionRecord() {
var result = false;
var avaudiosession = plus.ios.import("AVAudioSession");
var avaudio = avaudiosession.sharedInstance();
var permissionStatus = avaudio.recordPermission();
console.log("permissionStatus:" + permissionStatus);
if (permissionStatus == 1684369017 || permissionStatus == 1970168948) {
console.log("麦克风权限没有开启");
} else {
result = true;
console.log("麦克风权限已经开启");
}
plus.ios.deleteObject(avaudiosession);
return result;
}
// 判断相机权限是否开启
function judgeIosPermissionCamera() {
var result = false;
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
console.log("authStatus:" + authStatus);
if (authStatus == 3) {
result = true;
console.log("相机权限已经开启");
} else {
console.log("相机权限没有开启");
}
plus.ios.deleteObject(AVCaptureDevice);
return result;
}
// 判断相册权限是否开启
function judgeIosPermissionPhotoLibrary() {
var result = false;
var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
var authStatus = PHPhotoLibrary.authorizationStatus();
console.log("authStatus:" + authStatus);
if (authStatus == 3) {
result = true;
console.log("相册权限已经开启");
} else {
console.log("相册权限没有开启");
}
plus.ios.deleteObject(PHPhotoLibrary);
return result;
}
// 判断通讯录权限是否开启
function judgeIosPermissionContact() {
var result = false;
var CNContactStore = plus.ios.import("CNContactStore");
var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
if (cnAuthStatus == 3) {
result = true;
console.log("通讯录权限已经开启");
} else {
console.log("通讯录权限没有开启");
}
plus.ios.deleteObject(CNContactStore);
return result;
}
// 判断日历权限是否开启
function judgeIosPermissionCalendar() {
var result = false;
var EKEventStore = plus.ios.import("EKEventStore");
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
if (ekAuthStatus == 3) {
result = true;
console.log("日历权限已经开启");
} else {
console.log("日历权限没有开启");
}
plus.ios.deleteObject(EKEventStore);
return result;
}
// 判断备忘录权限是否开启
function judgeIosPermissionMemo() {
var result = false;
var EKEventStore = plus.ios.import("EKEventStore");
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
if (ekAuthStatus == 3) {
result = true;
console.log("备忘录权限已经开启");
} else {
console.log("备忘录权限没有开启");
}
plus.ios.deleteObject(EKEventStore);
return result;
}
// Android权限查询
function requestAndroidPermission(permissionID) {
return new Promise((resolve, reject) => {
plus.android.requestPermissions(
[permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
function(resultObj) {
var result = 0;
for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i];
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
var deniedAlwaysPermission = resultObj.deniedAlways[i];
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
result = -1
}
resolve(result);
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
// if (result != 1) {
// gotoAppPermissionSetting()
// }
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error.message);
resolve({
code: error.code,
message: error.message
});
}
);
});
}
// 使用一个方法,根据参数判断权限
function judgeIosPermission(permissionID) {
if (permissionID == "location") {
return judgeIosPermissionLocation()
} else if (permissionID == "camera") {
return judgeIosPermissionCamera()
} else if (permissionID == "photoLibrary") {
return judgeIosPermissionPhotoLibrary()
} else if (permissionID == "record") {
return judgeIosPermissionRecord()
} else if (permissionID == "push") {
return judgeIosPermissionPush()
} else if (permissionID == "contact") {
return judgeIosPermissionContact()
} else if (permissionID == "calendar") {
return judgeIosPermissionCalendar()
} else if (permissionID == "memo") {
return judgeIosPermissionMemo()
}
return false;
}
// 跳转到**应用**的权限页面
function gotoAppPermissionSetting() {
if (isIos) {
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);
}
}
// 检查系统的设备服务是否开启
// var checkSystemEnableLocation = async function () {
function checkSystemEnableLocation() {
if (isIos) {
var result = false;
var cllocationManger = plus.ios.import("CLLocationManager");
var result = cllocationManger.locationServicesEnabled();
console.log("系统定位开启:" + result);
plus.ios.deleteObject(cllocationManger);
return result;
} else {
var context = plus.android.importClass("android.content.Context");
var locationManager = plus.android.importClass("android.location.LocationManager");
var main = plus.android.runtimeMainActivity();
var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
var result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
console.log("系统定位开启:" + result);
return result
}
}
module.exports = {
judgeIosPermission: judgeIosPermission,
requestAndroidPermission: requestAndroidPermission,
checkSystemEnableLocation: checkSystemEnableLocation,
gotoAppPermissionSetting: gotoAppPermissionSetting
}
......@@ -9,12 +9,6 @@ Vue.prototype.request = request
//openApp();
App.mpType = 'app'
import nullComponents from '@/components/null/null.vue'
Vue.component('cell',nullComponents);
Vue.component('refresh',nullComponents);
Vue.component('refreshBox',nullComponents);
const app = new Vue({
...App,
store
......
......@@ -4,26 +4,9 @@
"path": "pages/list/list",
"style": {
"navigationStyle":"custom",
"enablePullDownRefresh": true,
"app-plus":{
// "titleNView":{ /*排除了H5*/
// "searchInput":{
// "placeholder":"请输入搜索的内容",
// "backgroundColor":"#efefef",
// "disabled":true,
// "borderRadius":"30px"
// }
// }
}
"enablePullDownRefresh": true
}
},
{
"path": "pages/test/test",
"style": {
"navigationBarTitleText": "测试页面",
"enablePullDownRefresh": false
}
},
{
"path": "pages/grid/grid",
"style": {
......@@ -218,9 +201,6 @@
{
"path": "pages/ucenter/login-page/index/index"
},
{
"path": "pages/test/test"
},
{
"path": "pages/ucenter/settings/settings"
}
......
......@@ -4,18 +4,12 @@
<uni-nav-bar :border="false"></uni-nav-bar>
<!-- #endif -->
<!-- 搜索功能 -->
<uni-search-bar class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
@click.native="searchClick" cancelButton="none" disabled />
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @load="handleLoad" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users"
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" cancelButton="none" disabled/>
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :page-size="10"
field="avatar,title,last_modify_date,user_id{username}">
<!-- 基于 uni-list 的页面布局 -->
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
<!-- #ifdef APP-NVUE -->
:style='{height:listHight+"px"}'
<!-- #endif -->
>
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true" :style="{height:listHight}">
<cell v-if="error">
<template slot="body">
<!-- 设置网络 -->
......@@ -34,7 +28,7 @@
</template>
</cell>
<uni-list-item :to="'./detail?id='+item._id+'&title='+item.title"
v-for="(item,index) in testData(data)" :key="index">
v-for="(item,index) in data" :key="index">
<!-- 通过header插槽定义列表左侧图片 -->
<template v-slot:header>
<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
......@@ -50,13 +44,13 @@
</view>
</uni-list-item>
<!-- 存在下一页数据,且不在加载中 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 -->
<template v-if="!loading">
<!-- 存在下一页数据 && 不是正在加载中 && 已经满一页; 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 -->
<template v-if="!loading&&data.length>10">
<cell v-if="hasMore">
<uni-load-more :status="options.status"></uni-load-more>
<uni-load-more status="more"></uni-load-more>
</cell>
<cell v-else>
<text class="noMore">- 没有更多数据了 -</text>
<cell v-else>
<uni-load-more status="noMore"></uni-load-more>
</cell>
</template>
</template>
......@@ -75,9 +69,23 @@
refreshState: 0,
listHight: 0
}
},
watch: {
keyword(keyword, oldValue) {
if(keyword){
this.where = `/${keyword}/.test(title)`;
}else{
this.where = '';
}
}
},
onReady() {
this.listHight = uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 65
// #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif
// #ifndef APP-NVUE
this.listHight = 'auto'
// #endif
cdbRef = this.$refs.udb
console.log(cdbRef);
},
......@@ -97,28 +105,18 @@
}
},
methods: {
testData(data) { //复制同一个数据多遍方便测试,正式项目中不要带
var testData = []
for (let i = 0; i < 10; i++) {
testData.push(...data)
}
return testData
},
handleLoad(data, ended, pagination) {
// `data` 当前查询结果 `ended` 是否有更多数据 `pagination` 分页信息 HBuilderX 3.1.5+ 支持
console.log(9527, data, ended, pagination);
//上拉加载成功
},
searchClick() {
// testData(data) { //复制同一个数据多遍方便测试,正式项目中不要带
// var testData = []
// for (let i = 0; i < 10; i++) {
// testData.push(...data)
// }
// return testData
// },
searchClick(e) { //点击搜索框
uni.hideKeyboard();
uni.navigateTo({
url: '/pages/list/search/search',
animationType: 'fade-in',
events: {
acceptDataFromOpenedPage(e) {
console.log(e);
}
}
animationType: 'fade-in'
});
},
retry(){
......@@ -189,8 +187,7 @@
/* #ifndef APP-PLUS */
z-index: 9;
/* #endif */
}
}
.show-refresh-tip {
transform: translateY(0);
height: 40px;
......@@ -214,15 +211,5 @@
width: 750rpx;
text-align: center;
}
.uni-list {}
.noMore {
width: 750rpx;
text-align: center;
color: #6E6E6E;
font-size: 26rpx;
height: 55px;
line-height: 55px;
}
</style>
<template>
<view>
<!-- <button type="default" @click="openSystemSetting('ACTION_BLUETOOTH_SETTINGS')">设置蓝牙</button>
<button type="default" @click="openSystemSetting('ACTION_LOCALE_SETTINGS')">设置语言</button>
<button type="default" @click="openSystemSetting('ACTION_LOCATION_SOURCE_SETTINGS')">设置gps</button>
<button type="default" @click="openSystemSetting('ACTION_WIFI_SETTINGS')">设置wifi</button>
<button type="default" @click="openSystemSetting('ACTION_DATA_ROAMING_SETTINGS')">数据网络</button>
<text>应用相关权限</text>
<button type="default" @click="openAppPermissionSetting">打开</button>
<button type="default" @click="iosSetting">iosSetting</button> -->
<button type="default" @click="open=1">打开</button>
<web-view v-if="open" style="height: 1px;" src="https://ur.alipay.com/2tZMWI"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
open:0
}
},
onLoad() {
// 当某个权限调用失败
// 1.先检测手机的该模块是否打开
// 2.检测当前应用是否被授权了该模块对应的权限
// 提示,并点击跳转到设置
// plus.runtime.openURL('https://ur.alipay.com/2tZMWI',e=>{
// console.log(e);
// })
},
methods: {
openCamera(){
uni.chooseImage({
sourceType: ["camera","album"],
complete: (e) => {
console.log(e);
}
})
},
iosSetting() {
plus.runtime.launchApplication({
action: 'App-Prefs:root=WIFI'
}, function(e) {
//console.log(JSON.stringify(e));
}); //WIFI
},
openSystemSetting(type) {
var main = plus.android.runtimeMainActivity(); //获取activity
var Intent = plus.android.importClass('android.content.Intent');
var Settings = plus.android.importClass('android.provider.Settings');
var intent = new Intent(Settings[type]); //可设置表中所有Action字段
main.startActivity(intent);
},
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);
}
},
}
}
</script>
<style>
</style>
<template>
<view>
<cdb-list v-slot="{data}" :reduce-height="0" collection="opendb-feedback" :page-size="3" class="j-list">
<cell v-for="(rows,index) in data" :key="index">
<view style="flex-direction: row;">
<view v-for="item in rows" :key="item._id" class="item">我是内容{{item}}-{{index}}</view>
</view>
</cell>
</cdb-list>
</view>
</template>
<script>
export default {
data() {
return {}
},
onLoad() {
},
methods: {}
}
</script>
<style>
.item {
height: 500px;
width: 750rpx;
background-color: #007AFF;
margin-bottom: 5px;
}
</style>
<template>
<view class="content">
<!-- 顶部文字 -->
<text class="tit">请输入验证码</text>
<text class="tip">{{tipText}}</text>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-easyinput type="number" class="easyinput" :inputBorder="false"
v-model="code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
<send-sms-code :phone="phone" ref="sendSmsCode"></send-sms-code>
</template>
</uni-easyinput>
<button class="send-btn" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">登录</button>
</uni-forms>
<uni-quick-login></uni-quick-login>
<view class="content">
<!-- 顶部文字 -->
<text class="tit">请输入验证码</text>
<text class="tip">{{tipText}}</text>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-easyinput type="number" class="easyinput" :inputBorder="false"
v-model="code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
<uni-send-sms-code :phone="phone" ref="sendSmsCode"></uni-send-sms-code>
</template>
</uni-easyinput>
<button class="send-btn" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">登录</button>
</uni-forms>
<uni-quick-login></uni-quick-login>
</view>
</template>
<script>
<script>
import mixin from '../common/login-page.mixin.js';
export default {
export default {
mixins:[mixin],
data() {
return {
code:'',
phone:''
code:'',
phone:''
}
},
computed: {
tipText() {
return `验证码已通过短信发送至${this.phone}。`;
},
canSubmit(){
return this.code.length==6;
canSubmit(){
return this.code.length==6;
}
},
onLoad({phoneNumber,phoneArea}) {
......@@ -40,17 +40,17 @@
onReady() {
this.$refs.sendSmsCode.start();
},
methods: {
submit(){ //完成并提交
this.request('user-center/loginBySms',
{
"mobile":this.phone,
"code":this.code
},
e=>{
console.log(e);
this.loginSuccess(e)
}
methods: {
submit(){ //完成并提交
this.request('user-center/loginBySms',
{
"mobile":this.phone,
"code":this.code
},
e=>{
console.log(e);
this.loginSuccess(e)
}
)
}
}
......
......@@ -2,7 +2,7 @@
<view class="content">
<!-- 顶部文字 -->
<text class="title">重置密码</text>
<login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw>
<text v-show="isPhone" class="login-iknow" >{{tipText}}</text>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone">
......@@ -14,7 +14,7 @@
<uni-easyinput :focus="formData.phone.length!=0" type="number" class="easyinput" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
<send-sms-code ref="shortCode" :phone="formData.phone"></send-sms-code>
<uni-send-sms-code ref="shortCode" :phone="formData.phone"></uni-send-sms-code>
</template>
</uni-easyinput>
</uni-forms-item>
......@@ -166,4 +166,4 @@
.content-top-title {
margin-bottom: 6px;
}
</style>
</style>
......@@ -11,8 +11,8 @@
<uni-list-item title="清理缓存" @click="clearTmp" link></uni-list-item>
<uni-list-item v-if="pushIsOn != 'wait'" @click.native="openSetting()" title="推送功能" showSwitch :switchChecked="pushIsOn"></uni-list-item>
<!-- #endif -->
<uni-list-item v-if="supportMode.includes('fingerPrint')" title="指纹解锁" @click="startSoterAuthentication('fingerPrint','指纹解锁')" link></uni-list-item>
<uni-list-item v-if="supportMode.includes('facial')" title="人脸解锁" @click="startSoterAuthentication('facial','人脸解锁')" link></uni-list-item>
<uni-list-item v-if="supportMode.includes('fingerPrint')" title="指纹解锁" @click="startSoterAuthentication('fingerPrint')" link></uni-list-item>
<uni-list-item v-if="supportMode.includes('facial')" title="人脸解锁" @click="startSoterAuthentication('facial')" link></uni-list-item>
</uni-list>
<!-- 退出/登陆 按钮 -->
......@@ -78,8 +78,7 @@
changePwd() {
uni.navigateTo({
url: '/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='
+ (this.userInfo && this.userInfo.phone ? this.userInfo.phone : '')
+ '&phoneArea=+86',
+ (this.userInfo && this.userInfo.phone ? this.userInfo.phone : ''),
fail: err => {
console.log(err);
}
......@@ -88,13 +87,14 @@
/**
* 开始生物认证
*/
startSoterAuthentication(requestAuthMode,title) {
startSoterAuthentication(checkAuthMode) {
let title = {"fingerPrint":"指纹解锁","facial":"人脸解锁"}[checkAuthMode]
// 检查是否开启认证
this.checkIsSoterEnrolledInDevice({name:requestAuthMode,title:title})
this.checkIsSoterEnrolledInDevice({checkAuthMode,title})
.then(() => {
// 开始认证
uni.startSoterAuthentication({
requestAuthModes: [requestAuthMode],
checkAuthModes: [requestAuthMode],
challenge: '123456', // 微信端挑战因子
authContent: `请用${title}`,
success: (res) => {
......@@ -126,23 +126,23 @@
})
})
},
checkIsSoterEnrolledInDevice(mode) {
checkIsSoterEnrolledInDevice({checkAuthMode,title}) {
return new Promise((resolve, reject) => {
uni.checkIsSoterEnrolledInDevice({
checkAuthMode: mode.name,
checkAuthMode: checkAuthMode,
success: (res) => {
if (res.isEnrolled) {
return resolve(res);
}
uni.showToast({
title: `设备未开启${mode.title}`,
title: `设备未开启${title}`,
icon: 'none'
});
reject(res);
},
fail: (err) => {
uni.showToast({
title: `${mode.title}失败`,
title: `${title}失败`,
icon: 'none'
});
reject(err);
......
......@@ -112,7 +112,8 @@
return getApp().appVersion
}
// #endif
,appConfig(){
,
appConfig() {
return getApp().globalData.config
}
},
......@@ -136,13 +137,14 @@
async checkVersion() {
let res = await callCheckVersion()
console.log(res);
if (res.result.code == 0) {
if (res.result.code > 0) {
checkUpdate()
} else {
uni.showToast({
title: res.result.message,
icon: 'none'
});
}
checkUpdate()
},
toUserInfo() {
uni.navigateTo({
......@@ -162,7 +164,7 @@
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == "ios") {
// 这里填写appstore应用id
let appstoreid = this.appConfig.marketId.ios;// 'id1417078253';
let appstoreid = this.appConfig.marketId.ios; // 'id1417078253';
plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/' + appstoreid + '?mt=8');
}
if (uni.getSystemInfoSync().platform == "android") {
......@@ -207,6 +209,7 @@
page {
background-color: #f8f8f8;
}
/* #endif*/
.center {
......@@ -214,6 +217,7 @@
flex-direction: column;
background-color: #f8f8f8;
}
.userInfo {
width: 750rpx;
padding: 20rpx;
......@@ -222,12 +226,14 @@
flex-direction: column;
align-items: center;
}
.logo-img {
width: 150rpx;
height: 150rpx;
border-radius: 150rpx;
border: solid 1px #FFFFFF;
}
.logo-title {
height: 150rpx;
flex: 1;
......@@ -242,15 +248,18 @@
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: 25rpx 0;
......@@ -299,4 +308,4 @@
/* #endif */
background-color: #DD524D;
}
</style>
</style>
......@@ -6,7 +6,7 @@
<uni-easyinput clearable type="number" class="input-box" :inputBorder="false" v-model="formData.code" maxlength="6"
placeholder="请输入验证码">
<template slot="right">
<send-sms-code ref="shortCode" code-type="bind" :phone="formData.phone"></send-sms-code>
<uni-send-sms-code ref="shortCode" code-type="bind" :phone="formData.phone"></uni-send-sms-code>
</template>
</uni-easyinput>
<button class="send-btn-box" type="primary" @click="submit">提交</button>
......
......@@ -60,6 +60,7 @@
font-family: uniicons;
src: url('./uni.ttf') format('truetype');
}
/* #endif */
.uni-icons {
......
## 1.0.8(2021-04-21)
- 优化 添加依赖 uni-icons, 导入后自动下载依赖
## 1.0.7(2021-04-15)
- uni-ui 新增 uni-search-bar 的 focus 事件
## 1.0.6(2021-02-05)
- 优化 组件引用关系,通过uni_modules引用组件
## 1.0.5(2021-02-05)
- 调整为uni_modules目录规范
- 新增 支持双向绑定
......
<template>
<template>
<view class="uni-searchbar">
<view :style="{borderRadius:radius+'px',backgroundColor: bgColor}" class="uni-searchbar__box" @click="searchClick">
<view class="uni-searchbar__box-icon-search">
<slot name="searchIcon">
<uni-icons color="#999999" size="18" type="search" />
</slot>
</view>
<input v-if="show || searchVal" :focus="showSync" :placeholder="placeholder" :maxlength="maxlength" class="uni-searchbar__box-search-input"
confirm-type="search" type="text" v-model="searchVal" @confirm="confirm" @blur="blur" />
<text v-else class="uni-searchbar__text-placeholder">{{ placeholder }}</text>
<view v-if="show && (clearButton==='always'||clearButton==='auto'&&searchVal!=='')" class="uni-searchbar__box-icon-clear"
@click="clear">
<slot name="clearIcon">
<uni-icons color="#c0c4cc" size="18" type="clear" />
</slot>
</view>
</view>
<text @click="cancel" class="uni-searchbar__cancel" v-if="cancelButton ==='always' || show && cancelButton ==='auto'">{{cancelText}}</text>
</view>
</template>
<script>
/**
* SearchBar 搜索栏
* @description 评分组件
* @tutorial https://ext.dcloud.net.cn/plugin?id=866
* @property {Number} radius 搜索栏圆角
* @property {Number} maxlength 输入最大长度
* @property {String} placeholder 搜索栏Placeholder
* @property {String} clearButton = [always|auto|none] 是否显示清除按钮
* @value always 一直显示
* @value auto 输入框不为空时显示
* @value none 一直不显示
* @property {String} cancelButton = [always|auto|none] 是否显示取消按钮
* @value always 一直显示
* @value auto 输入框不为空时显示
* @value none 一直不显示
* @property {String} cancelText 取消按钮的文字
* @property {String} bgColor 输入框背景颜色
* @property {Boolean} focus 是否自动聚焦
* @event {Function} confirm uniSearchBar 的输入框 confirm 事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} input uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的value,e=value
* @event {Function} cancel 点击取消按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} clear 点击清除按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} blur input失去焦点时触发事件,返回参数为uniSearchBar的value,e={value:Number}
*/
export default {
name: "UniSearchBar",
props: {
placeholder: {
type: String,
default: "请输入搜索内容"
},
radius: {
type: [Number, String],
default: 5
},
clearButton: {
type: String,
default: "auto"
},
cancelButton: {
type: String,
default: "auto"
},
cancelText: {
type: String,
default: '取消'
},
bgColor: {
type: String,
default: "#F8F8F8"
},
maxlength: {
type: [Number, String],
default: 100
},
value: {
type: [Number, String],
default: ""
},
<view :style="{borderRadius:radius+'px',backgroundColor: bgColor}" class="uni-searchbar__box" @click="searchClick">
<view class="uni-searchbar__box-icon-search">
<slot name="searchIcon">
<uni-icons color="#999999" size="18" type="search" />
</slot>
</view>
<input v-if="show || searchVal" :focus="showSync" :placeholder="placeholder" :maxlength="maxlength" class="uni-searchbar__box-search-input"
confirm-type="search" type="text" v-model="searchVal" @confirm="confirm" @blur="blur" @focus="emitFocus" />
<text v-else class="uni-searchbar__text-placeholder">{{ placeholder }}</text>
<view v-if="show && (clearButton==='always'||clearButton==='auto'&&searchVal!=='')" class="uni-searchbar__box-icon-clear"
@click="clear">
<slot name="clearIcon">
<uni-icons color="#c0c4cc" size="15" type="clear" />
</slot>
</view>
</view>
<text @click="cancel" class="uni-searchbar__cancel" v-if="cancelButton ==='always' || show && cancelButton ==='auto'">{{cancelText}}</text>
<view v-if="disabled" @click.stop="searchCoverClick" class="uni-search-cover"></view>
</view>
</template>
<script>
/**
* SearchBar 搜索栏
* @description 评分组件
* @tutorial https://ext.dcloud.net.cn/plugin?id=866
* @property {Number} radius 搜索栏圆角
* @property {Number} maxlength 输入最大长度
* @property {String} placeholder 搜索栏Placeholder
* @property {String} clearButton = [always|auto|none] 是否显示清除按钮
* @value always 一直显示
* @value auto 输入框不为空时显示
* @value none 一直不显示
* @property {String} cancelButton = [always|auto|none] 是否显示取消按钮
* @value always 一直显示
* @value auto 输入框不为空时显示
* @value none 一直不显示
* @property {String} cancelText 取消按钮的文字
* @property {String} bgColor 输入框背景颜色
* @property {Boolean} focus 是否自动聚焦
* @event {Function} confirm uniSearchBar 的输入框 confirm 事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} input uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的value,e=value
* @event {Function} cancel 点击取消按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} clear 点击清除按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
* @event {Function} blur input失去焦点时触发事件,返回参数为uniSearchBar的value,e={value:Number}
*/
export default {
name: "UniSearchBar",
props: {
placeholder: {
type: String,
default: "请输入搜索内容"
},
radius: {
type: [Number, String],
default: 5
},
clearButton: {
type: String,
default: "auto"
},
cancelButton: {
type: String,
default: "auto"
},
cancelText: {
type: String,
default: '取消'
},
bgColor: {
type: String,
default: "#F8F8F8"
},
maxlength: {
type: [Number, String],
default: 100
},
value: {
type: [Number, String],
default: ""
},
focus: {
type: Boolean,
default: false
}
},
data() {
return {
show: false,
showSync: false,
searchVal: ''
}
},
watch: {
value: {
immediate: true,
handler(newVal) {
this.searchVal = newVal
if (newVal) {
this.show = true
}
}
},
focus: {
immediate: true,
handler(newVal) {
if (newVal) {
this.show = true;
this.$nextTick(() => {
this.showSync = true
})
}
}
},
searchVal(newVal, oldVal) {
this.$emit("input", newVal)
}
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
show: false,
showSync: false,
searchVal: ''
}
},
watch: {
value: {
immediate: true,
handler(newVal) {
this.searchVal = newVal
if (newVal) {
this.show = true
}
}
},
focus: {
immediate: true,
handler(newVal) {
if (newVal) {
this.show = true;
this.$nextTick(() => {
this.showSync = true
})
}
}
},
searchVal(newVal, oldVal) {
this.$emit("input", newVal)
}
},
methods: {
searchClick() {
if (this.show) {
return
}
this.show = true;
this.$nextTick(() => {
this.showSync = true
})
},
clear() {
this.$emit("clear", {
value: this.searchVal
})
this.searchVal = ""
searchCoverClick(){
this.$emit('click')
},
searchClick() {
if (this.show) {
return
}
this.show = true;
this.$nextTick(() => {
this.showSync = true
})
},
clear() {
this.$emit("clear", {
value: this.searchVal
})
this.searchVal = ""
},
cancel() {
this.$emit("cancel", {
value: this.searchVal
});
this.searchVal = ""
this.show = false
this.showSync = false
// #ifndef APP-PLUS
uni.hideKeyboard()
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
},
confirm() {
// #ifndef APP-PLUS
uni.hideKeyboard();
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
this.$emit("confirm", {
value: this.searchVal
})
},
blur() {
// #ifndef APP-PLUS
uni.hideKeyboard();
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
this.$emit("blur", {
value: this.searchVal
})
},
cancel() {
this.$emit("cancel", {
value: this.searchVal
});
this.searchVal = ""
this.show = false
this.showSync = false
// #ifndef APP-PLUS
uni.hideKeyboard()
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
},
confirm() {
// #ifndef APP-PLUS
uni.hideKeyboard();
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
this.$emit("confirm", {
value: this.searchVal
})
},
blur() {
// #ifndef APP-PLUS
uni.hideKeyboard();
// #endif
// #ifdef APP-PLUS
plus.key.hideSoftKeybord()
// #endif
this.$emit("blur", {
value: this.searchVal
})
}
}
};
</script>
<style lang="scss" scoped>
$uni-searchbar-height: 36px;
.uni-searchbar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
position: relative;
padding: $uni-spacing-col-base;
// background-color: $uni-bg-color;
}
.uni-searchbar__box {
/* #ifndef APP-NVUE */
display: flex;
box-sizing: border-box;
/* #endif */
overflow: hidden;
position: relative;
flex: 1;
justify-content: center;
flex-direction: row;
align-items: center;
height: $uni-searchbar-height;
padding: 5px 8px 5px 0px;
border-width: 0.5px;
border-style: solid;
border-color: $uni-border-color;
}
.uni-searchbar__box-icon-search {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
// width: 32px;
padding: 0 8px;
justify-content: center;
align-items: center;
color: $uni-text-color-placeholder;
}
.uni-searchbar__box-search-input {
flex: 1;
font-size: $uni-font-size-base;
color: $uni-text-color;
}
.uni-searchbar__box-icon-clear {
align-items: center;
line-height: 24px;
emitFocus(e) {
this.$emit("focus", e.detail)
}
}
};
</script>
<style lang="scss" scoped>
$uni-searchbar-height: 36px;
.uni-searchbar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
position: relative;
padding: $uni-spacing-col-base;
// background-color: $uni-bg-color;
}
.uni-searchbar__box {
/* #ifndef APP-NVUE */
display: flex;
box-sizing: border-box;
/* #endif */
overflow: hidden;
position: relative;
flex: 1;
justify-content: center;
flex-direction: row;
align-items: center;
height: $uni-searchbar-height;
padding: 5px 8px 5px 0px;
border-width: 0.5px;
border-style: solid;
border-color: $uni-border-color;
}
.uni-searchbar__box-icon-search {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
// width: 32px;
padding: 0 8px;
justify-content: center;
align-items: center;
color: $uni-text-color-placeholder;
}
.uni-searchbar__box-search-input {
flex: 1;
font-size: $uni-font-size-base;
color: $uni-text-color;
}
.uni-searchbar__box-icon-clear {
align-items: center;
line-height: 24px;
padding-left: 8px;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.uni-searchbar__text-placeholder {
font-size: $uni-font-size-base;
color: $uni-text-color-placeholder;
margin-left: 5px;
}
.uni-searchbar__cancel {
padding-left: 10px;
line-height: $uni-searchbar-height;
font-size: 14px;
/* #endif */
}
.uni-searchbar__text-placeholder {
font-size: $uni-font-size-base;
color: $uni-text-color-placeholder;
margin-left: 5px;
}
.uni-searchbar__cancel {
padding-left: 10px;
line-height: $uni-searchbar-height;
font-size: 14px;
color: $uni-text-color;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
/* #endif */
}
.uni-search-cover{
height: $uni-searchbar-height;
margin-top: $uni-spacing-col-base;
width: 750rpx;
position: absolute;
top: 0;
left: 0;
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
}
</style>
{
"id": "uni-search-bar",
"displayName": "SearchBar 搜索栏",
"version": "1.0.6",
"version": "1.0.8",
"description": "搜索栏组件,通常用于搜索商品、文章等",
"keywords": [
"search-bar",
......@@ -40,7 +40,9 @@
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules": {
"dependencies": [],
"dependencies": [
"uni-icons"
],
"encrypt": [],
"platforms": {
"cloud": {
......
......@@ -2,6 +2,7 @@
## SearchBar 搜索栏
> **组件名:uni-search-bar**
> 代码块: `uSearchBar`
......@@ -21,6 +22,9 @@
<!-- 基本用法 -->
<uni-search-bar @confirm="search" @input="input" ></uni-search-bar>
<!-- v-model 用法 -->
<uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" @cancel="cancel" @change="change" @clear="clear">
<!-- 自定义Placeholder -->
<uni-search-bar placeholder="自定placeholder" @confirm="search"></uni-search-bar>
......@@ -34,8 +38,9 @@
|属性名 |类型 |默认值 |说明 |
|:-: |:-: |:-: |:-: |
|value/v-model |StringNumber | |搜索栏绑定值 |
|placeholder |String |搜索 |搜索栏Placeholder |
|radius |Number |10 |搜索栏圆角,单位rpx |
|radius |Number |10 |搜索栏圆角,单位px |
|clearButton |String |auto |是否显示清除按钮,可选值`always`-一直显示、`auto`-输入框不为空时显示、`none`-一直不显示 |
|cancelButton |String |auto |是否显示取消按钮,可选值`always`-一直显示、`auto`-输入框不为空时显示、`none`-一直不显示 |
|cancelText |String |取消 |取消按钮的文字 |
......@@ -52,7 +57,8 @@
|@input |uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的value|e=value |
|@cancel |点击取消按钮时触发事件,返回参数为uniSearchBar的value |e={value:Number} |
|@clear |点击清除按钮时触发事件,返回参数为uniSearchBar的value |e={value:Number} |
|@blur |input失去焦点时触发事件,返回参数为uniSearchBar的value |e={value:Number} |
|@focus |input 获取焦点时触发事件,返回参数为uniSearchBar的value |e={value:Number} |
|@blur |input 失去焦点时触发事件,返回参数为uniSearchBar的value |e={value:Number} |
### 替换 icon 的 slot 插槽
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册