diff --git a/common/wxSilentLogin.js b/common/wxSilentLogin.js new file mode 100644 index 0000000..de1ac3c --- /dev/null +++ b/common/wxSilentLogin.js @@ -0,0 +1,123 @@ +// 静默登录 +import { + isEmpty +} from './TextUtils.js' + +//引入bus +import bus from '@/common/bus'; + +const wxSilentLogin = () => { + return new Promise((resolve, reject) => { + wx.login({ + success: function(res) { + if (res.code) { + console.log('Http网络请求信息', { + "wxCode": res.code + }) + uni.request({ + // 组装请求地址 + url: getApp().globalData.wxSilentLoginURL + "?wxCode=" + res + .code, + // 请求方式 GET POST + method: "GET", + header: { + // 传参方式 + 'content-type': "application/x-www-form-urlencoded" + }, + // 具体参数 + data: { + "wxCode": res.code + }, + success: res => { + console.log("请求openid", res) + // if (getApp().globalData.isDebug) { + // console.log('Http网络路径', getApp().globalData + // .wxSilentLoginURL) + // } + if (res.statusCode == 200) { + if (!res.data.success) { + + // if (res.data.code == 500) { + // uni.showModal({ + // title: '温馨提示', + // content: '您的平台应用未被授权,请联系工作人员。', + // showCancel: false, + // success: function(res) { + // if (res.confirm) { + // wx.exitMiniProgram({ + // success: function() {}, + // fail: function() {} + // }) + // } else { + // console.log('点击了取消') + // } + // } + // }) + + + // return + // } + + // if (res.data.code == 100) { + // 未绑定用户 + uni.navigateTo({ + url: '../index/BindPhone?openid=' + + res.data.data.openid+"&unionid="+ + res.data.data.unionid + }) + // } + + } else { + + console.log("Http网络请求res", res) + console.log("Global-Auth-Token", res.data.data + .token) + + + getApp().globalData.username = res.data.data + .name + getApp().globalData.token = res.data.data.token + getApp().globalData.sid = res.data.data.sid + getApp().globalData.mobile = res.data.data + .mobile + + getApp().globalData.isAdmin = res.data.data.isAdmin + getApp().globalData.orgSidPath = res.data.data.orgSidPath + getApp().globalData.orgNamePath = res.data.data.orgNamePath + getApp().globalData.organizationSid = res.data.data.organizationSid + getApp().globalData.headImage = res.data.data.headImage + + getApp().globalData.isLogin = true + + uni.setStorageSync("Global-Auth-Token", res.data + .data.token) + uni.setStorageSync("sid", res.data.data.sid) + uni.setStorageSync("isLogin", true) + + bus.$emit('wholeSpin', true); + } + } else { + getApp().globalData.isLogin = false + } + }, + fail: (err) => { + if (getApp().globalData.isDebug) { + console.log("Http网络请求fail", err) + } + }, + complete: () => {} + }); + } + }, + fail: function(res) { + uni.showToast({ + title: "静默登录失败:" + res.errMsg, + icon: 'none' + }) + + reject(res.errMsg) + } + }); + }) +} +export default wxSilentLogin \ No newline at end of file diff --git a/components/UserItem/UserItem.vue b/components/UserItem/UserItem.vue new file mode 100644 index 0000000..469b35c --- /dev/null +++ b/components/UserItem/UserItem.vue @@ -0,0 +1,101 @@ + + + + + \ No newline at end of file diff --git a/pages/home/UserFragment.vue b/pages/home/UserFragment.vue new file mode 100644 index 0000000..1edc02b --- /dev/null +++ b/pages/home/UserFragment.vue @@ -0,0 +1,234 @@ + + + + + \ No newline at end of file