communityForm.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {formTypes} from "../../model/enum";
  2. import Api from "../../model/api";
  3. import Config from "../../model/config";
  4. import {showLoading} from "../../utils/utils";
  5. Page({
  6. data: {
  7. formTypesEnum: formTypes,
  8. type: '',
  9. directionData: [],
  10. modelData: [],
  11. typeData: [],
  12. categoryData: [],
  13. teamId: '',
  14. eduStuId: '',
  15. eduStuName: '',
  16. },
  17. async onLoad(options) {
  18. const {type, teamId, eduStuId, eduStuName} = options;
  19. wx.setNavigationBarTitle({title: type});
  20. if (type == formTypes.NEEDS) {
  21. showLoading();
  22. const [res1, res2, res3] = await Api.promiseAll([
  23. Api.getPulishDict(Config.DICT.TRAIN_DIRECTION),
  24. Api.getPulishDict(Config.DICT.TRAIN_MODEL),
  25. Api.getPulishDict(Config.DICT.COURSE_TYPE),
  26. ]);
  27. this.setData({
  28. directionData: res1.data,
  29. modelData: res2.data,
  30. typeData: res3.data,
  31. type
  32. })
  33. wx.hideLoading();
  34. }
  35. if (type == formTypes.TYPICAL) {
  36. const res = await Api.getPulishDict(Config.DICT.EXAMPLE_CATEGORY, true);
  37. this.setData({
  38. categoryData: res.data,
  39. type
  40. })
  41. }
  42. if (type == formTypes.DYNAMIC) {
  43. this.setData({
  44. teamId,
  45. eduStuId,
  46. eduStuName,
  47. type
  48. })
  49. }
  50. if (type == formTypes.HOT) {
  51. this.setData({
  52. type
  53. })
  54. }
  55. },
  56. async postFinish(e) {
  57. await wx.showModal({
  58. title: '发布成功',
  59. showCancel: false,
  60. })
  61. const eventChannel = this.getOpenerEventChannel()
  62. eventChannel.emit('publish', {isSuccess: true});
  63. wx.navigateBack()
  64. }
  65. });