From e7b81924e3fa4d7c5a52484f465efa6733e8c402 Mon Sep 17 00:00:00 2001
From: zhouwenxuan <1175765986@qq.com>
Date: 星期四, 26 十月 2023 11:10:38 +0800
Subject: [PATCH] 防止重复点击
---
pages/tabBar/notice/measures.vue | 5
pages/tabBar/notice/detail.vue | 53 +++++++++++-
common/anti_shake.js | 30 +++++++
main.js | 2
App.vue | 132 ++++++++++++++++----------------
pages/index/index.vue | 10 +-
pages/tabBar/response/response.vue | 2
7 files changed, 155 insertions(+), 79 deletions(-)
diff --git a/App.vue b/App.vue
index 4c65956..ea88211 100644
--- a/App.vue
+++ b/App.vue
@@ -3,72 +3,72 @@
var jpushModule = uni.requireNativePlugin("JG-JPush")
export default {
onLaunch: function() {
- // console.log('App Launch',jpushModule)
- // jpushModule.initJPushService();
- // jpushModule.setLoggerEnable(true);
- // jpushModule.addConnectEventListener(result=>{
- // let connectEnable = result.connectEnable
- // uni.$emit('connectStatusChange',connectEnable)
- // });
- // //消息回调——点击通知栏消息 跳转指定页面
- // jpushModule.addNotificationListener(result=>{
- // if (result.notificationEventType == "notificationOpened") {
- // //判断是否登录
- // if (uni.getStorageSync('tk')) {
- // //工作通知——工作人员工作通知页
- // if (result.title.includes('工作通知')){
- // uni.switchTab({
- // url: '/pages/tabBar/notice/notice',
- // })
- // //信息审核——领导审核页
- // }else if(result.title == '您有新的信息需要审批'){
- // uni.switchTab({
- // url: '/pages/tabBar/examine/examine',
- // })
- // //审核结果——首页(后续加pc端信息发布页)
- // }else if(result.title.includes('信息审核')){
- // uni.switchTab({
- // url: '/pages/tabBar/information/information',
- // })
- // }
- // }else {
- // console.log("未登录")
- // //未登录跳转首页
- // uni.navigateTo({
- // url: '/pages/index/index',
- // complete(res) {
- // console.log(res);
- // }
- // })
- // uni.showToast({
- // icon: 'none',
- // title: '请先登录',
- // duration: 3000
- // })
- // }
- // }
- // });
- // jpushModule.addCustomMessageListener(result=>{
- // let type = result.type
- // let messageType = result.messageType
- // let content = result.content
- // uni.showToast({
- // icon: 'none',
- // title: JSON.stringify(result),
- // duration: 3000
- // })
- // });
- // jpushModule.addLocalNotificationListener(result=>{
- // let messageID = result.messageID
- // let title = result.title
- // let content = result.content
- // let extras = result.extras
- // uni.showToast({
- // icon: 'none',
- // title: JSON.stringify(result),
- // duration: 3000
- // })
- // })
+ console.log('App Launch',jpushModule)
+ jpushModule.initJPushService();
+ jpushModule.setLoggerEnable(true);
+ jpushModule.addConnectEventListener(result=>{
+ let connectEnable = result.connectEnable
+ uni.$emit('connectStatusChange',connectEnable)
+ });
+ //消息回调——点击通知栏消息 跳转指定页面
+ jpushModule.addNotificationListener(result=>{
+ if (result.notificationEventType == "notificationOpened") {
+ //判断是否登录
+ if (uni.getStorageSync('tk')) {
+ //工作通知——工作人员工作通知页
+ if (result.title.includes('工作通知')){
+ uni.switchTab({
+ url: '/pages/tabBar/notice/notice',
+ })
+ //信息审核——领导审核页
+ }else if(result.title == '您有新的信息需要审批'){
+ uni.switchTab({
+ url: '/pages/tabBar/examine/examine',
+ })
+ //审核结果——首页(后续加pc端信息发布页)
+ }else if(result.title.includes('信息审核')){
+ uni.switchTab({
+ url: '/pages/tabBar/information/information',
+ })
+ }
+ }else {
+ console.log("未登录")
+ //未登录跳转首页
+ uni.navigateTo({
+ url: '/pages/index/index',
+ complete(res) {
+ console.log(res);
+ }
+ })
+ uni.showToast({
+ icon: 'none',
+ title: '请先登录',
+ duration: 3000
+ })
+ }
+ }
+ });
+ jpushModule.addCustomMessageListener(result=>{
+ let type = result.type
+ let messageType = result.messageType
+ let content = result.content
+ uni.showToast({
+ icon: 'none',
+ title: JSON.stringify(result),
+ duration: 3000
+ })
+ });
+ jpushModule.addLocalNotificationListener(result=>{
+ let messageID = result.messageID
+ let title = result.title
+ let content = result.content
+ let extras = result.extras
+ uni.showToast({
+ icon: 'none',
+ title: JSON.stringify(result),
+ duration: 3000
+ })
+ })
diff --git a/common/anti_shake.js b/common/anti_shake.js
new file mode 100644
index 0000000..2dbbd77
--- /dev/null
+++ b/common/anti_shake.js
@@ -0,0 +1,30 @@
+// 防止处理多次点击
+function noMoreClicks(methods, info) {
+ // methods是需要点击后需要执行的函数, info是点击需要传的参数
+ let that = this;
+ if (that.noClick) {
+ console.log("点击")
+ // 第一次点击
+ that.noClick= false;
+ if(info && info !== '') {
+ // info是执行函数需要传的参数
+ methods(info);
+ } else {
+ methods();
+ }
+ setTimeout(()=> {
+ that.noClick= true;
+ }, 2000)//时间可以自己定义
+ } else {
+ // 这里是重复点击的判断
+ uni.showToast({
+ title: '请稍后点击',
+ icon: 'error',
+ duration: 1000
+ })
+ }
+}
+//导出
+export default {
+ noMoreClicks,//禁止多次点击
+}
\ No newline at end of file
diff --git a/main.js b/main.js
index d344b41..8048a2b 100644
--- a/main.js
+++ b/main.js
@@ -5,10 +5,12 @@
import request from '@/common/request.js'
import uView from '@/uni_modules/uview-ui'
import store from './store/index.js'
+import commom from './common/anti_shake.js'
Vue.use(uView)
Vue.config.productionTip = false
Vue.prototype.$Z = request;
+Vue.prototype.$noMoreClicks = commom.noMoreClicks;
App.mpType = 'app'
const app = new Vue({
diff --git a/pages/index/index.vue b/pages/index/index.vue
index dab79d2..2b9226a 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -70,7 +70,7 @@
}
},
onLoad() {
- // this.connect()
+ this.connect()
},
methods: {
Login(){
@@ -80,10 +80,10 @@
this.isLogining = false;
//登录成功后
//设置别名
- // jpushModule.setAlias({
- // 'alias': this.phone,
- // 'sequence': 1
- // })
+ jpushModule.setAlias({
+ 'alias': this.phone,
+ 'sequence': 1
+ })
uni.setStorageSync("name", this.form.name);
uni.setStorageSync("pwd", this.form.pwd);
uni.setStorageSync("tk", res.data.tk);
diff --git a/pages/tabBar/notice/detail.vue b/pages/tabBar/notice/detail.vue
index 434a482..45b62ed 100644
--- a/pages/tabBar/notice/detail.vue
+++ b/pages/tabBar/notice/detail.vue
@@ -45,6 +45,14 @@
<view style="width: 100%; height: 550px;" v-if="directViewUrl">
<iframe :src="directViewUrl" class="frameStyle"></iframe>
</view>
+ <view style="width: 100%; height: 550px;" v-if="urls.length > 0">
+ <view v-for="(item, index) in urls" :key="index" >
+ <view style="display: flex;margin-top: 10px;" @click="openFile(item)" >
+ <u-icon name="attach" color="#2979ff" size="20"></u-icon> <span>{{item.name}}</span>
+ </view>
+ </view>
+ </view>
+
<!-- <view class="attache" v-if="isAllImg == 'no'">
<view v-for="(item, index) in detailData.attachments" :key="index" >
<view style="display: flex;margin-top: 10px;" v-if="item.suffix == 'jpg'|| item.suffix =='jpeg' || item.suffix =='png'">
@@ -150,16 +158,48 @@
unitType: '',
directViewUrl: '',
cityMessage: '响应措施反馈',
- measureData: {}
+ measureData: {},
+ urls: []
}
},
onLoad:function(options){
+ // #ifdef APP-PLUS
+ const currentWebview = this.$scope.$getAppWebview();//获取当前web-view 此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
+ setTimeout(function() {
+ const wv = currentWebview.children()[0];
+ console.log(wv);
+ wv.setStyle({//设置web-view距离顶部的距离以及自己的高度,单位为px
+ top: 68,
+ height:300
+ })
+ }, 1000);//如页面初始化调用需要写延迟
+ // #endif
this.role = uni.getStorageSync('roleName');
//获取手机状态栏高度
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
let test = options.data && JSON.parse(decodeURIComponent(options.data));
this.detailData = test;
+
this.directViewUrl = this.detailData.directViewUrl;
+ if(this.detailData.attachments && this.detailData.attachments.length >0){
+ this.urls = this.detailData.attachments.map(item => {
+ return {
+ url: VUE_APP_BASE_URL + item.attachement,
+ name: item.attachementName
+ }
+ })
+ }else if(this.detailData.attachment && this.detailData.attachment.length >0){
+ this.urls = this.detailData.attachment.map(item => {
+ return {
+ url: VUE_APP_BASE_URL + item.attachment,
+ name: item.attachmentName
+ }
+ })
+ }
+ console.log("urls",this.urls)
+
+
+
// this.directViewUrl = 'https://huaban.com/'
this.unitType = uni.getStorageSync('unittype');
if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ) {
@@ -279,11 +319,12 @@
openFile(item) {
let fileUrl = '';
console.log("iiii",item)
- if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ){
- fileUrl = VUE_APP_BASE_URL + item.attachment;
- }else {
- fileUrl = VUE_APP_BASE_URL + item.attachement;
- }
+ // if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ){
+ // fileUrl = VUE_APP_BASE_URL + item.attachment;
+ // }else {
+ // fileUrl = VUE_APP_BASE_URL + item.attachement;
+ // }
+ fileUrl = item.url
console.log("urlllllllll",fileUrl)
uni.downloadFile({
url: fileUrl,
diff --git a/pages/tabBar/notice/measures.vue b/pages/tabBar/notice/measures.vue
index 7aee752..b12f0ba 100644
--- a/pages/tabBar/notice/measures.vue
+++ b/pages/tabBar/notice/measures.vue
@@ -52,7 +52,7 @@
</view>
</view>
<view class="measures">
- <u-button class="measureBtn" type="primary" @click="submit">提交</u-button>
+ <u-button class="measureBtn" type="primary" @click="$noMoreClicks(submit)">提交</u-button>
</view>
</view>
</template>
@@ -79,7 +79,8 @@
measureIds : [],
baseUrl: VUE_APP_BASE_URL,
list: [],
- showBtn: false
+ showBtn: false,
+ noClick:true,
}
},
onLoad(options) {
diff --git a/pages/tabBar/response/response.vue b/pages/tabBar/response/response.vue
index 64cee7d..0d1fe8b 100644
--- a/pages/tabBar/response/response.vue
+++ b/pages/tabBar/response/response.vue
@@ -82,6 +82,8 @@
},
getResponseList() {
this.loading = true
+
+
getResponse(this.data).then(res => {
if (res.code === 100) {
let list = res.data ? res.data : [];
--
Gitblit v1.9.2