From 50eee9f9eddfc656688723c9a23792fb775b5cdc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 八月 2024 11:50:38 +0800 Subject: [PATCH] Merge branch 'develop' --- public/options.json | 1 src/index.js | 1 src/tabviews/custom/components/module/voucher/resetAttach/addAttach/fileupload/index.jsx | 109 ++-------- src/api/index.js | 55 +++-- src/tabviews/zshare/fileupload/index.jsx | 98 ++------- src/components/editor/index.jsx | 140 +------------ src/templates/zshare/verifycard/baseform/index.jsx | 48 ++-- src/tabviews/zshare/actionList/normalbutton/index.jsx | 120 +++++------ public/README.txt | 1 9 files changed, 162 insertions(+), 411 deletions(-) diff --git a/public/README.txt b/public/README.txt index 797760b..685c921 100644 --- a/public/README.txt +++ b/public/README.txt @@ -14,7 +14,6 @@ WXMerchID -- 浣跨敤寰俊鏀粯鏃讹紝缁戝畾鐨勫晢鎴稩D WXNotice -- 鏄惁寮�鍚槑绉戜簯鍏紬鍙锋秷鎭彁閱掞紝鍊间负 true 鏃跺紑鍚紝鍙�氳繃鏄庣浜戝彂閫佹ā鏉挎秷鎭� WXApps -- 瀛樺湪澶氫釜鍏紬鍙枫�佸皬绋嬪簭鎴栧晢鎴锋椂鍙娇鐢ㄥ井淇PP鍒楄〃锛屾敞鎰忓~鍐欓粯璁ゅ叕浼楀彿銆佸皬绋嬪簭涓庡晢鎴峰彿锛屾牸寮� [{"appId": "", "appName": "", "appType": "public/miniProgram/merchant"}] -nginx -- 鏄惁寮�鍚簡nginx鏈嶅姟锛屽�间负 true 鏃跺紑鍚紝濡傞渶浣跨敤寰俊妯℃澘娑堟伅绛夋湇鍔★紝璇峰厛璁剧疆nginx鏈嶅姟骞跺紑鍚閰嶇疆 debugger -- 鍊间负 true 鏃跺紑鍚皟璇曟ā寮忥紝寮�鍚悗绉诲姩绔瓙搴旂敤涓細鏈夋帶鍒跺彴 devTools -- 鍊间负 false 鏃朵笉鍏佽浣跨敤璋冭瘯妯″紡 licenseKey -- 璁稿彲瀵嗛挜锛屽湪鍐呴儴缃戠粶涓娇鐢ㄧ郴缁熸椂锛屼細璺宠繃epc楠岃瘉 diff --git a/public/options.json b/public/options.json index 65dcc59..73d5160 100644 --- a/public/options.json +++ b/public/options.json @@ -12,7 +12,6 @@ "WXminiAppID": "", "WXMerchID": "", "WXNotice": "true", - "nginx": "true", "debugger": false, "devTools": true, "licenseKey": "", diff --git a/src/api/index.js b/src/api/index.js index 7d3ae5f..768aa69 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -100,15 +100,15 @@ /** * @description 寰俊涓氬姟璇锋眰 鍘熸帴鍙� 'wxpay/getaccesstoken' */ - wxAccessToken (appId, domain = '') { - let _url = domain || window.GLOB.baseurl + // wxAccessToken (appId, domain = '') { + // let _url = domain || window.GLOB.baseurl - return axios({ - url: _url + 'wechat/getaccesstoken', - method: 'post', - data: JSON.stringify({app_id: appId}) - }) - } + // return axios({ + // url: _url + 'wechat/getaccesstoken', + // method: 'post', + // data: JSON.stringify({app_id: appId}) + // }) + // } /** * @description 寰俊涓氬姟璇锋眰 @@ -999,26 +999,37 @@ /** * @description 澶ф枃浠朵笂浼� */ - getLargeFileUpload (param) { - return axios({ - url: '/webapi/doupload', - method: 'post', - headers: { 'Content-Type': 'multipart/form-data' }, - data: param + getFileUpload (param) { + param.append('shardingCnt', 1) + param.append('LoginUID', sessionStorage.getItem('LoginUID') || '') + param.append('UserID', sessionStorage.getItem('UserID') || '') + + return new Promise((resolve, reject) => { + axios({ + url: '/webapi/doupload', + method: 'post', + headers: { 'Content-Type': 'multipart/form-data' }, + data: param + }).then(res => { + if (res.status && res.urlPath) { + res.urlPath = window.GLOB.baseurl + res.urlPath + } + resolve(res) + }) }) } /** * @description 鏌ヨ鏂囦欢鏄惁宸蹭笂浼� */ - getFilePreUpload (param) { - return axios({ - url: '/webapi/dopreload', - method: 'post', - headers: { 'Content-Type': 'multipart/form-data' }, - data: param - }) - } + // getFilePreUpload (param) { + // return axios({ + // url: '/webapi/dopreload', + // method: 'post', + // headers: { 'Content-Type': 'multipart/form-data' }, + // data: param + // }) + // } /** * @description oss鏂囦欢涓婁紶 diff --git a/src/components/editor/index.jsx b/src/components/editor/index.jsx index 05a82fa..a9e96de 100644 --- a/src/components/editor/index.jsx +++ b/src/components/editor/index.jsx @@ -1,12 +1,10 @@ -import React, {Component} from 'react' +import React, { Component } from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import BraftEditor from 'braft-editor' import 'braft-editor/dist/index.css' import 'braft-extensions/dist/table.css' import Table from 'braft-extensions/dist/table' -import SparkMD5 from 'spark-md5' -import moment from 'moment' import Api from '@/api' import './index.scss' @@ -73,37 +71,21 @@ } } - shardupload = (params, param) => { - let _param = params.chunks.shift() + handleUpload(param) { let form = new FormData() - form.append('file', _param.binary) - form.append('fileMd5', params.file.fileMd5) - form.append('shardingMd5', _param.chunkMd5) - form.append('baseDomain', window.GLOB.baseurl) - form.append('rootPath', 'Content/images/upload/') - form.append('fileName', params.file.fileName) - form.append('fileExt', params.file.fileType) - form.append('shardingCnt', _param.chunks) - form.append('shardingNo', _param.chunk) - form.append('LoginUID', sessionStorage.getItem('LoginUID') || '') - form.append('UserID', sessionStorage.getItem('UserID') || '') + form.append('file', param.file) - Api.getLargeFileUpload(form).then(res => { + Api.getFileUpload(form).then(res => { if (res.status) { - if (params.chunks.length > 0) { - param.progress(Math.floor(100 * (_param.chunk / _param.chunks))) - this.shardupload(params, param) + if (res.urlPath) { + param.success({ + url: res.urlPath + }) } else { - if (res.urlPath) { - param.success({ - url: res.urlPath - }) - } else { - param.error({ - url: '涓婁紶澶辫触锛�' - }) - } + param.error({ + url: '涓婁紶澶辫触锛�' + }) } } else { param.error({ @@ -111,106 +93,6 @@ }) } }) - } - - getuuid = () => { - let uuid = [] - let _options = '0123456789abcdefghigklmnopqrstuv' - for (let i = 0; i < 19; i++) { - uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) - } - uuid = uuid.join('') - return uuid - } - - handleUpload(param) { - const file = param.file - - let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice - let chunkSize = 1024 * 1024 * 2 // 鍒囩墖姣忔2M - let chunks = Math.ceil(file.size / chunkSize) // 鍒囩墖鎬绘暟 - let currentChunk = 0 // 褰撳墠涓婁紶鐨刢hunk - let spark = new SparkMD5.ArrayBuffer() // 瀵筧rrayBuffer鏁版嵁杩涜md5鍔犲瘑锛屼骇鐢熶竴涓猰d5瀛楃涓� - let chunkFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘瘡涓猚hunkMd5 - let totalFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘�绘枃浠剁殑fileMd5 - let params = {chunks: [], file: {}} // 鐢ㄤ簬涓婁紶鎵�鏈夊垎鐗囩殑md5淇℃伅 - - params.file.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 - params.file.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 - params.file.fileSize = file.size // 鏂囦欢澶у皬 - params.file.fileChunks = chunks // 璁板綍鎵�鏈塩hunks鐨勯暱搴� - - if (!/^[A-Za-z0-9]+$/.test(params.file.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� - params.file.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() - } - - totalFileReader.readAsArrayBuffer(file) - totalFileReader.onload = (e) => { // 瀵规暣涓猼otalFile鐢熸垚md5 - spark.append(e.target.result) - params.file.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 - - let _param = new FormData() - _param.append('fileMd5', params.file.fileMd5) - - Api.getFilePreUpload(_param).then(res => { - if (res.status && res.urlPath) { - param.success({ - url: res.urlPath - }) - } else if (res.shardings && res.shardings.length > 0) { - res.shardings.forEach(shard => { - if (shard.shardingNo && parseInt(shard.shardingNo) > currentChunk) { - currentChunk = parseInt(shard.shardingNo) - } - }) - loadNext() - } else { - loadNext() - } - }) - } - - chunkFileReader.onload = (e) => { - spark.append(e.target.result) // 瀵规瘡涓�鐗囧垎鐗囪繘琛宮d5鍔犲瘑 - - params.chunks[params.chunks.length - 1].chunkMd5 = spark.end() // 娣诲姞鍒囩墖md5 - - currentChunk++ // 姣忎竴娆″垎鐗噊nload,currentChunk閮介渶瑕佸鍔狅紝浠ヤ究鏉ヨ绠楀垎鐗囩殑娆℃暟 - - if (currentChunk < chunks) { // 褰撳墠鍒囩墖鎬绘暟娌℃湁杈惧埌鎬绘暟鏃� - loadNext() - } else { - this.shardupload(params, param) - } - } - - chunkFileReader.onerror = () => { - param.error({ - url: '涓婁紶澶辫触锛�' - }) - console.warn('File reading failed.') - } - totalFileReader.onerror = () => { - param.error({ - url: '涓婁紶澶辫触锛�' - }) - } - - let loadNext = () => { - let start = currentChunk * chunkSize // 璁$畻鍒嗙墖鐨勮捣濮嬩綅缃� - let end = Math.min(file.size, start + chunkSize) // 璁$畻鍒嗙墖鐨勭粨鏉熶綅缃� - - let obj = { // 姣忎竴涓垎鐗囬渶瑕佸寘鍚殑淇℃伅 - chunk: currentChunk + 1, - binary: file.slice(start, end), - start: start, - end: end, - chunks - } - - params.chunks.push(obj) - chunkFileReader.readAsArrayBuffer(blobSlice.call(file, start, end)) - } } render() { diff --git a/src/index.js b/src/index.js index ff118aa..3487b4a 100644 --- a/src/index.js +++ b/src/index.js @@ -45,7 +45,6 @@ GLOB.watermark = config.watermark + '' !== 'false' GLOB.transfer = config.transfer + '' === 'true' GLOB.keepKey = config.keepPassword + '' !== 'false' - GLOB.nginx = config.nginx + '' === 'true' GLOB.WXAppID = config.WXAppID || '' GLOB.WXminiAppID = config.WXminiAppID || '' GLOB.WXMerchID = config.WXMerchID || '' diff --git a/src/tabviews/custom/components/module/voucher/resetAttach/addAttach/fileupload/index.jsx b/src/tabviews/custom/components/module/voucher/resetAttach/addAttach/fileupload/index.jsx index 627a699..03c3d0f 100644 --- a/src/tabviews/custom/components/module/voucher/resetAttach/addAttach/fileupload/index.jsx +++ b/src/tabviews/custom/components/module/voucher/resetAttach/addAttach/fileupload/index.jsx @@ -1,10 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import moment from 'moment' import { Upload, Button, Progress, notification } from 'antd' import { UploadOutlined } from '@ant-design/icons' -import SparkMD5 from 'spark-md5' + import Api from '@/api' import './index.scss' @@ -90,54 +89,6 @@ }) } - shardupload = (param, name) => { - let form = new FormData() - - form.append('file', param.binary) - form.append('fileMd5', param.fileMd5) - form.append('shardingMd5', param.fileMd5) - form.append('baseDomain', window.GLOB.baseurl) - form.append('rootPath', 'Content/images/upload/') - form.append('fileName', param.fileName) - form.append('fileExt', param.fileType) - form.append('shardingCnt', 1) - form.append('shardingNo', 1) - form.append('LoginUID', sessionStorage.getItem('LoginUID') || '') - form.append('UserID', sessionStorage.getItem('UserID') || '') - - Api.getLargeFileUpload(form).then(res => { - if (res.status) { - if (res.urlPath) { - this.onUpdate(res.urlPath, name) - } else { - this.onFail() - } - this.setState({ - percent: 100 - }, () => { - setTimeout(() => { - this.setState({ - showprogress: false, - percent: 0 - }) - }, 200) - }) - } else { - this.onFail(res.message) - } - }) - } - - getuuid = () => { - let uuid = [] - let _options = '0123456789abcdefghigklmnopqrstuv' - for (let i = 0; i < 19; i++) { - uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) - } - uuid = uuid.join('') - return uuid - } - beforeUpload = (file) => { const { accepts, maxSize } = this.state @@ -172,49 +123,31 @@ percent: 0 }) - // 鍏煎鎬х殑澶勭悊 - let spark = new SparkMD5.ArrayBuffer() // 瀵筧rrayBuffer鏁版嵁杩涜md5鍔犲瘑锛屼骇鐢熶竴涓猰d5瀛楃涓� - let totalFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘�绘枃浠剁殑fileMd5 - let param = {} + let form = new FormData() - param.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 - param.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 + form.append('file', file) - if (!/^[A-Za-z0-9]+$/.test(param.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� - param.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() - } - - totalFileReader.readAsArrayBuffer(file) - totalFileReader.onload = (e) => { // 瀵规暣涓猼otalFile鐢熸垚md5 - spark.append(e.target.result) - param.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 - param.binary = file - - let _param = new FormData() - _param.append('fileMd5', param.fileMd5) - - Api.getFilePreUpload(_param).then(res => { - if (res.status && res.urlPath) { + Api.getFileUpload(form).then(res => { + if (res.status) { + if (res.urlPath) { this.onUpdate(res.urlPath, file.name) - this.setState({ - percent: 100 - }, () => { - setTimeout(() => { - this.setState({ - showprogress: false, - percent: 0 - }) - }, 200) - }) } else { - this.shardupload(param, file.name) + this.onFail() } - }) - } - - totalFileReader.onerror = () => { - this.onFail('鏂囦欢璇诲彇澶辫触锛�') - } + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else { + this.onFail(res.message) + } + }) return false } diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index be2ee38..1315430 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -2556,7 +2556,7 @@ } sendWxMessage = (verify, id) => { - let domain = '' + let domain = window.GLOB.baseurl let appId = window.GLOB.WXAppID || '' if (verify.wxAppId && verify.wxAppId !== appId) { @@ -2576,14 +2576,7 @@ appId = 'wx4d8a34c8d4494872' } - if (!window.GLOB.nginx && !domain) { - notification.warning({ - top: 92, - message: 'nginx鏈嶅姟灏氭湭寮�鍚紝涓嶅彲鍙戦�佹ā鏉挎秷鎭��', - duration: 5 - }) - return - } else if (!appId) { + if (!appId) { notification.warning({ top: 92, message: '灏氭湭娣诲姞鍏紬鍙稩D锛屼笉鍙彂閫佹ā鏉挎秷鎭��', @@ -2663,62 +2656,63 @@ return m }) - Api.wxAccessToken(appId, domain).then(res => { - if (!res.access_token) return - - params.forEach(n => { - Api.wxNginxRequest(`${domain}cgi-bin/message/template/send?access_token=${res.access_token}`, 'post', JSON.stringify(n)).then(re => { - if (verify.wxNoteCallback === 'true') { - let msg = re.errmsg || '' + // cgi-bin/message/template/send + params.forEach(n => { + Api.directRequest({ + url: domain + 'wechat/send?appid=' + appId, + method: 'post', + data: JSON.stringify(n) + }).then(re => { + if (verify.wxNoteCallback === 'true') { + let msg = re.errmsg || '' - if (msg.length > 50) { - msg = msg.substr(0, 50) - } - - let _p = { - func: 's_get_sms_weixin_local_suc_err', - upid: id, - send_id: n.client_msg_id || '', - status_result: re.errcode === 0 ? 'S' : 'E', - errcode: re.errcode, - msg_result: msg - } - - _p.LText = Utils.getuuid() - _p.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _p.secretkey = Utils.encrypt(_p.LText, _p.timestamp) - - Api.genericInterface(_p).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - }) - } else if (re.errcode !== 0 && re.errmsg) { - let msgs = [ - {errcode: -1, errmsg: '绯荤粺绻佸繖锛岃绋嶅�欏啀璇�'}, - {errcode: 40001, errmsg: 'access_token 鏃犳晥'}, - {errcode: 40003, errmsg: '涓嶅悎娉曠殑 OpenID'}, - {errcode: 40014, errmsg: '涓嶅悎娉曠殑 access_token'}, - {errcode: 40033, errmsg: '涓嶅悎娉曠殑璇锋眰瀛楃'}, - {errcode: 43004, errmsg: '闇�瑕佹帴鏀惰�呭叧娉�'}, - {errcode: 43019, errmsg: '闇�瑕佸皢鎺ユ敹鑰呬粠榛戝悕鍗曚腑绉婚櫎'}, - {errcode: 50005, errmsg: '鐢ㄦ埛鏈叧娉ㄥ叕浼楀彿'} - ] - - let msg = msgs.filter(m => m.errcode === re.errcode)[0] - msg = msg || re - - notification.warning({ - top: 92, - message: msg.errmsg, - duration: 5 - }) + if (msg.length > 50) { + msg = msg.substr(0, 50) } - }) + + let _p = { + func: 's_get_sms_weixin_local_suc_err', + upid: id, + send_id: n.client_msg_id || '', + status_result: re.errcode === 0 ? 'S' : 'E', + errcode: re.errcode, + msg_result: msg + } + + _p.LText = Utils.getuuid() + _p.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _p.secretkey = Utils.encrypt(_p.LText, _p.timestamp) + + Api.genericInterface(_p).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }) + } else if (re.errcode !== 0 && re.errmsg) { + let msgs = [ + {errcode: -1, errmsg: '绯荤粺绻佸繖锛岃绋嶅�欏啀璇�'}, + {errcode: 40001, errmsg: 'access_token 鏃犳晥'}, + {errcode: 40003, errmsg: '涓嶅悎娉曠殑 OpenID'}, + {errcode: 40014, errmsg: '涓嶅悎娉曠殑 access_token'}, + {errcode: 40033, errmsg: '涓嶅悎娉曠殑璇锋眰瀛楃'}, + {errcode: 43004, errmsg: '闇�瑕佹帴鏀惰�呭叧娉�'}, + {errcode: 43019, errmsg: '闇�瑕佸皢鎺ユ敹鑰呬粠榛戝悕鍗曚腑绉婚櫎'}, + {errcode: 50005, errmsg: '鐢ㄦ埛鏈叧娉ㄥ叕浼楀彿'} + ] + + let msg = msgs.filter(m => m.errcode === re.errcode)[0] + msg = msg || re + + notification.warning({ + top: 92, + message: msg.errmsg, + duration: 5 + }) + } }) }) }) diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx index ebf75f0..e061bd3 100644 --- a/src/tabviews/zshare/fileupload/index.jsx +++ b/src/tabviews/zshare/fileupload/index.jsx @@ -1,10 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import moment from 'moment' import { Upload, Button, Progress, notification } from 'antd' import { UploadOutlined } from '@ant-design/icons' -import SparkMD5 from 'spark-md5' import Api from '@/api' import MKEmitter from '@/utils/events.js' @@ -195,44 +193,6 @@ }) } - shardupload = (param, file_name) => { - let form = new FormData() - - form.append('file', param.binary) - form.append('fileMd5', param.fileMd5) - form.append('shardingMd5', param.fileMd5) - form.append('baseDomain', window.GLOB.baseurl) - form.append('rootPath', 'Content/images/upload/') - form.append('fileName', param.fileName) - form.append('fileExt', param.fileType) - form.append('shardingCnt', 1) - form.append('shardingNo', 1) - form.append('LoginUID', sessionStorage.getItem('LoginUID') || '') - form.append('UserID', sessionStorage.getItem('UserID') || '') - - Api.getLargeFileUpload(form).then(res => { - if (res.status) { - if (res.urlPath) { - this.onUpdate(res.urlPath, file_name) - } else { - this.onFail() - } - this.setState({ - percent: 100 - }, () => { - setTimeout(() => { - this.setState({ - showprogress: false, - percent: 0 - }) - }, 200) - }) - } else { - this.onFail(res.message) - } - }) - } - getuuid = () => { let uuid = [] let _options = '0123456789abcdefghigklmnopqrstuv' @@ -406,49 +366,31 @@ return false } - // 鍏煎鎬х殑澶勭悊 - let spark = new SparkMD5.ArrayBuffer() // 瀵筧rrayBuffer鏁版嵁杩涜md5鍔犲瘑锛屼骇鐢熶竴涓猰d5瀛楃涓� - let totalFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘�绘枃浠剁殑fileMd5 - let param = {} + let form = new FormData() - param.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 - param.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 + form.append('file', file) - if (!/^[A-Za-z0-9]+$/.test(param.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� - param.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() - } - - totalFileReader.readAsArrayBuffer(file) - totalFileReader.onload = (e) => { // 瀵规暣涓猼otalFile鐢熸垚md5 - spark.append(e.target.result) - param.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 - param.binary = file - - let _param = new FormData() - _param.append('fileMd5', param.fileMd5) - - Api.getFilePreUpload(_param).then(res => { - if (res.status && res.urlPath) { + Api.getFileUpload(form).then(res => { + if (res.status) { + if (res.urlPath) { this.onUpdate(res.urlPath, file_name) - this.setState({ - percent: 100 - }, () => { - setTimeout(() => { - this.setState({ - showprogress: false, - percent: 0 - }) - }, 200) - }) } else { - this.shardupload(param, file_name) + this.onFail() } - }) - } - - totalFileReader.onerror = () => { - this.onFail('鏂囦欢璇诲彇澶辫触锛�') - } + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else { + this.onFail(res.message) + } + }) return false } diff --git a/src/templates/zshare/verifycard/baseform/index.jsx b/src/templates/zshare/verifycard/baseform/index.jsx index 395564c..8922bbe 100644 --- a/src/templates/zshare/verifycard/baseform/index.jsx +++ b/src/templates/zshare/verifycard/baseform/index.jsx @@ -47,7 +47,7 @@ let wxTemps = sessionStorage.getItem('wxTemplates' + appId) - if (appId && window.GLOB.nginx && !wxTemps) { + if (appId && !wxTemps) { if (verify.wxNote === 'true') { this.getTemps(appId) } @@ -61,31 +61,28 @@ } getTemps = (appId) => { - Api.wxAccessToken(appId).then(res => { - if (res.status && res.access_token) { - Api.wxNginxRequest(`cgi-bin/template/get_all_private_template?access_token=${res.access_token}`, 'get').then(res => { - let temps = [] - if (res.template_list) { - temps = res.template_list.filter(item => { - if (!item.primary_industry || sysTempsIds.includes(item.template_id)) return false - if (item.content) { - item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') - } - - return true - }) - } else if (res.errcode && res.errmsg) { - message.warning(res.errcode + ': ' + res.errmsg) + // cgi-bin/template/get_all_private_template + Api.directRequest({ + url: window.GLOB.baseurl + 'wechat/get_all_private_template?appid=' + appId, + method: 'get', + }).then(res => { + let temps = [] + if (res.template_list) { + temps = res.template_list.filter(item => { + if (!item.primary_industry || sysTempsIds.includes(item.template_id)) return false + if (item.content) { + item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') } - - sessionStorage.setItem('wxTemplates' + appId, JSON.stringify(temps)) - this.resetTemps(temps) + return true }) - } else { - message.warning(res.message || '寰俊鎺堟潈澶辫触锛�') - sessionStorage.setItem('wxTemplates' + appId, JSON.stringify([])) + } else if (res.errcode && res.errmsg) { + message.warning(res.errcode + ': ' + res.errmsg) } + + sessionStorage.setItem('wxTemplates' + appId, JSON.stringify(temps)) + + this.resetTemps(temps) }) } @@ -206,7 +203,7 @@ this.props.onChange(_verify) - if (key === 'wxNote' && value === 'true' && window.GLOB.WXAppID && window.GLOB.nginx) { + if (key === 'wxNote' && value === 'true' && window.GLOB.WXAppID) { let wxTemps = sessionStorage.getItem('wxTemplates' + window.GLOB.WXAppID) if (wxTemps) { @@ -308,11 +305,6 @@ setTimeout(() => { this.props.onChange(_verify_) - - if (!window.GLOB.nginx) { - message.warning('nginx鏈嶅姟灏氭湭寮�鍚紝璇锋鏌ラ厤缃枃浠跺苟鍦ㄦ湇鍔″櫒涓畬鎴恘ginx璁剧疆銆�') - return - } let wxTemps = sessionStorage.getItem('wxTemplates' + val) -- Gitblit v1.8.0