nps接口联调

This commit is contained in:
谢思 2022-09-01 14:35:14 +08:00
parent 087d932906
commit 0dbe7d9f0f
9 changed files with 68 additions and 72 deletions

62
package-lock.json generated
View File

@ -7266,12 +7266,14 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -7286,17 +7288,20 @@
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"optional": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -7413,7 +7418,8 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"optional": true
},
"ini": {
"version": "1.3.5",
@ -7425,6 +7431,7 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -7439,6 +7446,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -7446,12 +7454,14 @@
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"optional": true
},
"minipass": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
"integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -7470,6 +7480,7 @@
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
"integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
@ -7531,7 +7542,8 @@
"npm-normalize-package-bin": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz",
"integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA=="
"integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==",
"optional": true
},
"npm-packlist": {
"version": "1.4.8",
@ -7559,7 +7571,8 @@
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -7571,6 +7584,7 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"optional": true,
"requires": {
"wrappy": "1"
}
@ -7684,6 +7698,7 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -15978,7 +15993,6 @@
"emoji-regex": "^7.0.1",
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^5.1.0"
<<<<<<< Updated upstream
}
},
"strip-ansi": {
@ -16007,36 +16021,6 @@
"strip-ansi": "^5.0.0"
}
},
=======
}
},
"strip-ansi": {
"version": "5.2.0",
"resolved": "http://173.15.15.82:8081/repository/npm-all/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "http://173.15.15.82:8081/repository/npm-all/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==",
"dev": true
},
"wrap-ansi": {
"version": "5.1.0",
"resolved": "http://173.15.15.82:8081/repository/npm-all/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
"integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.0",
"string-width": "^3.0.0",
"strip-ansi": "^5.0.0"
}
},
>>>>>>> Stashed changes
"y18n": {
"version": "4.0.3",
"resolved": "http://173.15.15.82:8081/repository/npm-all/y18n/-/y18n-4.0.3.tgz",

View File

@ -25,7 +25,7 @@ if (isDev) {
}
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' :
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student'
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {

View File

@ -438,7 +438,7 @@ class Detail extends Component {
.catch(error => {
console.log(error);
});
!flag && this.props.showNpsModal();
!flag && this.props.showNpsModal("indexProject", 1);
}
// 点赞和取消点赞
@ -457,7 +457,7 @@ class Detail extends Component {
.catch(error => {
console.log(error);
});
!flag && this.props.showNpsModal();
!flag && this.props.showNpsModal("indexProject", 2);
}
setWatchersCount = (count, is_watched) => {
@ -492,7 +492,7 @@ class Detail extends Component {
}
this.props.history.push(`/${current_user && current_user.login}/${result.data.identifier}`);
this.props.showNotification(result.data.message);
this.props.showNpsModal();
this.props.showNpsModal("indexProject", 3);
}
this.setState({
forkSpin: false

View File

@ -13,7 +13,7 @@ function DetailBanner({ history,list , owner , projectsId ,showNotification , ur
const {location} = history;
const {query} = location;
if(query && query.showNps){
showNpsModal();
showNpsModal("createProject", 1);
}
},[])

View File

@ -54,7 +54,7 @@ class MessageCount extends Component {
const {location, showNpsModal} = this.props;
const {query} = location;
if(query && query.showNps){
showNpsModal();
showNpsModal("createPullRequest", 1);
}
};
@ -125,7 +125,7 @@ class MessageCount extends Component {
});
console.log(error);
});
this.props.showNpsModal();
this.props.showNpsModal("auditPullRequest", 2);
};
//合并请求
@ -164,7 +164,7 @@ class MessageCount extends Component {
});
console.log(error);
});
this.props.showNpsModal();
this.props.showNpsModal("auditPullRequest", 1);
};
changtitlepr = (e) => {

View File

@ -212,7 +212,7 @@ class order_form extends Component {
this.props.history.push(`/${owner}/${projectsId}/issues/${result.data.id}`);
const { getDetail } = this.props;
getDetail && getDetail();
this.props.showNpsModal();
this.props.showNpsModal("createIssue", 1);
}
this.setState({
isSpin: false,

View File

@ -50,7 +50,7 @@ export default Form.create()(
if(result && result.data){
showNotification("组织创建成功!");
history.push(`/${result.data.name}`);
showNpsModal();
showNpsModal("createOrganization", 1);
}
}).catch(error=>{})
}

View File

@ -1,7 +1,9 @@
import { Button, Checkbox, Input, Modal } from 'antd';
import axios from 'axios';
import React, { useState } from 'react';
function NpmModal(props){
const {npsActionType, npsActionId} = props;
const [activeGrade, setActiveGrade] = useState(undefined);
const [checkGroupValue, setCheckGroupValue] = useState(undefined);
const [inputValue, setInputValue] = useState(undefined);
@ -12,12 +14,23 @@ function NpmModal(props){
//
function submit(){
console.log(activeGrade, checkGroupValue, inputValue);
setVisible(false);
setSuccess(true);
//
setTimeout(()=>{
setSuccess(false);
},3000)
axios.post(`/nps.json`,{
action_type: npsActionType,
action_id: npsActionId,
score: activeGrade,
memo:checkGroupValue.toString()+"。"+inputValue
}).then((response) => {
if (response.data) {
setVisible(false);
setSuccess(true);
//
setTimeout(()=>{
setSuccess(false);
},3000)
}
}).catch(function (error) {
console.log(error);
});
}
return <div>
<Modal
@ -37,10 +50,10 @@ function NpmModal(props){
{(activeGrade || activeGrade === 0) && <div>
<div className='font-16 mb15'>您觉得以下哪些我们可以做的更好选填</div>
<Checkbox.Group className='gradeCheckbox' onChange={(e)=>{setCheckGroupValue(e)}}>
<Checkbox value={1}>期待更加丰富的功能</Checkbox>
<Checkbox value={2}>部分功能不会用希望有新手引导</Checkbox>
<Checkbox value={3}>已有的功能模块用户体验需进一步提升</Checkbox>
<Checkbox value={4}>其他</Checkbox>
<Checkbox value="期待更加丰富的功能">期待更加丰富的功能</Checkbox>
<Checkbox value="部分功能不会用,希望有新手引导">部分功能不会用希望有新手引导</Checkbox>
<Checkbox value="已有的功能模块,用户体验需进一步提升">已有的功能模块用户体验需进一步提升</Checkbox>
<Checkbox value="其他">其他</Checkbox>
</Checkbox.Group>
<Input.TextArea placeholder='欢迎您填写宝贵建议(选填)' autoSize={{minRows: 6}} maxLength={500} className='gradeInput' onChange={(e)=>{setInputValue(e.target.value);}}/>
</div>}

View File

@ -31,7 +31,9 @@ export function TPMIndexHOC(WrappedComponent) {
showCP:false,
showNotice:true,
gopage: undefined,
npsModalVisible: false
npsModalVisible: false,
npsActionType: undefined,
npsActionId: undefined
}
}
@ -236,17 +238,14 @@ export function TPMIndexHOC(WrappedComponent) {
})
}
showNpsModal = ()=>{
console.log('调用啦');
// 获取是否已开启nps用户调研
var chromeSettingArray = JSON.parse(localStorage.getItem('chromesetting'));
// 判断三十天内是否弹出nps调研弹窗
var lastNpsTime = localStorage.getItem('npsTime');
(!lastNpsTime || (new Date().getTime()-lastNpsTime) >= 30*24*60*60) && localStorage.setItem('npsTime', new Date().getTime());
const isMoreThan30Days = lastNpsTime ? (new Date().getTime()-lastNpsTime) >= 30*24*60*60 : true;
setTimeout(() => {
showNpsModal = (type, index)=>{
this.setState({
npsActionType:type,
npsActionId: index
})
const {current_user} = this.state;
current_user && current_user.nps && setTimeout(() => {
this.setState({npsModalVisible: true})
// this.setState({npsModalVisible : isMoreThan30Days && chromeSettingArray.main_site})
}, 500)
}
@ -256,7 +255,7 @@ export function TPMIndexHOC(WrappedComponent) {
})
}
render() {
let { isRender , current_user , giteaVisible , email , completeProfile , showCP , showNotice , publicNav , mygetHelmetapi, npsModalVisible } = this.state;
let { isRender , current_user , giteaVisible , email , completeProfile , showCP , showNotice , publicNav , mygetHelmetapi, npsModalVisible, npsActionType, npsActionId } = this.state;
const common = {
showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin,
@ -284,7 +283,7 @@ export function TPMIndexHOC(WrappedComponent) {
{...this.props}
{...this.state}
/> : ""}
{(npsModalVisible) && <NpsModal closeNpsModal={()=>{this.closeNpsModal()}}/>}
{(npsModalVisible) && <NpsModal closeNpsModal={()=>{this.closeNpsModal()}} npsActionType={npsActionType} npsActionId={npsActionId}/>}
<Header {...this.state} {...this.props} {...common} publicNav={publicNav}></Header>
<Spin spinning={this.state.globalLoading} delay={0} className="globalSpin"
size="large" tip={this._gLoadingTip || "加载中..."}