You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1363 lines
35 KiB
JavaScript

2 years ago
const app = getApp();
const commonUtil = require("../../utils/commonUtil.js");
Page({
data: {
toped: "1",
chaShowed: false,
backHeight:wx.getMenuButtonBoundingClientRect().top + (wx.getMenuButtonBoundingClientRect().height/2) +'px',
isTrigger: false,
// background: ["../../assets/images/banner1.jpg", "../../assets/images/banner2.jpg", "../../assets/images/banner3.jpg", "../../assets/images/banner4.jpg"],
pullNum: 0, //下拉次数
tabs: [],
activeTab: 0,
systemInfo: {},
getMenuButtonBoundingClientRect: {},
// 手机基础信息
tabs2: [],
loadMore: "",
loadContent: ["马不停蹄加载更多数据中...", "-- 已经到底了,加不了咯 --"],
statusBarHeight: wx.getStorageSync("statusBarHeight"), // 状态栏高度
navigationBarHeight: wx.getStorageSync("navigationBarHeight"), // 导航栏高度
menuButtonHeight: wx.getStorageSync("menuButtonHeight"), // 胶囊按钮高度
menuButton: wx.getStorageSync("menuButtonInfo"), // 胶囊信息
navigatorHeight: 60,
activeTab2: 0,
contentIndex: 0,
latestClass: 0,
zoneClass: 0,
recordList: [],
jobSpecialLabelNames: [],
storeJobListSearchForm: {
pageNum: 1,
pageSize: 20,
classify: 1,
sex: -1,
workTypeStr: "",
lat: "",
lng: "",
jobClassify: "",
sortTag: 0,
jobSpecialLabelIds: "",
cityName: "",
brandIds: "",
jobCategoryLabelIds: "",
ucj: 1,
},
loading: true,
topJobList: [],
hasLocation: false,
chooseActive: false, //筛选是否高亮
labelItems: [],
checkedlabelItems: [],
hasMoreData: false, //下拉是否还有更多数据
inputShowed: false,
inputVal: "搜索工作",
wxCode: "",
isCollect: false,
collectTxt: "收藏",
isLogin: app.globalData.isLogin,
hasUserInfo: 0,
searchCityParamStorage: {
name: "",
shortName: "",
},
iosDialog1: false,
phoneDialog: false,
triggered: false,
pageShow: false,
whichOneShow: "",
siv: "",
activez: "zuigao",
sexid: "-1", // 性别筛选的id
dialog1: false,
dialog2: false,
jobSpecialLabelList: [],
brandList: [],
firstMenu: "排序", // 工价筛选tab显示
secondMenu: "性别", // 性别筛选tab显示
selectBrandList: [], // 选中的品牌标签
selectJobList: [], // 选中的特色标签
tagArray0: [],
tagArray1: [],
tagArray2: [],
tagArray3: [],
tagArray4: [],
recordBillType: "", // 报名类型(拍照或者直接报名)
signType: 0, // 职位类型(自营 三方)
recordCount: 0,
totalPage: 0,
currPage: 0,
currentJobDrawer: {}, // 当前简版职位抽屉信息
drawerShow: false, // 简版职位抽屉显隐
choiceCollect: 0, //收藏的筛选
corpUserFlag: app.globalData.loginUserInfo.corpUserFlag, // 内部成员的判断
agencyStatus: app.globalData.loginUserInfo.agencyStatus, // 是否是代理的判断
serviceInfo: {}, // 代理信息
navigatorBarHeight: 0, // 头部整体高度信息
iosDialog: false, // 成为代理弹窗
isLoading: true, // 成为代理图片加载loading效果
isScrollTop: false, // 控制职位列表的滚动
swiperTextList: ["日结工", "18岁", "电子厂", "短期工", "47岁", "保底", "小时工"], // 关键词轮播的关键词列表
placeholderText: "", // 当前关键词
leftShow: false, // 左侧智能匹配抽屉显示
from:'',
/**
* 滑动相关变量
*/
lastX: 0, //滑动开始x轴位置
lastY: 0, //滑动开始y轴位置
text: "没有滑动",
currentGesture: 0, //标识手势
listPosition: null, // 存储列表当前位置
halfHide: true, // 智能匹配显示一半控制
topNum: 0,
scrollTo: "", // 列表滚动的控制
navList: [
{
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/ztrt.png",
url: "/pages/hotList/index",
title: "主推/热推",
},
2 years ago
// { img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/dtld.png",url:'/pages/hotList/index', title: "报名助手亮点" },
2 years ago
// { img: "http://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/zjzp.png",url:'/pages/hotList/index', title: "职教职培" },
{
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/cwdl.png",
url: "/pages/tobeAgency/index",
title: "成为代理",
},
// { img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/dzkf.png",url:'/pages/hotList/index', title: "定制开发" },
{
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/xmhz.png",
url: "/pages/xiangmuhezuo/index",
title: "项目合作",
},
{
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/xtxx.png",
url: "/pages/message/index",
title: "消息中心",
},
{
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/lxwm.png",
url: "/pages/connectUs/index",
title: "联系我们",
},
// { img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/jqqd.png",url:'/pages/hotList/index', title: "敬请期待" },
],
bannerList: [],
/**
* 筛选的相关变量
*
*
*/
filterData: {
yanba: [
{
name: "无",
id: 1,
active: 0,
},
{
name: "小面积",
id: 2,
active: 0,
},
{
name: "大面积",
id: 3,
active: 0,
},
],
area: [
{
name: "江浙沪",
id: 1,
active: 0,
},
{
name: "鄂豫皖",
id: 2,
active: 0,
},
{
name: "京津冀",
id: 3,
active: 0,
},
{
name: "晋西北",
id: 4,
active: 0,
},
{
name: "粤桂闽",
id: 5,
active: 0,
},
{
name: "鲁东南",
id: 6,
active: 0,
},
{
name: "黑吉辽",
id: 7,
active: 0,
},
{
name: "疆藏青",
id: 8,
active: 0,
},
{
name: "渝湘赣",
id: 9,
active: 0,
},
{
name: "陕甘宁",
id: 10,
active: 0,
},
{
name: "云贵川",
id: 11,
active: 0,
},
{
name: "港澳台",
id: 12,
active: 0,
},
],
price: [
{
name: "3000-4000",
id: 1,
active: 0,
},
{
name: "4000-5000",
id: 2,
active: 0,
},
{
name: "5000-6000",
id: 3,
active: 0,
},
{
name: "6000-7000",
id: 4,
active: 0,
},
{
name: "7000-8000",
id: 5,
active: 0,
},
{
name: "8000以上",
id: 6,
active: 0,
},
],
sex: [
{
name: "男",
id: 1,
active: 0,
},
{
name: "女",
id: 2,
active: 0,
},
{
name: "男女不限",
id: -1,
active: -1,
},
],
jobFilter: {
tagArray0: [],
tagArray1: [],
tagArray2: [],
tagArray3: [],
tagArray4: [],
},
classifyList: [],
},
copyList: {},
innerFilter: false,
},
goBack(){
wx.navigateBack({
delta: -1,
})
},
// onPullDownRefresh:function(){
// this.getJobList();
// console.log(123);
// wx.stopPullDownRefresh({
// success() {
// app.refreshSuccess();
// }
// });
// },
goLogin() {
wx.setStorageSync("comeFromPage", "index");
wx.navigateTo({
url: "/pages/login/index",
});
},
onScrollRefresh: function () {
var that = this;
that.data.storeJobListSearchForm.pageNum = 1;
that.setData({
recordList: [],
});
that.getJobList();
},
cc: function () {},
onShareAppMessage: function () {
var path = commonUtil.getCurrentPageUrlWithArgs();
if (app.globalData.isLogin && app.globalData.agencyStatus - 0 != 0) {
//当前用户是代理人
path += (path.indexOf("?") >= 0 ? "&" : "?") + "agencyUserId=" + app.globalData.loginUserInfo.id;
}
console.log(path);
let img;
this.data.templateList.forEach((element) => {
2 years ago
if (element.title == "报名助手小程序首页卡片分享封面") {
2 years ago
img = element.img + "?" + new Date().getTime();
}
});
return {
title: " ",
path: path,
imageUrl: img,
};
},
/**
* 清除本地缓存
*
*
*/
clear() {
wx.clearStorage();
console.log("清除成功");
},
onLoad(options) {
var that = this;
console.log(options.from == 'shoucang');
console.log(wx.getSystemInfoSync());
// Array.prototype.logResult = function(){
// console.log('Array');
// }
if(options.from == 'shoucang'){
wx.setNavigationBarTitle({
title: '我的收藏',
})
this.setData({
from: 'shoucang',
});
}else if(options.from == 'baoming'){
wx.setNavigationBarTitle({
title: '我的报名',
})
this.setData({
from: 'baoming',
});
}
this.setData({
placeholderText: this.data.swiperTextList[0],
});
let arr = [];
arr.logResult();
// 查看是否授权
wx.getSetting({
success(res) {
if (res.authSetting["scope.userInfo"]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({
success: function (res) {
console.log(res.userInfo);
},
});
}
},
});
// if (app.isNotEmptyCheck(options.fromSearchPage) && options.fromSearchPage == 1) {
// try {
// var searchCityParamStorage = wx.getStorageSync("searchCityParamStorage");
// if (searchCityParamStorage) {
// console.log("searchCityParamStorage======", searchCityParamStorage);
// that.data.storeJobListSearchForm.cityName = searchCityParamStorage.name;
// if (app.isEmptyCheck(searchCityParamStorage.name)) {
// that.data.storeJobListSearchForm.cityName = "全国";
// }
// that.setData({
// searchCityParamStorage: searchCityParamStorage,
// });
// }
// } catch (e) {
// console.log("获取缓存设置的查询职位列表参数错误:", e);
// }
// } else {
// try {
// wx.removeStorageSync("searchJobListParamStorage");
// } catch (e) {
// console.log("删除缓存设置的查询职位列表参数错误:", e);
// }
// try {
// wx.removeStorageSync("searchCityParamStorage");
// } catch (e) {
// console.log("删除缓存设置的查询职位列表参数错误:", e);
// }
// }
try {
if (app.globalData.isScanQRCodes - 1 == 0) {
wx.showToast({
title: "欢迎查看好工作",
icon: "success",
duration: 2000,
});
if (!getApp().globalData.isLogin) {
setTimeout(function () {
if (!getApp().globalData.isLogin) {
that.openIOS2();
}
}, 5000);
}
}
} catch (e) {
console.log("获取缓存设置的查询职位列表参数错误:", e);
}
console.log("options==============================1");
console.log(options);
console.log("options==============================2");
if (app.isNotEmptyCheck(options.scene)) {
//扫小程序码携带参数
var sceneStr = decodeURIComponent(options.scene);
var sceneJson = commonUtil.sceneToJson(sceneStr);
console.log("sceneJson===", sceneJson);
if (sceneJson.fromType == 1) {
app.globalData.isCommission = 1;
wx.setStorageSync("storageSyncAgencyUserId", sceneJson.userId);
}
//先设置代理人缓存人再登录
app.getLoginUserTokenInfo();
} else if (app.isNotEmptyCheck(options.fromType)) {
//扫小程序普通二维码携带参数-来源ID
console.log("options.fromType========" + options.fromType);
if (options.fromType == 0) {
console.log("options.id========" + options.id);
console.log("options.userId========" + options.userId);
try {
app.globalData.isCommission = 1;
wx.setStorageSync("fromQrCodeChannelContactId", options.id);
that.getAgencyUserId(options.id);
} catch (e) {
console.log("0-扫描微信二维码,设置参数错误:", e);
}
} else if (options.fromType.indexOf("0&id=") >= 0) {
//兼容2021-9-9之前的二维码
var paramsTempId = options.fromType.replace("0&id=", "");
console.log("&paramsTempId========" + paramsTempId);
try {
app.globalData.isCommission = 1;
wx.setStorageSync("fromQrCodeChannelContactId", paramsTempId);
that.getAgencyUserId(paramsTempId);
} catch (e) {
console.log("0-扫描微信二维码,设置参数错误:", e);
}
} else {
//兼容2021-9-9之前的二维码
var paramsTempId = options.fromType.replace("0,id=", "");
console.log("=paramsTempId========" + paramsTempId);
try {
app.globalData.isCommission = 1;
wx.setStorageSync("fromQrCodeChannelContactId", paramsTempId);
that.getAgencyUserId(paramsTempId);
} catch (e) {
console.log("0-扫描微信二维码,设置参数错误:", e);
}
}
} else {
console.log("options.fromType===else=====" + options);
}
//this.wxLogin();
let res = wx.getStorageSync("storeJobId"); //详情页返回
console.log(res);
if (app.isEmptyCheck(res.data)) {
this.setData({
recordList: [],
});
} else {
wx.removeStorageSync({
key: "storeJobId",
});
}
console.log("on show");
//登录=================================start
if (app.globalData.isLogin) {
this.setData({
isLogin: app.globalData.isLogin,
hasUserInfo: app.globalData.hasUserInfo,
agencyStatus: app.globalData.loginUserInfo.agencyStatus,
corpUserFlag: app.globalData.loginUserInfo.corpUserFlag,
userInfo: app.globalData.loginUserInfo,
serviceInfo: app.globalData.serviceInfo,
isLoading: true,
});
} else {
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userLoginCallback = (res) => {
this.setData({
isLogin: app.globalData.isLogin,
hasUserInfo: app.globalData.hasUserInfo,
agencyStatus: app.globalData.loginUserInfo.agencyStatus,
corpUserFlag: app.globalData.loginUserInfo.corpUserFlag,
userInfo: app.globalData.loginUserInfo,
serviceInfo: app.globalData.serviceInfo,
});
console.log(that.data.serviceInfo);
};
console.log(that.data.serviceInfo);
}
//登录=================================end
var reset = true;
let agencyUserId = options.agencyUserId;
if (agencyUserId) {
wx.setStorageSync("storageSyncAgencyUserId", agencyUserId);
console.log("agencyUserId", agencyUserId);
app.globalData.isCommission = 1;
}
app.getLoginUserTokenInfo();
// this.getJobList();
if (wx.getStorageSync("FILTER_LIST")) {
let list = wx.getStorageSync("FILTER_LIST");
list.forEach((item) => {
item.active = 0;
if (item.typeClassify == "0") {
this.data.filterData.jobFilter["tagArray0"].push(item);
} else if (item.typeClassify == "1") {
this.data.filterData.jobFilter["tagArray1"].push(item);
} else if (item.typeClassify == "2") {
this.data.filterData.jobFilter["tagArray2"].push(item);
} else if (item.typeClassify == "3") {
this.data.filterData.jobFilter["tagArray3"].push(item);
} else if (item.typeClassify == "4") {
this.data.filterData.jobFilter["tagArray4"].push(item);
}
});
let jobFilter = "filterData.jobFilter";
this.setData({
[jobFilter]: this.data.filterData.jobFilter,
});
}
if (wx.getStorageSync("CLASSIFY_LIST")) {
this.data.filterData.classifyList = wx.getStorageSync("CLASSIFY_LIST");
this.data.filterData.classifyList.forEach((item) => {
item.active = 0;
});
let classifyList = "filterData.classifyList";
this.setData({
[classifyList]: this.data.filterData.classifyList,
});
}
this.setData({
copyList: JSON.parse(JSON.stringify(this.data.filterData)),
});
// that.getJobList();
},
/**
* 智能匹配结束
*
*
*
*/
/**
* 获取banner信息
*
*
*/
onChange(e) {
const index = e.detail.index;
this.setData({
activeTab: index,
});
},
emptyMethod(e) {
console.log(e);
},
onShow() {
let that = this;
that.setData({
recordList: [],
});
that.data.storeJobListSearchForm.pageNum = 1;
wx.setStorageSync("BILLFROM", "firstBill");
// wx.showTabBar({
// success(e) {},
// });
// let index = 1;
// that.setData({
// placeholderText: that.data.swiperTextList[0],
// });
// setInterval(() => {
// that.data.placeholderText = that.data.swiperTextList[index % that.data.swiperTextList.length];
// that.setData({
// placeholderText: that.data.placeholderText,
// });
// index++;
// }, 5000);
if (wx.getStorageSync("FROMCITY")) {
try {
var searchCityParamStorage = wx.getStorageSync("searchCityParamStorage");
if (searchCityParamStorage) {
console.log("searchCityParamStorage======", searchCityParamStorage);
that.data.storeJobListSearchForm.cityName = searchCityParamStorage.name;
if (app.isEmptyCheck(searchCityParamStorage.name)) {
that.data.storeJobListSearchForm.cityName = "全国";
}
that.setData({
searchCityParamStorage: searchCityParamStorage,
storeJobListSearchForm: that.data.storeJobListSearchForm,
});
that.setData({
recordList: [],
});
}
} catch (e) {
console.log("获取缓存设置的查询职位列表参数错误:", e);
}
wx.removeStorageSync("FROMCITY");
}else{
that.setData({
recordList: [],
});
}
if (typeof this.getTabBar === "function" && this.getTabBar()) {
this.getTabBar().setData({
selected: 0,
isShow: true,
});
}
wx.setStorageSync("comeFromPage", "index");
this.setData({
storeJobListSearchForm: that.data.storeJobListSearchForm,
isLogin: app.globalData.isLogin,
recordBillType: "",
});
console.log(app.globalData);
setTimeout(() => {
if (app.globalData.isLogin) {
that.setData({
agencyStatus: app.globalData.loginUserInfo.agencyStatus,
corpUserFlag: app.globalData.loginUserInfo.corpUserFlag,
userInfo: app.globalData.loginUserInfo,
serviceInfo: app.globalData.serviceInfo,
});
console.log(app.globalData.loginUserInfo);
} else {
that.setData({
serviceInfo: app.globalData.serviceInfo,
});
this.wxLogin();
}
}, 100);
console.log(app.globalData.headers);
// if (that.data.inputVal != "搜索工作") {
// console.log(that.data.inputVal);
// that.setData({
// recordList: [],
// });
// that.getJobList();
// }
wx.removeStorage({
key: "townsManInfo",
});
wx.removeStorage({
key: "townsManInfoJob",
});
/*this.wxLogin();
let res = wx.getStorageSync({
key: "storeJobId"
}); //详情页返回
if (app.isEmptyCheck(res.data)) {
this.setData({
recordList: []
});
} else {
wx.removeStorageSync({
key: "storeJobId"
});
}
console.log("on show");
var reset = true;*/
this.getJobList();
},
getJobList() {
var that = this;
// debugger
that.setData({
pageShow: false,
});
return new Promise(function (resolve, reject) {
if (that.data.storeJobListSearchForm.sortTag == 2) {
//如果按照距离排序,拼接上坐标
that.data.storeJobListSearchForm.lng = app.globalData.lng;
that.data.storeJobListSearchForm.lat = app.globalData.lat;
}
console.log(that.data.inputVal);
that.data.storeJobListSearchForm.cityName = that.data.searchCityParamStorage.name;
if (app.isEmptyCheck(that.data.searchCityParamStorage.name)) {
that.data.storeJobListSearchForm.cityName = "全国";
}
that.data.storeJobListSearchForm.keys = that.data.inputVal == "搜索工作" ? "" : that.data.inputVal;
// debugger;
wx.showLoading({
title: "加载中...",
});
console.log(that.data.storeJobListSearchForm);
let url = '';
if(that.data.from == 'shoucang'){
url = '/overall/store/job/list'
}else if(that.data.from == 'baoming'){
url = '/yishoudan/user/apply/order/mine'
}
wx.request({
url: app.globalData.ip + url,
method: "POST",
header: app.globalData.headers,
data: that.data.storeJobListSearchForm,
success: function (res) {
console.log("职位列表↓↓↓↓");
console.log(res);
if(that.data.from == 'baoming'){
res.data.data.recordList = res.data.data.list
}
that.setData({
totalPage: res.data.data.pageCount,
currPage: res.data.data.currentPage,
});
setTimeout(function () {
that.setData({
triggered: false,
});
}, 1000);
if (res.data.data.recordList == null || res.data.data.recordList.length == 0 || res.data.data.recordList.length < that.data.storeJobListSearchForm.pageSize) {
var jobListTemp = commonUtil.disposeJobListData(res.data.data.recordList);
that.data.recordList = that.data.recordList.concat(jobListTemp);
that.setData({
recordList: that.data.recordList,
hasMoreData: false,
isTrigger: false,
});
} else {
var jobListTemp = commonUtil.disposeJobListData(res.data.data.recordList);
that.data.recordList = that.data.recordList.concat(jobListTemp);
that.setData({
recordList: that.data.recordList,
hasMoreData: true,
isTrigger: false,
});
}
wx.hideLoading({
success: (res) => {},
});
that.setData({
loading: false,
pageShow: true,
storeJobListSearchForm: that.data.storeJobListSearchForm,
});
resolve();
that.data.recordList.forEach((item, index) => {
// console.log(item);
if (app.isNotEmptyCheck(item.returnFeeType) || item.returnFeeType == "0" || item.returnFee == "0") {
item["fuWuFei"] = commonUtil.getReturnFeeTypeName1ById(item.returnFeeType, item.returnFee);
} else {
item["fuWuFei"] = "";
}
// 简版弹窗通告显示
if (item.id == that.data.currentJobDrawer.id) {
item["jobDesp"] = item.jobDesp.replace(/\*\*\*\*\*/g, "").split("————————")[0];
// 展示用字段
item["jobDesp1"] = item.jobDesp.replace("⚠", "<i class='t-icon t-icon-zhuyi' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>");
item["jobDesp1"] = item.jobDesp1.replace("[红包]", "<i class='t-icon t-icon-hongbao' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>");
that.data.currentJobDrawer = {
...item,
index: that.data.currentJobDrawer.index ? that.data.currentJobDrawer.index : null,
};
}
});
that.setData({
recordList: that.data.recordList,
currentJobDrawer: that.data.currentJobDrawer,
});
// if (that.data.recordList.length < res.data.data.recordCount) {
// that.setData({
// hasMoreData: true,
// });
// } else {
// that.setData({
// hasMoreData: false,
// });
// }
},
});
});
},
/**
* 标准详情
*
*
*/
goDetail(e) {
console.log(e);
var that = this;
if (this.data.isLogin) {
wx.navigateTo({
url: "../detail/index?storeJobId=" + e.currentTarget.dataset.id + "&wxCode=" + that.data.wxCode+ "&fromShoucangOrBaoming="+that.data.from,
});
} else {
wx.navigateTo({
url: "../login/index",
});
}
},
goEnroll(e) {
console.log(e);
// wx.navigateTo({
// url: "../newEnroll/index?applyType=0"
// });
var that = this;
wx.removeStorageSync("townsManInfo");
wx.removeStorageSync("townsManInfoJob");
wx.removeStorageSync("storeInfoJob");
// if(app.isNotEmptyCheck(wx.getStorage('townsManInfo'))){
// wx.removeStorageSync('townsManInfo')
// }
// if(app.isNotEmptyCheck(wx.getStorage('townsManInfoJob'))){
// wx.removeStorageSync('townsManInfoJob')
// }
// if(app.isNotEmptyCheck(wx.getStorage('storeInfoJob'))){
// wx.removeStorageSync('storeInfoJob')
// }
// wx.removeStorageSync('townsManInfoJob')
console.log(app.globalData.loginUserInfo.tel);
wx.setStorageSync("jobDetailStorage", that.data.recordList[e.currentTarget.dataset.idx]);
let argument;
argument = JSON.stringify(e.currentTarget.dataset.info).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/enroll/index?applyType=1&info=${argument}`,
});
},
wxLogin() {
var that = this;
wx.login({
success(res) {
if (res.code) {
that.setData({
wxCode: res.code,
});
} else {
console.log("获取code失败" + res.errMsg);
}
},
});
},
getPhoneNumber(e) {
var that = this;
console.log(e);
console.log(e.detail.errMsg);
/*wx.setStorageSync({
key: "jobDetailStorage",
data: that.data.recordList[e.currentTarget.dataset.idx]
});*/
wx.setStorageSync("jobDetailStorage", that.data.recordList[e.currentTarget.dataset.idx]);
// console.log(e);
// console.log(e.detail.errMsg)
// console.log(e.detail.iv)
// console.log(e.detail.encryptedData)
if ("getPhoneNumber:ok" == e.detail.errMsg) {
//同意
var iv = e.detail.iv;
var encryptedData = e.detail.encryptedData;
console.log(iv, "=-=========", encryptedData);
wx.checkSession({
success() {
//session_key 未过期,并且在本生命周期一直有效
wx.request({
url: app.globalData.ip + "/getWechatTel",
data: {
code: that.data.wxCode,
iv: iv,
encryptedData: encryptedData,
type: "yishoudan",
appId:app.globalData.appId
},
success: function (res) {
console.log(res);
app.globalData.openId = res.data.data.openId;
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
var collected = e.currentTarget.dataset.collected;
if (collected) {
promise.then((res) => {
that.setData({
isLogin: app.globalData.isLogin,
});
that.doCollected(collected, e.currentTarget.dataset.jobid);
// that.collectedStoreJobList();
});
} else {
if (that.data.recordBillType == "photo" || that.data.recordBillType == "record") {
promise.then((res) => {
if (that.data.recordBillType == "photo") {
that.chooseIdCard();
} else {
that.navigatorToRecord();
}
});
} else {
promise.then((res) => {
let argument;
argument = JSON.stringify(e.currentTarget.dataset.info).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/enroll/index?applyType=1&info=${argument}`,
});
});
}
}
},
fail: function (res) {
console.log("获取用户手机号错误");
},
});
},
fail() {
// session_key 已经失效,需要重新执行登录流程
wx.login({
success(res) {
if (res.code) {
console.log(res.code);
//发起网络请求
wx.request({
url: app.globalData.ip + "/getWechatTel",
data: {
code: res.code,
iv: iv,
encryptedData: encryptedData,
type: "yishoudan",
appId:app.globalData.appId
},
success: function (res) {
console.log(res);
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
var collected = e.currentTarget.dataset.collected;
if (collected) {
promise.then((res) => {
that.setData({
isLogin: app.globalData.isLogin,
});
that.doCollected(collected, e.currentTarget.dataset.jobid);
});
} else {
promise.then((res) => {
wx.navigateTo({
url: "../enroll/index?applyType=1",
//url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber
});
});
}
},
fail: function (res) {
console.log("获取用户手机号错误");
},
});
} else {
console.log("获取手机号失败!" + res.errMsg);
}
},
});
},
});
} else {
//拒绝
var collected = e.currentTarget.dataset.collected;
if (collected) {
try {
wx.setStorageSync("comeFromPage", "index");
} catch (e) {
console.log("index-页面跳转,设置参数错误:", e);
}
wx.navigateTo({
url: "/pages/login/index",
});
} else {
wx.navigateTo({
url: "../enroll/index?applyType=1",
});
}
}
return false;
},
getPhoneNumber1(e) {
var that = this;
console.log(e);
console.log(e.detail.errMsg);
that.close();
// console.log(e);
// console.log(e.detail.errMsg)
// console.log(e.detail.iv)
// console.log(e.detail.encryptedData)
if ("getPhoneNumber:ok" == e.detail.errMsg) {
//同意
var iv = e.detail.iv;
var encryptedData = e.detail.encryptedData;
wx.checkSession({
success() {
//session_key 未过期,并且在本生命周期一直有效
wx.request({
url: app.globalData.ip + "/getWechatTel",
data: {
code: that.data.wxCode,
iv: iv,
encryptedData: encryptedData,
type: "yishoudan",
appId:app.globalData.appId
},
success: function (res) {
console.log(res);
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
promise.then((res) => {
that.setData({
isLogin: app.globalData.isLogin,
});
that.onScrollToLower();
});
},
fail: function (res) {
console.log("获取用户手机号错误");
},
});
},
fail() {
// session_key 已经失效,需要重新执行登录流程
wx.login({
success(res) {
if (res.code) {
console.log(res.code);
//发起网络请求
wx.request({
url: app.globalData.ip + "/getWechatTel",
data: {
code: res.code,
iv: iv,
encryptedData: encryptedData,
type: "yishoudan",
appId:app.globalData.appId
},
success: function (res) {
console.log(res);
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
promise.then((res) => {
that.setData({
isLogin: app.globalData.isLogin,
});
});
},
fail: function (res) {
console.log("获取用户手机号错误");
},
});
} else {
console.log("获取手机号失败!" + res.errMsg);
}
},
});
},
});
} else {
//拒绝
if (e.currentTarget.dataset.type != "close") {
try {
wx.setStorageSync("comeFromPage", "index");
} catch (e) {
console.log("index-页面跳转,设置参数错误:", e);
}
wx.navigateTo({
url: "/pages/login/index",
});
} else {
that.close();
}
}
return false;
},
modalMove() {
return false;
},
/**
* 获取搜索轮播的关键字索引
*
*
*/
goList() {
wx.navigateTo({
url: "/pages/filterPage/index",
});
},
recordBill(e) {
if (!this.data.isLogin) {
wx.navigateTo({
url: "/pages/login/index",
});
return;
}
console.log(e.currentTarget.dataset.job);
console.log(123);
let middleInfo = e.currentTarget.dataset.job;
let info = JSON.stringify({
id: middleInfo.id,
jobName: middleInfo.jobName,
storeName: middleInfo.storeName,
aliasName: middleInfo.aliasName,
storeId: middleInfo.storeId,
});
console.log(info);
wx.navigateTo({
url: `../newEnroll/enroll/index?applyType=1&info=${info}`,
});
// wx.navigateTo({
// url: `../newEnroll/enroll/index?applyType=1&info=${info}`,
// });
},
collectPaste(e) {
var txt;
var that = this;
if (!this.data.isLogin) {
wx.navigateTo({
url: "/pages/login/index",
});
return;
}
var collected = e.currentTarget.dataset.collected;
var storeJobId = e.currentTarget.dataset.jobid;
that.doCollected(collected, storeJobId);
// console.log(collected);
// if(!this.data.isCollect){
// that.setData({
// isCollect: true,
// collectTxt:'已收藏'
// })
// txt = '收藏成功'
// }else{
// that.setData({
// isCollect: false,
// collectTxt:'收藏'
// })
// }
},
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);
//发起网络请求
wx.request({
url: app.globalData.ip + url,
data: {
storeJobId: storeJobId,
},
header: app.globalData.headers,
method: "GET",
success: function (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,
});
},
fail: function (res) {
console.log("操作失败");
},
});
},
getUserInfoBtn: function (e) {
console.log(e);
let that = this;
let type = e.currentTarget.dataset.type;
var collected = e.currentTarget.dataset.collected;
var storeJobId = e.currentTarget.dataset.jobid;
let idx = e.currentTarget.dataset.idx;
console.log(type);
wx.getUserProfile({
desc: "用于完善会员资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res);
//发起网络请求
wx.request({
url: app.globalData.ip + "/updateUserWechatInfo",
data: {
nickName: res.userInfo.nickName,
avatarUrl: res.userInfo.avatarUrl,
gender: res.userInfo.gender,
country: res.userInfo.country,
province: res.userInfo.province,
city: res.userInfo.city,
},
method: "POST",
header: app.globalData.headers,
success: function (res) {
console.log(res);
app.globalData.hasUserInfo = 1;
that.setData({
hasUserInfo: 1,
});
that.doMenuClick(type, collected, storeJobId, idx);
},
fail: function (res) {
that.doMenuClick(type, collected, storeJobId, idx);
},
});
},
fail: (res) => {
console.log(res);
that.doMenuClick(type, collected, storeJobId, idx);
},
});
},
doMenuClick: function (_type, _collected, _storeJobId, _idx) {
let that = this;
if (_type - 1 == 0) {
//点击全国
that.goCity();
} else if (_type - 2 == 0) {
//搜索
} else if (_type - 3 == 0) {
//筛选
that.goScreen();
} else if (_type - 4 == 0) {
//收藏
that.doCollected(_collected, _storeJobId);
} else if (_type - 5 == 0) {
//报名
wx.setStorageSync("jobDetailStorage", that.data.recordList[_idx]);
wx.navigateTo({
url: "../enroll/index?applyType=1&tel=" + app.globalData.loginUserInfo.tel,
});
}
},
});