123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626 |
- var app = getApp();
- var util = require("../../../../utils/util.js")
- let wxParse = require("../../../../wxParse/wxParse.js");
- let pageid = ""
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- bottomLeft: app.bottomLeft,
- appAssetsUrl: app.appAssetsUrl,
- appAssetsUrl2: app.appAssetsUrl2,
- maskShow: false,
- options: {},
- detail: {},
- member: {},
- content: '',
- vipActivityMessage: '',
- peopleList: [],
- people6: [],
- isMore: true,
- dotLeft: 0,
- open: true,
- schoolInfo: {},
- roleList: ['平台管理员','校园代理人','行家','行家;平台管理员','行家;校园代理人'],
- dmoney: 0,
- point: 0,
- usePoints: 0,
- isWx: false,
- activeDetail: '',
- actualPrice: 0, // 实付价格
- isDev: true //审核
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- pageid = this.options.id;
- let _this = this;
- let user = util.getUser();
- this.setData({
- options: {
- ...options,
- type: 2, //类型(1兼职 2活动)
- stuId: user ? user.id : ''
- }
- })
- _this.loadData();
- _this.loadVipSel();
- _this.addRead();
- _this.env()
- },
- joinVip() {
- wx.navigateTo({
- url: '/pages/myMember/myMember',
- })
- },
- collect: function() {
- let that = this
- if (util.getUserId()) {
- app._post_form('favorite/addOrCancelFavorite', "application/json", {
- sid: that.data.options.id,
- vipid: that.data.options.stuId,
- type: 2 //1:兼职 2:活动
- },
- function(res) {
- if (res.code == 0) {
- that.setData({
- detail: {
- ...that.data.detail,
- collect: !that.data.detail.collect
- }
- })
- wx.showToast({
- title: that.data.detail.collect ? '收藏成功' : '取消收藏',
- icon: 'success',
- duration: 2000
- })
- }
- })
- } else {
- wx.showToast({
- title: '没有登录,操作失败',
- icon: 'fail',
- duration: 2000
- })
- }
- },
- // 获取参与人员
- getUser(id) {
- app._get(`activitystu/list`, {
- pid: id
- }, res => {
- if (res.code === 0) {
- this.setData({
- people6: res.page.list.slice(0,6),
- peopleList: res.page.list
- })
-
- }
- })
- },
- //获取支付价格
- getPayPrice() {
- let that = this
- // let actualPrice = this.data.open ? this.data.detail.money - this.data.dmoney : this.data.detail.money
- let id = util.getUserId();
- app._get(`activity/eventRegistrationPayPrice`, {
- id: id,
- activityId: that.data.detail.id
- // actualPrice: actualPrice
- }, res => {
- if (res.code === 0) {
- this.setData({
- actualPrice: res.data.actualPrice,
- })
-
- }
- })
- },
- // 查看地图
- goLocal() {
- let that = this
- let [latitude,longitude] = [this.data.detail.coordinate.split(',')[0],this.data.detail.coordinate.split(',')[1]]
- console.log(Number(latitude),Number(longitude))
- wx.openLocation({
- latitude:Number(longitude),
- longitude:Number(latitude),
- name:that.data.title,
- address: that.data.address,
- success: function() {
- console.log("success");
- },
- });
- },
- // 校园代理人信息
- schoolUser(id) {
- app._get(`activity/activeCampusAgent`, {
- activityId: id
- }, res => {
- if (res.code === 0) {
- this.setData({
- schoolInfo: res.data
- })
-
- }
- })
- },
- showMore() {
- this.setData({
- isMore:!this.data.isMore
- })
- },
- // 查看二维码
- seeCode() {
- let that = this
- if(!that.data.detail.activityStuYN){
- wx.showToast({
- title: '报名后查看!',
- icon: 'none'
- })
- return
- }
- this.popup3.showPopup();
- this.setData({
- maskShow: true
- })
- },
- // 报名是否抵扣积分
- changeSwitch() {
- this.setData({
- open: !this.data.open
- })
- },
- loadData: function() {
- let _this = this;
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('act/one', "", _this.data.options, function(res) {
- if (res.code === 0) {
- _this.setData({
- detail: {
- ...res.data,
- startDate: res.data.startTime.replace(/-/g,'.').split(' ')[0],
- endDate: res.data.endTime.replace(/-/g,'.').split(' ')[0],
- startTime: res.data.startTime.split(' ')[1],
- endTime: res.data.endTime.split(' ')[1],
- registrationEnd: res.data.registrationEnd.replace(/-/g,'.'),
- meetingTime: res.data.meetingTime.replace(/-/g,'.')
- }
- })
- _this.getUser(res.data.id)
- _this.schoolUser(res.data.id)
- _this.getPoint(res.data.id)
- // _this.getPayPrice()
- if(res.data.isAppletsRelease == 1) {
- // let str = Array.from(res.data.appletsDetails)
- _this.setData({
- isWx: true
- })
-
- }else {
- _this.setData({
- isWx: false
- })
- wxParse.wxParse('content', 'html', res.data.content, _this, 0);
- // wxParse.wxParse('content', 'html', res.data.content.replace(/</g,'<'), _this, 0);
- // wxParse.wxParse('content', 'html', res.data.content.replace(/(.*)</,'$1< '), _this, 0);
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- //获得popup组件
- this.popup = this.selectComponent("#popup");
- this.popup2 = this.selectComponent("#popup2");
- this.popup3 = this.selectComponent("#popup3"); // 二维码
- this.popup4 = this.selectComponent("#popup4"); // 提示升级开通会员/升级会员
- this.popup5 = this.selectComponent("#popup5"); // 报名
- },
- addRead() {
- app._post_form('read/num', '', {
- id: this.data.options.id,
- type: 2
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- this.PushVipInfo();
- let user = util.getUser();
- this.setData({
- options: {
- ...this.data.options,
- stuId: user ? user.id : ''
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- return
- let _this = this
- if (_this.data.isyn) {
- app._post_form('favorite/addFavorite', "application/json", JSON.stringify(_this.data.parm),
- function(res) {
- console.log(res)
- })
- } else {
- app._post_form('favorite/removeFavoriteByVipid', "application/json", JSON.stringify(_this.data
- .parm),
- function(res) {
- console.log(res)
- })
- }
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- //查询会员信息
- PushVipInfo() {
- let _this = this;
- let id = util.getUserId();
- if (id) {
- app._post_form('member/apiSelectMeberInfo', 'application/json', {id}, function(
- res) {
- if (res.code === 0) {
- _this.setData({
- member:res.member
- })
- }
- })
- }
- },
- // 判断是否开发huanjing
- env(){
- let that = this
- app._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
- null,
- function (res) {
- if (res.code === 0) {
- that.setData({
- isDev: res.wgFillInfo.isDev
- })
- }
- }
- )
- },
- submit() {
- // this.popup4.showPopup();
- //报名满了
- if(this.data.detail.statusName != '报名中'){
-
- return ;
- }
-
- let that = this;
- if (util.UserLoginStatus()) {
- // 活动,会员免费,用户是会员用户 或者活动金额是0元 直接报名
- if(this.data.detail.isNeedVip == 1 && (that.data.member.memberState > 0) || that.data.detail.money == 0){
- that.signUp();
- // 活动,会员免费,用户是普通用户
- }else if(this.data.detail.isNeedVip == 1 && (that.data.member.memberState == 0)){
- if(this.data.isDev){
- wx.showToast({
- title: '暂未开始报名,请关注进度!',
- icon: 'none',
- duration: 2000
- })
- return
- }
- that.popup4.showPopup();
- }else{
- // 所有用户付费
- that.popup5.showPopup();
- }
- // if((this.data.detail.isNeedVip && (this.data.member.memberState > 0)) || !this.data.detail.isNeedVip){
- // wx.showModal({
- // title: '提示',
- // content: '您确定要报名该活动吗',
- // success (res) {
- // if (res.confirm) {
- // that.signUp();
- // }
- // }
- // })
- // that.popup5.showPopup();
- // }else if(that.data.detail.isNeedVip == 0 && (that.data.member.memberState == 0)){
- // that.popup4.showPopup();
-
- // }
- // this.setData({
- // maskShow: true
- // })
- }
- },
- confirmPay() {
- this.singPay()
- },
- singPay() {
- let that = this;
- let money = that.data.open ? that.data.actualPrice : that.data.detail.money
- if(money == 0) {
- return that.signUp()
- }
-
- wx.showLoading({
- title: '提交中...',
- })
-
- let isDeductiblePrice = that.data.open ? 1 : 0
- // act/register/wx 支付时用这个
- app._post_form('act/register/wx', "", {
- aid:that.data.options.id,
- sid: that.data.options.stuId,
- isDeductiblePrice: isDeductiblePrice
- }, function(res) {
- if (res.code === 0) {
-
- wx.showActionSheet({
- itemList: ["微信支付"],
- success: (response) => {
- if (response.tapIndex === 0) {
- wx.showLoading({
- title: "正在处理...",
- mask: true,
- });
- wx.requestPayment({
- timeStamp: res.map.timestamp,
- nonceStr: res.map.nonce_str,
- package: "prepay_id=" + res.map.prepay_id,
- signType: "MD5",
- paySign: res.map.sign,
- success: (result) => {
- if (result.errMsg == "requestPayment:ok") {
- wx.showLoading({
- title: "正在处理...",
- mask: true,
- });
- console.log(result, 11111111);
- wx.hideLoading();
- that.popup3.showPopup();
- wx.showModal({
- title: "温馨提示",
- content: "报名成功!",
- showCancel: false,
- });
- // setTimeout(()=>{
- // wx.redirectTo({
- // url: '/pages/my/myPlay/myPlay',
- // })
- // },2000)
- } else {
- wx.hideLoading();
- wx.showToast({
- title: "支付失败!",
- icon: "none",
- duration: 1500,
- });
- }
- },
- fail: (error) => {
- wx.hideLoading();
- wx.showToast({
- title: "支付失败!",
- icon: "none",
- duration: 1500,
- });
- },
- });
- }
- },
- fail(errors) {},
- })
- }else if(res.msg == '请完善资料后进行报名操作'){
- wx.hideToast();
- that.popup2.showPopup();
- }else if(res.msg.indexOf('冻结阶段') > -1){
- wx.hideToast();
- wx.showToast({
- title: res.msg,
- icon: 'none',
- duration: 3000
- })
- }
- })
- },
- signUp(){
- let that = this;
- wx.showLoading({
- title: '提交中...',
- })
- let isDeductiblePrice = that.data.open ? 1 : 0
- // act/register/wx 支付时用这个
- app._post_form('act/register/wx', "", {
- aid:that.data.options.id,
- sid: that.data.options.stuId,
- isDeductiblePrice: isDeductiblePrice
- }, function(res) {
- if (res.code === 0) {
- wx.showToast({
- title: "报名成功!",
- icon: "none",
- duration: 1500,
- });
- that.popup3.showPopup();
- // setTimeout(()=>{
- // wx.redirectTo({
- // url: '/pages/my/myPlay/myPlay',
- // })
- // },2000)
-
- }else if(res.msg == '请完善资料后进行报名操作'){
- wx.hideToast();
- that.popup2.showPopup();
- }else if(res.msg.indexOf('冻结阶段') > -1){
- wx.hideToast();
- wx.showToast({
- title: res.msg,
- icon: 'none',
- duration: 3000
- })
- }
- })
- },
- loadVipSel() {
- let _this = this;
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
- null,
- function(res) {
- if (res.code === 0) {
- setTimeout(function() {
- wxParse.wxParse('vipActivityMessage', 'html', res.wgFillInfo.vipActivityMessage, _this, 5)
- }, 300)
- }
- }
- )
- },
- showShareMenu: function() {
- wx.showShareMenu();
- this.setData({
- show: true
- })
- },
- // 校园代理人详情
- perDetail() {
- // console.log(e)
- let that = this
- let role = that.data.roleList[that.data.schoolInfo.memberRoleStatus - 1]
- wx.navigateTo({
- url: '/expert/agentdetail/agentdetail?id=' + that.data.schoolInfo.id + '&activityId=' + that.data.detail.id + '&name=' + role
- })
- },
- hideShareMenu() {
- wx.hideShareMenu();
- this.setData({
- show: false
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage(){
- this.addScore();
- return {
- title: '活动详情',
- path: '/pages/home/index/activityDetail/activityDetail?id=' + pageid,
- desc: '欢迎大家踊跃报名',
- }
- },
- //统计积分(每日小程序分享)
- addScore: function() {
- if(!util.getUserId()){
- return ;
- }
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('scoreStu/share', "", {
- stuId: util.getUserId()
- }, function(res) {
- if (res.code === 0) {}
- })
- },
- // 查询积分抵扣
- getPoint(id) {
- app._get(`activity/eventRegistrationPayPrice`, {
- activityId: id,
- id: util.getUserId()
- }, res => {
- if (res.code === 0) {
- this.setData({
- dmoney: res.data.deductiblePrice,
- point: res.data.remainingPoints,
- actualPrice: res.data.actualPrice,
- usePoints: res.data.usePoints
- })
-
- }
- })
- },
- //取消事件
- _error(e) {
- this[e.currentTarget.dataset.name].hidePopup();
- if(e.currentTarget.dataset.name=='popup4') {
- this.popup5.showPopup();
- }else {
-
- this.setData({
- maskShow: false
- })
- }
-
- },
- _error2(e) {
- this[e.currentTarget.dataset.name].hidePopup();
- this.setData({
- maskShow: false
- })
- },
- //确认事件
- _success(e) {
- let that = this
- if(e.currentTarget.dataset.name=='popup3'){
-
- }else if(e.currentTarget.dataset.name=='popup5'){
- that.singPay();
- }else if(e.currentTarget.dataset.name=='popup4'){
- wx.navigateTo({
- url: '/pages/myMember/myMember'
- })
- }else if(e.currentTarget.dataset.name=='popup2'){
- wx.navigateTo({
- url: '/pages/my/myStudy/myStudy'
- })
- }else{
- wx.navigateTo({
- url: e.currentTarget.dataset.name=='popup'?'/pages/myMember/myMember':'/pages/my/myData/myData',
- })
- }
-
- this.setData({
- maskShow: false
- })
- this[e.currentTarget.dataset.name].hidePopup();
- },
-
- seeBigCode(e) {
- let arr = [this.data.detail.qrCodePicture];
- wx.previewImage({
- urls: arr, // 需要预览的图片http链接列表
- });
- },
- })
|