fillTeamInfo.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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"></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. type:'',
  14. next:'',
  15. questionnaireId:'',
  16. confirmText:'下一步'
  17. }
  18. },
  19. onLoad(options) {
  20. this.type = options.type;
  21. this.questionnaireId = options.questionnaireId||'';
  22. this.confirmText = options.type?'确定':'下一步';
  23. this.next = options.next;
  24. if(this.next) this.confirmText = '下一步';
  25. },
  26. methods:{
  27. handleConfirm(team){
  28. team.questionnaireId = this.questionnaireId;
  29. team.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  30. this.$api.post('/core/user/team',team).then(({data:res})=>{
  31. if(res.code!==0) return this.$showToast(res.msg)
  32. if(this.next){
  33. this.$api.post('/core/team/questionnaire/publish',{
  34. answerSetting:1,
  35. coachId:JSON.parse(uni.getStorageSync('userInfo')).id,
  36. startTime:new Date().Format('yyyy-MM-dd hh:mm:ss'),
  37. endTime:new Date(new Date().setDate(new Date().getDate()+30)).Format('yyyy-MM-dd hh:mm:ss'),
  38. questionnaireId:this.questionnaireId,
  39. teamId:res.data.teamId,
  40. type:1
  41. }).then(({data:res2})=>{
  42. if(res2.code!==0) return this.$showToast(res2.msg)
  43. this.$showToast('保存成功,即将填写问卷')
  44. setTimeout(()=>{
  45. uni.removeStorageSync('newUser')
  46. uni.navigateTo({
  47. url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+res2.data+'&teamId='+res.data.teamId+'&type='+this.type
  48. })
  49. },1500)
  50. })
  51. }else{
  52. this.$showToast('团队新增成功')
  53. setTimeout(()=>{
  54. this.getOpenerEventChannel().emit('saveTeamInfo')
  55. uni.navigateBack()
  56. },1500)
  57. }
  58. })
  59. }
  60. }
  61. }
  62. </script>
  63. <style scoped lang="scss">
  64. .default_page{
  65. box-sizing: border-box;
  66. }
  67. </style>