teamWork.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // pages/teamWork/teamWork.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. const urlDef = require("../../utils/urls")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. index: 0,
  11. array: [
  12. ]
  13. },
  14. len: function (s) {
  15. return (s == null ? 0 : s.length);
  16. },
  17. showToast: function (s) {
  18. wx.showToast({
  19. title: s,
  20. icon: 'none'
  21. })
  22. },
  23. formSubmit: function (e) {
  24. let urls = urlDef.urls
  25. let entity = e.detail.value
  26. let t = this.data.array[this.data.index]
  27. let companyType = t ? t.value : ''
  28. entity.cooperateType = companyType
  29. let stu = wx.getStorageSync('student');
  30. if (this.len(entity.corpName) === 0) {
  31. this.showToast('请输入企业名称');
  32. return false;
  33. }
  34. if (this.len(entity.cooperateType) === 0) {
  35. this.showToast('请选择企业类型');
  36. return false;
  37. }
  38. if (this.len(entity.summary) === 0) {
  39. this.showToast('请输入项目简介或合作方案');
  40. return false;
  41. }
  42. if (this.len(entity.contractName) === 0) {
  43. this.showToast('请选择联系人名称');
  44. return false;
  45. }
  46. if (this.len(entity.telephone) === 0) {
  47. this.showToast('请选择联系人电话号码');
  48. return false;
  49. }
  50. if (this.len(entity.wx) === 0) {
  51. this.showToast('请选择联系人微信号');
  52. return false;
  53. }
  54. entity.isRead = '0';
  55. entity.orgId = stu.orgId;
  56. util.apiPost(urls.cooperate_save, entity, 'application/json').then((rs) => {
  57. if (rs.message) {
  58. this.showToast(rs.message)
  59. return
  60. }
  61. this.showToast('您已提交成功,我们会尽快与您联系!');
  62. entity.id = rs.id;
  63. // 发送 合作推送给校长
  64. const body = { 'orgId': stu.orgId, 'id': rs.id }
  65. util.apiPost(urls.cooperate_send_message, body, 'application/json').then((rs) => {
  66. console.log('发送通知 ' + JSON.stringify(rs));
  67. });
  68. setTimeout(() => {
  69. wx.navigateBack({
  70. delta: 1, // 返回上一级页面。
  71. success: function () {
  72. console.log('成功!')
  73. }
  74. })
  75. }, 1000)
  76. })
  77. },
  78. bindPickerChange: function (e) {
  79. this.setData({
  80. index: e.detail.value
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad: function (options) {
  87. let urls = urlDef.urls
  88. util.apiPost(urls.get_cooperate_corp_type).then((rs) => {
  89. let corp_types = rs;
  90. let list = []
  91. corp_types.forEach(v => {
  92. this.item = {};
  93. this.item.text = v.detailName;
  94. this.item.value = v.id;
  95. list.push(this.item);
  96. });
  97. this.setData({ array: list })
  98. });
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })