// pages/my/postJob/detail.js 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, vipid: util.getUserId(), detail: {}, workContent: "", vipMsg: "", arrayPrice: [], heightList: [], priceUnit: null, heightUnit: null, sex: null, cashMethodList: [], cashMethodName: null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ detail: wx.getStorageSync("workDetail"), user: wx.getStorageSync("USER"), }); // this.ready() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { //获得popup组件 this.popup = this.selectComponent("#popup0"); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getUnit(); this.getHeightList(); this.sex(); this.getCashMethod(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, showShareMenu: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage() {}, // 预览图片 previewImage(e) { wx.previewImage({ urls: e.currentTarget.dataset.images, current: e.currentTarget.dataset.images[e.currentTarget.dataset.index], }); }, getUnit() { app._post_form("bizlibrary/infoList/workUnit", "", {}, (res) => { if (res.code === 0) { let priceUnit; for (let i = 0; i < res.dictList.length; i++) { if (res.dictList[i].itemcode == this.data.detail.unit) { priceUnit = res.dictList[i].itemname; break; } } this.setData({ priceUnit: priceUnit, arrayPrice: res.dictList, }); } }); }, getHeightList() { app._post_form("bizlibrary/infoList/workHeightLimit", "", {}, (res) => { if (res.code === 0) { let heightUnit; for (let i = 0; i < res.dictList.length; i++) { if (res.dictList[i].itemcode == this.data.detail.heightlimit) { heightUnit = res.dictList[i].itemname; break; } } this.setData({ heightUnit: heightUnit, heightList: res.dictList, }); } }); }, sex() { console.log(app.sexList, 111); let sex; let arr = [{ itemname: '仅限男生', itemcode: '01', },{ itemname: '仅限女生', itemcode: '02', },{ itemname: '男女不限', itemcode: '03', }] for (let i = 0; i < arr.length; i++) { if (arr[i].itemcode == this.data.detail.sexlimit) { sex = arr[i].itemname; break; } } this.setData({ sex: sex, }); }, // 获取结算方式 getCashMethod() { app._post_form("work/cashMethod", "", {}, (res) => { if (res.code === 0) { let cashMethodName; for (let i = 0; i < res.data.length; i++) { if (res.data[i].itemcode == this.data.detail.cashMethod) { cashMethodName = res.data[i].itemname; break; } } this.setData({ cashMethodName: cashMethodName, cashMethodList: res.data, }); } }); }, submit() { app._post_form( "work/saveWork", "", this.data.detail, (res) => { if (res.code === 0) { wx.showToast({ title: "添加成功", }); wx.removeStorageSync("workDetail"); wx.switchTab({ url: "/pages/home/index/index", }); } }, (err) => {}, (complete) => { setTimeout(() => { wx.hideLoading(); }, 300); } ); }, // 查看二维码 seeCode() { this.popup.showPopup(); }, // 查看地图 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"); }, }); }, // 会员必读 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.popup.hidePopup(); }, //确认事件 _success(e) { this.popup.hidePopup(); }, onUnload: function () { clearInterval(this.data.timer); }, });