// pages/creatorSelectPage/index.js const app = getApp(); import { customRequest } from '../../utils/request.js'; const commonUtil = require("../../utils/commonUtil.js"); Page({ /** * 页面的初始数据 */ data: { mamberList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady () { }, /** * 生命周期函数--监听页面显示 */ onShow () { this.getMemberList() }, /** * 生命周期函数--监听页面隐藏 */ onHide () { }, /** * 选择转让人 */ selectMember (e) { let that = this console.log(e); let info = e.currentTarget.dataset.info wx.showModal({ title: "是否将创建人转让给该成员", contentColor: "#ccc", confirmColor: "#1890ff", confirmText: "确定", // showCancel: false, success (res) { that.updateCreator(info) }, }); }, /** * 转让创建人 */ updateCreator (info) { console.log(this.data.creatorVal); let that = this customRequest( "/yishoudan/agency/changeCreator",{header:'headers', method: 'post', data: { tel: info.tel}}).then(({data})=>{ if (data.status == 200) { that.setData({ newCreatorShow: false }) wx.showToast({ title: '转让成功', icon: 'success', duration: 2000, success: function () { setTimeout(() => { app.globalData.loginUserInfo.user.agencyRole = 2 wx.navigateBack({ delta: 3 }); }, 1000); } }) } else { wx.showToast({ title: data.msg, icon: 'none' }) } }) // wx.request({ // url: app.globalData.ip + "/yishoudan/agency/changeCreator", // method: "post", // header: app.globalData.headers, // data: { tel: info.tel }, // success: function ({ data }) { // console.log(data); // if (data.status == 200) { // that.setData({ // newCreatorShow: false // }) // wx.showToast({ // title: '转让成功', // icon: 'success', // duration: 2000, // success: function () { // setTimeout(() => { // app.globalData.loginUserInfo.user.agencyRole = 2 // wx.navigateBack({ // delta: 3 // }); // }, 1000); // } // }) // } else { // wx.showToast({ // title: data.msg, // icon: 'none' // }) // } // } // }) }, /** * 获取全部成员列表 */ getMemberList () { let that = this; wx.showLoading({ title: "加载中...", mask: true, }); customRequest( "/yishoudan/user/getAgencyCorpUsers",{header:'headers', method: 'GET', data: {}}).then((res)=>{ if (res.data.status == 200) { try { let creatorInd = -1 res.data.data.recordList.forEach((item, index) => { item.name = commonUtil.getAgencyRoleTypeById(item.agencyRole); if (item.agencyRole == 1) { creatorInd = index } }); if (creatorInd != -1) { res.data.data.recordList.splice(creatorInd, 1) } res.data.data.recordList.sort((a, b) => { return a.agencyRole - b.agencyRole; }); wx.hideLoading(); that.setData({ mamberList: res.data.data.recordList, }); } catch (error) { wx.hideLoading(); console.log(error); } } }) // wx.request({ // url: app.globalData.ip + "/yishoudan/user/getAgencyCorpUsers", // method: "GET", // header: app.globalData.headers, // success: function (res) { // console.log(res); // if (res.data.status == 200) { // try { // let creatorInd = -1 // res.data.data.recordList.forEach((item, index) => { // item.name = commonUtil.getAgencyRoleTypeById(item.agencyRole); // if (item.agencyRole == 1) { // creatorInd = index // } // }); // if (creatorInd != -1) { // res.data.data.recordList.splice(creatorInd, 1) // } // res.data.data.recordList.sort((a, b) => { // return a.agencyRole - b.agencyRole; // }); // wx.hideLoading(); // that.setData({ // mamberList: res.data.data.recordList, // }); // } catch (error) { // wx.hideLoading(); // console.log(error); // } // } // }, // }); }, /** * 生命周期函数--监听页面卸载 */ onUnload () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom () { }, /** * 用户点击右上角分享 */ onShareAppMessage () { } })