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: {}, isyn: false, vipid: util.getUserId(), detail: { tags: [], appraiseManageVoList: [], collect: false, }, workContent: "", attention: "", member: {}, time: 5, timer: null, isDjs: false, isShowPop: true, peopleList: [], people6: [], isMore: true, dotLeft: 0, vipMsg: "", isWx: false, isDev: true, //审核 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { pageid = options.id; let _this = this; let user = util.getUser(); this.setData({ options: { ...options, type: 1, //类型(1兼职 2活动) stuId: user ? user.id : "", }, }); _this.loadData(); _this.addRead(); _this.ready(); _this.env(); }, 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: 1, //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, }); } }, loadData: function () { let _this = this; wx.showLoading({ title: "努力加载中...", }); app._post_form("work/one", "", _this.data.options, function (res) { if (res.code === 0) { _this.setData({ detail: res.data, }); _this.getUser(res.data.id); if (res.data.isAppletsRelease == 1) { // 小程序发布 _this.setData({ isWx: true, }); } else { // 后台发布 _this.setData({ isWx: false, }); wxparse.wxParse( "workContent", "html", res.data.workContent, _this, 0 ); wxparse.wxParse("attention", "html", res.data.attention, _this, 0); } } }); }, // 获取参与人员 getUser(id) { app._get( `work/participants`, { workId: id, }, (res) => { if (res.code === 0) { this.setData({ people6: res.list.slice(0, 6), peopleList: res.list, }); } } ); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { //获得popup组件 this.popup = this.selectComponent("#popup"); this.popup2 = this.selectComponent("#popup2"); this.popup0 = this.selectComponent("#popup0"); this.popup3 = this.selectComponent("#popup3"); this.popup4 = this.selectComponent("#popup4"); }, addRead() { app._post_form("read/num", "", { id: this.data.options.id, type: 1, }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.PushVipInfo(); let user = util.getUser(); this.setData({ options: { ...this.data.options, stuId: user ? user.id : "", }, }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, showShareMenu: function () { wx.showShareMenu(); }, hideShareMenu() { wx.hideShareMenu(); }, //查询会员信息 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, }); } } ); } }, /** * 用户点击右上角分享 */ onShareAppMessage() { this.addScore(); return { title: "兼职详情", path: `/pages/home/index/partDetail/partDetail?id=${pageid}`, desc: "欢迎大家踊跃报名", }; }, //统计积分(每日小程序分享) addScore: function () { if (!util.getUserId()) { return; } let _this = this; wx.showLoading({ title: "努力加载中...", }); app._post_form( "scoreStu/share", "", { stuId: util.getUserId(), }, function (res) { if (res.code === 0) {} } ); }, // 预览图片 previewImage(e) { wx.previewImage({ urls: e.currentTarget.dataset.images, current: e.currentTarget.dataset.images[e.currentTarget.dataset.index], }); }, // 判断是否开发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() { let that = this; //报名满了 if (this.data.detail.statusName != "预定中") { return; } if (util.UserLoginStatus()) { 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.popup4.showPopup(); that.setData({ maskShow: true, }); } else { if (that.data.isDev) { wx.showToast({ title: "暂未开始报名,请关注进度!", icon: "none", duration: 2000, }); return; } wx.showToast({ title: "您还不是会员,报名请联系平台客服处理", icon: "none", duration: 2000, }); // this.popup.showPopup(); // this.setData({ // maskShow: true, // }); } } }, showMore() { this.setData({ isMore: !this.data.isMore, }); }, // 查看二维码 seeCode() { if (!this.data.detail.workStuYN) { wx.showToast({ title: "请报名后查看", icon: "error", duration: 2000, }); return; } this.popup0.showPopup(); this.setData({ maskShow: true, }); // let that = this // this.popup3.showPopup(); // this.setData({ // maskShow: true, // isDjs: true, // timer: setInterval(that.countDown, 1000) // }) }, //倒计时 countDown() { var that = this; if (that.data.time <= 0) { this.setData({ isDjs: false, time: 5, }); clearInterval(that.data.timer); } else { --that.data.time; this.setData({ isDjs: true, time: that.data.time, }); } }, // 我已知晓 know() { this.popup3.hidePopup(); this.loadData(); if (this.data.isShowPop) { this.setData({ isShowPop: false, isDjs: false, maskShow: false, }); this.signUp(); } // if (!this.data.isDjs) {} }, // 查看地图 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.detail.title, address: that.data.detail.address, success: function () { console.log("success"); }, }); }, signUp() { let that = this; wx.showLoading({ title: "提交中...", }); app._post_form( "work/register", "", { wid: that.data.options.id, sid: that.data.options.stuId, }, function (res) { if (res.code === 0) { wx.hideToast(); wx.showToast({ title: "报名成功", icon: "none", }); if (that.data.isShowPop) { that.popup3.hidePopup(); that.setData({ isShowPop: false, isDjs: true, maskShow: true, timer: setInterval(that.countDown, 1000), }) } else { that.setData({ isShowPop: false, isDjs: false, maskShow: false, }); } that.loadData(); setTimeout(() => { that.popup0.showPopup(); that.setData({ maskShow: true, }); // wx.redirectTo({ // url: '/pages/my/myTimejob/myTimejob', // }) }, 1000); } else if (res.code == 502) { setTimeout(() => { that.loadData() }, 500); } else if (res.msg == "请完善学籍认证后进行报名操作") { wx.hideToast(); that.popup2.showPopup(); } } ); }, // 会员必读 ready() { let _this = this; app._post_form( "wgfillinfo/apiSelectwgfillinfo", "application/json", null, function (res) { if (res.code === 0) { // _this.setData({ // vipMsg: res.wgFillInfo.vipMessage // }) wxparse.wxParse( "vipMsg", "html", res.wgFillInfo.vipMessage, _this, 0 ); } } ); }, //取消事件 _error(e) { this[e.currentTarget.dataset.name].hidePopup(); this.setData({ maskShow: false, isDjs: false, time: 5, }); clearInterval(this.data.timer); }, //确认事件 _success(e) { let that = this; if (e.currentTarget.dataset.name == "popup0") {} else if (e.currentTarget.dataset.name == "popup4") { if (that.data.detail.isNeedVip && that.data.member.memberState > 0) { that.popup3.showPopup(); that.setData({ maskShow: true, isDjs: true, timer: setInterval(that.countDown, 1000), }); console.log("会员"); } else { // that.popup3.hidePopup(); // that.setData({ // isDjs: false, // maskShow: false, // time: 5 // }) that.signUp(); console.log("非会员"); } } 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链接列表 }); }, onUnload: function () { clearInterval(this.data.timer); }, });