// pages/activity/index.js const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); import { customRequest } from '../../utils/request.js'; Page({ /** * 页面的初始数据 */ data: { recordId: null, activity: [], isJob: false, recordList: [], isLogin: app.globalData.isLogin, agencyStatus: app.globalData.loginUserInfo.agencyStatus, // 是否是代理的判断 tagStyle: { p: "margin-top: 0; margin-bottom: 0;line-height: 1.8", body: " margin: 0; color: #333; font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-variant: tabular-nums; line-height: 1.8; -webkit-font-feature-settings: 'tnum'; font-feature-settings: 'tnum';", h1: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em;color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:24px; ", h2: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:21px; ", h3: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:16px; ", h4: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", h5: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", h6: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", strong: "font-weight: bolder;", b: "font-weight: bolder;", dl: "margin-top: 0; margin-bottom: 1em;", ol: "margin-top: 0; margin-bottom: 1em;", ul: "margin-top: 0; margin-bottom: 1em;", li: "line-height: 1.8", hr: "box-sizing: content-box;height:1px;overflow: visible;background-color: #ddd;border:0;", table: "border-collapse: collapse;border: 1px solid #d9d9d9;margin: 18px 0 16px 0;line-height: 1.8", td: "border: 1px solid #d9d9d9;vertical-align: top;padding: 4px 8px;line-height: 1.8", }, }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { console.log(options); if (options.recordId) { this.data.recordId = options.recordId; } this.setData({ recordId: this.data.recordId, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady () { }, /** * 生命周期函数--监听页面显示 */ onShow () { this.getActivity(); }, /** * 生命周期函数--监听页面隐藏 */ onHide () { }, getActivity () { let that = this; customRequest("/daotian/activity/get/" + that.data.recordId, {}).then((res) => { wx.setNavigationBarTitle({ title: res.data.data.activity.name, }); if (res.data.data.jobs) { var jobListTemp = commonUtil.disposeJobListData(res.data.data.jobs); jobListTemp.forEach((item) => { console.log(item); let monthlyPayStr; if (commonUtil.isNotEmptyCheck(item.minMonthlyPay) && commonUtil.isNotEmptyCheck(item.maxMonthlyPay)) { if (item.minMonthlyPay == item.maxMonthlyPay) { monthlyPayStr = item.minMonthlyPay / 100; } else { monthlyPayStr = item.minMonthlyPay / 100 + "-" + item.maxMonthlyPay / 100; } } else if (commonUtil.isNotEmptyCheck(item.minMonthlyPay)) { monthlyPayStr = item.minMonthlyPay / 100; } else if (commonUtil.isNotEmptyCheck(item.maxMonthlyPay)) { monthlyPayStr = item.maxMonthlyPay / 100; } item["monthlyPay"] = monthlyPayStr; if (app.isNotEmptyCheck(item.returnFeeType) || item.returnFeeType == "0" || item.returnFee == "0") { item["fuWuFei"] = commonUtil.getReturnFeeTypeName1ById(item.returnFeeType, item.returnFee / 100); } else { item["fuWuFei"] = ""; } console.log(item["fuWuFei"]); }); that.setData({ isJob: true, recordList: jobListTemp, }); } else { that.setData({ isJob: false, activity: res.data.data.activity, html: res.data.data.activity.content.replace(//g, ""), }); } }) // wx.request({ // url: app.globalData.ip + "/daotian/activity/get/" + that.data.recordId, // success(res) { // console.log(res); // if (res.data.status == 200) { // } // }, // }); }, goDetail (e) { console.log(e); var that = this; if (this.data.isLogin) { wx.navigateTo({ url: `../detail/index?storeJobId=${e.currentTarget.dataset.id}&jobClassify=${1}` , // url: "../detail/index?storeJobId=" + e.currentTarget.dataset.id + "&wxCode=" + that.data.wxCode, }); } else { wx.navigateTo({ url: "../login/index", }); } }, collectPaste (e) { console.log(1); var that = this; console.log(e); var collected = e.currentTarget.dataset.collected; var storeJobId = e.currentTarget.dataset.jobid; that.doCollected(collected, storeJobId); }, doCollected (collected, storeJobId) { var that = this; var url = "/user/collect/job/add"; if (collected - 1 == 0) { url = "/user/collect/job/remove"; } console.log(app.globalData.headers); //发起网络请求 customRequest(url, { header: 'headers', method: 'GET', data: { storeJobId: storeJobId, jobClassify: 1 } }).then((res) => { var txt; if (collected - 1 == 0) { //取消收藏 for (var i = 0; i != that.data.recordList.length; ++i) { if (that.data.recordList[i].id - storeJobId == 0) { that.data.recordList[i].collected = 2; break; } } txt = "取消收藏"; that.data.currentJobDrawer.collected = 2; if (that.data.choiceCollect == 1) { if (that.data.drawerShow) { that.data.drawerShow = false; } that.data.storeJobListSearchForm.pageNum = 1; that.setData({ recordList: [], drawerShow: that.data.drawerShow, storeJobListSearchForm: that.data.storeJobListSearchForm, }); that.getJobList(); } } else { //收藏 for (var i = 0; i != that.data.recordList.length; ++i) { if (that.data.recordList[i].id - storeJobId == 0) { that.data.recordList[i].collected = 1; break; } } that.data.currentJobDrawer.collected = 1; txt = "收藏成功"; } console.log(that.data.currentJobDrawer); that.setData({ recordList: that.data.recordList, currentJobDrawer: that.data.currentJobDrawer, isLogin: app.globalData.isLogin, }); wx.showToast({ icon: "none", title: txt, }); }) // wx.request({ // url: app.globalData.ip + url, // data: { // storeJobId: storeJobId, // }, // header: app.globalData.headers, // method: "GET", // success: function (res) { // }, // fail: function (res) { // console.log("操作失败"); // }, // }); }, /** * 生命周期函数--监听页面卸载 */ onUnload () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom () { }, /** * 用户点击右上角分享 */ onShareAppMessage() { return app.sharePageImage() }, });