Bladeren bron

feat(controller): 优化 登录等

xiansin 3 jaren geleden
bovenliggende
commit
9eb9068c72
6 gewijzigde bestanden met toevoegingen van 23 en 32 verwijderingen
  1. 1 7
      App.vue
  2. 4 0
      core/http.interceptor.js
  3. 2 1
      core/site.js
  4. 15 21
      core/util.js
  5. 0 2
      pages/login/login.vue
  6. 1 1
      pages/my/index.vue

+ 1 - 7
App.vue

xqd
@@ -8,13 +8,7 @@
                 'pages/login/login',
             ];
             if(!userToken && (notLogin.indexOf(options.path) === -1)){
-                let arr = [];
-                for (const key in options.query) {
-                    arr.push(`${key}=${options.query[key]}`)
-                }
-                uni.reLaunch({
-                    url: `/pages/login/login?redirect=${options.path}&${arr.join("&")}`,
-                });
+                this.$util.login();
             }
 		},
         onShow(options){

+ 4 - 0
core/http.interceptor.js

xqd
@@ -31,6 +31,10 @@ const install = (Vue, vm) => {
 			if(res.code === 200) {
 				// 如果把originalData设置为了true,这里return回什么,this.$u.post的then回调中就会得到什么
 				return typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
+			}if(res.code === 401) {
+				Vue.prototype.$u.vuex(Vue.prototype.$const.USER_TOKEN,null)
+				Vue.prototype.$u.vuex(Vue.prototype.$const.USER_DATA,null)
+				Vue.prototype.$util.login();
 			}else {
 				uni.showModal({
 					title: '提示',

+ 2 - 1
core/site.js

xqd
@@ -3,6 +3,7 @@
  */
 const ENV = process.env.NODE_ENV === 'development';
 module.exports = {
-    root: ENV ? 'https://t16.9026.com/' : 'https://t16.9026.com/',
+    root: 'http://www.sange-bridge.me/',
+    // root: ENV ? 'https://t16.9026.com/' : 'https://t16.9026.com/',
     authKey: "!j1^z9hE4sXJdEE$#S1GLYQnWfEBakex",
 }

+ 15 - 21
core/util.js

xqd xqd xqd
@@ -122,25 +122,6 @@ const shareMessage = user => {
  */
 const share = (user,scene = "WXSenceTimeline") => {
     uni.share({
-        provider: 'weixin',
-        scene: "WXSceneSession",
-        type: 5,
-        imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/962fc340-4f2c-11eb-bdc1-8bd33eb6adaa.png',
-        title: '欢迎体验uniapp',
-        miniProgram: {
-            id: 'gh_abcdefg',
-            path: 'pages/index/index',
-            type: 0,
-            webUrl: 'http://uniapp.dcloud.io'
-        },
-        success: ret => {
-            console.log(JSON.stringify(ret));
-        },
-        fail: err =>  {
-            console.error("fail:" + JSON.stringify(err));
-        }
-    });
-    /*uni.share({
         provider: "weixin",
         scene: scene,
         type: 5, // 小程序
@@ -157,7 +138,19 @@ const share = (user,scene = "WXSenceTimeline") => {
         fail: function (err) {
             console.error("fail:" + JSON.stringify(err));
         }
-    });*/
+    });
+}
+
+const login = () => {
+    let page = getCurrentPages()[0]
+    let route = page.route;
+    let arr = [];
+    for (const key in page.options) {
+        arr.push(`${key}=${page.options[key]}`)
+    }
+    uni.reLaunch({
+        url: `/pages/login/login?redirect=${route}&${arr.join("&")}`,
+    });
 }
 
 
@@ -178,5 +171,6 @@ export {
     round,
     objectToUrlParams,
     shareMessage,
-    share
+    share,
+    login
 }

+ 0 - 2
pages/login/login.vue

xqd xqd
@@ -7,7 +7,6 @@
             <view class="popup-content">
                 <view class="title">需要获取您的用户信息</view>
                 <view class="btn-popup main-between">
-                    <button @click="handleRedirect" class="cancel btn main-center cross-center">取消</button>
                     <button @click="handleLogin" class="btn main-center cross-center">确定</button>
                 </view>
             </view>
@@ -63,7 +62,6 @@
                 });
             },
             handleLogin(){
-                console.log('-->data 获取用户信息')
                 let _this = this;
                 uni.getUserProfile({
                     desc: '获取用户信息',

+ 1 - 1
pages/my/index.vue

xqd
@@ -32,7 +32,7 @@
 				</view>
 			</view>
 			<u-cell-group :border="false" class="tab-list">
-				<u-cell-item title="桥架会员" :border-bottom="false" bg-color="#f9f9f9" @click="handleJumpBuy">
+				<u-cell-item title="桥架会员" :border-bottom="false" bg-color="#f9f9f9" @click="handleJumpBuy" v-if="!setting.review_mode">
 					<view slot="icon" class="icon bridge"></view>
 				</u-cell-item>
 				<u-cell-item title="会员购买记录" :border-bottom="false" bg-color="#f9f9f9" @click="$jump({url:'/pages/my/member-record',type:'to'})">