diff --git a/common/globalJs/request.js b/common/globalJs/request.js index f631c22..0bf9859 100644 --- a/common/globalJs/request.js +++ b/common/globalJs/request.js @@ -6,454 +6,459 @@ const tokenKey = "token"; const tokenKeyValue = ""; class Request { - constructor(config = {}) { - this.config = {}; - this.config.baseUrl = config.baseUrl ? config.baseUrl : ""; - this.config.dataType = config.dataType ? config.dataType : "json"; - this.config.responseType = config.responseType - ? config.responseType - : "text"; - this.config.header = config.header ? config.header : {}; - this.reqInterceptors = null; - this.resInterceptors = null; - this.interceptors = { - request: (fn) => { - this.reqInterceptors = fn; - }, - response: (fn) => { - this.resInterceptors = fn; - }, - }; - } - setConfig(config = {}) { - this.config = this._deepCopy(this._merge(this.config, config)); - } - // 请求封装 - globalRequest(url, config, method, isForm = "") { - const _this = this; - let newConfig = this._deepCopy(this._merge(this.config, config)); - let lastConfig = {}; - if (this.reqInterceptors && typeof this.reqInterceptors === "function") { - let reqInterceptors = this.reqInterceptors(newConfig); - if (!reqInterceptors && process.env.NODE_ENV === "development") { - console.log("请求被拦截,此消息仅在开发环境显示。"); - return false; - } else if ( - Object.prototype.toString.call(reqInterceptors) === "[object Promise]" - ) { - return reqInterceptors; - } - lastConfig = this._deepCopy(reqInterceptors); - } else { - lastConfig = this._deepCopy(newConfig); - } - let header = {}; - let tokenData = $.getData("token"); - if (tokenData) { - header[tokenKey] = tokenKeyValue + tokenData; - } - if (isForm) { - header["content-type"] = "application/x-www-form-urlencoded"; - } - let fullUrl = this._formatUrl(lastConfig.baseUrl, url); - if (url.indexOf("http") != -1) { - fullUrl = url; - } - return new Promise((resolve, reject) => { - uni.request({ - url: fullUrl, - method: method, - data: config, - header: header, - async complete(response) { - let res = response; - if (response.statusCode == 404) { - $.toast("请求地址不存在"); - } else if (response.statusCode == 500) { - $.toast("服务器内部错误"); - } else { - console.log("response", response.statusCode); - let res = response; - if ( - _this.resInterceptors && - typeof _this.resInterceptors === "function" - ) { - let resInterceptors = _this.resInterceptors(res); - // console.log('resInterceptors-----------------',resInterceptors) - if ( - resInterceptors.statusCode == 401 || - resInterceptors.data.code == 403 - ) { - $.toast("登录信息已过期,请重新登录"); - $.removeData("token"); - setTimeout(() => { - $.openNew("/pages/logIn/logIn"); - }, 1500); - return; - } else if (resInterceptors.statusCode != 200) { - $.toast(resInterceptors.data.message); - } - if (!resInterceptors && resInterceptors != "") { - reject("返回值已被您拦截!"); - return; - } else if ( - Object.prototype.toString.call(resInterceptors) === - "[object Promise]" - ) { - try { - let promiseRes = await resInterceptors; - resolve(promiseRes); - } catch (error) { - reject(error); - } - } else { - res = resInterceptors; - } - } - } - resolve(res.data); - }, - }); - }); - } + constructor(config = {}) { + this.config = {}; + this.config.baseUrl = config.baseUrl ? config.baseUrl : ""; + this.config.dataType = config.dataType ? config.dataType : "json"; + this.config.responseType = config.responseType ? + config.responseType : + "text"; + this.config.header = config.header ? config.header : {}; + this.reqInterceptors = null; + this.resInterceptors = null; + this.interceptors = { + request: (fn) => { + this.reqInterceptors = fn; + }, + response: (fn) => { + this.resInterceptors = fn; + }, + }; + } + setConfig(config = {}) { + this.config = this._deepCopy(this._merge(this.config, config)); + } + // 请求封装 + globalRequest(url, config, method, isForm = "") { + const _this = this; + let newConfig = this._deepCopy(this._merge(this.config, config)); + let lastConfig = {}; + if (this.reqInterceptors && typeof this.reqInterceptors === "function") { + let reqInterceptors = this.reqInterceptors(newConfig); + if (!reqInterceptors && process.env.NODE_ENV === "development") { + console.log("请求被拦截,此消息仅在开发环境显示。"); + return false; + } else if ( + Object.prototype.toString.call(reqInterceptors) === "[object Promise]" + ) { + return reqInterceptors; + } + lastConfig = this._deepCopy(reqInterceptors); + } else { + lastConfig = this._deepCopy(newConfig); + } + let header = {}; + let tokenData = $.getData("token"); + if (tokenData) { + header[tokenKey] = tokenKeyValue + tokenData; + } + if (isForm) { + header["content-type"] = "application/x-www-form-urlencoded"; + } + let fullUrl = this._formatUrl(lastConfig.baseUrl, url); + if (url.indexOf("http") != -1) { + fullUrl = url; + } + return new Promise((resolve, reject) => { + uni.request({ + url: fullUrl, + method: method, + data: config, + header: header, + async complete(response) { + let res = response; + if ((response.errMsg == 'request:ok')) { - addFile(file, success, progress) { - const _this = this; - let newConfig = this._deepCopy(this._merge(this.config, {})); - let lastConfig = {}; - if (this.reqInterceptors && typeof this.reqInterceptors === "function") { - let reqInterceptors = this.reqInterceptors(newConfig); - if (!reqInterceptors && process.env.NODE_ENV === "development") { - console.log("请求被拦截,此消息仅在开发环境显示。"); - return false; - } else if ( - Object.prototype.toString.call(reqInterceptors) === "[object Promise]" - ) { - return reqInterceptors; - } - lastConfig = this._deepCopy(reqInterceptors); - } else { - lastConfig = this._deepCopy(newConfig); - } - let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); - let header = { - // 'content-Type':'multipart/form-data' - }; - return new Promise((resolve, reject) => { - const UploadTask = uni.uploadFile({ - url: fullUrl, - filePath: file[0].path, - header: header, - name: $.fileImgKey, - formData: {}, - async complete(response) { - let res = response; - if ( - _this.resInterceptors && - typeof _this.resInterceptors === "function" - ) { - let resInterceptors = _this.resInterceptors(res); - if (!resInterceptors && resInterceptors != "") { - reject("返回值已被您拦截!"); - return; - } else if ( - Object.prototype.toString.call(resInterceptors) === - "[object Promise]" - ) { - try { - let promiseRes = await resInterceptors; - resolve(promiseRes); - } catch (error) { - reject(error); - } - } else { - res = resInterceptors; - } - } - success(JSON.parse(res.data)); - }, - }); - // 监听上传进度 - if (progress) { - UploadTask.onProgressUpdate((res) => { - progress(res.progress); - }); - } - }); - } + if (response.statusCode == 404) { + $.toast("请求地址不存在"); + } else if (response.statusCode == 500) { + $.toast("服务器内部错误"); + } else { + // console.log("response", response.statusCode); + let res = response; + if ( + _this.resInterceptors && + typeof _this.resInterceptors === "function" + ) { + let resInterceptors = _this.resInterceptors(res); + // console.log('resInterceptors-----------------',resInterceptors) + if ( + resInterceptors.statusCode == 401 || + resInterceptors.data.code == 403 + ) { + $.toast("登录信息已过期,请重新登录"); + $.removeData("token"); + setTimeout(() => { + $.openNew("/pages/logIn/logIn"); + }, 1500); + return; + } else if (resInterceptors.statusCode != 200) { + $.toast(resInterceptors.data.message); + } + if (!resInterceptors && resInterceptors != "") { + reject("返回值已被您拦截!"); + return; + } else if ( + Object.prototype.toString.call(resInterceptors) === + "[object Promise]" + ) { + try { + let promiseRes = await resInterceptors; + resolve(promiseRes); + } catch (error) { + reject(error); + } + } else { + res = resInterceptors; + } + } + } + resolve(res.data); + }else{ + reject() + } - // 上传图片 - addImg(length = 1, success, progress, type = 1) { - // 获取本地图片的路径 - uni.chooseImage({ - count: length, - // original原图compressed压缩图 - sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有 - // camera相机album相册 - sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有 - success: (res) => { - // 显示上传动画 - $.showLoading("图片上传中..."); - var imgs; - imgs = res.tempFilePaths; - // #ifdef H5 - // 调用上传图片的函数 - // 处理多选 - // if (imgs.length > length) { - // imgs = imgs.slice(0, length); - // } - this.fileImg(imgs, 0, success, progress, type); - // #endif - // #ifdef APP - console.log("imgs", imgs); - // 将新添加的图片添加到imgs_arr中 - uni.compressImage({ - src: imgs[0], - quality: 60, // 仅对jpg有效 - success: (ress) => { - this.fileImg([ress.tempFilePath], 0, success, progress, type); - }, - fail: (err) => { - $.hideLoading("图片上传中..."); - }, - complete: (msg) => {}, - }); - // #endif - }, - complete: (err) => {}, - }); - } - fileImg(imgs, index, success, progress, type) { - const _this = this; - let newConfig = this._deepCopy(this._merge(this.config, {})); - let lastConfig = {}; - if (this.reqInterceptors && typeof this.reqInterceptors === "function") { - let reqInterceptors = this.reqInterceptors(newConfig); - if (!reqInterceptors && process.env.NODE_ENV === "development") { - console.log("请求被拦截,此消息仅在开发环境显示。"); - return false; - } else if ( - Object.prototype.toString.call(reqInterceptors) === "[object Promise]" - ) { - return reqInterceptors; - } - lastConfig = this._deepCopy(reqInterceptors); - } else { - lastConfig = this._deepCopy(newConfig); - } - let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); - if (type == 2) { - fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUserIdUrl); - } - let header = { - token: $.getData("token"), - }; - // 如果数组长度大于下标,说明没有上传完 - if (imgs.length > index) { - var src = imgs[index]; - return new Promise((resolve, reject) => { - const UploadTask = uni.uploadFile({ - url: fullUrl, - filePath: src, - header: header, - name: $.fileImgKey, - formData: {}, - async complete(response) { - let res = response; - if ( - _this.resInterceptors && - typeof _this.resInterceptors === "function" - ) { - let resInterceptors = _this.resInterceptors(res); - // console.log('resInterceptors',resInterceptors) - let datasJSON = JSON.parse(resInterceptors.data); - if (datasJSON.code == 1101) { - } - if (!resInterceptors && resInterceptors != "") { - reject("返回值已被您拦截!"); - return; - } else if ( - Object.prototype.toString.call(resInterceptors) === - "[object Promise]" - ) { - try { - let promiseRes = await resInterceptors; - resolve(promiseRes); - } catch (error) { - reject(error); - } - } else { - res = resInterceptors; - } - } - success(JSON.parse(res.data)); - _this.fileImg(imgs, index + 1, progress); - }, - }); - // 监听上传进度 - if (progress) { - UploadTask.onProgressUpdate((res) => { - progress(res.progress); - }); - } - }); - // #ifdef H5 - // 压缩 - // lrz(src, { - // quality: 0.7, - // }).then((rst) => { // fieldName 为 formData 中多媒体的字段名 + }, + }); + }); + } - // }) - // #endif - // #ifdef APP-PLUS - // #endif - } else { - $.hideLoading(); - } - } + addFile(file, success, progress) { + const _this = this; + let newConfig = this._deepCopy(this._merge(this.config, {})); + let lastConfig = {}; + if (this.reqInterceptors && typeof this.reqInterceptors === "function") { + let reqInterceptors = this.reqInterceptors(newConfig); + if (!reqInterceptors && process.env.NODE_ENV === "development") { + console.log("请求被拦截,此消息仅在开发环境显示。"); + return false; + } else if ( + Object.prototype.toString.call(reqInterceptors) === "[object Promise]" + ) { + return reqInterceptors; + } + lastConfig = this._deepCopy(reqInterceptors); + } else { + lastConfig = this._deepCopy(newConfig); + } + let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); + let header = { + // 'content-Type':'multipart/form-data' + }; + return new Promise((resolve, reject) => { + const UploadTask = uni.uploadFile({ + url: fullUrl, + filePath: file[0].path, + header: header, + name: $.fileImgKey, + formData: {}, + async complete(response) { + let res = response; + if ( + _this.resInterceptors && + typeof _this.resInterceptors === "function" + ) { + let resInterceptors = _this.resInterceptors(res); + if (!resInterceptors && resInterceptors != "") { + reject("返回值已被您拦截!"); + return; + } else if ( + Object.prototype.toString.call(resInterceptors) === + "[object Promise]" + ) { + try { + let promiseRes = await resInterceptors; + resolve(promiseRes); + } catch (error) { + reject(error); + } + } else { + res = resInterceptors; + } + } + success(JSON.parse(res.data)); + }, + }); + // 监听上传进度 + if (progress) { + UploadTask.onProgressUpdate((res) => { + progress(res.progress); + }); + } + }); + } - // 上传视频 - addVideo(url, success, progress) { - // 获取本地视频的路径 - uni.chooseVideo({ - sourceType: ["album", "camera"], // 选择方式 - success: (res) => { - if (res.size > $.videoSize) { - let size = parseInt($.videoSize / 1024000); - $.toast("上传视频过大,大小请不要超过" + size + "M"); - } else { - // 显示上传动画 - $.showLoading("视频上传中..."); - // 调用上传视频的函数 - this.fileVideo(res.tempFilePath, url, success, progress); - } - }, - fail: (res) => { - console.log(JSON.stringify(res)); - }, - }); - } - fileVideo(src, url, success, progress) { - const _this = this; - let newConfig = this._deepCopy(this._merge(this.config, {})); - let lastConfig = {}; - if (this.reqInterceptors && typeof this.reqInterceptors === "function") { - let reqInterceptors = this.reqInterceptors(newConfig); - if (!reqInterceptors && process.env.NODE_ENV === "development") { - console.log("请求被拦截,此消息仅在开发环境显示。"); - return false; - } else if ( - Object.prototype.toString.call(reqInterceptors) === "[object Promise]" - ) { - return reqInterceptors; - } - lastConfig = this._deepCopy(reqInterceptors); - } else { - lastConfig = this._deepCopy(newConfig); - } - let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); - //上传视频 - return new Promise((resolve, reject) => { - const UploadTask = uni.uploadFile({ - url: fullUrl, - filePath: src, - name: $.fileVideoKey, - async complete(response) { - let res = response; - if ( - _this.resInterceptors && - typeof _this.resInterceptors === "function" - ) { - let resInterceptors = _this.resInterceptors(res); - // console.log('resInterceptors',resInterceptors) - if (!resInterceptors && resInterceptors != "") { - reject("返回值已被您拦截!"); - return; - } else if ( - Object.prototype.toString.call(resInterceptors) === - "[object Promise]" - ) { - try { - let promiseRes = await resInterceptors; - resolve(promiseRes); - } catch (error) { - reject(error); - } - } else { - res = resInterceptors; - } - } - success(JSON.parse(res.data)); - $.hideLoading(); - }, - success: (res) => { - success(JSON.parse(res.data)); - // 关闭上传动画 - }, - fail: (e) => { - // 关闭上传动画 - $.hideLoading(); - $.toast("上传超时!"); - }, - }); - // 监听上传进度 - if (progress) { - UploadTask.onProgressUpdate((res) => { - progress(res.progress); - }); - } - }); - } + // 上传图片 + addImg(length = 1, success, progress, type = 1) { + // 获取本地图片的路径 + uni.chooseImage({ + count: length, + // original原图compressed压缩图 + sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有 + // camera相机album相册 + sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有 + success: (res) => { + // 显示上传动画 + $.showLoading("图片上传中..."); + var imgs; + imgs = res.tempFilePaths; + // #ifdef H5 + // 调用上传图片的函数 + // 处理多选 + // if (imgs.length > length) { + // imgs = imgs.slice(0, length); + // } + this.fileImg(imgs, 0, success, progress, type); + // #endif + // #ifdef APP + console.log("imgs", imgs); + // 将新添加的图片添加到imgs_arr中 + uni.compressImage({ + src: imgs[0], + quality: 60, // 仅对jpg有效 + success: (ress) => { + this.fileImg([ress.tempFilePath], 0, success, progress, type); + }, + fail: (err) => { + $.hideLoading("图片上传中..."); + }, + complete: (msg) => {}, + }); + // #endif + }, + complete: (err) => {}, + }); + } + fileImg(imgs, index, success, progress, type) { + const _this = this; + let newConfig = this._deepCopy(this._merge(this.config, {})); + let lastConfig = {}; + if (this.reqInterceptors && typeof this.reqInterceptors === "function") { + let reqInterceptors = this.reqInterceptors(newConfig); + if (!reqInterceptors && process.env.NODE_ENV === "development") { + console.log("请求被拦截,此消息仅在开发环境显示。"); + return false; + } else if ( + Object.prototype.toString.call(reqInterceptors) === "[object Promise]" + ) { + return reqInterceptors; + } + lastConfig = this._deepCopy(reqInterceptors); + } else { + lastConfig = this._deepCopy(newConfig); + } + let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); + if (type == 2) { + fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUserIdUrl); + } + let header = { + token: $.getData("token"), + }; + // 如果数组长度大于下标,说明没有上传完 + if (imgs.length > index) { + var src = imgs[index]; + return new Promise((resolve, reject) => { + const UploadTask = uni.uploadFile({ + url: fullUrl, + filePath: src, + header: header, + name: $.fileImgKey, + formData: {}, + async complete(response) { + let res = response; + if ( + _this.resInterceptors && + typeof _this.resInterceptors === "function" + ) { + let resInterceptors = _this.resInterceptors(res); + // console.log('resInterceptors',resInterceptors) + let datasJSON = JSON.parse(resInterceptors.data); + if (datasJSON.code == 1101) {} + if (!resInterceptors && resInterceptors != "") { + reject("返回值已被您拦截!"); + return; + } else if ( + Object.prototype.toString.call(resInterceptors) === + "[object Promise]" + ) { + try { + let promiseRes = await resInterceptors; + resolve(promiseRes); + } catch (error) { + reject(error); + } + } else { + res = resInterceptors; + } + } + success(JSON.parse(res.data)); + _this.fileImg(imgs, index + 1, progress); + }, + }); + // 监听上传进度 + if (progress) { + UploadTask.onProgressUpdate((res) => { + progress(res.progress); + }); + } + }); + // #ifdef H5 + // 压缩 + // lrz(src, { + // quality: 0.7, + // }).then((rst) => { // fieldName 为 formData 中多媒体的字段名 - _formatUrl(baseUrl, url) { - if (!baseUrl) return url; - let formatUrl = ""; - const baseUrlEndsWithSlash = baseUrl.endsWith("/"); - const urlStartsWithSlash = url.startsWith("/"); - if (baseUrlEndsWithSlash && urlStartsWithSlash) { - formatUrl = baseUrl + url.substring(1); - } else if (baseUrlEndsWithSlash || urlStartsWithSlash) { - formatUrl = baseUrl + url; - } else { - formatUrl = baseUrl + "/" + url; - } - return formatUrl; - } - _merge(oldConfig, newConfig) { - let mergeConfig = this._deepCopy(oldConfig); - if (!newConfig || !Object.keys(newConfig).length) return mergeConfig; - for (let key in newConfig) { - if (key !== "header") { - mergeConfig[key] = newConfig[key]; - } else { - if ( - Object.prototype.toString.call(newConfig[key]) === "[object Object]" - ) { - for (let headerKey in newConfig[key]) { - mergeConfig[key][headerKey] = newConfig[key][headerKey]; - } - } - } - } - return mergeConfig; - } - _deepCopy(obj) { - let result = Array.isArray(obj) ? [] : {}; - for (let key in obj) { - if (obj.hasOwnProperty(key)) { - if (typeof obj[key] === "object") { - result[key] = this._deepCopy(obj[key]); - } else { - result[key] = obj[key]; - } - } - } - return result; - } + // }) + // #endif + // #ifdef APP-PLUS + // #endif + } else { + $.hideLoading(); + } + } + + // 上传视频 + addVideo(url, success, progress) { + // 获取本地视频的路径 + uni.chooseVideo({ + sourceType: ["album", "camera"], // 选择方式 + success: (res) => { + if (res.size > $.videoSize) { + let size = parseInt($.videoSize / 1024000); + $.toast("上传视频过大,大小请不要超过" + size + "M"); + } else { + // 显示上传动画 + $.showLoading("视频上传中..."); + // 调用上传视频的函数 + this.fileVideo(res.tempFilePath, url, success, progress); + } + }, + fail: (res) => { + console.log(JSON.stringify(res)); + }, + }); + } + fileVideo(src, url, success, progress) { + const _this = this; + let newConfig = this._deepCopy(this._merge(this.config, {})); + let lastConfig = {}; + if (this.reqInterceptors && typeof this.reqInterceptors === "function") { + let reqInterceptors = this.reqInterceptors(newConfig); + if (!reqInterceptors && process.env.NODE_ENV === "development") { + console.log("请求被拦截,此消息仅在开发环境显示。"); + return false; + } else if ( + Object.prototype.toString.call(reqInterceptors) === "[object Promise]" + ) { + return reqInterceptors; + } + lastConfig = this._deepCopy(reqInterceptors); + } else { + lastConfig = this._deepCopy(newConfig); + } + let fullUrl = this._formatUrl(lastConfig.baseUrl, $.imgUrl); + //上传视频 + return new Promise((resolve, reject) => { + const UploadTask = uni.uploadFile({ + url: fullUrl, + filePath: src, + name: $.fileVideoKey, + async complete(response) { + let res = response; + if ( + _this.resInterceptors && + typeof _this.resInterceptors === "function" + ) { + let resInterceptors = _this.resInterceptors(res); + // console.log('resInterceptors',resInterceptors) + if (!resInterceptors && resInterceptors != "") { + reject("返回值已被您拦截!"); + return; + } else if ( + Object.prototype.toString.call(resInterceptors) === + "[object Promise]" + ) { + try { + let promiseRes = await resInterceptors; + resolve(promiseRes); + } catch (error) { + reject(error); + } + } else { + res = resInterceptors; + } + } + success(JSON.parse(res.data)); + $.hideLoading(); + }, + success: (res) => { + success(JSON.parse(res.data)); + // 关闭上传动画 + }, + fail: (e) => { + // 关闭上传动画 + $.hideLoading(); + $.toast("上传超时!"); + }, + }); + // 监听上传进度 + if (progress) { + UploadTask.onProgressUpdate((res) => { + progress(res.progress); + }); + } + }); + } + + _formatUrl(baseUrl, url) { + if (!baseUrl) return url; + let formatUrl = ""; + const baseUrlEndsWithSlash = baseUrl.endsWith("/"); + const urlStartsWithSlash = url.startsWith("/"); + if (baseUrlEndsWithSlash && urlStartsWithSlash) { + formatUrl = baseUrl + url.substring(1); + } else if (baseUrlEndsWithSlash || urlStartsWithSlash) { + formatUrl = baseUrl + url; + } else { + formatUrl = baseUrl + "/" + url; + } + return formatUrl; + } + _merge(oldConfig, newConfig) { + let mergeConfig = this._deepCopy(oldConfig); + if (!newConfig || !Object.keys(newConfig).length) return mergeConfig; + for (let key in newConfig) { + if (key !== "header") { + mergeConfig[key] = newConfig[key]; + } else { + if ( + Object.prototype.toString.call(newConfig[key]) === "[object Object]" + ) { + for (let headerKey in newConfig[key]) { + mergeConfig[key][headerKey] = newConfig[key][headerKey]; + } + } + } + } + return mergeConfig; + } + _deepCopy(obj) { + let result = Array.isArray(obj) ? [] : {}; + for (let key in obj) { + if (obj.hasOwnProperty(key)) { + if (typeof obj[key] === "object") { + result[key] = this._deepCopy(obj[key]); + } else { + result[key] = obj[key]; + } + } + } + return result; + } } if (!global.$request) { - global.$request = new Request(); + global.$request = new Request(); } -export default global.$request; +export default global.$request; \ No newline at end of file diff --git a/components/mp-html/parser.js b/components/mp-html/parser.js index e2e7a87..1d9391d 100644 --- a/components/mp-html/parser.js +++ b/components/mp-html/parser.js @@ -979,7 +979,8 @@ Parser.prototype.popNode = function () { const table = Object.assign({}, node) node.name = 'div' node.attrs = { - style: 'overflow:auto' + style: 'overflow:auto', + class: 'scrollbar-container' } node.children = [table] attrs = table.attrs diff --git a/components/no-data.vue b/components/no-data.vue index b3cc468..a50668b 100644 --- a/components/no-data.vue +++ b/components/no-data.vue @@ -51,8 +51,8 @@ export default { \ No newline at end of file diff --git a/manifest.json b/manifest.json index 310fc1c..1936b6f 100644 --- a/manifest.json +++ b/manifest.json @@ -135,8 +135,8 @@ "https" : false, "proxy" : { "/HiatmpPro" : { - // "target" : "http://49.235.207.167:8800", - "target" : "http://219.147.31.25:30001/tht-app-api", + "target" : "http://49.235.207.167:8800", + // "target" : "http://219.147.31.25:30001/tht-app-api", "changeOrigin" : true, "secure" : false, "pathRewrite" : { diff --git a/pages/index/detail.vue b/pages/index/detail.vue index 6d7d24c..822911a 100644 --- a/pages/index/detail.vue +++ b/pages/index/detail.vue @@ -601,7 +601,7 @@ console.log({ uni.chooseImage({ count: 6, //默认9 sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有 - sourceType: ["album"], //从相册选择 + sourceType: ["album",'camera'], //从相册选择 success: async (res) => { console.log(res); if (res.tempFilePaths && res.tempFilePaths.length) { diff --git a/pages/index/index.vue b/pages/index/index.vue index f25cfd3..4b59f3f 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -60,11 +60,11 @@ - + {{ item.name }} - 排查 + {{ item.enumname || '--' }} {{ item.deadlineStatus || '--' }} @@ -410,7 +410,7 @@ } .Unit { - padding: 12rpx; + padding: 24rpx 12rpx; display: flex; justify-content: space-between; align-items: center; diff --git a/pages/investigation/complete.vue b/pages/investigation/complete.vue index 01c4a99..654a858 100644 --- a/pages/investigation/complete.vue +++ b/pages/investigation/complete.vue @@ -2,7 +2,7 @@ - + @@ -310,6 +310,11 @@ // this.getList() }, + skipPage(){ + this.$.setData('pageStatus', 3) + this.$.setData('pageType', '3') + this.$.openTab('/pages/investigation/index') + }, initTroubleshootingData(id, index) { this.troubleshootingData[index].extraConfigs = [] this.$request diff --git a/pages/investigation/index.vue b/pages/investigation/index.vue index 3fc9733..689a844 100644 --- a/pages/investigation/index.vue +++ b/pages/investigation/index.vue @@ -26,23 +26,23 @@ 正在办理 {{ totalData.InGovernance }} --> - + 已完成 {{ totalData.InGovernance }} - + 全部 - + 人工上报 - + - + 系统下发 - + @@ -53,12 +53,13 @@ - + {{ item.name }} - 排查 - 治理 + + {{ item.enumname || '--' }} {{ item.deadlineStatus || '--' }} @@ -107,7 +108,7 @@ Finished: 0, Unconfirmed: 0, }, - status: '10', + status: '1', search: '', tabbarShow: true, queryType: '1', @@ -124,8 +125,10 @@ // tabFun.tabbar() this.getData() let pageStatus = this.$.getData('pageStatus') - this.pageStatus = pageStatus this.queryType = this.$.getData('pageType') + this.pageStatus = pageStatus + console.log(this.$.getData('pageType')) + if (pageStatus == 1) { this.handleTabClick(1) this.$.setData('pageStatus', '0') @@ -149,20 +152,33 @@ }, // 方法 methods: { - handleTabClick(tab) { + queryTypeChange(e) { + this.queryType = e + this.page = 1; + this.$.setData('pageType', e) + this.list = []; + this.isMore = true + this.getList() + }, + handleTabClick(tab, falg = false) { this.tab = tab; this.page = 1; this.list = []; this.isMore = true switch (tab) { case 1: - this.status = '10'; + this.status = '1'; + this.queryType = null break; // case 2: // this.status = '20'; // break; case 3: - this.status = '20'; + if (falg) { + this.queryType = '1' + } + + this.status = '2'; break; } this.getList() @@ -190,12 +206,13 @@ getList() { let datas = { nuserid: this.$.getData('token'), - status: this.status, + status: '10', } this.loadmorestatus = 'loading' + let query=this.status==2?`pageNum=${this.page}&pageSize=${10}&search=${this.search}&approve=${this.status}&classification=${this.queryType}`:`pageNum=${this.page}&pageSize=${10}&search=${this.search}&approve=${this.status}` this.$request.globalRequest( - `/hiddenDanger/highDanger/getHigDangerDealt?pageNum=${this.page}&pageSize=${10}&search=${this.search}`, + `/hiddenDanger/highDanger/getHigDangerDealt?${query}`, datas, 'POST') .then(res => { this.loadmorestatus = 'loadmore' @@ -214,6 +231,12 @@ } else { this.$.toast(res.message) } + if (this.status == 1) { + this.$set(this.totalData, 'UnderInvestigation', res.result.total) + } + if (this.status == 2) { + this.$set(this.totalData, 'InGovernance', res.result.total) + } }).catch((err) => { this.loadmorestatus = 'nomore' uni.stopPullDownRefresh(); @@ -234,7 +257,7 @@ '&deptId=' + row.handleDept + '&pcType=' + row.pcType + '&type=' + (this.tab == 1 ? 'edit' : 'view') + '§ionName=' + row.sectionName + - '§ionCode=' + row.sectionCode) + '§ionCode=' + row.sectionCode + '&taskName=' + row.name) // this.$.open('/pages/map/index?businessId=' + row.businessId) } @@ -394,7 +417,8 @@ width: calc(100% - 100rpx); padding: 0 50rpx; height: 108rpx; - .type-item{ + + .type-item { width: 28%; border-radius: 200rpx; height: 50rpx; @@ -404,9 +428,10 @@ border: #999999 solid 1rpx; margin-top: 15rpx; } - .type-active{ + + .type-active { border: #3c6dc3 solid 1rpx; - color:#3c6dc3; + color: #3c6dc3; } } } @@ -420,7 +445,7 @@ } .Unit { - padding: 12rpx; + padding: 20rpx 12rpx; display: flex; justify-content: space-between; align-items: center; @@ -448,7 +473,7 @@ .title { font-size: 16px; width: 380rpx; - min-height: 80rpx; + min-height: 60rpx; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; diff --git a/pages/investigation/task.vue b/pages/investigation/task.vue index 6c05016..c54eece 100644 --- a/pages/investigation/task.vue +++ b/pages/investigation/task.vue @@ -270,7 +270,7 @@ {{ indexData + 1 }}. {{ itemData.length > 0 ? itemData[0].nname : '' }} - @@ -324,7 +324,7 @@ - @@ -500,7 +500,6 @@ this.sectionCode = e.sectionCode this.name = e.taskName this.sectionName = e.sectionName - console.log(e) this.type = e.type; this.getBaseData(e.id); diff --git a/pages/knowledge/index.vue b/pages/knowledge/index.vue index fd75c6a..77fd48d 100644 --- a/pages/knowledge/index.vue +++ b/pages/knowledge/index.vue @@ -1,6 +1,6 @@ @@ -120,7 +118,13 @@ }, ], timer: null, - iconsType: '' + isHandleScroll: true, + startX: 0, // 触摸开始时的X坐标 + startY: 0, // 触摸开始时的Y坐标 + isScrolling: false, // 是否正在滑动 + isToBottom: false, + lastScrollTop: 0, // 记录上一次滚动位置 + temp: 0, }; }, onLoad() { @@ -148,35 +152,68 @@ } }, methods: { - clickIcon(type) { - if(this.iconsType == '') { - this.iconsType = type - } else { - if(this.iconsType == 'handUp') { - if(type == 'handUp') { - this.iconsType = '' - } else { - this.iconsType = 'handDown' - } - } else { - if(type == 'handUp') { - this.iconsType = 'handUp' - } else { - this.iconsType = '' - } + handleTouchStart(e) { + // 获取触摸开始时的坐标 + this.startX = e.touches[0].clientX; + this.startY = e.touches[0].clientY; + // this.isScrolling = false; // 重置滑动状态 + }, + handleTouchMove(e) { + // 获取触摸移动时的坐标 + let moveX = e.touches[0].clientX; + let moveY = e.touches[0].clientY; + + // 计算坐标变化量 + let deltaX = moveX - this.startX; + let deltaY = moveY - this.startY; + + // 判断是否发生了足够的滑动(这里以5px为例) + if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) { + // this.isScrolling = true; // 标记为正在滑动 + this.isHandleScroll = false + // 根据deltaY的正负判断滑动方向 + if (deltaY > 0) { + console.log('用户正在向下滑动'); + } else if (deltaY < 0) { + + console.log('用户正在向上滑动'); } + + // 如果需要,可以在这里更新startX和startY为moveX和moveY,以继续追踪滑动 + // 但在这个简单的示例中,我们不需要这样做 } - const params = { - qaId: '', - feedbackStatus : this.iconsType == '' ? 0 : (this.iconsType == 'handUp' ? 1 : 2), - feedbackInfo: '' + + // 注意:这里不更新startX和startY,因为我们只关心触摸开始到当前位置的相对变化 + }, + handleTouchEnd(e) { + // 触摸结束时的处理 + // 例如,可以重置startX和startY,或者执行其他清理工作 + // 但在这个示例中,我们不做额外处理 + }, + handleScroll(event) { + // event.detail 包含了滚动事件的详细信息 + const scrollTop = event.detail.scrollTop; + if (scrollTop > this.lastScrollTop) { + console.log('向下滑动'); + } else { + this.temp++ + if (this.temp == 2) { + this.isHandleScroll = false + } + + console.log('向上滑动'); } - // this.$request.globalRequest('/hitapChat/hitap/feadBack', params, 'POST').then(res => {}) + this.lastScrollTop = scrollTop; + }, + toBottom() { + this.isToBottom = false + this.scrollTop = Number(this.scrollTop) + 100; + this.isHandleScroll = true + }, async queryChat(voiceText) { // console.log(voiceText,"voiceText"); clearInterval(this.timer) - this.answerIsOver = false this.loading = true; const [err, res] = await uni.request({ // url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat', @@ -246,6 +283,8 @@ duration: 2000, }); } + this.temp = 0 + this.isHandleScroll = true this.changeMsgList("0", this.inputValue || text); this.queryChat(this.inputValue || text); this.inputValue = ""; @@ -271,7 +310,6 @@ id, answerId, data: newdata, - isSuccess: true }, ]; } else { @@ -285,11 +323,13 @@ // this.$refs.scrollView.$refs.content // ? this.$refs.scrollView.$refs.content.scrollHeight // : 0; - this.scrollTop = this.scrollTop + 100; + if (this.isHandleScroll) { + this.scrollTop = Number(this.scrollTop) + 100; + } + }); if (newdata == data) { clearInterval(this.timer); - this.msgList[this.msgList.length - 1].isOver = true } }, 50); } else { @@ -308,13 +348,17 @@ // this.$refs.scrollView.$refs.content // ? this.$refs.scrollView.$refs.content.scrollHeight // : 0; - this.scrollTop = this.scrollTop + 100; + if (this.isHandleScroll) { + this.scrollTop = Number(this.scrollTop) + 100; + } }); } - + }, handlePlus() { - this.isExpanded = !this.isExpanded; + this.$.toast("此功能暂不开放"); + + // this.isExpanded = !this.isExpanded; }, clickContent() { if (this.isExpanded) { @@ -733,7 +777,7 @@ } .text { - font-size: 28rpx; + font-size: 32rpx; } } @@ -975,12 +1019,24 @@ transform: scale(1); } } - .icon{ + + .downward { + position: fixed; + z-index: 100rpx; + right: 20rpx; + bottom: 150rpx; + background: #ffffff; + border: #cccccc solid 1px; + width: 60rpx; + height: 60rpx; + border-radius: 50%; display: flex; - justify-content: flex-end; - margin: 0 15rpx 15rpx 12rpx; - .uni-icons{ - margin-left: 15rpx; + justify-content: center; + align-items: center; + + /deep/ .u-icon__icon { + font-size: 30rpx !important; + color: #999999 !important; } } diff --git a/pages/logIn/logIn.vue b/pages/logIn/logIn.vue index 9d6dd5d..6d6811c 100644 --- a/pages/logIn/logIn.vue +++ b/pages/logIn/logIn.vue @@ -1,17 +1,18 @@ + .Content { + width: calc(100% - 176rpx); + padding: 132rpx 0rpx 180rpx 0rpx; + + .Logo { + width: 150rpx; + height: 150rpx; + } + + .NavBox { + .Unit { + margin-right: 110rpx; + + .Line { + left: 50%; + transform: translateX(-50%); + bottom: -26rpx; + width: 74rpx; + height: 10rpx; + border-radius: 6rpx; + } + } + } + + .TypeBox { + .Unit { + margin-right: 108rpx; + + .Point { + width: 46rpx; + height: 46rpx; + } + + .Border { + width: 46rpx; + height: 46rpx; + border: 4rpx solid #B3BACB; + } + } + } + + .InputBox { + .Input { + height: 110rpx; + border-radius: 56rpx; + + .CodeBox { + text { + line-height: 110rpx; + } + } + + .Num { + width: 110rpx; + border-right: 4rpx solid #DADADA; + margin-top: 34rpx; + } + + .Input1 { + width: calc(100% - 260rpx); + } + + .Input2 { + width: calc(100% - 120rpx); + } + } + } + + .Agree { + .Point { + width: 34rpx; + height: 34rpx; + } + + .Border { + width: 34rpx; + height: 34rpx; + border: 2rpx solid #B3BACB; + } + } + + .Btn { + margin-top: 196rpx; + height: 108rpx; + background: linear-gradient(90deg, #0064FF 0%, #2D99FD 100%); + box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(194, 218, 255, 1); + border-radius: 54rpx; + line-height: 108rpx; + } + } + } + \ No newline at end of file diff --git a/pages/map/index.vue b/pages/map/index.vue index f00b91a..b5dc652 100644 --- a/pages/map/index.vue +++ b/pages/map/index.vue @@ -1,1095 +1,1094 @@ \ No newline at end of file diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 2d61da3..c02a5ae 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -6,7 +6,7 @@ - {{ userInfo.realName || userInfo.username || '请登录'}} + {{ dataInfo.cusername || userInfo.username || '请登录'}} - - - + + + + @@ -59,9 +60,9 @@ \ No newline at end of file diff --git a/uni_modules/uni-easyinput/changelog.md b/uni_modules/uni-easyinput/changelog.md new file mode 100644 index 0000000..84c72eb --- /dev/null +++ b/uni_modules/uni-easyinput/changelog.md @@ -0,0 +1,115 @@ +## 1.1.19(2024-07-18) +- 修复 初始值传入 null 导致input报错的bug +## 1.1.18(2024-04-11) +- 修复 easyinput组件双向绑定问题 +## 1.1.17(2024-03-28) +- 修复 在头条小程序下丢失事件绑定的问题 +## 1.1.16(2024-03-20) +- 修复 在密码输入情况下 清除和小眼睛覆盖bug 在edge浏览器下显示双眼睛bug +## 1.1.15(2024-02-21) +- 新增 左侧插槽:left +## 1.1.14(2024-02-19) +- 修复 onBlur的emit传值错误 +## 1.1.12(2024-01-29) +- 补充 adjust-position文档属性补充 +## 1.1.11(2024-01-29) +- 补充 adjust-position属性传递值:(Boolean)当键盘弹起时,是否自动上推页面 +## 1.1.10(2024-01-22) +- 去除 移除无用的log输出 +## 1.1.9(2023-04-11) +- 修复 vue3 下 keyboardheightchange 事件报错的bug +## 1.1.8(2023-03-29) +- 优化 trim 属性默认值 +## 1.1.7(2023-03-29) +- 新增 cursor-spacing 属性 +## 1.1.6(2023-01-28) +- 新增 keyboardheightchange 事件,可监听键盘高度变化 +## 1.1.5(2022-11-29) +- 优化 主题样式 +## 1.1.4(2022-10-27) +- 修复 props 中背景颜色无默认值的bug +## 1.1.0(2022-06-30) + +- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 +- 新增 clear 事件,点击右侧叉号图标触发 +- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 +- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 + +## 1.0.5(2022-06-07) + +- 优化 clearable 显示策略 + +## 1.0.4(2022-06-07) + +- 优化 clearable 显示策略 + +## 1.0.3(2022-05-20) + +- 修复 关闭图标某些情况下无法取消的 bug + +## 1.0.2(2022-04-12) + +- 修复 默认值不生效的 bug + +## 1.0.1(2022-04-02) + +- 修复 value 不能为 0 的 bug + +## 1.0.0(2021-11-19) + +- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput) + +## 0.1.4(2021-08-20) + +- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug + +## 0.1.3(2021-08-11) + +- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 + +## 0.1.2(2021-07-30) + +- 优化 vue3 下事件警告的问题 + +## 0.1.1 + +- 优化 errorMessage 属性支持 Boolean 类型 + +## 0.1.0(2021-07-13) + +- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) + +## 0.0.16(2021-06-29) + +- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug + +## 0.0.15(2021-06-21) + +- 修复 passwordIcon 属性拼写错误的 bug + +## 0.0.14(2021-06-18) + +- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标 +- 修复 confirmType 属性不生效的问题 + +## 0.0.13(2021-06-04) + +- 修复 disabled 状态可清出内容的 bug + +## 0.0.12(2021-05-12) + +- 新增 组件示例地址 + +## 0.0.11(2021-05-07) + +- 修复 input-border 属性不生效的问题 + +## 0.0.10(2021-04-30) + +- 修复 ios 遮挡文字、显示一半的问题 + +## 0.0.9(2021-02-05) + +- 调整为 uni_modules 目录规范 +- 优化 兼容 nvue 页面 diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/common.js b/uni_modules/uni-easyinput/components/uni-easyinput/common.js new file mode 100644 index 0000000..fde8d3c --- /dev/null +++ b/uni_modules/uni-easyinput/components/uni-easyinput/common.js @@ -0,0 +1,54 @@ +/** + * @desc 函数防抖 + * @param func 目标函数 + * @param wait 延迟执行毫秒数 + * @param immediate true - 立即执行, false - 延迟执行 + */ +export const debounce = function(func, wait = 1000, immediate = true) { + let timer; + return function() { + let context = this, + args = arguments; + if (timer) clearTimeout(timer); + if (immediate) { + let callNow = !timer; + timer = setTimeout(() => { + timer = null; + }, wait); + if (callNow) func.apply(context, args); + } else { + timer = setTimeout(() => { + func.apply(context, args); + }, wait) + } + } +} +/** + * @desc 函数节流 + * @param func 函数 + * @param wait 延迟执行毫秒数 + * @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发 + */ +export const throttle = (func, wait = 1000, type = 1) => { + let previous = 0; + let timeout; + return function() { + let context = this; + let args = arguments; + if (type === 1) { + let now = Date.now(); + + if (now - previous > wait) { + func.apply(context, args); + previous = now; + } + } else if (type === 2) { + if (!timeout) { + timeout = setTimeout(() => { + timeout = null; + func.apply(context, args) + }, wait) + } + } + } +} diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue new file mode 100644 index 0000000..34ede14 --- /dev/null +++ b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue @@ -0,0 +1,676 @@ + + + + + \ No newline at end of file diff --git a/uni_modules/uni-easyinput/package.json b/uni_modules/uni-easyinput/package.json new file mode 100644 index 0000000..2939256 --- /dev/null +++ b/uni_modules/uni-easyinput/package.json @@ -0,0 +1,88 @@ +{ + "id": "uni-easyinput", + "displayName": "uni-easyinput 增强输入框", + "version": "1.1.19", + "description": "Easyinput 组件是对原生input组件的增强", + "keywords": [ + "uni-ui", + "uniui", + "input", + "uni-easyinput", + "输入框" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [ + "uni-scss", + "uni-icons" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y", + "alipay": "n" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-easyinput/readme.md b/uni_modules/uni-easyinput/readme.md new file mode 100644 index 0000000..f1faf8f --- /dev/null +++ b/uni_modules/uni-easyinput/readme.md @@ -0,0 +1,11 @@ + + +### Easyinput 增强输入框 +> **组件名:uni-easyinput** +> 代码块: `uEasyinput` + + +easyinput 组件是对原生input组件的增强 ,是专门为配合表单组件[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)而设计的,easyinput 内置了边框,图标等,同时包含 input 所有功能 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-easyinput) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 \ No newline at end of file diff --git a/uni_modules/uview-ui/components/u-checkbox/props.js b/uni_modules/uview-ui/components/u-checkbox/props.js index be1d842..8a85663 100644 --- a/uni_modules/uview-ui/components/u-checkbox/props.js +++ b/uni_modules/uview-ui/components/u-checkbox/props.js @@ -4,6 +4,10 @@ export default { name: { type: [String, Number, Boolean], default: uni.$u.props.checkbox.name, + }, + isSel: { + type: [Boolean], + default:true, }, // item obj: { diff --git a/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue b/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue index b9f3d6b..caaab59 100644 --- a/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue +++ b/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue @@ -214,7 +214,10 @@ this.preventEvent(e) // 如果按钮整体被禁用或者label被禁用,则不允许点击文字修改状态 if (!this.elLabelDisabled && !this.elDisabled) { - this.setRadioCheckedStatus() + if(this.isSel){ + this.setRadioCheckedStatus() + } + this.$emit('click', this.obj) } },