搜索下拉框
This commit is contained in:
@@ -8,7 +8,9 @@ uni-page-body {
|
|||||||
min-height: 100% !important;
|
min-height: 100% !important;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
}
|
}
|
||||||
|
uni-button:after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
/** iconfont */
|
/** iconfont */
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'iconfont';
|
font-family: 'iconfont';
|
||||||
@@ -52,6 +54,15 @@ uni-page-body {
|
|||||||
line-height: 52rpx;
|
line-height: 52rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
.icon_scan {
|
||||||
|
font-size: 48rpx;
|
||||||
|
line-height: 70rpx;
|
||||||
|
color: #323232;
|
||||||
|
}
|
||||||
|
.icon_search {
|
||||||
|
color: #323232;
|
||||||
|
line-height: 70rpx;
|
||||||
|
}
|
||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
.container {
|
.container {
|
||||||
@@ -172,19 +183,19 @@ uni-page-body {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding-top: 15rpx;
|
padding-top: 10rpx;
|
||||||
box-shadow: 0 0 20rpx 0 rgba(160,160,160,0.7);
|
box-shadow: 0 0 20rpx 0 rgba(160,160,160,0.7);
|
||||||
}
|
}
|
||||||
.submit-button {
|
.submit-button {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
line-height: 52rpx;
|
line-height: 62rpx;
|
||||||
color: #ff6a00;
|
color: #ff6a00;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
letter-spacing: 1rpx;
|
letter-spacing: 1rpx;
|
||||||
padding: 0 22rpx;
|
padding: 0 22rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #ff6a00;
|
border: 1px solid #ff6a00;
|
||||||
margin: 0 20rpx 15rpx 0;
|
margin: 0 20rpx 10rpx 0;
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
}
|
}
|
||||||
.btn-disabled {
|
.btn-disabled {
|
||||||
|
|||||||
100
components/SearchBox.vue
Normal file
100
components/SearchBox.vue
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<template>
|
||||||
|
<view class="search_wraper">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="filter_input search_input"
|
||||||
|
:value="value"
|
||||||
|
@input="handleChange($event)">
|
||||||
|
<view class="buttons_wraper">
|
||||||
|
<span class="iconfont icon_scan" @tap="toScan"></span>
|
||||||
|
<span v-show="seaShow" class="iconfont icon_search" @tap="toSearch"></span>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import permision from "@/utils/permission.js"
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
cur: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
model: {
|
||||||
|
prop: 'value',
|
||||||
|
event: 'input'
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: String,
|
||||||
|
seaShow: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleChange ($event) {
|
||||||
|
if ($event.target.value) {
|
||||||
|
this.cur = $event.target.value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toSearch () {
|
||||||
|
this.$emit('toSearch', this.cur)
|
||||||
|
},
|
||||||
|
async toScan() {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
let status = await this.checkPermission();
|
||||||
|
if (status !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
uni.scanCode({
|
||||||
|
success: (res) => {
|
||||||
|
this.$emit('input', res.result)
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '出错',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
,
|
||||||
|
async checkPermission(code) {
|
||||||
|
let status = permision.isIOS ? await permision.requestIOS('camera') :
|
||||||
|
await permision.requestAndroid('android.permission.CAMERA');
|
||||||
|
|
||||||
|
if (status === null || status === 1) {
|
||||||
|
status = 1;
|
||||||
|
} else {
|
||||||
|
uni.showModal({
|
||||||
|
content: "需要相机权限",
|
||||||
|
confirmText: "设置",
|
||||||
|
success: function(res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
permision.gotoAppSetting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus">
|
||||||
|
@import '../common/style/mixin.styl';
|
||||||
|
.search_wraper
|
||||||
|
position relative
|
||||||
|
_wh(100%, 70rpx)
|
||||||
|
.search_input
|
||||||
|
padding-right: 140rpx;
|
||||||
|
.buttons_wraper
|
||||||
|
position absolute
|
||||||
|
top 0
|
||||||
|
right 0
|
||||||
|
_wh(auto, 70rpx)
|
||||||
|
</style>
|
||||||
@@ -5,10 +5,13 @@
|
|||||||
<view class="wrapper">
|
<view class="wrapper">
|
||||||
<view class="filter_item">
|
<view class="filter_item">
|
||||||
<view class="filter_label_wraper">
|
<view class="filter_label_wraper">
|
||||||
<span class="filter_label">物料</span>
|
<span class="filter_label">点位</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="filter_input_wraper">
|
<view class="filter_input_wraper">
|
||||||
<input type="text" class="filter_input">
|
<search-box
|
||||||
|
v-model="val1"
|
||||||
|
@toSearch="toSearch"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="filter_item">
|
<view class="filter_item">
|
||||||
@@ -17,6 +20,12 @@
|
|||||||
<input type="text" class="filter_input">
|
<input type="text" class="filter_input">
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="filter_item">
|
||||||
|
<view class="filter_label">区域</view>
|
||||||
|
<view class="filter_input_wraper">
|
||||||
|
<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="wrapper grid-wraper">
|
<view class="wrapper grid-wraper">
|
||||||
<view class="slide_new">
|
<view class="slide_new">
|
||||||
@@ -60,16 +69,28 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import NavBar from '@/components/NavBar.vue'
|
import NavBar from '@/components/NavBar.vue'
|
||||||
|
import SearchBox from '@/components/SearchBox.vue'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
NavBar
|
NavBar,
|
||||||
|
SearchBox
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dataList: [{task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}, {task_no: '1'}]
|
val1: '',
|
||||||
|
options: [],
|
||||||
|
index: 0,
|
||||||
|
dataList: [{task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1'}, {task_no: '1', start_devicecode: '000fjopd', create_time: '2020-1-1444'}]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
toSearch (e) {
|
||||||
|
console.log(e)
|
||||||
|
},
|
||||||
|
/** 选择器 */
|
||||||
|
selectChange(e) {
|
||||||
|
this.index = e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
245
utils/permission.js
Normal file
245
utils/permission.js
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
/// null = 未请求,1 = 已允许,0 = 拒绝|受限, 2 = 系统未开启
|
||||||
|
|
||||||
|
var isIOS
|
||||||
|
|
||||||
|
function album() {
|
||||||
|
var result = 0;
|
||||||
|
var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
|
||||||
|
var authStatus = PHPhotoLibrary.authorizationStatus();
|
||||||
|
if (authStatus === 0) {
|
||||||
|
result = null;
|
||||||
|
} else if (authStatus == 3) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(PHPhotoLibrary);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function camera() {
|
||||||
|
var result = 0;
|
||||||
|
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||||
|
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||||
|
if (authStatus === 0) {
|
||||||
|
result = null;
|
||||||
|
} else if (authStatus == 3) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(AVCaptureDevice);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function location() {
|
||||||
|
var result = 0;
|
||||||
|
var cllocationManger = plus.ios.import("CLLocationManager");
|
||||||
|
var enable = cllocationManger.locationServicesEnabled();
|
||||||
|
var status = cllocationManger.authorizationStatus();
|
||||||
|
if (!enable) {
|
||||||
|
result = 2;
|
||||||
|
} else if (status === 0) {
|
||||||
|
result = null;
|
||||||
|
} else if (status === 3 || status === 4) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(cllocationManger);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function push() {
|
||||||
|
var result = 0;
|
||||||
|
var UIApplication = plus.ios.import("UIApplication");
|
||||||
|
var app = UIApplication.sharedApplication();
|
||||||
|
var enabledTypes = 0;
|
||||||
|
if (app.currentUserNotificationSettings) {
|
||||||
|
var settings = app.currentUserNotificationSettings();
|
||||||
|
enabledTypes = settings.plusGetAttribute("types");
|
||||||
|
if (enabledTypes == 0) {
|
||||||
|
result = 0;
|
||||||
|
console.log("推送权限没有开启");
|
||||||
|
} else {
|
||||||
|
result = 1;
|
||||||
|
console.log("已经开启推送功能!")
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(settings);
|
||||||
|
} else {
|
||||||
|
enabledTypes = app.enabledRemoteNotificationTypes();
|
||||||
|
if (enabledTypes == 0) {
|
||||||
|
result = 3;
|
||||||
|
console.log("推送权限没有开启!");
|
||||||
|
} else {
|
||||||
|
result = 4;
|
||||||
|
console.log("已经开启推送功能!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(app);
|
||||||
|
plus.ios.deleteObject(UIApplication);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function contact() {
|
||||||
|
var result = 0;
|
||||||
|
var CNContactStore = plus.ios.import("CNContactStore");
|
||||||
|
var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
|
||||||
|
if (cnAuthStatus === 0) {
|
||||||
|
result = null;
|
||||||
|
} else if (cnAuthStatus == 3) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(CNContactStore);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function record() {
|
||||||
|
var result = null;
|
||||||
|
var avaudiosession = plus.ios.import("AVAudioSession");
|
||||||
|
var avaudio = avaudiosession.sharedInstance();
|
||||||
|
var status = avaudio.recordPermission();
|
||||||
|
console.log("permissionStatus:" + status);
|
||||||
|
if (status === 1970168948) {
|
||||||
|
result = null;
|
||||||
|
} else if (status === 1735552628) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(avaudiosession);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calendar() {
|
||||||
|
var result = null;
|
||||||
|
var EKEventStore = plus.ios.import("EKEventStore");
|
||||||
|
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
|
||||||
|
if (ekAuthStatus == 3) {
|
||||||
|
result = 1;
|
||||||
|
console.log("日历权限已经开启");
|
||||||
|
} else {
|
||||||
|
console.log("日历权限没有开启");
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(EKEventStore);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function memo() {
|
||||||
|
var result = null;
|
||||||
|
var EKEventStore = plus.ios.import("EKEventStore");
|
||||||
|
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
|
||||||
|
if (ekAuthStatus == 3) {
|
||||||
|
result = 1;
|
||||||
|
console.log("备忘录权限已经开启");
|
||||||
|
} else {
|
||||||
|
console.log("备忘录权限没有开启");
|
||||||
|
}
|
||||||
|
plus.ios.deleteObject(EKEventStore);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function requestIOS(permissionID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
switch (permissionID) {
|
||||||
|
case "push":
|
||||||
|
resolve(push());
|
||||||
|
break;
|
||||||
|
case "location":
|
||||||
|
resolve(location());
|
||||||
|
break;
|
||||||
|
case "record":
|
||||||
|
resolve(record());
|
||||||
|
break;
|
||||||
|
case "camera":
|
||||||
|
resolve(camera());
|
||||||
|
break;
|
||||||
|
case "album":
|
||||||
|
resolve(album());
|
||||||
|
break;
|
||||||
|
case "contact":
|
||||||
|
resolve(contact());
|
||||||
|
break;
|
||||||
|
case "calendar":
|
||||||
|
resolve(calendar());
|
||||||
|
break;
|
||||||
|
case "memo":
|
||||||
|
resolve(memo());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
resolve(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestAndroid(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);
|
||||||
|
},
|
||||||
|
function(error) {
|
||||||
|
console.log('result error: ' + error.message)
|
||||||
|
resolve({
|
||||||
|
code: error.code,
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function gotoAppPermissionSetting() {
|
||||||
|
if (permission.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const permission = {
|
||||||
|
get isIOS(){
|
||||||
|
return typeof isIOS === 'boolean' ? isIOS : (isIOS = uni.getSystemInfoSync().platform === 'ios')
|
||||||
|
},
|
||||||
|
requestIOS: requestIOS,
|
||||||
|
requestAndroid: requestAndroid,
|
||||||
|
gotoAppSetting: gotoAppPermissionSetting
|
||||||
|
}
|
||||||
|
|
||||||
|
export default permission
|
||||||
Reference in New Issue
Block a user