123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- // pages/teamWork/teamWork.js
- const app = getApp()
- const util = require("../../utils/util")
- const urlDef = require("../../utils/urls")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- index: 0,
- array: [
- ]
- },
- len: function (s) {
- return (s == null ? 0 : s.length);
- },
- showToast: function (s) {
- wx.showToast({
- title: s,
- icon: 'none'
- })
- },
- formSubmit: function (e) {
- let urls = urlDef.urls
- let entity = e.detail.value
- let t = this.data.array[this.data.index]
- let companyType = t ? t.value : ''
- entity.cooperateType = companyType
- let stu = wx.getStorageSync('student');
- if (this.len(entity.corpName) === 0) {
- this.showToast('请输入企业名称');
- return false;
- }
- if (this.len(entity.cooperateType) === 0) {
- this.showToast('请选择企业类型');
- return false;
- }
- if (this.len(entity.summary) === 0) {
- this.showToast('请输入项目简介或合作方案');
- return false;
- }
- if (this.len(entity.contractName) === 0) {
- this.showToast('请选择联系人名称');
- return false;
- }
- if (this.len(entity.telephone) === 0) {
- this.showToast('请选择联系人电话号码');
- return false;
- }
- if (this.len(entity.wx) === 0) {
- this.showToast('请选择联系人微信号');
- return false;
- }
- entity.isRead = '0';
- entity.orgId = stu.orgId;
- util.apiPost(urls.cooperate_save, entity, 'application/json').then((rs) => {
- if (rs.message) {
- this.showToast(rs.message)
- return
- }
- this.showToast('您已提交成功,我们会尽快与您联系!');
- entity.id = rs.id;
- // 发送 合作推送给校长
- const body = { 'orgId': stu.orgId, 'id': rs.id }
- util.apiPost(urls.cooperate_send_message, body, 'application/json').then((rs) => {
- console.log('发送通知 ' + JSON.stringify(rs));
- });
- setTimeout(() => {
- wx.navigateBack({
- delta: 1, // 返回上一级页面。
- success: function () {
- console.log('成功!')
- }
- })
- }, 1000)
- })
- },
- bindPickerChange: function (e) {
- this.setData({
- index: e.detail.value
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let urls = urlDef.urls
- util.apiPost(urls.get_cooperate_corp_type).then((rs) => {
- let corp_types = rs;
- let list = []
- corp_types.forEach(v => {
- this.item = {};
- this.item.text = v.detailName;
- this.item.value = v.id;
- list.push(this.item);
- });
- this.setData({ array: list })
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|