Parcourir la source

我要合作、邀请有礼 数据对接

zhangshuling il y a 3 ans
Parent
commit
d944ff0307

+ 1 - 1
pages/Components/selectDate/selectDate.js

@@ -5,7 +5,7 @@ Component({
       var date = new Date()
       const year = date.getFullYear()
       const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
-      const day = date.getDate() + 1 < 10 ? '0' + date.getDate() : data.getDate()
+      const day = date.getDate() + 1 < 10 ? '0' + date.getDate() : date.getDate()
       this.setData({
         endDate: year + '-' + month + '-' + day,
         lastDate: year + '-' + month + '-' + day

+ 1 - 1
pages/forBack/forBack.js

@@ -104,7 +104,7 @@ Page({
   doInput: function (e) {
     this.setData({ content: e.detail.value })
   },
-  len(s) {
+  len: function(s) {
     return (s == null ? 0 : s.length);
   },
   doSave: function () {

+ 9 - 9
pages/forBack/forBack.wxml

@@ -7,17 +7,17 @@
   </view>
   <view class="change-view">
     <view class="curSchool" wx:if="{{radioType == 'school'}}">当前学校:{{curStu.orgName}}</view>
-  <view class="picker-view" wx:elif="{{radioType == 'select'}}">
-    <view class="section">
-      <view class="section__title">请选择板块:</view>
-      <picker bindchange="bindPickerChange" value="{{plateIndex}}" range="{{plateList}}" range-key="name">
-        <view class="picker">
-          {{plateList[plateIndex].name}}
-        </view>
-      </picker>
+    <view class="picker-view" wx:elif="{{radioType == 'select'}}">
+      <view class="section">
+        <view class="section__title">请选择板块:</view>
+        <picker bindchange="bindPickerChange" value="{{plateIndex}}" range="{{plateList}}" range-key="name">
+          <view class="picker">
+            {{plateList[plateIndex].name}}
+          </view>
+        </picker>
+      </view>
     </view>
   </view>
-  </view>
   <view class="line"></view>
 
   <view class="title">问题描述</view>

+ 135 - 9
pages/student/student.js

@@ -1,4 +1,7 @@
 // pages/student/student.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
@@ -7,10 +10,14 @@ Page({
   data: {
     height: 0,
     animation: {},
-    left: 750
+    left: 750,
+    inviteConfig: {},
+    count: 0,
+    enroll: 0,
+    coin: '0',
+    invitations: []
   },
-
-  closeCamera:function(){
+  closeCamera: function () {
     this.animation = wx.createAnimation({
       timingFunction: 'linear',
       duration: 400
@@ -18,11 +25,11 @@ Page({
     const left = 750
     this.animation.translateX(left).step()
     this.setData({
-      animation:this.animation.export()
+      animation: this.animation.export()
     })
   },
 
-  showCamaer:function(){
+  showCamaer: function () {
     this.animation = wx.createAnimation({
       timingFunction: 'linear',
       duration: 100
@@ -30,13 +37,11 @@ Page({
     const left = 0
     this.animation.translateX(left).step()
     this.setData({
-      animation:this.animation.export(),
+      animation: this.animation.export(),
       left
     })
-   
   },
-
-  scanCode:function(e){
+  scanCode: function (e) {
     console.log(JSON.stringify(e))
   },
 
@@ -51,6 +56,12 @@ Page({
         })
       },
     })
+
+    this.queryInvitation(null);
+    let t = this;
+    setTimeout(() => {
+      t.doSearch();
+    }, 1000);
   },
 
   /**
@@ -100,5 +111,120 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+  queryInvitation: function (methodName) {
+    let urls = urlDef.urls
+    let stu = wx.getStorageSync('student');
+    let inviteConfig = {}
+    util.apiPost(urls.get_activity_share + '&q.orgId=' + stu.orgId).then((rs) => {
+      if (rs && rs.length > 0) {
+        let r = rs[0];
+        inviteConfig.title = (r.name ? r.name : '邀请有礼');
+        inviteConfig.description = (r.remark ? r.remark : '邀请新学员,赢得奖励');
+        inviteConfig.imageUrl = r.imgUrl;
+        if (r.activityUrl && r.activityUrl.length > 0) {
+          inviteConfig.url = r.activityUrl + (r.activityUrl.indexOf('?') === -1 ? '?' : '&') + 'studentId=' + stu.studentId + '&orgId=' + stu.orgId;
+        }
+
+        this.setData({ inviteConfig: inviteConfig })
+        if ('billShare' === methodName) {
+          this.billShare();
+        }
+        if ('share' === methodName) {
+          this.share();
+        }
+        if ('codeInvite' === methodName) {
+          this.codeInvite();
+        }
+      }
+    });
+  },
+  doSearch: function () {
+    let urls = urlDef.urls
+    let stu = wx.getStorageSync('student');
+    util.apiPost(urls.get_invitation_count + '&q.introducer=' + stu.studentId).then(rs => {
+      if (rs) {
+        this.setData({ count: rs.num })
+      }
+    });
+
+    util.apiPost(urls.get_invitation_enroll + '&q.introducer=' + stu.studentId).then(rs => {
+      if (rs) {
+        this.setData({ enroll: rs.num })
+      }
+    });
+
+    util.apiPost(urls.get_invitation_coin + '&q.introducer=' + stu.studentId).then(rs => {
+      if (rs && rs.length > 0) {
+        let i = 0;
+        let coin = ''
+        rs.forEach(r => {
+          coin += (r.amount + '<view class=\'unit\'>' + (r.type === 1 ? '元' : '课时') + '</view>');
+          if (i < rs.length - 1) {
+            coin += '<view class=\'sl\'>/</view>';
+          }
+          i++;
+        });
+        this.setData({ coin: coin })
+      }
+    });
+
+    util.apiPost(urls.query_invitation_list + '&q.introducer=' + stu.studentId).then(rs => {
+      if (rs) {
+        rs.map(o => {
+          o.name = o.studentName ? o.studentName : o.clientName
+          o.statusText = this.getStatus(o)
+          o.face = this.getHead(o)
+        })
+        this.setData({ invitations: rs })
+      }
+    });
+  },
+  getHead(item) {
+    let urls = urlDef.urls
+    return item.imageUrl ? urls.oss_file + 'image/' + item.imageUrl : '/images/head.png';
+  },
+  getStatus(item) {
+    if (item.orderCount > 0) { // 有已付款的订单
+      return '已报名';
+    } else {
+      if (item.isAudition === 0) { // 未试听
+        return '已注册';
+      }
+      return '已试听';
+    }
+  },
+  billShare: function () {
+    if (this.data.inviteConfig.url && this.data.inviteConfig.url.length > 4) {
+      console.log('弹出海报分享页面')
+      // this.modal = this.modalCtrl.create('BillSharePage', { item: this.inviteConfig });
+      // this.modal.present();
+    } else {
+      this.queryInvitation('billShare');
+    }
+  },
+  share: function () {
+    if (this.data.inviteConfig.url && this.data.inviteConfig.url.length > 4) {
+      // this.modal = this.modalCtrl.create('SharePage', { item: this.inviteConfig });
+      // this.modal.present();
+      console.log('弹出享页面')
+    } else {
+      this.queryInvitation('share');
+    }
+  },
+  codeInvite: function () {
+    let urls = urlDef.urls
+    if (this.data.inviteConfig.url && this.data.inviteConfig.url.length > 4) {
+      let regUrl = this.data.inviteConfig.url;
+      let imgUrl = urls.get_qr_code + '?content=' + encodeURIComponent(regUrl);
+      this.openModal(imgUrl);
+    } else {
+      this.queryInvitation('codeInvite');
+    }
+  },
+  openModal: function (imgUrl) {
+    // 弹出页面
+    console.log('...' + imgUrl)
   }
+
 })

+ 13 - 6
pages/student/student.wxml

@@ -1,9 +1,11 @@
 <view class="container">
+  <!--
   <view class="camera-view" animation="{{animation}}" style="left:{{left}}rpx">
     <view class="close-camera" bindtap="closeCamera">关闭</view>
     <camera device-position="back" mode="scanCode" resolution="high" flash="off" bindscancode="scanCode"
       binderror="error" style="width: 100%; height: {{height}}px;"></camera>
   </view>
+  -->
 
   <image class="bgImg" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation_bg.png">
   </image>
@@ -11,15 +13,15 @@
     <view class="left-radius"></view>
     <view class="right-radius"></view>
     <view class="btn-box">
-      <view class="share-btn">海报分享邀请好友</view>
+      <view class="share-btn" bindtap="billShare">海报分享邀请好友</view>
       <view class="line"></view>
       <view class="other-btn">
-        <view class="">
+        <view class="" bindtap="share">
           <image class="icon-img" mode="heightFix"
             src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_link.png"></image>
           <text>链接邀请</text>
         </view>
-        <view class="" bindtap="showCamaer">
+        <view class="" bindtap="codeInvite">
           <image class="icon-img" mode="heightFix"
             src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_code.png"></image>
           <text>面对面扫码</text>
@@ -33,18 +35,23 @@
     src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c2.png"></image>
   <view class="total-view">
     <view>
-      0
+    {{count}}
       <text>已试听/人</text>
     </view>
     <view>
-      0
+     {{enroll}}
       <text>已购课/人</text>
     </view>
     <view>
-      0
+     {{coin}}
       <text>获得奖励</text>
     </view>
   </view>
   <image class="bgImg step-three" mode="widthFix"
     src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c3.png"></image>
+    <view class="total-view"  wx:for="{{invitations}}">
+    <view>{{item.name}}</view>
+    <view>{{item.subDate}}</view>
+    <view>{{item.statusText}}</view>
+  </view>
 </view>

+ 9 - 0
pages/student/student.wxss

@@ -136,4 +136,13 @@ image{
     width: 750rpx;
     left: 750rpx;
     z-index: 3;
+}
+.sl {
+  color: #ccc;
+  padding: 0 2px;
+}
+
+.unit {
+  color: #999;
+  font-size: 0.9rem;
 }

+ 87 - 15
pages/teamWork/teamWork.js

@@ -1,4 +1,7 @@
 // pages/teamWork/teamWork.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 
   /**
@@ -6,30 +9,99 @@ Page({
    */
   data: {
     index: 0,
-    array:[
-      '本地生活服务',
-      '亲子早教',
-      '文化课培训',
-      '餐饮娱乐',
-      '文化演艺',
-      '银行金融',
-      '特许加盟',
-      '其他',
+    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)
+    })
 
-  formSubmit:function(e){
-    let value = e.detail.value
-    let companyType = this.data.array[value.companyType]
-    value.companyType = companyType
-    console.log(value)
   },
 
+  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 })
+    });
   },
 
   /**

+ 7 - 7
pages/teamWork/teamWork.wxml

@@ -3,16 +3,16 @@
     <view class="input-box">
       <view class="title">企业名称</view>
       <view class="input-view">
-        <input class="weui-input" name="companyName"  placeholder="请填写" maxlength="50" />
+        <input class="weui-input" name="corpName"  placeholder="请填写" maxlength="50" />
       </view>
     </view>
 
     <view class="select-box">
       <view class="title">企业类型</view>
       <view class="select-view">
-        <picker bindchange="bindPickerChange" name="companyType" value="{{index}}" range="{{array}}">
+        <picker bindchange="bindPickerChange" name="cooperateType" value="{{index}}" range="{{array}}" range-key="text">
           <view class="picker">
-            {{array[index]}}
+            {{array[index].text}}
           </view>
         </picker>
       </view>
@@ -21,21 +21,21 @@
     <view class="input-box">
       <view class="title">联系人姓名</view>
       <view class="input-view">
-        <input class="weui-input" name="contactName"  placeholder="请填写" maxlength="5" />
+        <input class="weui-input" name="contractName"  placeholder="请填写" maxlength="5" />
       </view>
     </view>
 
     <view class="input-box">
       <view class="title">联系人电话</view>
       <view class="input-view">
-        <input class="weui-input" name="phone"  placeholder="请填写" minlength="8" maxlength="11" />
+        <input class="weui-input" name="telephone"  placeholder="请填写" minlength="8" maxlength="11" />
       </view>
     </view>
 
     <view class="input-box">
       <view class="title">联系人微信</view>
       <view class="input-view">
-        <input class="weui-input" name="weChat" placeholder="请填写" maxlength="50" />
+        <input class="weui-input" name="wx" placeholder="请填写" maxlength="50" />
       </view>
     </view>
 
@@ -43,7 +43,7 @@
 
     <view class="textarea-box">
       <view class="title">项目简介/合作方案</view>
-      <textarea class="textarea" name="textarea" placeholder="请在此填写项目简介或初步合作方案说明..." maxlength="200"></textarea>
+      <textarea class="textarea" name="summary" placeholder="请在此填写项目简介或初步合作方案说明..." maxlength="200"></textarea>
     </view>
     <view class="line"></view>