diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 42c97811b699dabac88a3c69a1e20d24ca3b35c5..daea482fb61128bf3c82debf4dd25a7bc236cad5 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -96,6 +96,7 @@ class User extends Common { return DataReturn('获取授权信息失败', -10); } else { + $result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 'm') ? 2 : 1; $result['openid'] = $result['user_id']; $result['referrer']= isset($this->data_post['referrer']) ? intval($this->data_post['referrer']) : 0; return UserService::AuthUserProgram($result, 'alipay_openid'); @@ -134,6 +135,9 @@ class User extends Common if(is_array($result)) { + $result['nick_name'] = isset($result['nickName']) ? $result['nickName'] : ''; + $result['avatar'] = isset($result['avatarUrl']) ? $result['avatarUrl'] : ''; + $result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 2) ? 1 : 2; $result['openid'] = $result['openId']; $result['referrer']= isset($this->data_post['referrer']) ? intval($this->data_post['referrer']) : 0; return UserService::AuthUserProgram($result, 'weixin_openid'); diff --git a/public/appmini/old/wechat/app.js b/public/appmini/old/wechat/app.js index 99562dc2e69ae575803d8376b7695fc62ec45cae..936c1c3d5b4126a772a7189cfdde8bc5c47a883e 100755 --- a/public/appmini/old/wechat/app.js +++ b/public/appmini/old/wechat/app.js @@ -163,7 +163,7 @@ App({ if (params != "" && params.substr(0, 1) != "&") { params = "&" + params; } - var user = this.GetUserCacheInfo(); + var user = this.get_user_cache_info(); var app_client_user_id = user == false ? "" : user.wechat_openid; var user_id = user == false ? 0 : user.id; return ( @@ -184,22 +184,21 @@ App({ * method 回调操作对象的函数 * return 有用户数据直接返回, 则回调调用者 */ - GetUserInfo(object, method) { - var user = this.GetUserCacheInfo(); + get_user_info(object, method) { + var user = this.get_user_cache_info(); if (user == false) { // 唤醒用户授权 - this.UserAuthCode(object, method); + this.user_auth_code(object, method); return false; - } else { - return user; } + return user; }, /** * 从缓存获取用户信息 */ - GetUserCacheInfo() { + get_user_cache_info() { let user = wx.getStorageSync(this.data.cache_user_info_key); if ((user || null) == null) { return false; @@ -207,26 +206,12 @@ App({ return user; }, - /** - * 从缓存获美啦取用户信息 - */ - GetMeiLaUserCacheInfo() { - let user = wx.getStorageSync(this.data.cache_user_info_key); - if ((user || null) == null) { - return null; - } - if ((user.my_user || null) == null) { - return null; - } - return user.my_user; - }, - /** * 用户授权 * object 回调操作对象 * method 回调操作对象的函数 */ - UserAuthCode(object, method) { + user_auth_code(object, method) { // 加载loding wx.showLoading({ title: '授权中...' }); var $this = this; @@ -234,8 +219,6 @@ App({ // 请求授权接口 wx.getSetting({ success(res) { - console.log('app.js 授权部分'); - if (!res.authSetting['scope.userInfo']) { wx.navigateTo({ url: "/pages/login/login" @@ -349,12 +332,16 @@ App({ if (res.data.code == 0) { wx.setStorage({ key: $this.data.cache_user_info_key, - data: res.data.data + data: res.data.data, + success: (res) => { + if (typeof object === 'object' && (method || null) != null) { + object[method](); + } + }, + fail: () => { + $this.showToast('用户信息缓存失败'); + } }); - - if (typeof object === 'object' && (method || null) != null) { - object[method](); - } } else { $this.showToast(res.data.text); } diff --git a/public/appmini/old/wechat/pages/answer-form/answer-form.js b/public/appmini/old/wechat/pages/answer-form/answer-form.js index 78864b406350f428d21a6528beb96dddf2211c25..07fbf1388b66fd75fcb9547ae90474ea0166a6ca 100755 --- a/public/appmini/old/wechat/pages/answer-form/answer-form.js +++ b/public/appmini/old/wechat/pages/answer-form/answer-form.js @@ -13,7 +13,7 @@ Page({ // 初始化 init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/cart/cart.js b/public/appmini/old/wechat/pages/cart/cart.js index 1d059d8b596e83a31f699fbca488e9ff575604a2..68eb216390483e41fb23dd561a68ef11b5b2e3b2 100755 --- a/public/appmini/old/wechat/pages/cart/cart.js +++ b/public/appmini/old/wechat/pages/cart/cart.js @@ -17,15 +17,15 @@ Page({ }, init(e) { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { - wx.confirm({ + wx.showModal({ title: '温馨提示', content: '绑定手机号码', - confirmButtonText: '确认', - cancelButtonText: '暂不', + confirmText: '确认', + cancelText: '暂不', success: (result) => { if (result.confirm) { wx.navigateTo({ @@ -194,11 +194,11 @@ Page({ if (type == 'edit') { this.goods_favor_event(id, goods_id, type); } else { - wx.confirm({ + wx.showModal({ title: '温馨提示', content: '删除后不可恢复,确定继续吗?', - confirmButtonText: '确定', - cancelButtonText: '取消', + confirmText: '确定', + cancelText: '取消', success: (result) => { if (result.confirm) { this.cart_delete(id, type); diff --git a/public/appmini/old/wechat/pages/goods-detail/goods-detail.js b/public/appmini/old/wechat/pages/goods-detail/goods-detail.js index 084fe1da93a0a8b2170f77839eab9fdc43b2a730..42159e459207c3a8a35a1bd80711d96e1710d3b4 100755 --- a/public/appmini/old/wechat/pages/goods-detail/goods-detail.js +++ b/public/appmini/old/wechat/pages/goods-detail/goods-detail.js @@ -200,7 +200,7 @@ Page({ // 收藏事件 goods_favor_event(e) { - var user = app.GetUserInfo(this, 'goods_favor_event'); + var user = app.get_user_info(this, 'goods_favor_event'); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -252,7 +252,7 @@ Page({ // 加入购物车事件 goods_cart_event(e, spec) { - var user = app.GetUserInfo(this, 'goods_cart_event'); + var user = app.get_user_info(this, 'goods_cart_event'); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -535,7 +535,7 @@ Page({ // 确认 goods_buy_confirm_event(e) { - var user = app.GetUserInfo(this, 'goods_buy_confirm_event'); + var user = app.get_user_info(this, 'goods_buy_confirm_event'); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/login/login.js b/public/appmini/old/wechat/pages/login/login.js index fcd23b46e233534e0460faf8eaadf2cc45a7f95a..56eab627e07478591b644235c96fc7ec3de3decb 100755 --- a/public/appmini/old/wechat/pages/login/login.js +++ b/public/appmini/old/wechat/pages/login/login.js @@ -22,7 +22,7 @@ Page({ // 设置用户信息 this.setData({ params: option, - user: app.GetUserCacheInfo() || null + user: app.get_user_cache_info() || null }); }, @@ -30,8 +30,9 @@ Page({ * 登录授权事件 */ get_user_info_event(e) { - console.log(e, e.detail.userInfo) - app.user_auth_login(); + console.log(e, e.detail.userInfo); + //app.user_auth_login(); + wx.navigateBack(); }, /** diff --git a/public/appmini/old/wechat/pages/message/message.js b/public/appmini/old/wechat/pages/message/message.js index 17d88263be342cba760b984d971a84f200c1ced7..cd9e35e40dd1285b6fa6841db2e0a4d6a08207e5 100755 --- a/public/appmini/old/wechat/pages/message/message.js +++ b/public/appmini/old/wechat/pages/message/message.js @@ -14,7 +14,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/user-address-save/user-address-save.js b/public/appmini/old/wechat/pages/user-address-save/user-address-save.js index 828cbda12bfd9c02d984232e0516bb6d26ca8833..993593a238b954a0afe330175a9cec7d3452dd95 100755 --- a/public/appmini/old/wechat/pages/user-address-save/user-address-save.js +++ b/public/appmini/old/wechat/pages/user-address-save/user-address-save.js @@ -32,7 +32,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/user-address/user-address.js b/public/appmini/old/wechat/pages/user-address/user-address.js index cfb8a8d4d114dfbb5571a6d92dbaf70303268405..720a4e3e0716092e96a55f4833659b6f0db383e8 100755 --- a/public/appmini/old/wechat/pages/user-address/user-address.js +++ b/public/appmini/old/wechat/pages/user-address/user-address.js @@ -19,7 +19,7 @@ Page({ // 初始化 init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -120,11 +120,11 @@ Page({ } var self = this; - wx.confirm({ + wx.showModal({ title: "温馨提示", content: "删除后不可恢复,确定继续吗?", - confirmButtonText: "确认", - cancelButtonText: "不了", + confirmText: "确认", + cancelText: "不了", success: result => { if (result.confirm) { // 加载loding diff --git a/public/appmini/old/wechat/pages/user-answer-list/user-answer-list.js b/public/appmini/old/wechat/pages/user-answer-list/user-answer-list.js index af97d872946df38c9def1e005d2f660ed46d4d65..a77c94213318791e9ee4ce2bb9e6f25a19799f4c 100755 --- a/public/appmini/old/wechat/pages/user-answer-list/user-answer-list.js +++ b/public/appmini/old/wechat/pages/user-answer-list/user-answer-list.js @@ -16,7 +16,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/user-faovr/user-faovr.js b/public/appmini/old/wechat/pages/user-faovr/user-faovr.js index 2d9d939aa3f2b932bfc12e6932136b0a36063683..5ec717e87c5d205af9521dbe5d3cf28b6348d0fb 100755 --- a/public/appmini/old/wechat/pages/user-faovr/user-faovr.js +++ b/public/appmini/old/wechat/pages/user-faovr/user-faovr.js @@ -14,7 +14,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -128,11 +128,11 @@ Page({ // 取消 cancel_event(e) { - wx.confirm({ + wx.showModal({ title: "温馨提示", content: "取消后不可恢复,确定继续吗?", - confirmButtonText: "确认", - cancelButtonText: "不了", + confirmText: "确认", + cancelText: "不了", success: result => { if (result.confirm) { // 参数 diff --git a/public/appmini/old/wechat/pages/user-goods-browse/user-goods-browse.js b/public/appmini/old/wechat/pages/user-goods-browse/user-goods-browse.js index fb8604aa50f315c6a12970dc4059a4b2880e5ee8..9c023a574cf0648b5f92e9128b62aab8b0bd1392 100755 --- a/public/appmini/old/wechat/pages/user-goods-browse/user-goods-browse.js +++ b/public/appmini/old/wechat/pages/user-goods-browse/user-goods-browse.js @@ -14,7 +14,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -127,11 +127,11 @@ Page({ // 删除 delete_event(e) { - wx.confirm({ + wx.showModal({ title: "温馨提示", content: "删除后不可恢复?,确定继续吗?", - confirmButtonText: "确认", - cancelButtonText: "不了", + confirmText: "确认", + cancelText: "不了", success: result => { if (result.confirm) { // 参数 diff --git a/public/appmini/old/wechat/pages/user-integral/user-integral.js b/public/appmini/old/wechat/pages/user-integral/user-integral.js index 9d572d020a71eca46aeb07bad81519bb9df1a587..fbcb5ff3ccab02fa979bcb736b73d1ac31373703 100755 --- a/public/appmini/old/wechat/pages/user-integral/user-integral.js +++ b/public/appmini/old/wechat/pages/user-integral/user-integral.js @@ -14,7 +14,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { diff --git a/public/appmini/old/wechat/pages/user-order/user-order.js b/public/appmini/old/wechat/pages/user-order/user-order.js index eec25ebd1ee2c5d851548749704378e9d829fb88..a615c257976abde660428243b1af2925156af6ae 100755 --- a/public/appmini/old/wechat/pages/user-order/user-order.js +++ b/public/appmini/old/wechat/pages/user-order/user-order.js @@ -49,7 +49,7 @@ Page({ }, init() { - var user = app.GetUserInfo(this, "init"); + var user = app.get_user_info(this, "init"); if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { @@ -291,11 +291,11 @@ Page({ // 取消 cancel_event(e) { - wx.confirm({ + wx.showModal({ title: "温馨提示", content: "取消后不可恢复,确定继续吗?", - confirmButtonText: "确认", - cancelButtonText: "不了", + confirmText: "确认", + cancelText: "不了", success: result => { if (result.confirm) { // 参数 @@ -344,11 +344,11 @@ Page({ // 收货 collect_event(e) { - wx.confirm({ + wx.showModal({ title: "温馨提示", content: "请确认已收到货物或已完成,操作后不可恢复,确定继续吗?", - confirmButtonText: "确认", - cancelButtonText: "不了", + confirmText: "确认", + cancelText: "不了", success: result => { if (result.confirm) { // 参数 diff --git a/public/appmini/old/wechat/pages/user/user.js b/public/appmini/old/wechat/pages/user/user.js index 7e96a74f01f3ed682e2cbdcc796dfe57b708ec65..e780a192947da0881c3f1541fcd98f262fd4da48 100755 --- a/public/appmini/old/wechat/pages/user/user.js +++ b/public/appmini/old/wechat/pages/user/user.js @@ -52,16 +52,16 @@ Page({ }, init(e) { - var user = app.GetUserInfo(this, "init"), + var user = app.get_user_info(this, "init"), self = this; if (user != false) { // 用户未绑定用户则转到登录页面 if ((user.mobile || null) == null) { - wx.confirm({ + wx.showModal({ title: '温馨提示', content: '绑定手机号码', - confirmButtonText: '确认', - cancelButtonText: '暂不', + confirmText: '确认', + cancelText: '暂不', success: (result) => { if(result.confirm) { wx.navigateTo({