瀏覽代碼

优化:1.登录过程优化,不再需要用户每次手动登录甚至点击授权
2.挖矿页面认证优化:和 index 有重复,重用 index 认证组件

TODO: request.js 目前自动重登录功能存在交叉引用问题。

joe 4 年之前
父節點
當前提交
f5bb19108e

+ 7 - 3
view/xcx/api/user.js

@@ -16,15 +16,19 @@ export function login(data) {
 /**
  * 利用 code 来登录
  */
-export function simple_login(data) {
-
+export function login_simple(data) {
+    return request.post("wechat/mp_auth_simple", data, {
+        noAuth: true
+    });
 }
 
 /**
  * 提交加密的用户信息用于注册或刷新资料
  */
 export function login_with_userinfo(data) {
-
+    return request.post("wechat/mp_auth_with_userinfo", data, {
+        noAuth: true
+    });
 }
 
 /**

+ 6 - 50
view/xcx/components/authorize/authorize.js

@@ -57,6 +57,7 @@ Component({
 
     methods: {
         close() {
+            wx.hideLoading();
             let pages = getCurrentPages();
             let currPage = pages[pages.length - 1];
             if (this.data.isGoIndex) {
@@ -101,33 +102,9 @@ Component({
                         iShidden: true
                     });
                 }
-                if (res.isLogin) {
-                    if (!Util.isLoginValid()) {
-                        return Promise.reject({
-                            authSetting: true,
-                            msg: '用户token失效',
-                            userInfo: res.userInfo
-                        });
-                    }
-                    that.triggerEvent('onLoadFun', app.globalData.userInfo);
-                } else {
-                    wx.showLoading({
-                        title: '正在登录中'
-                    });
-                    that.setUserInfo(res.userInfo, true);
-                }
-            }).catch(res => {
-                if (res.authSetting === false) {
-                    //没有授权不会自动弹出登录框
-                    if (that.data.isAuto === false) return;
-                    //自动弹出授权
-                    that.setData({
-                        iShidden: false
-                    });
-                } else if (res.authSetting) {
-                    //授权后登录token失效了
-                    that.setUserInfo(res.userInfo);
-                }
+                that.triggerEvent('onLoadFun', app.globalData.userInfo);
+            }).catch(err => {
+                console.log(err);
             })
         }, // setAuthStatus()
 
@@ -158,30 +135,11 @@ Component({
                 // console.log(userInfo);
                 that.loginAuth(userInfo);
             }).catch((err) => {
-                console.log(err)
+                wx.hideLoading();
+                console.log('err:', err)
             })
         }, // agreeAndAuth
 
-        //授权
-        setUserInfo(userInfo, isLogin) {
-            let that = this;
-            wx.showLoading({
-                title: '正在登录中'
-            });
-            if (isLogin) {
-                that.loginAuth(userInfo);
-            } else {
-                Util.wxLogin((res) => {
-                    Util.wxGetUserProfile().then(userInfo => {
-                        userInfo.code = res.code;
-                        that.loginAuth(userInfo);
-                    }).catch(res => {
-                        wx.hideLoading();
-                    });
-                });
-            }
-        }, // setUserInfo()
-
         // 从后台获取详细信息
         loginAuth: function (userInfo) {
             let that = this;
@@ -221,8 +179,6 @@ Component({
                     Util.Tips({
                         title: err
                     });
-                } else {
-                    that.setUserInfo(userInfo);
                 }
             });
         }, // loginAuth()

+ 11 - 4
view/xcx/components/mine/index.js

@@ -30,7 +30,8 @@ Component({
         price: 0.0,
 
         displaying: false, // 当前是否在这个界面
-        iShidden: false,
+        // iShidden: false,
+        // isGoIndex: false,
         stepTimer: null,
         syncTimer: null
     },
@@ -42,11 +43,13 @@ Component({
         show: function () {
             // console.log('show:', app.globalData.token)
             if (app.globalData.isLog) {
-                this.setData({
-                    iShidden: true
-                })
+                // this.setData({
+                //     iShidden: true
+                // })
                 this.getStatus()
                 this.getHistory()
+            } else {
+                this.triggerEvent('onNeedLogin');
             }
 
             this.setData({
@@ -151,6 +154,10 @@ Component({
         },
 
         onClickStart: function () {
+            if (!app.globalData.isLog) {
+                this.triggerEvent('onNeedLogin')
+                return
+            }
             if (this.data.progress > 0.0) {
                 return
             }

+ 1 - 1
view/xcx/components/mine/index.wxml

@@ -41,4 +41,4 @@
         </view>
     </view>
 </view>
-<authorize bind:onLoadFun='onLoadFun' iShidden="{{iShidden}}"></authorize>
+<!-- <authorize bind:onLoadFun='onLoadFun' isGoIndex="{{isGoIndex}}" iShidden="{{iShidden}}"></authorize> -->

+ 126 - 131
view/xcx/pages/index/index.js

@@ -66,11 +66,11 @@ Page({
             'return': '0',
             'class': '5'
         },
-        window: false,
-        iShiddenTip: false,
-        isAuto: false, //是否自动授权;
-        iShidden: true, //是否隐藏;
-        isGoIndex: false, //是否返回首页;
+        window: false, // 是否显示优惠券窗口
+        iShiddenTip: false, // 是否显示提示
+        isAuto: true, // 是否自动授权;
+        iShidden: true, // 是否隐藏;
+        isGoIndex: false, // 是否返回首页;
         navH: "",
         recommend: {
             loadend: false,
@@ -109,7 +109,13 @@ Page({
             iShiddenTip: true
         })
     },
-    
+
+    // 挖矿组件绑定
+    onNeedLogin: function () {
+        this.setData({
+            iShidden: false
+        })
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -122,16 +128,22 @@ Page({
         wxh.selfLocation(1);
         this.getCategoryData();
         // this.getCoupon();
-        this.get_host_product();
+        this.get_hot_product();
         this.get_product_list();
         this.setData({
             navH: app.globalData.navHeight
         });
-        if (options.spid) app.globalData.spid = options.spid;
-        if (options.scene) app.globalData.code = decodeURIComponent(options.scene);
-        if (wx.getStorageSync('msg_key')) this.setData({
-            iShiddenTip: true
-        });
+        if (options.spid) {
+            app.globalData.spid = options.spid;
+        }
+        if (options.scene) {
+            app.globalData.code = decodeURIComponent(options.scene);
+        }
+        if (wx.getStorageSync('msg_key')) {
+            this.setData({
+                iShiddenTip: true
+            });
+        }
         this.getTemlIds();
         this.getLiveList();
     },
@@ -140,15 +152,19 @@ Page({
         let messageTmplIds = wx.getStorageSync(CACHE_SUBSCRIBE_MESSAGE);
         if (!messageTmplIds) {
             getTemlIds().then(res => {
-                if (res.data)
+                if (res.data) {
                     wx.setStorageSync(CACHE_SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
+                }
             }).catch(() => {})
         }
     },
 
     //授权
     onLoadFun: function () {
-        //this.getCoupon();
+        // 挖矿组件认证回调
+        if (this.data.cpnMine != null) {
+            this.data.cpnMine.onLoadFun();
+        }
     },
 
     catchTouchMove: function (res) {
@@ -167,7 +183,9 @@ Page({
      */
     onReady: function () {},
 
-    /** 轮播监听 */
+    /** 
+     * 轮播监听 
+     */
     bindchange(e) {
         var index = e.detail.current;
         this.setData({
@@ -219,21 +237,6 @@ Page({
                 logoUrl: res.data.logoUrl,
                 couponList: res.data.couponList,
             });
-            // 检测是否授权;scope.userInfo存在为授权;
-            wx.getSetting({
-                success(res) {
-                    if (!res.authSetting['scope.userInfo']) {
-                        that.setData({
-                            window: that.data.couponList.length ? true : false
-                        });
-                    } else {
-                        that.setData({
-                            window: false,
-                            iShidden: true
-                        });
-                    }
-                }
-            });
 
             app.setUnread(res.data.notice);
         })
@@ -282,7 +285,7 @@ Page({
     /**
      * 获取我的推荐
      */
-    get_host_product: function (isPage) {
+    get_hot_product: function (isPage) {
         var that = this;
         if (that.data.recommend.loadend) return;
         if (that.data.recommend.loading) return;
@@ -314,48 +317,49 @@ Page({
 
     /** 点击上方活动标签按钮 */
     onTapCategoryTabItem: function (event) {
-        let that = this,
-            activeTabIndex = event.detail.index;
+        let activeTabIndex = event.detail.index;
         if (activeTabIndex <= 0 || activeTabIndex > this.data.categoryOne.children.length) {
             return
         }
 
-        that.setData({
-            activeTabIndex: activeTabIndex
-        })
-        // 黑洞
         this.setData({
-            cpnMine: this.selectComponent('#mine'),
+            activeTabIndex: activeTabIndex
         })
+
         if (this.data.categoryOne.children[activeTabIndex - 1].id === 199) {
+            // 黑洞
+            if (this.data.cpnMine == null) {
+                this.setData({
+                    cpnMine: this.selectComponent('#mine'),
+                })
+            }
             var _ = this.data.cpnMine && this.data.cpnMine.show()
             return
         } else {
             var _ = this.data.cpnMine && this.data.cpnMine.hide()
         }
 
-        that.setData({
+        this.setData({
             'where.page': 1,
             loadend: false,
             loading: false,
-            'where.cid': that.data.categoryOne.id,
-            'where.sid': that.data.categoryOne.children[activeTabIndex - 1].id,
+            'where.cid': this.data.categoryOne.id,
+            'where.sid': this.data.categoryOne.children[activeTabIndex - 1].id,
             categoryActive: 0
         })
-        that.get_product_list(true);
+        this.get_product_list(true);
     },
 
     productTap: function (e) {
-        let that = this,
-            index = e.currentTarget.dataset.indexn;
-        that.setData({
+        let index = e.currentTarget.dataset.indexn;
+        this.setData({
             categoryActive: index,
             'where.page': 1,
             loadend: false,
             loading: false,
-            'where.sid': that.data.categoryOne[that.data.activeTabIndex - 1].children[index].id
+            'where.sid': this.data.categoryOne[this.data.activeTabIndex - 1].children[index].id
         })
-        that.get_product_list(true);
+        this.get_product_list(true);
     },
 
     get_product_list: function (isPage) {
@@ -411,51 +415,42 @@ Page({
 
     // 页面事件, 不再使用
     setTime: function (e) {
-        var that = this,
-            index = e.currentTarget.dataset.index;
-        that.setData({
+        let index = e.currentTarget.dataset.index;
+        this.setData({
             killIndex: index,
             status: that.data.timeList[index].status
         })
-        that.getSeckillLists();
+        // that.getSeckillLists();
     },
 
     // 不再触发
-    getSeckillLists: function () {
-        let that = this;
-        let timeId = that.data.timeList[that.data.killIndex].id;
-        getSeckillList(timeId, {
-            page: 1,
-            limit: 20
-        }).then(res => {
-            that.setData({
-                seckillList: res.data
-            })
-
-            if (this.data.timeList.length) {
-                let query = wx.createSelectorQuery().in(this);
-                query.select('.timeLen').boundingClientRect(function (res) {
-                    if (res) {
-                        that.setData({
-                            scrollLeft: (that.data.killIndex - 1.8) * res.width
-                        });
-                    }
-                }).exec();
-                if (that.data.killIndex === that.data.seckillTimeIndex) {
-                    that.setData({
-                        killIndexLen: res.data.length
-                    })
-                }
-            }
-        }).catch(() => {});
-    },
-
-    // 秒杀详情
-    // goDetail: function (e) {
-    //   let index = this.data.timeList[this.data.killIndex];
-    //   wx.navigateTo({
-    //     url: '/pages/activity/goods_seckill_details/index?id=' + e.currentTarget.dataset.id + '&time=' + index.stop + '&status=' + index.status
-    //   })
+    // getSeckillLists: function () {
+    //     let that = this;
+    //     let timeId = that.data.timeList[that.data.killIndex].id;
+    //     getSeckillList(timeId, {
+    //         page: 1,
+    //         limit: 20
+    //     }).then(res => {
+    //         that.setData({
+    //             seckillList: res.data
+    //         })
+
+    //         if (this.data.timeList.length) {
+    //             let query = wx.createSelectorQuery().in(this);
+    //             query.select('.timeLen').boundingClientRect(function (res) {
+    //                 if (res) {
+    //                     that.setData({
+    //                         scrollLeft: (that.data.killIndex - 1.8) * res.width
+    //                     });
+    //                 }
+    //             }).exec();
+    //             if (that.data.killIndex === that.data.seckillTimeIndex) {
+    //                 that.setData({
+    //                     killIndexLen: res.data.length
+    //                 })
+    //             }
+    //         }
+    //     }).catch(() => {});
     // },
 
     /** 获取分类列表 */
@@ -469,52 +464,52 @@ Page({
     },
 
     /** 获取优惠券列表 不再触发*/
-    getCoupon: function () {
-        var that = this;
-        getCoupons({
-            page: 1,
-            limit: 6
-        }).then(res => {
-            that.setData({
-                getCouponList: res.data
-            })
-        }).catch(err => {
-            // app.Tips({
-            //   title: err
-            // });
-        });
-    },
+    // getCoupon: function () {
+    //     var that = this;
+    //     getCoupons({
+    //         page: 1,
+    //         limit: 6
+    //     }).then(res => {
+    //         that.setData({
+    //             getCouponList: res.data
+    //         })
+    //     }).catch(err => {
+    //         // app.Tips({
+    //         //   title: err
+    //         // });
+    //     });
+    // },
 
     // 页面回调,不再触发
-    receiveCoupon: function (e) {
-        if (!app.globalData.isLog) {
-            this.setData({
-                iShidden: false
-            });
-        } else {
-            var that = this;
-            var list = that.data.getCouponList;
-            var index = e.currentTarget.dataset.index;
-            var id = that.data.getCouponList[index].id;
-            getCouponReceive({
-                    couponId: id
-                })
-                .then(function () {
-                    list[index].is_use = true;
-                    that.setData({
-                        getCouponList: that.data.getCouponList
-                    })
-                    app.Tips({
-                        title: "领取成功"
-                    });
-                })
-                .catch(function (err) {
-                    // app.Tips({
-                    //   title: err
-                    // });
-                });
-        }
-    },
+    // receiveCoupon: function (e) {
+    //     if (!app.globalData.isLog) {
+    //         this.setData({
+    //             iShidden: false
+    //         });
+    //     } else {
+    //         var that = this;
+    //         var list = that.data.getCouponList;
+    //         var index = e.currentTarget.dataset.index;
+    //         var id = that.data.getCouponList[index].id;
+    //         getCouponReceive({
+    //                 couponId: id
+    //             })
+    //             .then(function () {
+    //                 list[index].is_use = true;
+    //                 that.setData({
+    //                     getCouponList: that.data.getCouponList
+    //                 })
+    //                 app.Tips({
+    //                     title: "领取成功"
+    //                 });
+    //             })
+    //             .catch(function (err) {
+    //                 // app.Tips({
+    //                 //   title: err
+    //                 // });
+    //             });
+    //     }
+    // },
 
     /**
      * 生命周期函数--监听页面隐藏
@@ -553,7 +548,7 @@ Page({
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function () {
-        this.get_host_product();
+        this.get_hot_product();
         this.get_product_list();
     },
 

+ 3 - 2
view/xcx/pages/index/index.wxml

@@ -445,7 +445,7 @@
         <Tab wx:for="{{categoryOne.children}}" title="{{item.cate_name}}" wx:key='index'>
             <!--黑洞星球活动-->
             <view wx:if="{{item.id === 199}}">
-                <Mine id="mine"></Mine>
+                <Mine bind:onNeedLogin="onNeedLogin" id="mine"></Mine>
             </view>
 
             <!-- 其他活动 -->
@@ -497,4 +497,5 @@
 </view>
 
 <!-- coupon-window window='{{window}}' couponList="{{couponList}}" bind:onClose="onClose"></coupon-window -->
-<authorize bind:onLoadFun='onLoadFun' isGoIndex='{{isGoIndex}}' iShidden="{{iShidden}}" isAuto="{{isAuto}}"></authorize>
+<authorize wx:if="{{ !isShowMine }}" bind:onLoadFun='onLoadFun' isGoIndex='{{isGoIndex}}' iShidden="{{iShidden}}"
+    isAuto="{{isAuto}}"></authorize>

+ 13 - 13
view/xcx/pages/user_info/index.js

@@ -5,7 +5,7 @@ import {
 import {
     switchH5Login
 } from '../../api/api.js';
-import authLogin from '../../utils/autoLogin.js';
+// import authLogin from '../../utils/authLogin.js';
 import util from '../../utils/util.js';
 
 const app = getApp();
@@ -68,18 +68,18 @@ Page({
                 });
             })
         } else {
-            wx.showLoading({
-                title: '正在切换中'
-            });
-            authLogin('routine').then(res => {
-                that.getUserInfo();
-                wx.hideLoading();
-            }).catch(err => {
-                wx.hideLoading();
-                return app.Tips({
-                    title: err
-                });
-            });
+            // wx.showLoading({
+            //     title: '正在切换中'
+            // });
+            // authLogin('routine').then(res => {
+            //     that.getUserInfo();
+            //     wx.hideLoading();
+            // }).catch(err => {
+            //     wx.hideLoading();
+            //     return app.Tips({
+            //         title: err
+            //     });
+            // });
         }
     },
 

+ 0 - 31
view/xcx/utils/autoLogin.js

@@ -1,31 +0,0 @@
-import util from './util.js';
-import {
-    login
-} from '../api/user.js';
-
-export default function authLogin(login_type) {
-    return new Promise((reslove, reject) => {
-        util.autoLogin().then((userInfo) => {
-            if (login_type !== undefined) {
-                userInfo.login_type = 'routine';
-            }
-            login(userInfo).then(res => {
-                getApp().globalData.token = res.data.token;
-                getApp().globalData.userInfo = res.data.userInfo;
-                getApp().globalData.isLog = true;
-                getApp().globalData.expiresTime = res.data.expires_time;
-                if (res.data.cache_key) {
-                    wx.setStorage({
-                        key: 'cache_key',
-                        data: res.data.cache_key
-                    });
-                }
-                reslove();
-            }).catch(err => {
-                reject();
-            });
-        }).catch(err => {
-            reject();
-        });
-    })
-}

+ 66 - 0
view/xcx/utils/login.js

@@ -0,0 +1,66 @@
+import {
+    CACHE_USERINFO,
+    CACHE_TOKEN,
+    CACHE_EXPIRES_TIME
+} from '../config.js';
+import {
+    login_simple,
+} from '../api/user.js';
+
+// 新的登录逻辑实现文件
+// 新的逻辑要求尽量减少用户授权确认,用户只有在首次注册时和以后定期不定期的才需要确认(用于获取用户微信头像等资料)上传资料用于注册、系统同步更新用户资料。
+
+// 静默登录,不再需要用户授权。
+// 用于小程序启动后,token 过期的情况下,后台静默登录。如果失败,则不用处理,等待后续的用户授权过程。
+export function loginSilently() {
+    return new Promise((resolve, reject) => {
+        wx.login({
+            success: (login_res) => {
+                login_simple({
+                    code: login_res.code
+                }).then((simple_res) => {
+                    if (simple_res.data.status == 1) {
+                        // 需要提交用户资料,此时必须有 cache_key
+                        if (simple_res.data.cache_key) {
+                            wx.setStorage({
+                                key: 'cache_key',
+                                data: simple_res.data.cache_key
+                            });
+                        } else {
+                            reject({
+                                err: '登录失败'
+                            });
+                        }
+                        reject({
+                            status: 1,
+                            err: ''
+                        });
+                    } else if (simple_res.data.status == 0) {
+                        // todo: clear cache_key
+                        wx.removeStorage({
+                            key: 'cache_key',
+                        });
+                        var app = getApp();
+                        app.globalData.token = simple_res.data.token;
+                        app.globalData.isLog = true;
+                        app.globalData.userInfo = simple_res.data.userInfo;
+                        app.globalData.expiresTime = simple_res.data.expires_time;
+                        wx.setStorageSync(CACHE_TOKEN, simple_res.data.token);
+                        wx.setStorageSync(CACHE_EXPIRES_TIME, simple_res.data.expires_time);
+                        wx.setStorageSync(CACHE_USERINFO, JSON.stringify(simple_res.data.userInfo));
+                        resolve(simple_res.data);
+                    }
+                }).catch((err) => {
+                    reject({
+                        err: err
+                    });
+                })
+            },
+            fail: (err) => {
+                reject({
+                    err: err
+                })
+            }
+        })
+    });
+}

+ 17 - 16
view/xcx/utils/request.js

@@ -1,5 +1,5 @@
+// import {checkWxLogin} from './login.js';
 import util from './util.js';
-import authLogin from './autoLogin.js';
 import {
     HEADER,
     TOKENNAME
@@ -16,14 +16,14 @@ export default function request(api, method, data, {
         header = HEADER;
     if (!noAuth) {
         //登录过期自动登录
-        if (!util.isLoginValid()) {
-            return authLogin().then(res => {
-                return request(api, method, data, {
-                    noAuth,
-                    noVerify
-                });
-            });
-        }
+        // if (!Util.isLoginValid()) {
+        //     return checkWxLogin().then(res => {
+        //         return request(api, method, data, {
+        //             noAuth,
+        //             noVerify
+        //         });
+        //     });
+        // }
     }
 
     if (getApp().globalData.token) {
@@ -44,13 +44,14 @@ export default function request(api, method, data, {
                 } else if (res.data.status == 402) {
                     reslove(res.data, res);
                 } else if ([410000, 410001, 410002].indexOf(res.data.status) !== -1) {
-                    util.logout()
-                    return authLogin().then(res => {
-                        return request(api, method, data, {
-                            noAuth,
-                            noVerify
-                        });
-                    });
+                    // util.logout()
+                    // return checkWxLogin().then(res => {
+                    //     return request(api, method, data, {
+                    //         noAuth,
+                    //         noVerify
+                    //     });
+                    // });
+                    reject('请登录');
                 } else {
                     reject(res.data.msg || '系统错误');
                 }

+ 12 - 84
view/xcx/utils/util.js

@@ -1,6 +1,9 @@
 import {
     TOKENNAME
 } from './../config.js';
+import {
+    loginSilently
+} from './login.js';
 
 
 const formatTime = (date) => {
@@ -220,14 +223,6 @@ const isLoginValid = function (token, expiresTime, isLog) {
     return res2;
 } // isLoginValid
 
-const wxLogin = function (successFn) {
-    wx.login({
-        success(res) {
-            successFn(res);
-        }
-    })
-} // wxLogin
-
 const logout = function () {
     getApp().globalData.token = '';
     getApp().globalData.isLog = false;
@@ -243,83 +238,18 @@ const checkWxLogin = function () {
     return new Promise((resolve, reject) => {
         if (isLoginValid()) {
             return resolve({
-                userinfo: getApp().globalData.userInfo,
-                isLogin: true
+                userinfo: getApp().globalData.userInfo
             });
         }
-        wx.getSetting({
-            success(res) {
-                if (!res.authSetting['scope.userInfo']) {
-                    return reject({
-                        authSetting: false
-                    });
-                } else {
-                    wx.getStorage({
-                        key: 'cache_key',
-                        success(res) {
-                            wxGetUserProfile().then((userInfo) => {
-                                userInfo.cache_key = res.data;
-                                return resolve({
-                                    userInfo: userInfo,
-                                    isLogin: false
-                                });
-                            }).catch(res => {
-                                return reject(res);
-                            });
-                        },
-                        fail() {
-                            wxLogin((code) => {
-                                wxGetUserProfile().then((userInfo) => {
-                                    userInfo.code = code;
-                                    return resolve({
-                                        userInfo: userInfo,
-                                        isLogin: false
-                                    });
-                                }).catch(res => {
-                                    return reject(res);
-                                })
-                            });
-                        }
-                    })
-                }
-            },
-            fail(res) {
-                return reject(res);
-            }
-        })
-    })
-} // checkWxLogin
-
-/**
- * 授权过后自动登录
- * 逻辑:从缓存中读取 cache_key (对应服务端可获取 session_key, openid)
- *      读到则直接读取用户信息, 否则使用 wxLogin 走完整流程
- */
-const autoLogin = function () {
-    return new Promise((resolve, reject) => {
-        wx.getStorage({
-            key: 'cache_key',
-            success(res) {
-                wxGetUserProfile().then((userInfo) => {
-                    userInfo.cache_key = res.data;
-                    return resolve(userInfo);
-                }).catch(res => {
-                    return reject(res);
-                })
-            },
-            fail() {
-                wxLogin((code) => {
-                    wxGetUserProfile().then((userInfo) => {
-                        userInfo.code = code;
-                        return resolve(userInfo);
-                    }).catch(res => {
-                        return reject(res);
-                    })
-                });
-            }
+        loginSilently().then((res) => {
+            resolve({
+                userinfo: res.userInfo
+            });
+        }).catch((err) => {
+            reject(err);
         });
-    })
-} // autoLogin
+    });
+} // checkWxLogin
 
 /**
  * 合并数组
@@ -665,9 +595,7 @@ module.exports = {
     AnimationNumber: AnimationNumber,
     getUrlParams: getUrlParams,
     checkWxLogin: checkWxLogin,
-    wxLogin: wxLogin,
     isLoginValid: isLoginValid,
     wxGetUserProfile: wxGetUserProfile,
-    autoLogin: autoLogin,
     logout: logout
 }