This commit is contained in:
yangtao 2024-03-28 11:10:52 +08:00
parent baed7bba7f
commit 9261d39004
17 changed files with 1086 additions and 39 deletions

View File

@ -247,3 +247,9 @@ export function getAdminInfo(merId) {
export function updateAdminInfo(data,merId) {
return request.post(`server/${merId}/store/update`, data, { login: true });
}
/**
* 获取商户修改配置
*/
export function getAdminConfig(merId) {
return request.get(`server/${merId}/store/service`,{}, { login: true });
}

View File

@ -2,7 +2,7 @@
"name" : "铸源商城",
"appid" : "__UNI__496DF55",
"description" : "",
"versionName" : "1.0.4",
"versionName" : "1.0.5",
"versionCode" : 127,
"transformPx" : false,
/* 5+App */
@ -86,7 +86,7 @@
"maps" : {
"amap" : {
"appkey_ios" : "f868a24eddab123b4e3a2cadb78b6fba",
"appkey_android" : "a4fc891e60ccdf388ce0996cc833aca1",
"appkey_android" : "b6c88d12b305ff5535bfdd92da78cdfe",
"name" : "amapKPWKfVew"
}
},
@ -100,7 +100,7 @@
"amap" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "f868a24eddab123b4e3a2cadb78b6fba",
"appkey_android" : "a4fc891e60ccdf388ce0996cc833aca1",
"appkey_android" : "b6c88d12b305ff5535bfdd92da78cdfe",
"name" : "amapKPWKfVew"
}
},

View File

@ -1,4 +1,5 @@
{
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/guide/index",
@ -103,6 +104,16 @@
}
}
},
{
"path": "pages/shop/location/index",
"style": {
"enablePullDownRefresh": false,
"navigationStyle": "custom",
"app-plus": {
"scrollIndicator": false //
}
}
},
{
"path": "pages/news_list/index",
"style": {
@ -676,7 +687,7 @@
{
"path": "shopInfo/index",
"style": {
"navigationBarTitleText": "商家信息"
"navigationBarTitleText": "基本信息"
}
},
{
@ -1310,6 +1321,10 @@
]
}
],
"easycom" : {
"^u-(.*)" : "@/uni_modules/uview-ui/components/u-$1/u-$1.vue",
"^uv-(.*)" : "@climblee/uv-ui/components/uv-$1/uv-$1.vue"
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "加载中...",
@ -1373,4 +1388,5 @@
}]
},
"sitemapLocation": "sitemap.json"
}

View File

