diff --git a/pages/chat/customer_list/chat.vue b/pages/chat/customer_list/chat.vue index d783203..ebd5bf3 100644 --- a/pages/chat/customer_list/chat.vue +++ b/pages/chat/customer_list/chat.vue @@ -1,1892 +1,2032 @@ - - - - - - {{storeInfo.mer_name}} - - - 进店 - - - - - - - - - - {{items.time}} - - - - - - - 对方撤回了一条消息 - - - - - - - 退款单号:{{ item.refundOrder.refund_order_sn }} - - - - - - - - {{item.refundOrder.refund_num}}件商品 - - - - {{val.product.cart_info.product.store_name}} - - ¥{{ item.refundOrder.refund_price }} - - - - - - - - - - 订单号:{{ item.orderInfo.order_sn }} - - 复制 - - - 复制 - - - - - - - - - {{item.orderInfo.total_num}}件商品 - - - - {{val.cart_info.product.store_name}} - - ¥{{ item.orderInfo.pay_price }} - - - - - - - - - - - - - - - - ¥{{ item.product.price }} - - {{item.product.store_name}} - - - - - - - - - - - - - - ¥{{ item.presell.price }} - - {{item.presell.store_name}} - - - - - - - - - - - - - - ¥{{ item.productGroup.product.price }} - - {{item.productGroup.product.store_name}} - - - - - - - - - - - - {{item.msn}} - - - - - - - - - - - - - - 订单号:{{ item.refundOrder.refund_order_sn }} - - 复制 - - - 复制 - - - - - - - - - {{item.refundOrder.refund_num}}件商品 - - - - {{val.product.cart_info.product.store_name}} - - ¥{{ item.refundOrder.refund_price }} - - - - - - - - - - 订单号:{{ item.orderInfo.order_sn }} - - 复制 - - - 复制 - - - - - - - - - {{item.orderInfo.total_num}}件商品 - - - - {{val.cart_info.product.store_name}} - - ¥{{ item.orderInfo.pay_price }} - - - - - - - - - - - - - - - - ¥{{ item.product.price }} - - {{item.product.store_name}} - - - - - - - - - - - - - - ¥{{ item.presell.price }} - - {{item.presell.store_name}} - - - - - - - - - - - - - - ¥{{ item.productGroup.product.price }} - - {{item.productGroup.product.store_name}} - - - - - - - - - - - - {{item.msn}} - - - - - - - 复制 - - - - - - 复制 - - - - 撤回 - - - - - - - 你撤回了一条消息 - - - - - - {{items.time}} - - - - - - - 对方撤回了一条消息 - - - - - - - 退款单号:{{ item.refundOrder.refund_order_sn }} - - - - - - - - - {{item.refundOrder.refund_num}}件商品 - - - - {{val.product.cart_info.product.store_name}} - - ¥{{ val.product.cart_info.productAttr.price }} - - - - - - - - - - 订单号:{{ item.orderInfo.order_sn }} - - 复制 - - - 复制 - - - - - - - - - - {{item.orderInfo.total_num}}件商品 - - - - {{val.cart_info.product.store_name}} - - ¥{{ item.orderInfo.pay_price }} - - - - - - - - - - - - - - - - ¥{{ item.product.price }} - - {{item.product.store_name}} - - - - - - - - - - - - - - ¥{{ item.presell.price }} - - {{item.presell.store_name}} - - - - - - - - - - - - - - ¥{{ item.productGroup.product.price }} - - {{item.productGroup.product.store_name}} - - - - - - - - - - - - {{item.msn}} - - - - - - - - - - - - - - 退款单号:{{ item.refundOrder.refund_order_sn }} - - - - - - - - - {{item.refundOrder.refund_num}}件商品 - - - - {{val.product.cart_info.product.store_name}} - - 共{{item.refundOrder.refund_num}}件商品, - 合计 ¥{{ item.refundOrder.refund_price }} - - - - - - - - - - 订单号:{{ item.orderInfo.order_sn }} - - 复制 - - - 复制 - - - - - - - - - {{item.orderInfo.total_num}}件商品 - - - - {{val.cart_info.product.store_name}} - - ¥{{ item.orderInfo.pay_price }} - - - - - - - - - - - - - - - - ¥{{ item.product.price }} - - {{item.product.store_name}} - - - - - - - - - - - - - - ¥{{ item.presell.price }} - - {{item.presell.store_name}} - - - - - - - - - - - - - - ¥{{ item.productGroup.product.price }} - - {{item.productGroup.product.store_name}} - - - - - - - - - - - - {{ item.msn }} - - - - - - - 复制 - - - - - - 复制 - - - - 撤回 - - - - - - - 你撤回了一条消息 - - - - - - - - - - - - - - - + + + + + + {{storeInfo.mer_name}} + + + 进店 + + + + + + + + + + {{items.time}} + + + + + + + 对方撤回了一条消息 + + + + + + + 退款单号:{{ item.refundOrder.refund_order_sn }} + + + + + + + + {{item.refundOrder.refund_num}}件商品 + + + + {{val.product.cart_info.product.store_name}} + + ¥{{ item.refundOrder.refund_price }} + + + + + + + + + + 订单号:{{ item.orderInfo.order_sn }} + + 复制 + + + 复制 + + + + + + + + + {{item.orderInfo.total_num}}件商品 + + + + {{val.cart_info.product.store_name}} + + ¥{{ item.orderInfo.pay_price }} + + + + + + + + + + + + + + + + ¥{{ item.product.price }} + + {{item.product.store_name}} + + + + + + + + + + + + + + ¥{{ item.presell.price }} + + {{item.presell.store_name}} + + + + + + + + + + + + + + ¥{{ item.productGroup.product.price }} + + {{item.productGroup.product.store_name}} + + + + + + + + + + + + {{item.msn}} + + + + + + + + + + + + + + 订单号:{{ item.refundOrder.refund_order_sn }} + + 复制 + + + 复制 + + + + + + + + + {{item.refundOrder.refund_num}}件商品 + + + + {{val.product.cart_info.product.store_name}} + + ¥{{ item.refundOrder.refund_price }} + + + + + + + + + + 订单号:{{ item.orderInfo.order_sn }} + + 复制 + + + 复制 + + + + + + + + + {{item.orderInfo.total_num}}件商品 + + + + {{val.cart_info.product.store_name}} + + ¥{{ item.orderInfo.pay_price }} + + + + + + + + + + + + + + + + ¥{{ item.product.price }} + + {{item.product.store_name}} + + + + + + + + + + + + + + ¥{{ item.presell.price }} + + {{item.presell.store_name}} + + + + + + + + + + + + + + ¥{{ item.productGroup.product.price }} + + {{item.productGroup.product.store_name}} + + + + + + + + + + + + {{item.msn}} + + + + + + + 复制 + + + + + + 复制 + + + + + 撤回 + + + + + + + + 你撤回了一条消息 + + + + + + {{items.time}} + + + + + + + 对方撤回了一条消息 + + + + + + + 退款单号:{{ item.refundOrder.refund_order_sn }} + + + + + + + + + {{item.refundOrder.refund_num}}件商品 + + + + {{val.product.cart_info.product.store_name}} + + ¥{{ val.product.cart_info.productAttr.price }} + + + + + + + + + + 订单号:{{ item.orderInfo.order_sn }} + + 复制 + + + 复制 + + + + + + + + + + {{item.orderInfo.total_num}}件商品 + + + + {{val.cart_info.product.store_name}} + + ¥{{ item.orderInfo.pay_price }} + + + + + + + + + + + + + + + + ¥{{ item.product.price }} + + {{item.product.store_name}} + + + + + + + + + + + + + + ¥{{ item.presell.price }} + + {{item.presell.store_name}} + + + + + + + + + + + + + + ¥{{ item.productGroup.product.price }} + + {{item.productGroup.product.store_name}} + + + + + + + + + + + + {{item.msn}} + + + + + + + + + + + + + + 退款单号:{{ item.refundOrder.refund_order_sn }} + + + + + + + + + {{item.refundOrder.refund_num}}件商品 + + + + {{val.product.cart_info.product.store_name}} + + 共{{item.refundOrder.refund_num}}件商品, + 合计 ¥{{ item.refundOrder.refund_price }} + + + + + + + + + + 订单号:{{ item.orderInfo.order_sn }} + + 复制 + + + 复制 + + + + + + + + + {{item.orderInfo.total_num}}件商品 + + + + {{val.cart_info.product.store_name}} + + ¥{{ item.orderInfo.pay_price }} + + + + + + + + + + + + + + + + ¥{{ item.product.price }} + + {{item.product.store_name}} + + + + + + + + + + + + + + ¥{{ item.presell.price }} + + {{item.presell.store_name}} + + + + + + + + + + + + + + ¥{{ item.productGroup.product.price }} + + {{item.productGroup.product.store_name}} + + + + + + + + + + + + {{ item.msn }} + + + + + + + 复制 + + + + + + 复制 + + + + + 撤回 + + + + + + + + 你撤回了一条消息 + + + + + + + + + + + + + + + + .line1 { + max-width: 203rpx; + } + } + + uni-swiper-item { + background: #fff; + } + + .footer_count { + margin-top: 20rpx; + width: 710rpx; + position: fixed; + bottom: 120rpx; + bottom: calc(120rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/ + bottom: calc(120rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/ + left: 20rpx; + + .broadcast-details_box, + .broadcast_box { + margin-bottom: 0; + position: relative; + } + + .icon-guanbi { + font-size: 20rpx; + color: #C4C4C4; + position: absolute; + right: 20rpx; + top: 20rpx; + } + } + + .broadcast-details_order { + // padding: 15rpx; + } + + .copy { + color: var(--view-theme); + margin-left: 24rpx; + font-size: 22rpx; + opacity: .5; + } + + .broadcast-details_box { + padding: 20rpx; + display: flex; + background: #fff; + border-radius: 0 0 10rpx 10rpx; + margin-bottom: 24rpx; + } + + .broadcast_details_model { + width: 100%; + height: 43rpx; + background: rgba(0, 0, 0, 0.5); + border-radius: 0 0 16rpx 16rpx; + position: absolute; + z-index: 0; + bottom: 0; + font-size: 22rpx; + color: #fff; + text-align: center; + line-height: 43rpx; + } + + .broadcast_details_img { + width: 160rpx; + height: 160rpx; + border-radius: 10px; + overflow: hidden; + position: relative; + } + + .broadcast_details_img uni-image, + .broadcast_details_img image { + width: 160rpx; + height: 160rpx; + } + + .broadcast_details_img_no { + width: 456rpx; + height: 456rpx; + border-radius: 10px 10px 0px 0px; + overflow: hidden; + margin-bottom: 10rpx; + } + + .broadcast_details_picBox_no { + width: 100%; + } + + .broadcast_details_img_no uni-image, + .broadcast_details_img_no img { + width: 100%; + height: 100%; + } + + .broadcast_details_tit { + font-size: 30rpx; + color: #282828; + // height: 30rpx; + max-width: 400rpx; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + text-align: left !important; + } + + .product_price { + margin-top: 66rpx; + } + + .broadcast_details_tit_no { + font-size: 28rpx; + color: #333333; + font-weight: 800; + text-align: left; + margin-top: 5rpx; + max-width: 420rpx; + } + + .broadcast_details_picBox { + width: 75%; + margin-left: 24rpx; + } + + .broadcast_details_pic { + margin-top: 15rpx; + font-size: 24rpx; + color: #999999; + text-align: left; + } + + .broadcast_details_pic_num { + text-decoration: line-through; + font-size: 28rpx; + color: rgba(0, 0, 0, 0.5); + margin-left: 0.1rem; + } + + .broadcast_details_btn { + width: 130rpx; + height: 50rpx; + background: var(--view-theme); + opacity: 1; + border-radius: 125rpx; + color: #fff; + font-size: 24rpx; + text-align: center; + line-height: 50rpx; + margin-top: 16px; + float: right; + + &.product_btn { + margin-top: 0; + float: none; + } + + &.refund_btn { + width: 150rpx; + } + } + + .p-color { + color: var(--view-priceColor); + } + + .broadcast-details .chat { + padding: 1rpx 23rpx 0 23rpx; + margin-bottom: 3rpx; + + } + + .broadcast-details .chat .item { + margin-top: 37rpx; + } + + .broadcast-details .create_time { + dislay: block; + width: 100%; + text-align: center; + color: #999999; + font-size: 22rpx; + margin: 30rpx 0; + } + + .broadcast-details .chat .item .pictrue { + width: 80rpx; + height: 80rpx; + margin-top: 10rpx; + } + + .broadcast-details .chat .item .pictrue image { + width: 100%; + height: 100%; + border-radius: 50%; + } + + .broadcast-details .chat .item .text { + margin-left: 20rpx; + } + + .broadcast-details .chat .item .text.textR { + text-align: right; + margin: 0 20rpx 0 0; + position: relative; + + .recall { + position: absolute; + width: 220rpx; + height: 114rpx; + border-radius: 6rpx; + background: #4C4C4C; + color: #fff; + top: -140rpx; + right: 0; + display: flex; + align-items: center; + justify-content: center; + z-index: 200; + + &.recall00 { + top: auto; + bottom: -130rpx; + + &::after { + border-top-color: transparent; + border-bottom-color: rgba(0, 0, 0, .6); + bottom: auto; + top: -26rpx; + } + } + + &::after { + content: ""; + display: block; + border: 14rpx solid transparent; + border-top-color: rgba(0, 0, 0, .6); + position: absolute; + bottom: -26rpx; + right: 30rpx; + } + + .recall-item { + text-align: center; + margin: 0 30rpx; + font-size: 24rpx; + + .copy-data { + color: #fff; + margin-left: 0; + opacity: 1; + } + + .iconfont { + display: block; + font-size: 32rpx; + margin-bottom: 8rpx; + } + } + } + } + + .broadcast-details .chat .item .text .name { + font-size: 24rpx; + color: #999; + } + + .broadcast-details .chat .item .text .name .return { + color: #509efb; + margin-left: 17rpx; + } + + .broadcast-details .chat .item .text.textR .name .return { + margin: 0 0.17rem 0 0; + } + + .broadcast-details .chat .item .text .conter { + background-color: #fff; + border-radius: 8rpx; + padding: 16rpx 20rpx; + font-size: 30rpx; + color: #333; + position: relative; + max-width: 600rpx; + margin-top: 2rpx; + word-break: break-all; + text-align: left; + + .em { + margin: 0; + } + } + + .recall-msg { + display: block; + width: 100%; + text-align: center; + color: #999; + font-size: 24rpx; + margin: 10rpx 0; + } + + .broadcast-details .chat .item .text .spot { + width: 15rpx; + height: 15rpx; + background-color: #c00000; + border-radius: 50%; + margin-left: 20rpx; + } + + .broadcast-details .chat .item .text .conter:before { + position: absolute; + content: ""; + width: 0; + height: 0; + border-bottom: 9rpx solid transparent; + border-right: 14rpx solid #fff; + border-top: 9rpx solid transparent; + left: -14rpx; + top: 25rpx; + } + + .broadcast-details .chat .item .text.textR .conter:before { + left: unset; + right: -14rpx; + transform: rotateY(180deg); + } + + .broadcast-details .chat .item .text .conter img { + /* #ifdef H5 */ + width: 100%; + /* #endif */ + display: block; + } + + .broadcast-details .chat .item .text .conter .signal { + width: 48rpx; + height: 48rpx; + } + + .broadcast-details .chat .item .text .conter .signal.signalR { + transform: rotate(180deg); + -ms-transform: rotate(180deg); + -webkit-transform: rotate(180deg); + } + + .broadcast-details .footerCon { + height: 100rpx; + width: 100%; + transition: all 0.005s cubic-bezier(0.25, 0.5, 0.5, 0.9); + background-color: #fff; + position: fixed; + bottom: 0; + height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/ + height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/ + left: 0; + } + + .broadcast-details .footerCon .banner { + background: #fff; + margin-top: calc(0rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/ + margin-top: calc(0rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/ + } + + .broadcast-details .footerCon.on { + position: relative; + top: -300rpx; + transform: translate3d(0, 0, 0) !important; + + .banner { + margin-top: 0; + } + } + + .broadcast-details .footerCon .banner .swiper-slide { + flex-wrap: wrap; + -webkit-flex-wrap: wrap; + background-color: #fff; + padding-bottom: 50rpx; + border-top: 1px solid #f5f5f5; + } + + .broadcast-details .footerCon .banner .swiper-slide .emoji-outer, + .swiper-slide .em { + display: block; + width: 50rpx; + height: 50rpx; + margin: 40rpx 0 0 50rpx; + } + + .broadcast-details .footerCon .banner .swiper-container-horizontal>.swiper-pagination-bullets { + bottom: 10rpx; + } + + .broadcast-details .footerCon .slider-banner .swiper-pagination-bullet-active { + background-color: #999; + } + + .broadcast-details .recording { + width: 300rpx; + height: 300rpx; + position: fixed; + top: 40%; + left: 50%; + margin-left: -150rpx; + } + + .broadcast-details .recording img { + width: 100%; + height: 100%; + } + + .broadcast-details .footer { + // width: 100%; + background-color: #fff; + padding: 17rpx 26rpx; + align-items: center; + + } + + .footer_box { + margin-top: 260rpx; + } + + .broadcast-details .footer image { + width: 61rpx; + height: 60rpx; + display: block; + } + + .broadcast-details .footer .icon-biaoqing2, + .broadcast-details .footer .icon-tupian2 { + font-size: 60rpx; + display: block; + } + + .broadcast-details .footer .voice { + width: 440rpx; + border-radius: 10rpx; + background-color: #e5e5e5; + /* padding: 17rpx 30rpx; */ + height: 60rpx; + padding-left: 20rpx; + } + + .broadcast-details .footer .input_count { + margin-left: 20rpx; + width: 544rpx; + box-sizing: border-box; + border-radius: 38rpx; + background-color: #F6F6F6; + padding: 0 80rpx 0 30rpx; + height: 76rpx; + position: relative; + } + + .broadcast-details .footer .placeholder { + color: #999999; + font-size: 26rpx; + } + + .broadcast-details .footer .input { + max-height: 150rpx; + overflow-y: auto; + overflow-x: hidden; + color: #999999; + height: 76rpx; + font-size: 26rpx; + } + + .broadcast-details .footer .send { + font-size: 48rpx; + color: #cccccc; + position: absolute; + right: 15rpx; + top: 15rpx; + } + + .em { + display: inline-block; + width: 50rpx; + height: 50rpx; + margin: 40rpx 0 0 50rpx; + } + + .emoji-outer { + position: absolute; + right: 70rpx; + /* bottom: 12rpx; */ + width: 50rpx; + height: 50rpx; + margin: 40rpx 0 0 50rpx; + } + + .broadcast-details { + display: flex; + flex-direction: column; + width: 100%; + overflow: hidden; + + .hd-wrapper { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; + + &.on { + padding-bottom: 300rpx; + } + } + } + + .store-wrapper { + display: flex; + align-items: center; + justify-content: space-between; + padding: 15rpx 20rpx; + background-color: #fff; + width: 100%; + position: fixed; + top: 0; + left: 0; + z-index: 100; + + image { + width: 60rpx; + height: 60rpx; + margin-right: 10rpx; + } + + .left { + display: flex; + align-items: center; + } + + .link { + width: 80rpx; + height: 40rpx; + line-height: 38rpx; + border: 1px solid var(--view-theme); + border-radius: 20px; + font-size: 24rpx; + color: var(--view-theme); + text-align: center; + } + + .store-opeation { + align-items: center; + + .icon-dadianhua01 { + color: var(--view-theme); + margin-left: 28rpx; + font-size: 34rpx; + } + } + } + \ No newline at end of file diff --git a/pages/gather/gather.vue b/pages/gather/gather.vue index 3492c2e..f4ea2a0 100644 --- a/pages/gather/gather.vue +++ b/pages/gather/gather.vue @@ -357,7 +357,12 @@ } }) }, - scanQRcode() { + async scanQRcode() { + // #ifdef APP-PLUS + let result = await this.$store.dispatch("permission/requestPermissions", + 'CAMERA') + if (result !== 1) return; + // #endif uni.scanCode({ success: (res) => { console.log(res); diff --git a/pages/index/component/homeComb.vue b/pages/index/component/homeComb.vue index d507a3f..857d1f4 100644 --- a/pages/index/component/homeComb.vue +++ b/pages/index/component/homeComb.vue @@ -1,269 +1,272 @@ - - - - - - - - - {{street||'定位中' }} - - - - - - - - - - - - + + + + + + + + + {{street||'定位中' }} + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/newActivity/share/share.vue b/pages/newActivity/share/share.vue index c140828..9e42072 100644 --- a/pages/newActivity/share/share.vue +++ b/pages/newActivity/share/share.vue @@ -31,9 +31,14 @@ let that = this; uni.downloadFile({ url: imageUrl, - success(res) { + success: async (res)=> { if (res.statusCode === 200) { let tempFilePath = res.tempFilePath; // 临时文件路径 + // #ifdef APP-PLUS + let result = await this.$store.dispatch("permission/requestPermissions", + 'WRITE_EXTERNAL_STORAGE') + if (result !== 1) return; + // #endif uni.saveImageToPhotosAlbum({ filePath: tempFilePath, success() { diff --git a/pages/select_address_n/select_address_n.nvue b/pages/select_address_n/select_address_n.nvue index 95520dd..942f13a 100644 --- a/pages/select_address_n/select_address_n.nvue +++ b/pages/select_address_n/select_address_n.nvue @@ -1,8 +1,8 @@ - + - @@ -97,8 +97,19 @@ } }, onLoad(options) { + // #ifdef APP-PLUS + this.$store.dispatch("permission/requestPermissions", + 'ACCESS_FINE_LOCATION').then(result => { + if (result == 1) { + this.getLoaction(); + this.loadArea(); + } + }) + // #endif + // #ifndef APP-PLUS this.getLoaction(); this.loadArea(); + // #endif }, onShow() {}, computed: { @@ -250,7 +261,7 @@ latitude: this.latitude, longitude: this.longitude } - console.log({...obj}); + console.log({ ...obj }); uni.navigateBack({ success: () => { uni.$emit('changeAddress', obj) @@ -260,7 +271,7 @@ return Toast('地址有误,请重新选择') } }, - searchMap(){ + searchMap() { uni.request({ url: 'https://restapi.amap.com/v3/place/text?keywords=北京大学&city=beijing&offset=20&page=1&key=0799f37420c0784f1e6cba230a68bdb1&extensions=all', success: (res) => { diff --git a/pages/users/order_confirm/index.vue b/pages/users/order_confirm/index.vue index 9316d52..168f5f6 100644 --- a/pages/users/order_confirm/index.vue +++ b/pages/users/order_confirm/index.vue @@ -1564,7 +1564,7 @@ title: '下单成功,请上传支付凭证!' }, { tab: 5, - url: "/pages/users/order_list/index" + url: "/pages/users/order_list/index?sale_type="+ this.sale_type }); break; // #ifdef H5 diff --git a/pages/users/user_info/index.vue b/pages/users/user_info/index.vue index e6e0b9b..b638fa3 100644 --- a/pages/users/user_info/index.vue +++ b/pages/users/user_info/index.vue @@ -245,7 +245,15 @@ * 上传图片文件 * */ - uploadpic: function() { + uploadpic: async function() { + // #ifdef APP-PLUS + let result = await this.$store.dispatch("permission/requestPermissions", + 'CAMERA') + if (result !== 1) return; + result = await this.$store.dispatch("permission/requestPermissions", + 'READ_EXTERNAL_STORAGE') + if (result !== 1) return; + // #endif let that = this; if (that.open_update_info == 0) { return; diff --git a/store/modules/index.js b/store/modules/index.js index 6703754..86ed1e9 100644 --- a/store/modules/index.js +++ b/store/modules/index.js @@ -9,7 +9,9 @@ // +---------------------------------------------------------------------- import app from "./app"; import storage from "./storage.js"; +import permission from "./permission.js"; export default { app, - storage + storage, + permission }; \ No newline at end of file diff --git a/store/modules/permission.js b/store/modules/permission.js new file mode 100644 index 0000000..8886a03 --- /dev/null +++ b/store/modules/permission.js @@ -0,0 +1,249 @@ +// 权限说明 + +const state = { + WRITE_EXTERNAL_STORAGE: false, + READ_EXTERNAL_STORAGE: false, + CAMERA: false, + CALL_PHONE: false, + ACCESS_FINE_LOCATION: false, + /* #ifdef APP-PLUS */ + isIos: plus.os.name == "iOS", + /* #endif */ + mapping: { + 'WRITE_EXTERNAL_STORAGE': { + title: "存储空间/照片权限说明", + content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中读取和写入相册和文件内容。", + methods: 'SET_WRITE_EXTERNAL_STORAGE' + }, + 'READ_EXTERNAL_STORAGE': { + title: "存储空间/照片权限说明", + content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中读取和写入相册和文件内容。", + methods: 'SET_READ_EXTERNAL_STORAGE' + }, + 'CAMERA': { + title: "相机/存储空间/照片权限说明", + content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中读取和写入相册和文件内容。", + methods: 'SET_CAMERA' + }, + 'CALL_PHONE': { + title: "拨打/管理电话权限说明", + content: "便于您使用该功能联系商家或者商家与您联系等场景", + methods: 'SET_CALL_PHONE' + }, + 'ACCESS_FINE_LOCATION': { + title: "获取位置权限说明", + content: "便于您使用该功能查看附近店铺/附近商品/店铺所在位置等场景", + methods: 'SET_ACCESS_FINE_LOCATION' + } + } +} +const mutations = { + SET_WRITE_EXTERNAL_STORAGE(state, val) { + state.WRITE_EXTERNAL_STORAGE = val + }, + SET_CALL_PHONE(state, val) { + state.CALL_PHONE = val + }, + SET_READ_EXTERNAL_STORAGE(state, val) { + state.READ_EXTERNAL_STORAGE = val + }, + SET_CAMERA(state, val) { + state.CAMERA = val + }, + SET_ACCESS_FINE_LOCATION(state, val) { + state.ACCESS_FINE_LOCATION = val + }, +} +const actions = { + //权限获取 + async requestPermissions({ + state, + dispatch, + commit + }, permissionID) { + try { + if (!state[permissionID] && !state.isIos) { + var viewObj = await dispatch('nativeObjView', permissionID); + viewObj.show(); + } + console.log('android.permission.' + permissionID, '当前手机权限'); + return new Promise(async (resolve, reject) => { + //苹果不需要这个 + if(state.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++) { + 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('申请权限错误:' + error.code + " = " + error + .message); + resolve({ + code: error.code, + message: error.message + }); + } + ); + }); + } + + const result = await requestAndroidPermission( + 'android.permission.' + permissionID + ); + if (result === 1) { + //'已获得授权' + commit(state.mapping[permissionID].methods, true) + } else if (result === 0) { + //'未获得授权' + commit(state.mapping[permissionID].methods, false) + } else { + commit(state.mapping[permissionID].methods, true) + uni.showModal({ + title: '提示', + content: '操作权限已被拒绝,请手动前往设置', + confirmText: "立即设置", + success: (res) => { + if (res.confirm) { + dispatch('gotoAppPermissionSetting') + } + } + }) + } + if (viewObj) viewObj.close() + resolve(result); + }); + } catch (error) { + console.log(error); + reject(error); + } + }, + //提示框 + nativeObjView({ + state + }, permissionID) { + const systemInfo = uni.getSystemInfoSync(); + const statusBarHeight = systemInfo.statusBarHeight; + const navigationBarHeight = systemInfo.platform === 'android' ? 48 : + 44; // Set the navigation bar height based on the platform + const totalHeight = statusBarHeight + navigationBarHeight; + let view = new plus.nativeObj.View('per-modal', { + top: '0px', + left: '0px', + width: '100%', + backgroundColor: '#444', + //opacity: .5; + }) + view.drawRect({ + color: '#fff', + radius: '5px' + }, { + top: totalHeight + 'px', + left: '5%', + width: '90%', + height: "100px", + }) + view.drawText(state.mapping[permissionID].title, { + top: totalHeight + 5 + 'px', + left: "8%", + height: "30px" + }, { + align: "left", + color: "#000", + }, { + onClick: function (e) { + console.log(e); + } + }) + view.drawText(state.mapping[permissionID].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 + } + return { + show, + close + } + }, + + // 跳转到**应用**的权限页面 + gotoAppPermissionSetting({ + state + }) { + if (state.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); + } + } +} +export default { + namespaced: true, + state, + mutations, + actions +}; \ No newline at end of file