Compare commits
11 Commits
dff1f49269
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c7b62b0f4d | |||
| 8a67e20fc2 | |||
| 8d46ee78d3 | |||
| df34c1ad48 | |||
| 5f4a4d4ae4 | |||
| 708804cbbf | |||
| 7523441a17 | |||
| bb1d9ef281 | |||
| 1f01ceb3ee | |||
| 02436fe222 | |||
| ff66593f4f |
@@ -4,6 +4,7 @@ if (process.env.NODE_ENV === 'development') {
|
||||
// 开发环境
|
||||
// baseUrl = "http://192.168.110.100:9200/pb/"; // 张川川
|
||||
baseUrl = "https://api.nuttyreading.com/"; // 线上正式
|
||||
// baseUrl = "http://192.168.110.131:9200/pb/"; // 王亚男
|
||||
} else if (process.env.NODE_ENV === 'production') {
|
||||
// 生产环境11
|
||||
//baseUrl = "http://192.168.110.100:9200/pb/"; // 张川川
|
||||
|
||||
@@ -84,11 +84,12 @@ $http.getAliToken = function(callback) {
|
||||
//请求开始拦截器
|
||||
$http.requestStart = function(options) {
|
||||
// console.log("请求开始", options);
|
||||
if (options.load && options.data.loadAnimate != 'none') {
|
||||
const resData = options.data || {}
|
||||
if (options.load && resData.loadAnimate != 'none') {
|
||||
//打开加载动画
|
||||
store.commit("setLoadingShow", true);
|
||||
}
|
||||
if (options.data.loadAnimate == 'none') {
|
||||
if (resData.loadAnimate == 'none') {
|
||||
delete options.data.loadAnimate
|
||||
}
|
||||
// 图片、视频上传大小限制
|
||||
@@ -351,7 +352,8 @@ $http.dataFactory = async function(res) {
|
||||
// 返回错误的结果(catch接受数据)
|
||||
return Promise.reject({
|
||||
statusCode: 0,
|
||||
errMsg: "【request】" + (httpData.info || httpData.msg),
|
||||
// errMsg: "【request】" + (httpData.info || httpData.msg),
|
||||
errMsg: (httpData.info || httpData.msg),
|
||||
data: res.data
|
||||
});
|
||||
}
|
||||
|
||||
3
main.js
3
main.js
@@ -125,6 +125,9 @@ Vue.component('common-video', commonVideo);
|
||||
import CommonCourseVideo from 'edu-core/components/course-video'
|
||||
Vue.component('CommonCourseVideo', CommonCourseVideo);
|
||||
|
||||
import CommonRefundDestination from 'edu-core/components/order/refund-destination.vue'
|
||||
Vue.component('common-refund-destination', CommonRefundDestination);
|
||||
|
||||
import commonCoupon from '@/pages/component/commonComponents/coupon/index.vue'
|
||||
Vue.component('common-coupon', commonCoupon);
|
||||
import commonGoodsList from '@/pages/component/commonComponents/goodsList.vue'
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"src" : "图片路径"
|
||||
}
|
||||
],
|
||||
"versionName" : "1.0.56",
|
||||
"versionCode" : 1056,
|
||||
"versionName" : "1.0.65",
|
||||
"versionCode" : 1065,
|
||||
"app-plus" : {
|
||||
"nvueCompiler" : "weex",
|
||||
"compatible" : {
|
||||
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "3.4.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"edu-core": "file:../edu-core",
|
||||
"edu-core": "git+https://git.nuttyreading.com/chenghuan/edu-core.git#v1.0.14",
|
||||
"jquery": "^3.7.1",
|
||||
"tcplayer.js": "^5.1.0"
|
||||
},
|
||||
@@ -17,11 +17,6 @@
|
||||
"postcss-px-to-viewport": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"../edu-core": {
|
||||
"version": "1.0.8",
|
||||
"license": "ISC",
|
||||
"devDependencies": {}
|
||||
},
|
||||
"node_modules/babel-runtime": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmmirror.com/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
||||
@@ -73,8 +68,9 @@
|
||||
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w=="
|
||||
},
|
||||
"node_modules/edu-core": {
|
||||
"resolved": "../edu-core",
|
||||
"link": true
|
||||
"version": "1.0.14",
|
||||
"resolved": "git+https://git.nuttyreading.com/chenghuan/edu-core.git#eb9eccdc3d281fe84127a93e019650512859ff0c",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/es5-shim": {
|
||||
"version": "4.6.7",
|
||||
@@ -397,7 +393,8 @@
|
||||
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w=="
|
||||
},
|
||||
"edu-core": {
|
||||
"version": "file:../edu-core"
|
||||
"version": "git+https://git.nuttyreading.com/chenghuan/edu-core.git#eb9eccdc3d281fe84127a93e019650512859ff0c",
|
||||
"from": "edu-core@git+https://git.nuttyreading.com/chenghuan/edu-core.git#v1.0.14"
|
||||
},
|
||||
"es5-shim": {
|
||||
"version": "4.6.7",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/dcloudio/hello-uniapp#readme",
|
||||
"dependencies": {
|
||||
"edu-core": "file:../edu-core",
|
||||
"edu-core": "git+https://git.nuttyreading.com/chenghuan/edu-core.git#v1.0.14",
|
||||
"jquery": "^3.7.1",
|
||||
"tcplayer.js": "^5.1.0"
|
||||
},
|
||||
|
||||
24
pages.json
24
pages.json
@@ -193,6 +193,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bookShop/refundDestination",
|
||||
"style": {
|
||||
"navigationBarTitleText": "钱款去向",
|
||||
"enablePullDownRefresh": false,
|
||||
"app-plus": {
|
||||
"bounce": "none",
|
||||
"titleNView": false,
|
||||
"popGesture": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/goods/order/index",
|
||||
"style": {
|
||||
@@ -557,6 +569,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/medicaldes/medurl",
|
||||
"style": {
|
||||
"navigationBarTitleText": "详细介绍",
|
||||
"enablePullDownRefresh": false,
|
||||
"app-plus": {
|
||||
"bounce": "none",
|
||||
"titleNView": false,
|
||||
"popGesture": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/medicaldes/recordDetail",
|
||||
"style": {
|
||||
|
||||
@@ -88,6 +88,16 @@
|
||||
v-if="orderContet.orderStatus == 5"
|
||||
>已超时</text
|
||||
>
|
||||
<text
|
||||
class="orderState orderState6"
|
||||
v-if="orderContet.orderStatus == 6"
|
||||
>已退款</text
|
||||
>
|
||||
<text
|
||||
class="orderState orderState7"
|
||||
v-if="orderContet.orderStatus == 7"
|
||||
>退款中</text
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
class="orderContent"
|
||||
@@ -1029,6 +1039,29 @@ export default {
|
||||
orderTabCLi(e) {
|
||||
this.orderListTab = e;
|
||||
},
|
||||
async getCouponDetail(id) {
|
||||
await this.$http
|
||||
.request({
|
||||
url: "common/coupon/getCouponHistoryInfo",
|
||||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||||
data: {
|
||||
id,
|
||||
},
|
||||
header: {
|
||||
//默认 无 说明:请求头
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res.code != 0) return this.$commonJS.showToast(res.errMsg);
|
||||
this.orderContet.couponAmount =
|
||||
res.couponHistory.couponEntity.couponAmount;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
this.$commonJS.showToast(e.errMsg);
|
||||
});
|
||||
},
|
||||
// 获取订单详情
|
||||
getOrderList() {
|
||||
console.log("this.orderType", this.orderType);
|
||||
@@ -1045,12 +1078,16 @@ export default {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
.then(async (res) => {
|
||||
this.customButton = [];
|
||||
console.log("订单详情", res);
|
||||
this.orderContet = res.data.buyOrder;
|
||||
this.goodsList = res.data.productInfo;
|
||||
this.consigneeShow = true;
|
||||
// 存在优惠券信息,就查询优惠券集体金额
|
||||
if (this.orderContet.couponId && this.orderContet.couponId != null) {
|
||||
await this.getCouponDetail(this.orderContet.couponId);
|
||||
}
|
||||
if (
|
||||
this.orderContet.orderStatus == 2 &&
|
||||
this.sheetList.length > 0 &&
|
||||
@@ -1078,14 +1115,15 @@ export default {
|
||||
text: "继续付款",
|
||||
});
|
||||
}
|
||||
if (this.orderContet.orderStatus == 0) {
|
||||
this.customButton.push({
|
||||
width: "160rpx",
|
||||
text: "取消订单",
|
||||
color: "#333",
|
||||
backgroundColor: "#f0f0f0",
|
||||
});
|
||||
}
|
||||
// sociology:注释取消订单按钮
|
||||
// if (this.orderContet.orderStatus == 0) {
|
||||
// this.customButton.push({
|
||||
// width: "160rpx",
|
||||
// text: "取消订单",
|
||||
// color: "#333",
|
||||
// backgroundColor: "#f0f0f0",
|
||||
// });
|
||||
// }
|
||||
|
||||
// var seconds = res.result.timestamp + 30 * 60 + 2 // 过期时间
|
||||
// var nowSeconds = Math.floor(new Date().getTime() / 1000);
|
||||
@@ -1104,6 +1142,10 @@ export default {
|
||||
this.titleStat = "待收到";
|
||||
} else if (this.orderContet.orderStatus == 3) {
|
||||
this.titleStat = "已完成";
|
||||
} else if (this.orderContet.orderStatus == 6) {
|
||||
this.titleStat = "已退款";
|
||||
} else if (this.orderContet.orderStatus == 7) {
|
||||
this.titleStat = "退款中";
|
||||
}
|
||||
if (
|
||||
this.orderContet.orderStatus >= 2 &&
|
||||
@@ -1146,10 +1188,28 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
checkPayTimeout(payItem) {
|
||||
const createTime = payItem && payItem.createTime;
|
||||
if (!createTime) return true;
|
||||
const createdAt = new Date(String(createTime).replace(/-/g, "/")).getTime();
|
||||
if (!createdAt) return true;
|
||||
const expired = Date.now() - createdAt > 10 * 60 * 1000;
|
||||
if (expired) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "订单已超时,不能继续支付,请重新下单",
|
||||
confirmText: "知道了",
|
||||
showCancel: false,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// 支付
|
||||
goPay(payItem) {
|
||||
console.log(payItem, "订单数据");
|
||||
if (!this.checkPayTimeout(payItem)) return;
|
||||
if (payItem.paymentMethod == 2) {
|
||||
console.log("阿里支付");
|
||||
setPay(
|
||||
@@ -1293,6 +1353,12 @@ uni-view {
|
||||
.orderState5 {
|
||||
background-color: #787878;
|
||||
}
|
||||
.orderState6 {
|
||||
background-color: #f56c6c;
|
||||
}
|
||||
.orderState7 {
|
||||
background-color: #f56c6c;
|
||||
}
|
||||
.guoqi {
|
||||
font-size: 28rpx;
|
||||
align-items: center;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<view class="cateList flexbox">
|
||||
<common-sticky
|
||||
itemStyle="width:20%; height: 68rpx;font-size:24rpx;"
|
||||
itemStyle="height: 68rpx;font-size:24rpx; padding: 0 20rpx;"
|
||||
:list="ordersTabs"
|
||||
label="name"
|
||||
:currentCateIndex="currentCateIndex"
|
||||
@@ -120,6 +120,16 @@
|
||||
v-show="slotProps.row.orderStatus == 5"
|
||||
>已过期</text
|
||||
>
|
||||
<text
|
||||
class="orderstatus"
|
||||
v-show="slotProps.row.orderStatus == 6"
|
||||
>已退款</text
|
||||
>
|
||||
<text
|
||||
class="orderstatus"
|
||||
v-show="slotProps.row.orderStatus == 7"
|
||||
>退款中</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
@@ -380,11 +390,12 @@
|
||||
class="operation_box boxShadow"
|
||||
v-if="slotProps.row.isShowMore == true"
|
||||
>
|
||||
<view
|
||||
<!-- sociology:注释取消订单入口 -->
|
||||
<!-- <view
|
||||
v-if="slotProps.row.orderStatus == 0"
|
||||
@click.native.stop="canceOrder(slotProps.row)"
|
||||
>取消订单</view
|
||||
>
|
||||
> -->
|
||||
</view>
|
||||
<view class="btns flexbox" style="margin-top: 10rpx">
|
||||
<view
|
||||
@@ -421,8 +432,18 @@
|
||||
>
|
||||
<view
|
||||
class="orderstatusbtn"
|
||||
v-if="slotProps.row.orderStatus == 3"
|
||||
>申请售后</view
|
||||
v-if="
|
||||
slotProps.row.orderStatus == 6 ||
|
||||
slotProps.row.orderStatus == 7
|
||||
"
|
||||
@click.stop="goRefundDestination(slotProps.row)"
|
||||
>钱款去向</view
|
||||
>
|
||||
<view
|
||||
class="orderstatusbtn"
|
||||
v-if="slotProps.row.refundableStatus === true"
|
||||
@click.stop="confirmApplyRefund(slotProps.row)"
|
||||
>申请退款</view
|
||||
>
|
||||
<!-- <view
|
||||
class="orderstatusbtn"
|
||||
@@ -615,12 +636,14 @@ export default {
|
||||
come: "1",
|
||||
isShowTab: false,
|
||||
isLoadingHide: false,
|
||||
moreList: [
|
||||
{
|
||||
name: "取消订单",
|
||||
key: "false",
|
||||
},
|
||||
],
|
||||
// sociology:注释取消订单菜单
|
||||
// moreList: [
|
||||
// {
|
||||
// name: "取消订单",
|
||||
// key: "false",
|
||||
// },
|
||||
// ],
|
||||
moreList: [],
|
||||
currentCateIndex: 0,
|
||||
pagination: {
|
||||
// 请求参数
|
||||
@@ -671,6 +694,16 @@ export default {
|
||||
value: 3,
|
||||
badge: {},
|
||||
},
|
||||
{
|
||||
name: "已退款",
|
||||
value: 6,
|
||||
badge: {},
|
||||
},
|
||||
{
|
||||
name: "退款中",
|
||||
value: 7,
|
||||
badge: {},
|
||||
},
|
||||
],
|
||||
selectOrderInfo: {},
|
||||
ordersListTab: 1,
|
||||
@@ -790,7 +823,8 @@ export default {
|
||||
console.log("index at line 609:", index);
|
||||
if (index.key == "false") {
|
||||
this.isShowMore = false;
|
||||
this.canceOrder(this.selectOrderInfo);
|
||||
// sociology:注释取消订单触发
|
||||
// this.canceOrder(this.selectOrderInfo);
|
||||
}
|
||||
},
|
||||
openMore(row, index) {
|
||||
@@ -856,6 +890,51 @@ export default {
|
||||
val.orderSn,
|
||||
});
|
||||
},
|
||||
goRefundDestination(row) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/bookShop/refundDestination?orderId=${row.orderId}`,
|
||||
});
|
||||
},
|
||||
confirmApplyRefund(row) {
|
||||
uni.showModal({
|
||||
title: "申请退款",
|
||||
content: "请确认是否提交退款申请?",
|
||||
confirmText: "确认提交",
|
||||
cancelText: "取消",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.submitOrderRefund(row);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
submitOrderRefund(orderRow) {
|
||||
this.$http
|
||||
.request({
|
||||
url: "book/buyOrder/refundOrder",
|
||||
method: "POST",
|
||||
data: {
|
||||
orderId: orderRow.orderId,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$commonJS.showToast("申请退款成功");
|
||||
this.newestpage = 1;
|
||||
this.pagination.page = 1;
|
||||
this.newList = [];
|
||||
this.getBookList(this.ordersListTab, false);
|
||||
return;
|
||||
}
|
||||
this.$commonJS.showToast(res.errMsg || "申请退款失败");
|
||||
})
|
||||
.catch(() => {
|
||||
this.$commonJS.showToast("申请退款失败");
|
||||
});
|
||||
},
|
||||
getBookList(flag, refreshflag) {
|
||||
this.isLoadingHide = false;
|
||||
var that = this;
|
||||
@@ -882,6 +961,8 @@ export default {
|
||||
// * 3:已完成
|
||||
// * 4: 交易失败
|
||||
// * 5: 已过期
|
||||
// * 6: 已退款
|
||||
// * 7: 退款中
|
||||
|
||||
console.log("res at line 757:", res);
|
||||
that.map = res.data;
|
||||
@@ -909,7 +990,7 @@ export default {
|
||||
var params = {
|
||||
userId: this.userInfo.id,
|
||||
come: this.come,
|
||||
orderStatus: flag == -1 ? "" : flag, //传null为全部,订单状态 0-待付款 1-待发出 2-待收到 3-已完成 4-交易失败 5-已过期
|
||||
orderStatus: flag == -1 ? "" : flag, //传null为全部,订单状态 0-待付款 1-待发出 2-待收到 3-已完成 4-交易失败 5-已过期 6-已退款 7-退款中
|
||||
...this.pagination,
|
||||
// limit: 10,
|
||||
// page: this.newestpage,
|
||||
@@ -949,9 +1030,27 @@ export default {
|
||||
|
||||
this.axiosStatus = 1;
|
||||
},
|
||||
checkPayTimeout(payItem) {
|
||||
const createTime = payItem && payItem.createTime;
|
||||
if (!createTime) return true;
|
||||
const createdAt = new Date(String(createTime).replace(/-/g, "/")).getTime();
|
||||
if (!createdAt) return true;
|
||||
const expired = Date.now() - createdAt > 10 * 60 * 1000;
|
||||
if (expired) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "订单已超时,不能继续支付,请重新下单",
|
||||
confirmText: "知道了",
|
||||
showCancel: false,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// 支付
|
||||
goPay(payItem) {
|
||||
console.log(payItem, "订单数据");
|
||||
if (!this.checkPayTimeout(payItem)) return;
|
||||
if (payItem.paymentMethod == 2) {
|
||||
console.log("阿里支付");
|
||||
setPay(
|
||||
@@ -1629,9 +1728,9 @@ export default {
|
||||
z-index: 970;
|
||||
}
|
||||
|
||||
/deep/.u-tabs__wrapper__nav__item {
|
||||
padding: 0 !important;
|
||||
}
|
||||
// /deep/.u-tabs__wrapper__nav__item {
|
||||
// padding: 0 !important;
|
||||
// }
|
||||
|
||||
.commonDetailPage {
|
||||
background-color: #f5f5f5;
|
||||
|
||||
27
pages/bookShop/refundDestination.vue
Normal file
27
pages/bookShop/refundDestination.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<view class="page-wrap">
|
||||
<public-module></public-module>
|
||||
<common-refund-destination :order-id="orderId" :http="$http" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
orderId: "",
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options && options.orderId != null) {
|
||||
this.orderId = options.orderId;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
min-height: 100vh;
|
||||
}
|
||||
</style>
|
||||
@@ -520,6 +520,17 @@
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<u-modal
|
||||
:show="presaleRemarkModalShow"
|
||||
title="提示"
|
||||
:content="presaleRemarkModalContent"
|
||||
:showCancelButton="true"
|
||||
confirmText="继续购买"
|
||||
cancelText="取消"
|
||||
@confirm="handlePresaleRemarkConfirm"
|
||||
@cancel="handlePresaleRemarkCancel"
|
||||
@close="handlePresaleRemarkCancel"
|
||||
></u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -621,6 +632,9 @@ export default {
|
||||
|
||||
orderModalShowInfo: {},
|
||||
orderModalShow: false,
|
||||
presaleRemarkModalShow: false,
|
||||
presaleRemarkModalContent: "",
|
||||
presaleRemarkModalResolve: null,
|
||||
payType: 1,
|
||||
freightNum: 0,
|
||||
addressData: {
|
||||
@@ -1344,6 +1358,62 @@ export default {
|
||||
this.content = this.remark;
|
||||
}
|
||||
},
|
||||
openPresaleRemarkModal(content) {
|
||||
this.presaleRemarkModalContent = content;
|
||||
this.presaleRemarkModalShow = true;
|
||||
return new Promise((resolve) => {
|
||||
this.presaleRemarkModalResolve = resolve;
|
||||
});
|
||||
},
|
||||
handlePresaleRemarkConfirm() {
|
||||
this.presaleRemarkModalShow = false;
|
||||
if (this.presaleRemarkModalResolve) {
|
||||
const resolve = this.presaleRemarkModalResolve;
|
||||
this.presaleRemarkModalResolve = null;
|
||||
resolve(true);
|
||||
}
|
||||
},
|
||||
handlePresaleRemarkCancel() {
|
||||
this.presaleRemarkModalShow = false;
|
||||
if (this.presaleRemarkModalResolve) {
|
||||
const resolve = this.presaleRemarkModalResolve;
|
||||
this.presaleRemarkModalResolve = null;
|
||||
resolve(false);
|
||||
}
|
||||
},
|
||||
async checkPresaleRemark() {
|
||||
if (this.pageType != "goods") {
|
||||
return true;
|
||||
}
|
||||
const productIds = this.goodsDataList
|
||||
.map((e) => e.productId)
|
||||
.filter((id) => id)
|
||||
.join(",");
|
||||
if (!productIds || !this.urlList.presaleRemark) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const res = await this.$http.request({
|
||||
url: `${this.urlList.presaleRemark}`,
|
||||
method: "POST",
|
||||
data: {
|
||||
productIds,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
const remark =
|
||||
res && typeof res.remark == "string" ? res.remark.trim() : "";
|
||||
if (!remark) {
|
||||
return true;
|
||||
}
|
||||
return await this.openPresaleRemarkModal(remark);
|
||||
} catch (error) {
|
||||
console.log("presaleRemark error:", error);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
async goBuyJie() {
|
||||
if (this.pageType == "vip") {
|
||||
if (this.radioValue != "1") {
|
||||
@@ -1449,6 +1519,11 @@ export default {
|
||||
});
|
||||
thisproduct = thisproduct.join(",");
|
||||
}
|
||||
const passPresaleRemark = await this.checkPresaleRemark();
|
||||
if (!passPresaleRemark) {
|
||||
this.buyingFlag = false;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.historyOrderInfo &&
|
||||
thisproduct == this.historyOrderInfo.product &&
|
||||
|
||||
@@ -445,4 +445,8 @@ export default {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.title_list {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- <scroll-view class="scroll-view_H cateList" scroll-x="true" scroll-left="0"> -->
|
||||
<view class="" style="background-color: #fff; width: 100%">
|
||||
<view class="" style="background-color: #fff; width: 100%; padding: 0 20rpx;">
|
||||
<u-tabs
|
||||
lineWidth="30"
|
||||
lineColor="#3AB3AE"
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
<CommonCourseVideo
|
||||
:video-list="videoArray"
|
||||
:current-index="currentVideoIndex !== null ? currentVideoIndex : 0"
|
||||
:course="{courseTitle:options.navTitle, chapterTitle: curriculumData.title}"
|
||||
:course="{courseTitle:options.navTitle, chapterTitle: curriculumData.title, catalogueId: curriculumData.catalogueId || '', courseId: curriculumData.courseId || ''}"
|
||||
:cover="options.curriculumImgUrl || ''"
|
||||
:http="$http"
|
||||
:user-info="userInfo"
|
||||
/>
|
||||
|
||||
<view
|
||||
|
||||
@@ -702,9 +702,11 @@ export default {
|
||||
role = "心理学";
|
||||
} else if (type == 9) {
|
||||
role = "中西汇通学";
|
||||
} else if (type == 10) {
|
||||
role = "妇幼生殖";
|
||||
}
|
||||
this.goBuyTitle =
|
||||
"尊贵的" + role + "VIP,您的有效期到" + res.userVip.endTime;
|
||||
"尊贵的" + role + "VIP,您的有效期到" + res.userVip.endTime + '(不包含论坛)';
|
||||
this.goBuyType = 1;
|
||||
} else {
|
||||
//否则没有开通vip
|
||||
@@ -745,12 +747,14 @@ export default {
|
||||
text = "心理学";
|
||||
} else if (item == "9") {
|
||||
text = "中西汇通学";
|
||||
} else if (item == "10") {
|
||||
text = "妇幼生殖";
|
||||
}
|
||||
this.textList.push(text);
|
||||
});
|
||||
|
||||
const joinedText = this.textList.join("/");
|
||||
this.goBuyTitle = "购买" + joinedText + "VIP,即可畅享更多专属权益";
|
||||
this.goBuyTitle = "购买" + joinedText + "VIP,即可畅享更多专属权益(不包含论坛)";
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -145,6 +145,7 @@ export default {
|
||||
list: "app/phone.do?getCourseDetail_new",
|
||||
initPrepareOrder: "common/buyOrder/initPrepareOrder",
|
||||
buyOrder: "book/buyOrder/placeOrder",
|
||||
presaleRemark: "book/buyOrder/presaleRemark",
|
||||
curriculumInfo: "app/phone.do?getCourseInfo",
|
||||
detailInfo: "app/phoneDoctor.do?getTaiHuClassInfo_new",
|
||||
userInfo: "common/user/getUserInfo",
|
||||
|
||||
@@ -39,19 +39,22 @@
|
||||
<!-- </scroll-view> -->
|
||||
<template v-if="!showSearchList">
|
||||
<view class="grid twoCateList" v-if="twoCateList.length > 0">
|
||||
<u-grid :col="3" border class="u-grid-list cateList">
|
||||
<u-grid-item
|
||||
<view
|
||||
class="custom-grid"
|
||||
:class="curOneCateIndex == 1 ? 'col-4' : 'col-3'"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in twoCateList"
|
||||
:key="item.dictType"
|
||||
class="grid-item"
|
||||
@click="setTwoCateIndex(item, index)"
|
||||
>
|
||||
<!-- <u-button :type="success">成功按钮</u-button> -->
|
||||
<view
|
||||
:class="['grid-text', curTwoCateIndex == index ? 'cur' : '']"
|
||||
>{{ item.dictValue }}
|
||||
</view>
|
||||
</u-grid-item>
|
||||
</u-grid>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
@@ -90,8 +93,6 @@
|
||||
"
|
||||
>
|
||||
<common-list
|
||||
@lower="onReachBottom1"
|
||||
:pagination="pagination"
|
||||
:dataList="titleList"
|
||||
@hancleClick="gotoDetail"
|
||||
label="title"
|
||||
@@ -104,7 +105,6 @@
|
||||
</template>
|
||||
<template v-else-if="curOneCateIndex == 0 || curOneCateIndex == 2">
|
||||
<common-list
|
||||
@lower="onReachBottom1"
|
||||
:dataList="titleList"
|
||||
@hancleClick="gotoDetail"
|
||||
label="name"
|
||||
@@ -122,7 +122,6 @@
|
||||
</template>
|
||||
<template v-if="curOneCateIndex == 3">
|
||||
<common-list
|
||||
@lower="onReachBottom1"
|
||||
:dataList="titleList"
|
||||
@hancleClick="gotoDetail"
|
||||
label="title"
|
||||
@@ -199,7 +198,6 @@
|
||||
</view>
|
||||
</u-modal> -->
|
||||
|
||||
<z-navigation></z-navigation>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -573,8 +571,12 @@ export default {
|
||||
// }).exec();
|
||||
await uni
|
||||
.createSelectorQuery()
|
||||
.select(".cateList")
|
||||
.in(this)
|
||||
.select(".twoCateList")
|
||||
.boundingClientRect(function (rect) {
|
||||
if (!rect || typeof rect.height !== "number") {
|
||||
return;
|
||||
}
|
||||
console.log(rect.height, "22222");
|
||||
|
||||
var height = 42 + rect.height + 20;
|
||||
@@ -773,6 +775,51 @@ export default {
|
||||
// height: 40rpx;
|
||||
}
|
||||
|
||||
.custom-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
// border-top: 1px solid #dadbde;
|
||||
// border-bottom: 1px solid #dadbde;
|
||||
|
||||
&.col-3 {
|
||||
.grid-item {
|
||||
min-width: 33.33%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
// .grid-item:nth-child(-n + 3) {
|
||||
// border-top: 0;
|
||||
// }
|
||||
// .grid-item:nth-child(3n + 1) {
|
||||
// border-left: 0;
|
||||
// }
|
||||
}
|
||||
|
||||
&.col-4 {
|
||||
.grid-item {
|
||||
min-width: 25%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
// .grid-item:nth-child(-n + 4) {
|
||||
// border-top: 0;
|
||||
// }
|
||||
// .grid-item:nth-child(4n + 1) {
|
||||
// border-left: 0;
|
||||
// }
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
// border-left: 1px solid #dadbde;
|
||||
// border-top: 1px solid #dadbde;
|
||||
padding: 10rpx 0;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
cursor: pointer;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.searchList {
|
||||
.item {
|
||||
font-size: 28rpx;
|
||||
@@ -799,20 +846,20 @@ export default {
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
width: 32%;
|
||||
padding: 20rpx 0;
|
||||
padding: 16rpx 0;
|
||||
font-size: 34rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.cur {
|
||||
background-color: #3ab3ae;
|
||||
background-color: #3AB3AE;
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.twoCateList {
|
||||
font-size: 28rpx;
|
||||
font-size: 30rpx;
|
||||
margin-top: 20rpx;
|
||||
|
||||
.grid-text {
|
||||
@@ -824,7 +871,7 @@ export default {
|
||||
color: #3ab3ae;
|
||||
}
|
||||
|
||||
// .u-grid-list{border: 0.5px solid #dadbde;}
|
||||
.u-grid-list{border: 0.5px solid #dadbde;}
|
||||
}
|
||||
|
||||
.titleList {
|
||||
|
||||
@@ -63,12 +63,15 @@
|
||||
<uni-section
|
||||
class="mb-10"
|
||||
titleFontSize="18px"
|
||||
title="详细介绍"
|
||||
title="说明"
|
||||
type="line"
|
||||
v-if="prescriptDetail.content && prescriptDetail.content != ''"
|
||||
>
|
||||
<view class="item" v-html="prescriptDetail.content"> </view>
|
||||
</uni-section>
|
||||
<div class="detail-link-wrap" v-if="prescriptDetail.url && prescriptDetail.url != ''">
|
||||
<text class="detail-link" @click="openDetailUrl">详细介绍>></text>
|
||||
</div>
|
||||
|
||||
<!-- <uni-section class="mb-10" titleFontSize="18px" title="配伍" type="line">
|
||||
<view class="item" v-if="prescriptDetail.compatibility && prescriptDetail.compatibility != ''" v-html="prescriptDetail.compatibility">
|
||||
@@ -129,6 +132,13 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
openDetailUrl() {
|
||||
uni.navigateTo({
|
||||
url:
|
||||
"/pages/medicaldes/medurl?url=" +
|
||||
encodeURIComponent(this.prescriptDetail.url),
|
||||
});
|
||||
},
|
||||
// 方剂详情
|
||||
getDetail() {
|
||||
$http
|
||||
@@ -207,6 +217,18 @@ export default {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.detail-link-wrap {
|
||||
padding: 10rpx 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
|
||||
.detail-link {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: #007aff;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .uni-section-header__decoration.line {
|
||||
background-color: #18bc37;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,25 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
this.id = uni.getStorageSync("prescriptUrl");
|
||||
this.id = e.url ? decodeURIComponent(e.url) : uni.getStorageSync("prescriptUrl");
|
||||
// #ifdef APP-PLUS
|
||||
const pages = getCurrentPages()
|
||||
const page = pages[pages.length - 1];
|
||||
const currentWebview = page.$getAppWebview()
|
||||
currentWebview.setStyle({
|
||||
titleNView: {
|
||||
buttons: [{
|
||||
float: 'right',
|
||||
type: 'close',
|
||||
onclick: function() {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
|
||||
@@ -65,9 +65,10 @@
|
||||
</view>
|
||||
|
||||
<view class="userInfoBox" style="margin-left: 20rpx">
|
||||
<view class="name"
|
||||
>昵称:{{ userMes.nickname ? userMes.nickname : "未设置" }}</view
|
||||
>
|
||||
<view class="name">
|
||||
{{ userMes.nickname ? userMes.nickname : "未设置" }}
|
||||
<text v-if="userMes.profile" class="user-profile">({{userMes.profile}})</text>
|
||||
</view>
|
||||
<view
|
||||
class="name"
|
||||
style="
|
||||
@@ -91,13 +92,18 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view>
|
||||
<u-tag v-if="userMes.todayWatch" :text="userMes.todayWatch" size="mini" plain plainFill type="success" class="watch-time"></u-tag>
|
||||
<u-tag v-if="userMes.totalWatch" :text="userMes.totalWatch" size="mini" plain plainFill class="watch-time"></u-tag>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
style="
|
||||
padding: 20rpx 20rpx 0;
|
||||
margin-top: 50rpx;
|
||||
margin-top: 25rpx;
|
||||
height: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -637,6 +643,9 @@ export default {
|
||||
if (this.userInfo.id != undefined) {
|
||||
this.$http.post("common/user/getUserInfo").then((res) => {
|
||||
this.userMes = res.result;
|
||||
this.userMes.profile = res.des || '';
|
||||
this.userMes.todayWatch = res.todayWatch || '';
|
||||
this.userMes.totalWatch = res.totalWatch || '';
|
||||
if (this.userMes.userVip) {
|
||||
}
|
||||
});
|
||||
@@ -754,6 +763,9 @@ export default {
|
||||
} else if (item.type == "9") {
|
||||
item.text = "中西汇通学";
|
||||
this.textList.push(item.text);
|
||||
} else if (item.type == "10") {
|
||||
item.text = "妇幼生殖";
|
||||
this.textList.push(item.text);
|
||||
} else if (item.type == "1") {
|
||||
item.text = "医学S";
|
||||
} else if (item.type == "2") {
|
||||
@@ -795,18 +807,21 @@ export default {
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
color: #333 !important;
|
||||
color: #6990c7 !important;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 6rpx;
|
||||
}
|
||||
|
||||
.user-profile{
|
||||
font-size: 28rpx;
|
||||
font-weight: normal;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.phone {
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.tong {
|
||||
color: #999;
|
||||
font-size: 25upx;
|
||||
font-size: 26rpx;
|
||||
color: #6990c7 !important;
|
||||
margin: 6rpx 0;
|
||||
}
|
||||
|
||||
.per_user_img {
|
||||
@@ -816,6 +831,16 @@ export default {
|
||||
margin-left: 10rpx;
|
||||
vertical-align: super;
|
||||
}
|
||||
|
||||
.watch-time {
|
||||
margin-top: 10rpx;
|
||||
display: inline-block;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.userInfoBox {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1033,9 +1058,9 @@ export default {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
uni-page-body {
|
||||
// background: #d8f8e4 !important;
|
||||
}
|
||||
// uni-page-body {
|
||||
// // background: #d8f8e4 !important;
|
||||
// }
|
||||
|
||||
.bg_top {
|
||||
padding: 0 30rpx;
|
||||
@@ -1406,8 +1431,8 @@ uni-page-body {
|
||||
// margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.zhanghu {
|
||||
}
|
||||
// .zhanghu {
|
||||
// }
|
||||
|
||||
.quanyi {
|
||||
border-top: 1rpx solid #f2d494;
|
||||
@@ -1448,6 +1473,7 @@ uni-page-body {
|
||||
.vip_type {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.vip_type_item {
|
||||
display: flex;
|
||||
@@ -1462,6 +1488,7 @@ uni-page-body {
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-right: 8rpx;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
.vip_type_item_len {
|
||||
padding: 0 7rpx;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -88,21 +88,21 @@
|
||||
>
|
||||
<text class="font_bold" style="display: block" v-else>VIP权限:</text>
|
||||
<view class="vip_qx_v" v-if="item.type == 1"
|
||||
>无限制观看吴门医述APP中医学、中西汇通学、针灸学、肿瘤学四个板块任意课程;</view
|
||||
>无限制观看吴门医述APP中医学、中西汇通学、针灸学、肿瘤学、妇幼生殖五个板块任意课程(不包含论坛);</view
|
||||
>
|
||||
<view class="vip_qx_v" v-else-if="item.type == 2"
|
||||
>无限制观看众妙之门APP与心灵空间APP任意课程;</view
|
||||
>无限制观看众妙之门APP与心灵空间APP任意课程(不包含论坛);</view
|
||||
>
|
||||
<view class="vip_qx_v" v-else-if="item.type == 7"
|
||||
>无限制观看众妙之门APP任意课程;</view
|
||||
>无限制观看众妙之门APP任意课程(不包含论坛);</view
|
||||
>
|
||||
<view class="vip_qx_v" v-else-if="item.type == 8"
|
||||
>无限制观看心灵空间APP任意课程;</view
|
||||
>无限制观看心灵空间APP任意课程(不包含论坛);</view
|
||||
>
|
||||
<view class="vip_qx_v" v-else
|
||||
>无限制观看吴门医述APP{{
|
||||
item.title.replace(/VIP/g, "")
|
||||
}}板块任意课程;</view
|
||||
}}板块任意课程(不包含论坛);</view
|
||||
>
|
||||
|
||||
<view class="vip_qx_v">
|
||||
|
||||
@@ -63,8 +63,9 @@
|
||||
>
|
||||
<template slot="labelSlot" slot-scope="slotProps">
|
||||
<view class="label_content AC_List">
|
||||
<view style=" display: flex; align-items: center; justify-content: space-between;">
|
||||
<view class="left">
|
||||
<view class="title">{{ slotProps.row.orderType }}</view>
|
||||
<view class="title">{{ slotProps.row.productName || slotProps.row.orderType}}</view>
|
||||
</view>
|
||||
<view
|
||||
:class="`right ${
|
||||
@@ -74,6 +75,7 @@
|
||||
<text v-if="slotProps.row.changeAmount > 0">+</text>
|
||||
<text>{{ slotProps.row.changeAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="AC_mark" v-if="slotProps.row.remark">{{slotProps.row.remark}}</view>
|
||||
<view class="AC_note" v-if="slotProps.row.note&&slotProps.row.note!='null'">说明:{{slotProps.row.note}}</view>
|
||||
<view class="AC_time">{{ slotProps.row.createTime }}</view>
|
||||
@@ -348,6 +350,12 @@ export default {
|
||||
|
||||
.AC_List {
|
||||
overflow: hidden;
|
||||
.title,
|
||||
.AC_note,
|
||||
.AC_mark {
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.left {
|
||||
width: calc(100% - 220rpx) !important;
|
||||
font-weight: 700;
|
||||
@@ -365,6 +373,19 @@ export default {
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
}
|
||||
> view:first-child {
|
||||
.left {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: auto !important;
|
||||
float: none;
|
||||
}
|
||||
.right {
|
||||
flex-shrink: 0;
|
||||
float: none;
|
||||
width: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
// border-bottom: 1px solid #eee;
|
||||
// padding: 40rpx 10rpx;
|
||||
|
||||
@@ -377,3 +377,7 @@ button::after {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uni-text {
|
||||
white-space: normal;
|
||||
}
|
||||
14
uni_modules/uni-usercapturescreen/changelog.md
Normal file
14
uni_modules/uni-usercapturescreen/changelog.md
Normal file
@@ -0,0 +1,14 @@
|
||||
## 1.0.6(2024-11-22)
|
||||
- 修复 HarmonyOS Next 上调用 setUserCaptureScreen 报错的 Bug
|
||||
## 1.0.5(2024-10-14)
|
||||
- 新增 支持 HarmonyOS Next 调用
|
||||
## 1.0.4(2023-03-24)
|
||||
新增开启/关闭防截屏功能
|
||||
## 1.0.3(2023-03-17)
|
||||
修复android平台 部分场景下js可能报错的问题
|
||||
## 1.0.2(2023-03-16)
|
||||
修复Android平台在小米设备无法监听的问题 修复Android平台调用uni.onUserCaptureScreen必然会触发回调的问题
|
||||
## 1.0.1(2022-10-27)
|
||||
修改插件描述
|
||||
## 1.0.0(2022-10-26)
|
||||
支持安卓、iOS、微信小程序平台
|
||||
157
uni_modules/uni-usercapturescreen/index.d.ts
vendored
Normal file
157
uni_modules/uni-usercapturescreen/index.d.ts
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
declare namespace UniNamespace {
|
||||
/**
|
||||
* uni.onUserCaptureScreen/uni.offUserCaptureScreen回调参数
|
||||
*/
|
||||
type OnUserCaptureScreenCallbackResult = {
|
||||
/**
|
||||
* 截屏文件路径(仅Android返回)
|
||||
*/
|
||||
path ?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* uni.onUserCaptureScreen/uni.offUserCaptureScreen回调函数定义
|
||||
*/
|
||||
type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void
|
||||
|
||||
type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
|
||||
|
||||
type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen成功回调参数
|
||||
*/
|
||||
type SetUserCaptureScreenSuccess = {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen成功回调函数定义
|
||||
*/
|
||||
type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuccess) => void
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
* - 12001 "setUserCaptureScreen:system not support"
|
||||
* - 12010 "setUserCaptureScreen:system internal error"
|
||||
*/
|
||||
type SetUserCaptureScreenErrorCode = 12001 | 12010;
|
||||
|
||||
/**
|
||||
* SetUserCaptureScreen 的错误回调参数
|
||||
*/
|
||||
interface SetUserCaptureScreenFail {
|
||||
errCode : SetUserCaptureScreenErrorCode
|
||||
}
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen失败回调函数定义
|
||||
*/
|
||||
type SetUserCaptureScreenFailCallback = (res : SetUserCaptureScreenFail) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen完成回调函数定义
|
||||
*/
|
||||
type SetUserCaptureScreenCompleteCallback = (res : any) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen参数
|
||||
*/
|
||||
type SetUserCaptureScreenOptions = {
|
||||
/**
|
||||
* true: 允许用户截屏 false: 不允许用户截屏,防止用户截屏到应用页面内容
|
||||
*/
|
||||
enable : boolean;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
// success : SetUserCaptureScreenSuccessCallback | null,
|
||||
success ?: SetUserCaptureScreenSuccessCallback,
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
// fail : SetUserCaptureScreenFailCallback | null,
|
||||
fail ?: SetUserCaptureScreenFailCallback,
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
// complete : SetUserCaptureScreenSuccessCallback | SetUserCaptureScreenFailCallback | null
|
||||
complete ?: SetUserCaptureScreenCompleteCallback
|
||||
}
|
||||
|
||||
type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void
|
||||
}
|
||||
|
||||
declare interface Uni {
|
||||
/**
|
||||
* 开启截屏监听
|
||||
*
|
||||
* @param {UserCaptureScreenCallback} callback
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "9.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
* @autotest { expectCallback: true }
|
||||
*/
|
||||
onUserCaptureScreen(callback : UniNamespace.UserCaptureScreenCallback | null) : void,
|
||||
/**
|
||||
* 关闭截屏监听
|
||||
*
|
||||
* @param {UserCaptureScreenCallback} callback
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "9.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
* @autotest { expectCallback: true }
|
||||
*/
|
||||
offUserCaptureScreen(callback : UniNamespace.UserCaptureScreenCallback | null) : void,
|
||||
/**
|
||||
* 设置防截屏
|
||||
*
|
||||
* @param {SetUserCaptureScreenOptions} options
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "13.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
*/
|
||||
setUserCaptureScreen(options : UniNamespace.SetUserCaptureScreenOptions) : void
|
||||
}
|
||||
97
uni_modules/uni-usercapturescreen/package.json
Normal file
97
uni_modules/uni-usercapturescreen/package.json
Normal file
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"id": "uni-usercapturescreen",
|
||||
"displayName": "uni-usercapturescreen",
|
||||
"version": "1.0.6",
|
||||
"description": "用户主动截屏事件监听",
|
||||
"keywords": [
|
||||
"截屏"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.7.7"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "uts",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "插件不采集任何数据",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"uni-ext-api":{
|
||||
"uni": {
|
||||
"onUserCaptureScreen": {
|
||||
"web": false
|
||||
},
|
||||
"offUserCaptureScreen": {
|
||||
"web": false
|
||||
},
|
||||
"setUserCaptureScreen": {
|
||||
"web": false,
|
||||
"mp-weixin": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y",
|
||||
"alipay": "n"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
},
|
||||
"App": {
|
||||
"app-android": "y",
|
||||
"app-ios": "y",
|
||||
"app-harmony": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "n",
|
||||
"Android Browser": "n",
|
||||
"微信浏览器(Android)": "n",
|
||||
"QQ浏览器(Android)": "n"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "n",
|
||||
"IE": "n",
|
||||
"Edge": "n",
|
||||
"Firefox": "n",
|
||||
"Safari": "n"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "n",
|
||||
"百度": "n",
|
||||
"字节跳动": "n",
|
||||
"QQ": "n",
|
||||
"钉钉": "n",
|
||||
"快手": "n",
|
||||
"飞书": "n",
|
||||
"京东": "n"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "n",
|
||||
"联盟": "n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
uni_modules/uni-usercapturescreen/readme.md
Normal file
21
uni_modules/uni-usercapturescreen/readme.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# uni-usercapturescreen
|
||||
|
||||
用户主动截屏事件监听
|
||||
|
||||
### uni.onUserCaptureScreen
|
||||
|
||||
监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件。
|
||||
|
||||
> 使用文档:[https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen)
|
||||
|
||||
### uni.offUserCaptureScreen
|
||||
|
||||
用户主动截屏事件。取消事件监听。
|
||||
|
||||
> 使用文档:[https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen)
|
||||
|
||||
### uni.setUserCaptureScreen
|
||||
|
||||
开启/关闭防截屏。
|
||||
|
||||
> 使用文档:[https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen)
|
||||
139
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
Normal file
139
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
Normal file
@@ -0,0 +1,139 @@
|
||||
import { UTSAndroid } from "io.dcloud.uts";
|
||||
import ActivityCompat from "androidx.core.app.ActivityCompat";
|
||||
import Manifest from "android.Manifest";
|
||||
import PackageManager from "android.content.pm.PackageManager";
|
||||
import Build from "android.os.Build";
|
||||
import FileObserver from "android.os.FileObserver";
|
||||
import File from "java.io.File";
|
||||
import Environment from "android.os.Environment";
|
||||
import System from 'java.lang.System';
|
||||
import WindowManager from 'android.view.WindowManager';
|
||||
import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts";
|
||||
import string from 'android.R.string';
|
||||
|
||||
|
||||
/**
|
||||
* 文件监听器
|
||||
*/
|
||||
let observer : ScreenFileObserver | null = null;
|
||||
/**
|
||||
* 记录文件监听器上次监听的时间戳,避免重复监听
|
||||
*/
|
||||
let lastObserverTime : number = 0;
|
||||
/**
|
||||
* 截屏回调
|
||||
*/
|
||||
let listener : UserCaptureScreenCallback | null = null;
|
||||
|
||||
/**
|
||||
* android 文件监听实现
|
||||
*/
|
||||
class ScreenFileObserver extends FileObserver {
|
||||
|
||||
/**
|
||||
* 截屏文件目录
|
||||
*/
|
||||
private screenFile : File;
|
||||
|
||||
constructor(screenFileStr : string) {
|
||||
super(screenFileStr);
|
||||
this.screenFile = new File(screenFileStr);
|
||||
}
|
||||
|
||||
override onEvent(event : Int, path : string | null) : void {
|
||||
// 只监听文件新增事件
|
||||
if (event == FileObserver.CREATE) {
|
||||
if (path != null) {
|
||||
const currentTime = System.currentTimeMillis();
|
||||
if ((currentTime - lastObserverTime) < 1000) {
|
||||
// 本地截屏行为比上一次超过1000ms, 才认为是一个有效的时间
|
||||
return;
|
||||
}
|
||||
lastObserverTime = currentTime;
|
||||
|
||||
const screenShotPath = new File(this.screenFile, path).getPath();
|
||||
const res : OnUserCaptureScreenCallbackResult = {
|
||||
path: screenShotPath
|
||||
}
|
||||
listener?.(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启截图监听
|
||||
*/
|
||||
export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UserCaptureScreenCallback | null) {
|
||||
// 检查相关权限是否已授予
|
||||
if (ActivityCompat.checkSelfPermission(UTSAndroid.getAppContext()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
// 无权限,申请权限
|
||||
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 1001);
|
||||
return;
|
||||
}
|
||||
// 更新监听
|
||||
listener = callback;
|
||||
|
||||
let directory_screenshot : File;
|
||||
if (Build.MANUFACTURER.toLowerCase() == "xiaomi") {
|
||||
// @Suppress("DEPRECATION")
|
||||
directory_screenshot = new File(new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM), "Screenshots");
|
||||
} else {
|
||||
// @Suppress("DEPRECATION")
|
||||
directory_screenshot = new File(new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES), "Screenshots");
|
||||
}
|
||||
// 先结束监听 再开启监听
|
||||
observer?.stopWatching();
|
||||
observer = new ScreenFileObserver(directory_screenshot.getPath());
|
||||
observer?.startWatching();
|
||||
|
||||
|
||||
UTSAndroid.onAppActivityDestroy(function(){
|
||||
observer?.stopWatching()
|
||||
observer = null
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭截屏监听
|
||||
*/
|
||||
export const offUserCaptureScreen : OffUserCaptureScreen = function (_ : UserCaptureScreenCallback | null) {
|
||||
// android10以上,关闭监听通过移除文件监听器实现
|
||||
observer?.stopWatching();
|
||||
observer = null;
|
||||
lastObserverTime = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否禁止截屏
|
||||
*/
|
||||
export const setUserCaptureScreen : SetUserCaptureScreen = function (option : SetUserCaptureScreenOptions) {
|
||||
// 切换到UI线程
|
||||
UTSAndroid.getUniActivity()?.runOnUiThread(new SetUserCaptureScreenRunnable(option.enable));
|
||||
const res : SetUserCaptureScreenSuccess = {}
|
||||
option.success?.(res);
|
||||
option.complete?.(res);
|
||||
}
|
||||
|
||||
class SetUserCaptureScreenRunnable extends Runnable {
|
||||
|
||||
/**
|
||||
* ture: 允许用户截屏
|
||||
* false: 不允许用户截屏,防止用户截屏到应用页面内容
|
||||
*/
|
||||
private enable : boolean;
|
||||
|
||||
constructor(enable : boolean) {
|
||||
super();
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
override run() : void {
|
||||
if (this.enable) {
|
||||
UTSAndroid.getUniActivity()?.getWindow()?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
} else {
|
||||
UTSAndroid.getUniActivity()?.getWindow()?.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { display } from '@kit.ArkUI';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { Callback, BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
import { getAbilityContext } from '@dcloudio/uni-runtime';
|
||||
|
||||
import {
|
||||
OnUserCaptureScreen, UserCaptureScreenCallback,
|
||||
OffUserCaptureScreen,
|
||||
SetUserCaptureScreen, SetUserCaptureScreenOptions, SetUserCaptureScreenSuccess
|
||||
} from '../interface.uts';
|
||||
|
||||
const onUserCaptureScreenCallbacks: Function[] = []
|
||||
|
||||
const harmonyCaptureStatusChange: Callback<boolean> = (captureStatus: boolean) => {
|
||||
if (captureStatus) {
|
||||
onUserCaptureScreenCallbacks.forEach(cb => {
|
||||
typeof cb === 'function' && cb()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
display.on('captureStatusChange', harmonyCaptureStatusChange)
|
||||
|
||||
export const onUserCaptureScreen: OnUserCaptureScreen = function (callback: UserCaptureScreenCallback | null) {
|
||||
if (callback) {
|
||||
onUserCaptureScreenCallbacks.push(callback)
|
||||
}
|
||||
}
|
||||
|
||||
export const offUserCaptureScreen: OffUserCaptureScreen = function (callback: UserCaptureScreenCallback | null) {
|
||||
if (callback) {
|
||||
const index = onUserCaptureScreenCallbacks.indexOf(callback)
|
||||
if (index > -1) {
|
||||
onUserCaptureScreenCallbacks.splice(index, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const setUserCaptureScreen: SetUserCaptureScreen = function (options: SetUserCaptureScreenOptions) {
|
||||
const errSubject = 'uni-usercapturescreen'
|
||||
const setUserCaptureScreenSuccess: SetUserCaptureScreenSuccess = {}
|
||||
window.getLastWindow(getAbilityContext()!, (err, window) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
options.fail?.({
|
||||
errCode: (err as BusinessError).code,
|
||||
errSubject,
|
||||
errMsg: `setUserCaptureScreen:fail ${(err as BusinessError).message}`
|
||||
} as IUniError)
|
||||
options.complete?.(setUserCaptureScreenSuccess);
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
UTSHarmony.requestSystemPermission(['ohos.permission.PRIVACY_WINDOW'], (allRight: boolean, _grantedList: string[]) => {
|
||||
if (allRight) {
|
||||
window.setWindowPrivacyMode(!options.enable, (err: BusinessError) => {
|
||||
const errCode: number = err.code;
|
||||
if (errCode) {
|
||||
options.fail?.({
|
||||
errCode: err.code,
|
||||
errSubject,
|
||||
errMsg: `setUserCaptureScreen:fail ${err.message}`
|
||||
} as IUniError)
|
||||
options.complete?.(setUserCaptureScreenSuccess);
|
||||
return;
|
||||
}
|
||||
options.success?.(setUserCaptureScreenSuccess);
|
||||
options.complete?.(setUserCaptureScreenSuccess);
|
||||
});
|
||||
} else {
|
||||
throw new Error('permission denied')
|
||||
}
|
||||
}, (_doNotAskAgain: boolean, _grantedList: string[]) => {
|
||||
throw new Error('permission denied');
|
||||
})
|
||||
} catch (err) {
|
||||
options.fail?.({
|
||||
errCode: (err as BusinessError).code,
|
||||
errSubject,
|
||||
errMsg: `setUserCaptureScreen:fail ${(err as BusinessError).message}`
|
||||
} as IUniError)
|
||||
options.complete?.(setUserCaptureScreenSuccess);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
141
uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
Normal file
141
uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
Normal file
@@ -0,0 +1,141 @@
|
||||
import { NotificationCenter } from 'Foundation';
|
||||
import { CGRect } from "CoreFoundation";
|
||||
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
|
||||
import { UTSiOS } from "DCloudUTSFoundation"
|
||||
import { DispatchQueue } from 'Dispatch';
|
||||
import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess } from "../interface.uts"
|
||||
import { SetUserCaptureScreenFailImpl } from "../unierror.uts"
|
||||
/**
|
||||
* 定义监听截屏事件工具类
|
||||
*/
|
||||
class CaptureScreenTool {
|
||||
static listener : UserCaptureScreenCallback | null;
|
||||
static secureView : UIView | null;
|
||||
|
||||
// 监听截屏
|
||||
static listenCaptureScreen(callback : UserCaptureScreenCallback | null) {
|
||||
this.listener = callback
|
||||
|
||||
// 注册监听截屏事件及回调方法
|
||||
// target-action 回调方法需要通过 Selector("方法名") 构建
|
||||
const method = Selector("userDidTakeScreenshot")
|
||||
NotificationCenter.default.addObserver(this, selector = method, name = UIApplication.userDidTakeScreenshotNotification, object = null)
|
||||
}
|
||||
|
||||
// 捕获截屏回调的方法
|
||||
// target-action 的方法前需要添加 @objc 前缀
|
||||
@objc static userDidTakeScreenshot() {
|
||||
// 回调
|
||||
const res: OnUserCaptureScreenCallbackResult = {
|
||||
}
|
||||
this.listener?.(res)
|
||||
}
|
||||
|
||||
// 移除监听事件
|
||||
static removeListen(callback : UserCaptureScreenCallback | null) {
|
||||
this.listener = null
|
||||
NotificationCenter.default.removeObserver(this)
|
||||
}
|
||||
|
||||
static createSecureView() : UIView | null {
|
||||
let field = new UITextField(frame = CGRect.zero)
|
||||
field.isSecureTextEntry = true
|
||||
if (field.subviews.length > 0 && UIDevice.current.systemVersion != '15.1') {
|
||||
let view = field.subviews[0]
|
||||
view.subviews.forEach((item) => {
|
||||
item.removeFromSuperview()
|
||||
})
|
||||
view.isUserInteractionEnabled = true
|
||||
return view
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 开启防截屏
|
||||
static onAntiScreenshot(option : SetUserCaptureScreenOptions) {
|
||||
// uts方法默认会在子线程中执行,涉及 UI 操作必须在主线程中运行,通过 DispatchQueue.main.async 方法可将代码在主线程中运行
|
||||
DispatchQueue.main.async(execute = () : void => {
|
||||
let secureView = this.createSecureView()
|
||||
let window = UTSiOS.getKeyWindow()
|
||||
let rootView = window.rootViewController == null ? null : window.rootViewController!.view
|
||||
if (secureView != null && rootView != null) {
|
||||
let rootSuperview = rootView!.superview
|
||||
if (rootSuperview != null) {
|
||||
this.secureView = secureView
|
||||
rootSuperview!.addSubview(secureView!)
|
||||
rootView!.removeFromSuperview()
|
||||
secureView!.addSubview(rootView!)
|
||||
// secureView 充满父视图并随父视图宽高自适应(横竖屏、全屏切换时自动跟随)
|
||||
secureView!.frame = rootSuperview!.bounds
|
||||
secureView!.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight]
|
||||
// rootView 充满 secureView 并自适应,避免全屏时被固定在竖屏尺寸而缩到角落
|
||||
rootView!.frame = secureView!.bounds
|
||||
rootView!.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight]
|
||||
}
|
||||
}
|
||||
let res: SetUserCaptureScreenSuccess = {
|
||||
}
|
||||
option.success?.(res)
|
||||
option.complete?.(res)
|
||||
})
|
||||
}
|
||||
|
||||
// 关闭防截屏
|
||||
static offAntiScreenshot(option : SetUserCaptureScreenOptions) {
|
||||
DispatchQueue.main.async(execute = () : void => {
|
||||
if (this.secureView != null) {
|
||||
let window = UTSiOS.getKeyWindow()
|
||||
let rootView = window.rootViewController == null ? null : window.rootViewController!.view
|
||||
if (rootView != null && this.secureView!.superview != null) {
|
||||
let rootSuperview = this.secureView!.superview
|
||||
if (rootSuperview != null) {
|
||||
rootSuperview!.addSubview(rootView!)
|
||||
this.secureView!.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
this.secureView = null
|
||||
}
|
||||
let res: SetUserCaptureScreenSuccess = {
|
||||
}
|
||||
option.success?.(res)
|
||||
option.complete?.(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启截图监听
|
||||
*/
|
||||
export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UserCaptureScreenCallback | null) {
|
||||
CaptureScreenTool.listenCaptureScreen(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭截屏监听
|
||||
*/
|
||||
export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : UserCaptureScreenCallback | null) {
|
||||
CaptureScreenTool.removeListen(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭防截屏
|
||||
*/
|
||||
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
|
||||
if (UIDevice.current.systemVersion < "13.0") {
|
||||
let res = new SetUserCaptureScreenFailImpl(12001)
|
||||
options.fail?.(res);
|
||||
options.complete?.(res);
|
||||
|
||||
} else if (UIDevice.current.systemVersion == "15.1") {
|
||||
let res = new SetUserCaptureScreenFailImpl(12010)
|
||||
options.fail?.(res);
|
||||
options.complete?.(res);
|
||||
} else {
|
||||
if (options.enable == true) {
|
||||
CaptureScreenTool.offAntiScreenshot(options)
|
||||
} else {
|
||||
CaptureScreenTool.onAntiScreenshot(options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
170
uni_modules/uni-usercapturescreen/utssdk/interface.uts
Normal file
170
uni_modules/uni-usercapturescreen/utssdk/interface.uts
Normal file
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* uni.onUserCaptureScreen/uni.offUserCaptureScreen回调参数
|
||||
*/
|
||||
export type OnUserCaptureScreenCallbackResult = {
|
||||
/**
|
||||
* 截屏文件路径(仅Android返回)
|
||||
*/
|
||||
path ?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* uni.onUserCaptureScreen/uni.offUserCaptureScreen回调函数定义
|
||||
*/
|
||||
export type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void
|
||||
|
||||
export type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
|
||||
|
||||
export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen成功回调参数
|
||||
*/
|
||||
export type SetUserCaptureScreenSuccess = {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen成功回调函数定义
|
||||
*/
|
||||
export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuccess) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen失败回调函数定义
|
||||
*/
|
||||
export type SetUserCaptureScreenFailCallback = (res : IUniError) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen完成回调函数定义
|
||||
*/
|
||||
export type SetUserCaptureScreenCompleteCallback = (res : any) => void
|
||||
|
||||
/**
|
||||
* uni.setUserCaptureScreen参数
|
||||
*/
|
||||
|
||||
export type SetUserCaptureScreenOptions = {
|
||||
/**
|
||||
* true: 允许用户截屏 false: 不允许用户截屏,防止用户截屏到应用页面内容
|
||||
*/
|
||||
enable : boolean;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
// success : SetUserCaptureScreenSuccessCallback | null,
|
||||
success ?: SetUserCaptureScreenSuccessCallback,
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
// fail : SetUserCaptureScreenFailCallback | null,
|
||||
fail ?: SetUserCaptureScreenFailCallback,
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
// complete : SetUserCaptureScreenSuccessCallback | SetUserCaptureScreenFailCallback | null
|
||||
complete ?: SetUserCaptureScreenCompleteCallback
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
* - 12001 "setUserCaptureScreen:system not support"
|
||||
* - 12010 "setUserCaptureScreen:system internal error"
|
||||
*/
|
||||
export type SetUserCaptureScreenErrorCode = 12001 | 12010;
|
||||
/**
|
||||
* SetUserCaptureScreen 的错误回调参数
|
||||
*/
|
||||
export interface SetUserCaptureScreenFail extends IUniError {
|
||||
errCode : SetUserCaptureScreenErrorCode
|
||||
};
|
||||
|
||||
export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void
|
||||
|
||||
export interface Uni {
|
||||
/**
|
||||
* 开启截屏监听
|
||||
*
|
||||
* @param {UserCaptureScreenCallback} callback
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "4.11"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.25",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
* @autotest { expectCallback: true }
|
||||
*/
|
||||
onUserCaptureScreen(callback : UserCaptureScreenCallback | null) : void,
|
||||
/**
|
||||
* 关闭截屏监听
|
||||
*
|
||||
* @param {UserCaptureScreenCallback} callback
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "4.11"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.25",,
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
* @autotest { expectCallback: true }
|
||||
*/
|
||||
offUserCaptureScreen(callback : UserCaptureScreenCallback | null) : void,
|
||||
/**
|
||||
* 设置防截屏
|
||||
*
|
||||
* @param {SetUserCaptureScreenOptions} options
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4.4",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "13.0",
|
||||
* "uniVer": "3.7.7",
|
||||
* "unixVer": "4.11"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.25",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @uniVersion 3.7.7
|
||||
* @uniVueVersion 2,3 //支持的vue版本
|
||||
*/
|
||||
setUserCaptureScreen(options : SetUserCaptureScreenOptions) : void
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function onUserCaptureScreen (callback) {
|
||||
return wx.onUserCaptureScreen(callback)
|
||||
}
|
||||
|
||||
export function offUserCaptureScreen (callback) {
|
||||
return wx.offUserCaptureScreen(callback)
|
||||
}
|
||||
35
uni_modules/uni-usercapturescreen/utssdk/unierror.uts
Normal file
35
uni_modules/uni-usercapturescreen/utssdk/unierror.uts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { SetUserCaptureScreenErrorCode, SetUserCaptureScreenFail } from "./interface.uts"
|
||||
/**
|
||||
* 错误主题
|
||||
*/
|
||||
export const UniErrorSubject = 'uni-usercapturescreen';
|
||||
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
* @UniError
|
||||
*/
|
||||
export const UniErrors : Map<SetUserCaptureScreenErrorCode, string> = new Map([
|
||||
/**
|
||||
* 错误码及对应的错误信息
|
||||
*/
|
||||
[12001, 'setUserCaptureScreen:system not support'],
|
||||
[12010, 'setUserCaptureScreen:system internal error'],
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* 错误对象实现
|
||||
*/
|
||||
export class SetUserCaptureScreenFailImpl extends UniError implements SetUserCaptureScreenFail {
|
||||
|
||||
/**
|
||||
* 错误对象构造函数
|
||||
*/
|
||||
constructor(errCode : SetUserCaptureScreenErrorCode) {
|
||||
super();
|
||||
this.errSubject = UniErrorSubject;
|
||||
this.errCode = errCode;
|
||||
this.errMsg = UniErrors[errCode] ?? "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user