@ -73,17 +73,27 @@
</view>
</view>
<view class="popup_group_item" style="display: flex;flex-direction: column;">
<view class="popup_group_item_label" style="width: 100%;">提货点营业日期</view>
<view class="popup_group_item_label" style="width: 100%;">提供服务</view>
<view class="" style="margin-top: 14px;">
<checkbox-group @change="checkServiceChange" style="display: flex;flex-direction: row;flex-wrap: wrap;grid-row-gap: 8px;grid-column-gap: 35px;">
<label v-for="(item,index) in list">
<checkbox :value="item" :checked="shopInfo.detail.services.indexOf(item)>-1" />{{item}}
</label>
</checkbox-group>
</view>
</view>
<view class="popup_group_item" style="display: flex;flex-direction: column;">
<view class="popup_group_item_label" style="width: 100%;">营业日期</view>
<view class="" style="margin-top: 14px;">
<checkbox-group @change="checkboxChange" style="display: flex;flex-direction: row;flex-wrap: wrap;grid-row-gap: 8px;grid-column-gap: 35px;">
<label v-for="(item,index) in week">
<checkbox :value="item.value+''" />{{item.name}}
<checkbox :value="item.value+''" :checked="shopInfo.mer_take_day.indexOf(item.value)>-1" />{{item.name}}
</label>
</checkbox-group>
</view>
</view>
<view class="popup_group_item" >
<view class="popup_group_item_label">提货点营业时间</view>
<view class="popup_group_item_label">营业时间</view>
<view class="popup_group_item_value">
<picker mode="time" style="min-width: 50px;height: 20px;text-align:center;" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
<view class="uni-input">{{time}}</view>
@ -137,7 +147,7 @@
</template>
<script>
import {getAdminInfo,updateAdminInfo} from '@/api/admin.js'
import {getAdminInfo,updateAdminInfo,getAdminConfig} from '@/api/admin.js'
export default {
components: {
},
@ -149,7 +159,9 @@ export default {
pics:[],
time:'',
time2:'',
day:[],
list:[],
service:[],
navtop:0,
// week: [ "", "", "", "", "", "",""],
week:[{name:'周一',value:1},{name:'周二',value:2},
{name:'周三',value:3},{name:'周四',value:4},
@ -162,11 +174,28 @@ export default {
},
onShow() {
this.getInfo()
this.getInfo();
getAdminConfig(this.mer_id).then((res)=>{
if(res){
this.list=res.data;
}
});
},
created() {
let statusBarHeight= uni.getSystemInfoSync().statusBarHeight+"px";
this.navtop=statusBarHeight;
},
methods:{
goBack(){
uni.navigateBack({
delta:1
})
},
checkboxChange (e) {
this.day = e.detail.value.map(Number);
this.shopInfo.mer_take_day = e.detail.value.map(Number);
},
checkServiceChange(e){
this.service=e.detail.value;
},
bindTimeChange(e) {
this.time = e.detail.value
@ -183,6 +212,8 @@ export default {
this.pics=res.data.detail.images;
}
})
},
updateInfo(){
let data1={
@ -190,9 +221,9 @@ export default {
promise:this.shopInfo.detail.promise,
images:this.pics,
mer_take_phone:this.shopInfo.mer_take_phone,
mer_take_day:this.day,
mer_take_time:[this.shopInfo.mer_take_time[0],this.shopInfo.mer_take_time[1]],
services:['wifi','免费停车']
mer_take_day:this.shopInfo.mer_take_day,
mer_take_time:[this.time,this.time2],
services:this.service,
}
updateAdminInfo(data1,this.mer_id).then((res)=>{
@ -250,6 +281,35 @@ export default {
padding-top: 20rpx;
padding-bottom: 156rpx;
}
.container .top-tab{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
position: relative;
padding: 28rpx 0;
font-size: 32rpx;
font-weight: bold;
background-color: white;
}
.container .top-tab .tab-location{
font-size: 28rpx;
font-weight: 500;
position: absolute;
left:28rpx;
display: flex;
align-items: center;
}
.container .top-tab .tab-sao{
font-size: 40rpx;
position: absolute;
right:28rpx;
color:var(--view-theme);
}
.container .top-tab .tab-location .icon-dingwei{
color: var(--view-theme);
font-size: 28rpx;
}
/deep/ .uni-checkbox-input.uni-checkbox-input-checked{
border: 1px solid #2291F8 !important;
background-color: #2291F8 !important;

View File

@ -15,7 +15,7 @@
font-weight: bold;
}
.content .top-tab .tab-location{
font-size: 28rpx;
font-size: 32rpx;
font-weight: 500;
position: absolute;
left:28rpx;

View File

@ -2,9 +2,10 @@
<template>
<view class="content" :style="viewColor">
<view class="top-tab" :style="`padding-top:`+navtop">
<view class="tab-location">
深圳
<view class="tab-location" @click="getLocation">
{{city}}
<view class="iconfont icon-dingwei"></view>
<view style="font-size: 14px;margin-left: 10px;" @click="selectLocation">切换</view>
</view>
商家联盟
<view class="tab-sao iconfont icon-saoma" @tap='handleBorcode'></view>
@ -73,6 +74,7 @@
import { mapGetters } from "vuex";
import {shopInit,shopNearby} from '@/api/shop.js'
import {getOrderOfflinePay} from '@/api/admin.js'
import prompt from '@/utils/prompt.js'
export default {
components:{
customTab,
@ -89,6 +91,7 @@
addressInfo:[],
latitude: '',
longitude: '',
city:'深圳',
}
},
onLoad(){
@ -109,6 +112,52 @@
this.activeRouter = '/' + curRoute
},
methods:{
async getLocation(){
let self=this;
// #ifdef APP-PLUS
let res = await prompt.requestPermissions(['ACCESS_FINE_LOCATION'])
if(res!==1)return
else {
console.log('999: ',999);
}
// #endif
uni.getLocation({
type: 'gcj02',
success: (res) => {
console.log('res==: ',res);
let latitude, longitude;
latitude = res.latitude.toString();
longitude = res.longitude.toString();
self.latitude = res.latitude;
self.longitude = res.longitude;
uni.hideLoading();
let data1={
mini:1,
type_id:4,
location:res.latitude+','+res.longitude
}
shopNearby(data1).then((r)=>{
if(r.data.list){
this.shopList=r.data.list;
}
})
},
fail: (res) => {
uni.hideLoading();
uni.showToast({
title: res.errMsg,
icon: 'none',
duration: 1000
});
}
});
},
selectLocation(){
uni.navigateTo({
url:'/pages/shop/location/index'
})
},
init(){
shopInit().then((res)=>{
if(res.data.lst){
@ -134,17 +183,11 @@
longitude = res.longitude.toString();
self.latitude = res.latitude
self.longitude = res.longitude
getGeocoder({
lat: latitude,
long: longitude
}).then(res => {
uni.hideLoading();
const data = res.data;
console.log('data: ',data);
let data1={
mini:1,
type_id:4,
location:data.location.lat+','+data.location.lng
location:res.latitude+','+res.longitude
}
shopNearby(data1).then((r)=>{
if(r.data.list){
@ -162,14 +205,6 @@
// duration: 1000
// });
// })
}).catch(e=>{
uni.hideLoading();
uni.showToast({
title: '定位失败,请手动输入地址',
icon: 'none',
duration: 1000
});
})
},
fail: (res) => {
uni.hideLoading();

View File

@ -0,0 +1,616 @@
<template>
<view>
<u-navbar>
<view class="slot-wrap">
<image class="icon" src="@/static/images/sousuohui@3.png" mode=""></image>
<input type="text" v-model="value" placeholder="输入中文/拼音/首字母"
placeholder-style="color:#999999;font-size:28rpx" @confirm="choseAddress(value)" />
</view>
</u-navbar>
<view class="container modal" v-if="cityList.length>0">
<view class="list-cell u-border-bottom" v-for="(item1, index) in cityList" :key="index"
@click="choseAddress2(item1)">
{{ item1.station_name}}
</view>
</view>
<view class="container" v-else>
<!-- <view class="citynow" :style="{ display: data.length <= 0 ? 'none' : '' }">
<view class="lable">当前/历史</view>
<view class="city-ul">
<view class="city-li" v-for="(item, index) in data" :key="index"
@click="choseAddress(item.station)">
<u-icon v-if="index == 0" name="map-fill" color="#2979ff" size="28"></u-icon>
{{ item.station }}
</view>
</view>
</view> -->
<!-- <view class="cityhot" v-if="status">
<view class="lable">
热门城
</view>
<view class="city-ul">
<view class="city-li" v-for="(item,index) in gleam" :key='index' @click="choseAddress(item.name)">
{{item.name}}
</view>
</view>
</view> -->
<view class="cityIndex" v-if="status">
<u-index-list :scrollTop="scrollTop" :index-list="indexList">
<view v-for="(item, index) in list" :key="index">
<u-index-anchor :index="item.letter" />
<view class="list-cell u-border-bottom" v-for="(item1, index) in item.data" :key="index"
@click="choseAddress(item1)">
{{ item1 }}
</view>
</view>
</u-index-list>
</view>
<view class="cityBox" v-else>
<view class="box-ul">
<view class="box-li" v-if="searchList" @click="choseAddress(searchList)">
{{ searchList }}
</view>
</view>
</view>
<u-back-top :scroll-top="scrollTop"></u-back-top>
</view>
</view>
</template>
<script>
const {
globalData
} = getApp();
import oRequest from '@/api/admin.js';
// import my from '@/api/my';
// import railway from '@/api/railway.js';
export default {
data() {
return {
type: '',
data: [],
gleam: [{
name: '北京'
},
{
name: '上海'
},
{
name: '深圳'
},
{
name: '广州'
}
],
status: true,
indexList: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'W',
'X', 'Y', 'Z'
],
scrollTop: 0,
searchList: '',
value: '',
cityList: [],
//lists:_stations,
list: [{
letter: 'A',
data: ['阿拉善盟', '鞍山', '安庆', '安阳', '阿坝', '安顺', '阿里', '安康', '阿克苏', '阿勒泰']
},
{
letter: 'B',
data: [
'北京','保定','包头','巴彦淖尔','本溪','白山','白城','蚌埠','亳州','滨州','北海','百色','巴中','毕节','保山','宝鸡','白银','博尔塔拉','巴音郭楞'
]
},
{
letter: 'C',
data: [
'承德','沧州','长治','赤峰','长春','常州','滁州','池州','长沙','常德','郴州','潮州','崇左','重庆','成都','楚雄','昌都','昌吉'
]
},
{
letter: 'D',
data: [
'大同','大连','丹东','大庆','大兴安岭','东营','德州','东莞','东沙群岛','德阳','达州','大理','德宏','迪庆','定西'
]
},
{
letter: 'E',
data: ['鄂尔多斯', '鄂州', '恩施']
},
{
letter: 'F',
data: ['抚顺', '阜新', '阜阳', '福州', '抚州', '佛山', '防城港']
},
{
letter: 'G',
data: ['赣州', '广州', '桂林', '贵港', '广元', '广安', '甘孜', '贵阳', '甘南', '果洛', '固原',
'高雄'
]
},
{
letter: 'H',
data: [
'邯郸','衡水','呼和浩特','呼伦贝尔','葫芦岛','哈尔滨','鹤岗','黑河','淮安','杭州','湖州','合肥','淮南','淮北','黄山','菏泽','鹤壁','黄石','黄冈','衡阳','怀化','惠州','河源','贺州','河池','海口','红河','汉中','海东','海北','黄南','海南','海西','哈密','和田','花莲县','海外'
]
},
{
letter: 'J',
data: [
'晋城',
'晋中',
'锦州',
'吉林',
'鸡西',
'佳木斯',
'嘉兴',
'金华',
'景德镇',
'九江',
'吉安',
'济南',
'济宁',
'焦作',
'荆门',
'荆州',
'江门',
'揭阳',
'嘉峪关',
'金昌',
'酒泉',
'金门县',
'基隆',
'嘉义',
'嘉义县',
'九龙'
]
},
{
letter: 'K',
data: ['开封', '昆明', '克拉玛依', '克孜勒苏柯尔克孜', '喀什', '可克达拉']
},
{
letter: 'L',
data: [
'廊坊',
'临汾',
'吕梁',
'辽阳',
'辽源',
'连云港',
'丽水',
'六安',
'龙岩',
'莱芜',
'临沂',
'聊城',
'洛阳',
'娄底',
'柳州',
'来宾',
'泸州',
'乐山',
'凉山',
'六盘水',
'丽江',
'临沧',
'拉萨',
'林芝',
'兰州',
'陇南',
'临夏',
'连江县',
'离岛'
]
},
{
letter: 'M',
data: ['牡丹江', '马鞍山', '茂名', '梅州', '绵阳', '眉山', '苗栗县']
},
{
letter: 'N',
data: ['南京', '南通', '宁波', '南平', '宁德', '南昌', '南阳', '南宁', '内江', '南充', '怒江', '那曲',
'南投县'
]
},
{
letter: 'P',
data: ['盘锦', '莆田', '萍乡', '平顶山', '濮阳', '攀枝花', '普洱', '平凉', '屏东县', '澎湖县']
},
{
letter: 'Q',
data: [
'秦皇岛',
'齐齐哈尔',
'七台河',
'衢州',
'泉州',
'青岛',
'清远',
'钦州',
'黔西南',
'黔东南',
'黔南布',
'曲靖',
'庆阳'
]
},
{
letter: 'R',
data: ['日照', '日喀则']
},
{
letter: 'S',
data: [
'石家庄',
'朔州',
'沈阳',
'四平',
'松原',
'双鸭山',
'绥化',
'上海',
'苏州',
'宿迁',
'绍兴',
'宿州',
'三明',
'上饶',
'三门峡',
'商丘',
'十堰',
'随州',
'邵阳',
'韶关',
'深圳',
'汕头',
'汕尾',
'三亚',
'三沙',
'遂宁',
'山南',
'商洛',
'石嘴山'
]
},
{
letter: 'T',
data: [
'天津',
'唐山',
'太原',
'通辽',
'铁岭',
'通化',
'泰州',
'台州',
'铜陵',
'泰安',
'漯河',
'铜仁',
'铜川',
'天水',
'吐鲁番',
'塔城',
'台北',
'台南',
'台中',
'桃园',
'台东县'
]
},
{
letter: 'W',
data: [
'乌海',
'乌兰察布',
'无锡',
'温州',
'芜湖',
'潍坊',
'威海',
'武汉',
'梧州',
'文山',
'渭南',
'武威',
'吴忠',
'乌鲁木齐'
]
},
{
letter: 'X',
data: [
'邢台',
'忻州',
'兴安盟',
'锡林郭勒盟',
'徐州',
'宣城',
'厦门',
'新余',
'新乡',
'许昌',
'信阳',
'襄阳',
'孝感',
'咸宁',
'湘潭',
'湘西',
'西双版纳',
'西安',
'咸阳',
'西宁',
'新竹',
'新北',
'新竹县',
'香港岛',
'新界'
]
},
{
letter: 'Y',
data: [
'阳泉',
'运城',
'营口',
'延边',
'伊春',
'盐城',
'扬州',
'鹰潭',
'宜春',
'烟台',
'宜昌',
'岳阳',
'益阳',
'永州',
'阳江',
'云浮',
'玉林',
'宜宾',
'雅安',
'玉溪',
'延安',
'榆林',
'玉树',
'银川',
'伊犁',
'宜兰县',
'云林县'
]
},
{
letter: 'Z',
data: [
'张家口',
'朝阳',
'镇江',
'舟山',
'漳州',
'淄博',
'枣庄',
'郑州',
'周口',
'驻马店',
'株洲',
'张家界',
'珠海',
'湛江',
'肇庆',
'中山',
'自贡',
'资阳',
'遵义',
'昭通',
'张掖',
'中卫',
'彰化县'
]
}
]
};
},
watch: {
value(newName, oldName) {
if (!this.value) {
this.cityList = [];
return
}
this.list.forEach((item, index, arr) => {
const fin = item.data.find((items) => {
return newName == items;
});
if (typeof fin == 'string') {
this.searchList = fin;
//console.log(this.searchList)
}
});
}
},
onLoad(options) {
this.type = options.type;
// this.railways()
// this.getStation()
},
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
methods: {
// async getStation() {
// const _this = this;
// let res = await railway.getStationList();
// if (res.status) {
// _this.indexList.forEach((val, key) => {
// _this.lists[key] = {
// letter: val,
// data: []
// };
// res.data.list.forEach((item) => {
// if (item.pinyin1 === val) {
// _this.lists[key].data.push(item.name);
// }
// });
// });
// console.log(_this.lists);
// }
// },
// async railways() {
// const {
// data
// } = await railway.history({
// type: '',
// size: 10
// });
// this.data = data;
// },
choseAddress2(val) {
let geoAddress = val
let params = {
address: {
city: geoAddress.station_name,
poiName: ''
},
name: geoAddress.station_name,
city_code: geoAddress.station_code,
}
if (this.type == 1) {
uni.setStorageSync('hccity', params);
} else if (this.type == 2) {
uni.setStorageSync('hcscity', params);
}
uni.setStorageSync('locationCity', params);
uni.navigateBack({
delta: 1
});
},
async choseAddress(val) {
this.value = val;
console.log(val)
let cityCode = ''
let res = await oRequest.getTrainAllInfo({
name: val,
hot: 0
});
if (res[globalData.status] == globalData.ERR_OK) {
cityCode = res.data.id
this.cityList = res.data;
}
}
}
};
</script>
<style lang="scss" scoped>
.body {}
.cityBox {
width: 100%;
height: auto;
background-color: #ffffff;
.box-ul {
padding: 0 20rpx;
.box-li {
width: 100%;
height: 88rpx;
line-height: 88rpx;
}
}
}
.slot-wrap {
width: 624rpx;
height: 64rpx;
background: #f4f4f4;
border-radius: 40rpx;
display: flex;
align-items: center;
.icon {
width: 32rpx;
height: 32rpx;
margin-left: 28rpx;
}
input {
font-size: 28rpx;
color: #333333;
text-indent: 22rpx;
}
}
.container {
.citynow,
.cityhot {
padding: 24rpx 28rpx 0;
.lable {
font-size: 32rpx;
font-family: Segoe UI;
font-weight: bold;
color: #333333;
}
.city-ul {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-top: 18rpx;
.city-li {
width: 210rpx;
height: 66rpx;
background: #f8f8f8;
border-radius: 4rpx;
text-align: center;
line-height: 66rpx;
margin-bottom: 16rpx;
image {
width: 28rpx;
height: 28rpx;
margin-right: 8rpx;
}
&:nth-child(3n-1) {
margin-left: 32rpx;
margin-right: 32rpx;
}
}
}
}
}
.modal {
width: 100%;
height: 100%;
position: fixed;
background-color: white;
overflow: scroll;
}
.cityIndex {
width: 100%;
height: auto;
}
.list-cell {
display: flex;
box-sizing: border-box;
width: 100%;
padding: 10px 24rpx;
overflow: hidden;
color: #323233;
font-size: 14px;
line-height: 24px;
background-color: #fff;
}
</style>

View File

@ -160,7 +160,7 @@
is_trader: '',
filter_params: '',
page:1,
limit:30
limit:10
},
price: 0,
stock: 0,
@ -229,12 +229,14 @@
type_id:4,//
category_id:this.id, // lst id
keyword:this.where.keyword,
page:this.where.page,
limit:this.where.limit,
}
shopNearby(data1).then((res)=>{
console.log('res: ',res);
if(res.data){
this.productList=res.data.list
console.log('this.productList: ',this.productList);
this.productList=res.data.list;
that.$set(that.where, 'page', that.where.page + 1);
}
})
},
@ -477,9 +479,10 @@
},
onReachBottom() {
if (this.productList.length > 0) {
this.get_product_list('');
this.search();
// this.get_product_list('');
} else {
this.get_host_product();
// this.get_host_product();
}
},
onPullDownRefresh(){

View File

@ -1,6 +1,6 @@
<template>
<view class="shop_details" :style="viewColor">
<view class="head">
<view class="head" style="min-height: 200px;">
<swipers v-if="shopInfo.detail&&shopInfo.detail.images" :imgUrls="shopInfo.detail.images"></swipers>
<view class="back" @tap="toRouter"
><i class="iconfont icon-xiangzuo"></i

View File

@ -28,6 +28,10 @@
-moz-osx-font-smoothing: grayscale;
}
.haiyueqiehuan:before {
content: "\e903";
}
.haiyue-info:before {
content: "\e901";
}

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,13 @@
"css_prefix_text": "haiyue",
"description": "",
"glyphs": [
{
"icon_id": "39724446",
"name": "切换",
"font_class": "qiehuan",
"unicode": "e903",
"unicode_decimal": 59651
},
{
"icon_id": "39681063",
"name": "商品信息",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

300
utils/prompt.js Normal file
View File

@ -0,0 +1,300 @@
export default {
// 处理应用程序权限请求
// #ifdef APP-PLUS
isIos: plus.os.name == "iOS",
os:uni.getSystemInfoSync().osName,
// #endif
mapping: {
'CAMERA': {
title: "对摄像头/存储空间/照片权限申请说明",
content: "摄像头权限将用于拍摄照片和视频,照片/图片用于更换头像场景中读取和写入相册和文件内容",
methods: 'SET_CAMERA'
},
'WRITE_EXTERNAL_STORAGE': {
title: "对存储空间/照片权限申请说明",
content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像场景中读取和写入相册和文件内容。",
methods: 'SET_WRITE_EXTERNAL_STORAGE'
},
'ACCESS_FINE_LOCATION': {
title: "铸源商城对地理位置权限申请说明",
content: "铸源商城应用程序可以提供基于位置的服务、定位导航、附近搜索等功能。",
methods: 'SET_ACCESS_FINE_LOCATION'
},
'CALL_PHONE': {
title: "铸源商城拨打/管理电话权限申请说明",
content: "便于您使用该功能获取手机验证码场景下使用",
methods: 'SET_CALL_PHONE'
}
},
// ios权限是否开启
iosPermissionCheck(permissionID) {
// ios权限列表
let iosPermissions = {
camera: 'iosCamera', // 摄像头
location: 'iosLocation', // 位置
storage: 'iosAlbum', // 相册
}
return new Promise((resolve, reject) => {
let res = iosPermissions[permissionID]();
resolve(res);
});
},
// ios定位权限
iosLocation() {
let result = 0,
cLLocationManager = plus.ios.importClass("CLLocationManager"),
authStatus = cLLocationManager.authorizationStatus(),
enable = cLLocationManager.locationServicesEnabled();
if (enable && authStatus != 2) {
result = 1;
} else {
result = 0;
}
plus.ios.deleteObject(cLLocationManager);
return result;
},
// 安卓权限是否开启
androidPermission(permissionID){
// android权限列表
let androidPermissions = {
camera: "android.permission.CAMERA", // 摄像头权限
location: "android.permission.ACCESS_FINE_LOCATION", // 位置权限
storage: "android.permission.WRITE_EXTERNAL_STORAGE" // 存储写入权限
}
console.log(androidPermissions[permissionID]);
return new Promise((resolve, reject) => {
let result = 0
let compat = plus.android.importClass('androidx.core.content.ContextCompat')
let context = plus.android.runtimeMainActivity()
let results = compat.checkSelfPermission(context, androidPermissions[permissionID])
if (results != -1) {
console.log(results);
result = 1;
} else {
result = 0;
}
resolve(result)
})
},
permission(val){
let permissionCheck = {
android: this.androidPermission,
ios: this.iosPermissionCheck,
}
return new Promise(async(resolve, reject)=>{
let res = await permissionCheck[this.os](val)
resolve(res)
})
},
// 检查系统的设备服务是否开启
checkSystemEnableLocation() {
if (this.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
}
},
// 获取权限
async requestPermissions(permissionID) {
let results;
if(!this.isIos){
results = permissionID.every((item)=>{
let compat = plus.android.importClass('androidx.core.content.ContextCompat')
let context = plus.android.runtimeMainActivity()
let results = compat.checkSelfPermission(context, 'android.permission.' + item)
return results!=0
})
}
// console.log(permissionID);
// console.log(results);
if (results && !this.isIos) {
var viewObj = await this.nativeObjView(permissionID);
viewObj.show();
}
// console.log('android.permission.' + permissionID, '当前手机权限');
return new Promise(async (resolve, reject) => {
//苹果
if (this.isIos) {
resolve(1);
return
}
// 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++) {
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
result = -1
}
resolve(result);
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error
.message);
resolve({
code: error.code,
message: error.message
});
}
);
});
}
let permissionList = permissionID.map((item)=>{
return 'android.permission.' + item
})
const result = await requestAndroidPermission(permissionList);
console.log(result);
if (viewObj) viewObj.close()
if (result === 1) {
//'已获得授权'
} else if (result === 0) {
//'未获得授权'
} else {
uni.showModal({
title: '提示',
content: '操作权限已被拒绝,请手动前往设置',
confirmText: "立即设置",
success: (res) => {
if (res.confirm) {
this.gotoAppPermissionSetting()
}
}
})
}
resolve(result);
});
},
//提示框
nativeObjView(permissionID) {
return new Promise((resolve, reject) => {
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
// const navigationBarHeight = systemInfo.platform === 'android' ? 48 :
// 44;
// const totalHeight = statusBarHeight + navigationBarHeight;
const totalHeight = statusBarHeight;
let view = new plus.nativeObj.View('per-modal', {
top: '0px',
left: '0px',
width: '100%',
backgroundColor: '#444',
//opacity: .5;
})
view.drawRect({
color: '#fff',
radius: '8px'
}, {
top: totalHeight + 'px',
left: '5%',
width: '90%',
height: "100px",
})
view.drawText(this.mapping[permissionID[0]].title, {
top: totalHeight + 5 + 'px',
left: "8%",
height: "30px"
}, {
align: "left",
color: "#000",
}, {
onClick: function(e) {
console.log(e);
}
})
view.drawText(this.mapping[permissionID[0]].content, {
top: totalHeight + 35 + 'px',
height: "60px",
left: "8%",
width: "84%"
}, {
whiteSpace: 'normal',
size: "14px",
align: "left",
color: "#656563"
})
function show() {
view = plus.nativeObj.View.getViewById('per-modal');
view.show()
view = null //展示的时候也得清空,不然影响下次的关闭
}
function close() {
view = plus.nativeObj.View.getViewById('per-modal');
view.close();
view = null
}
resolve({
show,
close
})
})
},
// 打开系统服务
gotoLocationServer(){
if (this.isIos) {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
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 intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
}
},
// 跳转到**应用**的权限页面
gotoAppPermissionSetting() {
if (this.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);
}
}
}