|
@@ -1,4 +1,7 @@
|
|
// pages/student/student.js
|
|
// pages/student/student.js
|
|
|
|
+const app = getApp()
|
|
|
|
+const util = require("../../utils/util")
|
|
|
|
+const urlDef = require("../../utils/urls")
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -7,10 +10,14 @@ Page({
|
|
data: {
|
|
data: {
|
|
height: 0,
|
|
height: 0,
|
|
animation: {},
|
|
animation: {},
|
|
- left: 750
|
|
|
|
|
|
+ left: 750,
|
|
|
|
+ inviteConfig: {},
|
|
|
|
+ count: 0,
|
|
|
|
+ enroll: 0,
|
|
|
|
+ coin: '0',
|
|
|
|
+ invitations: []
|
|
},
|
|
},
|
|
-
|
|
|
|
- closeCamera:function(){
|
|
|
|
|
|
+ closeCamera: function () {
|
|
this.animation = wx.createAnimation({
|
|
this.animation = wx.createAnimation({
|
|
timingFunction: 'linear',
|
|
timingFunction: 'linear',
|
|
duration: 400
|
|
duration: 400
|
|
@@ -18,11 +25,11 @@ Page({
|
|
const left = 750
|
|
const left = 750
|
|
this.animation.translateX(left).step()
|
|
this.animation.translateX(left).step()
|
|
this.setData({
|
|
this.setData({
|
|
- animation:this.animation.export()
|
|
|
|
|
|
+ animation: this.animation.export()
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- showCamaer:function(){
|
|
|
|
|
|
+ showCamaer: function () {
|
|
this.animation = wx.createAnimation({
|
|
this.animation = wx.createAnimation({
|
|
timingFunction: 'linear',
|
|
timingFunction: 'linear',
|
|
duration: 100
|
|
duration: 100
|
|
@@ -30,13 +37,11 @@ Page({
|
|
const left = 0
|
|
const left = 0
|
|
this.animation.translateX(left).step()
|
|
this.animation.translateX(left).step()
|
|
this.setData({
|
|
this.setData({
|
|
- animation:this.animation.export(),
|
|
|
|
|
|
+ animation: this.animation.export(),
|
|
left
|
|
left
|
|
})
|
|
})
|
|
-
|
|
|
|
},
|
|
},
|
|
-
|
|
|
|
- scanCode:function(e){
|
|
|
|
|
|
+ scanCode: function (e) {
|
|
console.log(JSON.stringify(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 () {
|
|
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)
|
|
}
|
|
}
|
|
|
|
+
|
|
})
|
|
})
|