fillTeamInfo.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='填写所在团队信息'></cus-header>
  4. <cus-team-info-fill @handleConfirm="handleConfirm" :confirmText="confirmText" :qtype="qtype"></cus-team-info-fill>
  5. </view>
  6. </template>
  7. <script>
  8. import CusTeamInfoFill from '@/components/CusTeamInfoFill/index.vue'
  9. export default {
  10. components:{ CusTeamInfoFill },
  11. data(){
  12. return {
  13. title:'',
  14. type:'',
  15. next:'',
  16. questionnaireId:'',
  17. confirmText:'下一步',
  18. qtype:''
  19. }
  20. },
  21. onLoad(options) {
  22. this.title = options.title||'';
  23. this.type = options.type;
  24. this.qtype = options.qtype||'';
  25. this.questionnaireId = options.questionnaireId||'';
  26. this.confirmText = options.type?'确定':'下一步';
  27. this.next = options.next;
  28. if(this.next) this.confirmText = '下一步';
  29. },
  30. methods:{
  31. handleConfirm(team){
  32. team.questionnaireId = this.questionnaireId;
  33. team.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  34. this.$api.post('/core/user/team',team).then(({data:res})=>{
  35. if(res.code!==0) return this.$showToast(res.msg)
  36. if(this.next){
  37. this.$api.post('/core/team/questionnaire/publish',{
  38. answerSetting:1,
  39. coachId:JSON.parse(uni.getStorageSync('userInfo')).id,
  40. startTime:new Date().Format('yyyy-MM-dd hh:mm:ss'),
  41. endTime:new Date(new Date().setDate(new Date().getDate()+30)).Format('yyyy-MM-dd hh:mm:ss'),
  42. questionnaireId:this.questionnaireId,
  43. teamId:res.data.teamId,
  44. type:1
  45. }).then(({data:res2})=>{
  46. if(res2.code!==0) return this.$showToast(res2.msg)
  47. this.$showToast('保存成功,即将填写问卷')
  48. setTimeout(()=>{
  49. uni.removeStorageSync('newUser')
  50. uni.navigateTo({
  51. url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+res2.data+'&teamId='+res.data.teamId+'&type='+this.type+'&title='+this.title
  52. })
  53. },1500)
  54. })
  55. }else{
  56. this.$showToast('团队新增成功')
  57. setTimeout(()=>{
  58. this.getOpenerEventChannel().emit('saveTeamInfo')
  59. uni.navigateBack()
  60. },1500)
  61. }
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .default_page{
  69. box-sizing: border-box;
  70. }
  71. </style>