日照项目的居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

90 lines
2.0 KiB

import {
wxRequestPost,
wxGetSetting,
wxGetUserProfile
} from "../../utils/promise-wx-api";
let tempReslove = () => {};
const defaultData = {
title: "需获取您的用户信息",
content: "该操作需要您授权!"
};
Component({
data: {
hidden: true,
showCancel: true,
title: "",
content: "",
userInfo: {}
},
methods: {
async updateApi() {
const { userInfo } = this.data;
const {
data: {
data: { code, data }
},
msg
} = await wxRequestPost("epmetuser/user/updatewxuserinfo", userInfo, {
// isMock: true
});
if (msg === "success" && code === 0) {
console.log("更新微信用户信息成功");
}
},
async get() {
const retAuth = await wxGetSetting({});
console.log(retAuth);
if (retAuth.msg == "success") {
if (retAuth.data.authSetting["scope.userInfo"]) {
const retUser = await wxGetUserProfile({desc: '用于完善居民信息'});
if (retUser.msg == "success") {
this.setData({
userInfo: retUser.data.userInfo
});
return this.data.userInfo;
}
} else {
return this.show();
}
} else {
return false;
}
},
show(opts) {
this.setData({
...defaultData,
...opts,
hidden: false
});
return new Promise(reslove => {
tempReslove = reslove;
});
},
hide() {
this.setData({ hidden: true });
},
async confirm() {
const {msg, data} = await wxGetUserProfile({
desc: '用于完善居民信息'
});
if (msg=='success') {
this.setData({
userInfo: data.userInfo
});
return tempReslove(this.data.userInfo);
} else {
return tempReslove(false);
}
},
cancel() {
this.hide();
return tempReslove(false);
}
}
});