import request from "../../../../config/rerquest"; // import { $wuxToptips } from '../../../../wux/index.js' import { wxGetUserProfile } from "@utils/promise-wx-api"; const app = getApp(); Component({ data: { userState: "", showTips: false, showModel: false, visible: false, joinMessage: "", currentGid: "", completeInfoDialogVisible: false, }, properties: { recommandGroupList: { type: Array, value: [], }, noDataVisible: { type: Boolean, value: true, }, }, lifetimes: { attached() { // this.setData({ // userState: app.globalData.infoCompleted // }) }, }, ready() { this.requestMsg = this.selectComponent("#requestMsg"); }, methods: { cancelModel() { this.setData({ joinMessage: "", showModel: false, }); }, closeDialog() { this.setData({ visible: false, }); }, gotomanage(e) { let gid = e.currentTarget.dataset.gid; wx.navigateTo({ url: "/subpages/group/pages/group/groupManage/groupManage?gid=" + gid, }); }, confirmModel() { let that = this; let params = { groupId: this.data.currentGid, operateDes: this.data.joinMessage, }; if (this.data.joinMessage == "") { wx.showToast({ title: "入组理由不能为空", icon: "none", duration: 3000, }); return false; } this.applyJoinGroupData(params).then(async (res) => { console.log(res); const { msg } = res; if (msg === "success") { console.log("success"); that.setData({ joinMessage: "", showModel: false, showTips: true, }); setTimeout(function () { that.setData({ showTips: false, }); }, 3000); // 刷新父组件方法 await that.requestMsg.handleMsg(); that.triggerEvent("callSomeFun"); } }); }, bindTextAreaBlur: function (e) { this.setData({ joinMessage: e.detail.value, }); console.log(this.data.joinMessage); }, async pureJoinGroup(groupId) { const $ele = this.selectComponent("#joinGroup"); const addReturn = await $ele.show({ groupId }); if (!addReturn) return; await this.requestMsg.handleMsg(); this.triggerEvent("callSomeFun"); }, toCreateGroup() { // 调父组件方法 this.triggerEvent("callCreatGroup"); }, async updateWxuserInfoData(params: any) { return request({ method: "POST", url: "epmetuser/user/updatewxuserinfo", options: params, ifToken: true, }); }, async confirm() { const { msg, data } = await wxGetUserProfile({ desc: "用于完善居民信息", }); if (msg == "success") { // 同意授权,更新用户信息 console.log(data.avatarUrl); let params = { nickName: data.userInfo.nickName, gender: data.userInfo.gender, avatarUrl: data.userInfo.avatarUrl, province: data.userInfo.province, country: data.userInfo.country, city: data.userInfo.city, }; await this.updateWxuserInfoData(params).then((res) => {}); wx.navigateTo({ url: "/subpages/mine/pages/register/communist/index?from=group_joinGroup", }); this.setData({ visible: false, }); } }, async confirm2() { const { msg, data } = await wxGetUserProfile({ desc: "用于完善居民信息", }); if (msg == "success") { // 同意授权,更新用户信息 console.log(data); let params = { nickName: data.userInfo.nickName, gender: data.userInfo.gender, avatarUrl: data.userInfo.avatarUrl, province: data.userInfo.province, country: data.userInfo.country, city: data.userInfo.city, }; await this.updateWxuserInfoData(params).then((res) => {}); wx.navigateTo({ url: "/subpages/mine/pages/register/resident/index?from=group_joinGroup", }); this.setData({ visible: false, }); } }, gotoGroup(e) { let gid = e.currentTarget.dataset.gid; let status = e.currentTarget.dataset.status; if (status == "under_auditting") { wx.navigateTo({ url: "/subpages/group/pages/group/groupManage/groupManage?gid=" + gid, }); } else { wx.navigateTo({ url: "/subpages/group/pages/topic/topicIndex/topicIndex?gid=" + gid, }); } }, applyJoinGroupData(params: any) { return request({ method: "POST", url: "resi/group/member/applyjoingroup", options: params, ifToken: true, }); }, joinAssocition(e) { console.log(app.globalData.userRoleList); const type = e.currentTarget.dataset.type; const gid = e.currentTarget.dataset.gid; let userRoleList = app.globalData.userRoleList; if (type === "branch") { if (userRoleList.indexOf("partymember") >= 0) { // this.setData({ // showModel: true, // currentGid: gid, // }); this.pureJoinGroup(gid); } else { wx.showModal({ content: "该小组需党员才能加入,是否注册党员", confirmText: "是", cancelText: "否", success: (res) => { if (res.confirm) { console.log("用户点击确定"); wx.navigateTo({ url: "/subpages/mine/pages/register/communist/index", }); } else if (res.cancel) { console.log("用户点击取消"); } }, }); } } else { if (userRoleList.indexOf("registered_resi") >= 0) { // 认证居民 console.log("gid=" + gid); // this.setData({ // showModel: true, // currentGid: gid, // }); this.pureJoinGroup(gid); } else { this.setData({ visible: true, }); } } }, previewImage(e) { app.globalData.previewImage = true; wx.previewImage({ urls: [e.currentTarget.dataset.src], }); }, }, });