123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- 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,
- 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
- }
- 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() {
- if(!this.data.isDjs) {
- this.signUp();
-
- }
-
- },
- // 查看地图
- 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) {
- // that.popup3.hidePopup();
- if (res.code === 0) {
- wx.hideToast();
- wx.showToast({
- title: '报名成功',
- icon: 'none'
- })
- that.popup3.hidePopup();
- that.setData({
- isDjs: false,
- maskShow: false
- })
- setTimeout(()=>{
- wx.redirectTo({
- url: '/pages/my/myTimejob/myTimejob',
- })
- },2000)
- }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();
- },
- onUnload: function () {
- clearInterval(this.data.timer)
- }
- })
|