Browse Source

登录完成后跳转回触发登录的页面

master
kola-web 2 months ago
parent
commit
66552cc272
  1. 2
      project.config.json
  2. 18
      src/app.ts
  3. 2
      src/pages/article/index.scss
  4. 11
      src/pages/article/index.ts
  5. 2
      src/pages/article/index.wxml
  6. 7
      src/pages/classify/index.ts
  7. 4
      src/pages/home/index.scss
  8. 5
      src/pages/login/index.ts
  9. 7
      src/pages/search/index.ts
  10. 9
      src/pages/search/index.wxml
  11. 3
      typings/index.d.ts

2
project.config.json

@ -61,5 +61,5 @@ @@ -61,5 +61,5 @@
}
]
},
"appid": "wxa4a28b299df7d921"
"appid": "wxbdf6f933281b1eb4"
}

18
src/app.ts

@ -17,20 +17,22 @@ App<IAppOption>({ @@ -17,20 +17,22 @@ App<IAppOption>({
// 测试号 wx2b0bb13edf717c1d
// dev
// appid:wxbdf6f933281b1eb4
// url: 'https://m.shizhong.hbraas.com',
// upFileUrl: 'https://m.shizhong.hbraas.com/',
// imageUrl: 'https://m.shizhong.hbraas.com/api/shizhong/',
url: 'https://m.shizhong.hbraas.com',
upFileUrl: 'https://m.shizhong.hbraas.com/',
imageUrl: 'https://m.shizhong.hbraas.com/api/shizhong/',
// pro
// appid:wxa4a28b299df7d921
url: 'https://m.shizhong.hbsaas.com',
upFileUrl: 'https://m.shizhong.hbsaas.com/',
imageUrl: 'https://m.shizhong.hbsaas.com/api/shizhong/',
// url: 'https://m.shizhong.hbsaas.com',
// upFileUrl: 'https://m.shizhong.hbsaas.com/',
// imageUrl: 'https://m.shizhong.hbsaas.com/api/shizhong/',
loginState: '',
isLogin: 0,
isAnswer: '0',
scene: null,
backPath: '',
},
onLaunch() {
Page = page as WechatMiniprogram.Page.Constructor;
@ -63,7 +65,7 @@ App<IAppOption>({ @@ -63,7 +65,7 @@ App<IAppOption>({
this.globalData.scene = parseScene(options.query.scene);
}
},
waitLogin(waitLoginState = false, requireLogin = false) {
waitLogin(waitLoginState = false, requireLogin = false, bakcPath = '') {
let time: number;
return new Promise((resolve) => {
time = setInterval(() => {
@ -73,8 +75,10 @@ App<IAppOption>({ @@ -73,8 +75,10 @@ App<IAppOption>({
if (waitLoginState) {
resolve(true);
} else if (isLogin === 0 || !isLogin) {
this.globalData.backPath = bakcPath;
wx.reLaunch({ url: '/pages/login/index' });
} else if (requireLogin && isLogin === 999) {
this.globalData.backPath = bakcPath;
wx.reLaunch({ url: '/pages/login/index' });
} else {
resolve(true);

2
src/pages/article/index.scss

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
.page {
padding: 48rpx 32rpx 200rpx;
padding: 48rpx 20rpx 200rpx;
.page-title {
font-size: 44rpx;

11
src/pages/article/index.ts

@ -246,9 +246,18 @@ Page({ @@ -246,9 +246,18 @@ Page({
this.setData({
toastShow: false,
});
wx.navigateBack();
wx.navigateBack({
fail() {
wx.reLaunch({
url: '/pages/classify/index',
});
},
});
},
handleAuthConform() {
const { BookId, ChapterId } = this.data;
const backPath = `/pages/article/index?id=${BookId}&cid=${ChapterId}`;
app.globalData.backPath = backPath;
wx.navigateTo({
url: '/pages/login/index?back=1',
});

2
src/pages/article/index.wxml

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
</van-slider>
</view>
<view class="rich">
<mp-html content="{{chapter.Content}}" scroll-table="{{true}}"></mp-html>
<mp-html content="{{chapter.Content}}" scroll-table="{{true}}" show-img-menu="{{false}}"></mp-html>
</view>
<view
class="quick-article"

7
src/pages/classify/index.ts

@ -26,7 +26,7 @@ Page({ @@ -26,7 +26,7 @@ Page({
},
onLoad(options) {
this.setData({
CateId: options.id,
CateId: options.id || '',
});
app.waitLogin().then(() => {
this.getCateList();
@ -185,9 +185,10 @@ Page({ @@ -185,9 +185,10 @@ Page({
},
handleDetail(e) {
const { id } = e.currentTarget.dataset;
app.waitLogin(false, true).then(() => {
const backPath = `/pages/article/index?id=${id}`;
app.waitLogin(false, true, backPath).then(() => {
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
url: backPath,
});
});
},

4
src/pages/home/index.scss

@ -43,7 +43,7 @@ page { @@ -43,7 +43,7 @@ page {
}
}
.swiper {
margin: 36rpx 32rpx 0;
margin: 36rpx 32rpx -52rpx;
height: 318rpx;
.wx-swiper-dots {
@ -89,7 +89,7 @@ page { @@ -89,7 +89,7 @@ page {
}
.cards {
margin: 0 32rpx;
margin: 52rpx 32rpx 0;
display: grid;
gap: 28rpx 26rpx;
grid-template-columns: repeat(2, 1fr);

5
src/pages/login/index.ts

@ -136,7 +136,9 @@ Page({ @@ -136,7 +136,9 @@ Page({
},
submitCallback() {
app.globalData.isLogin = 1;
wx.reLaunch({ url: '/pages/home/index' });
const backPath = app.globalData.backPath;
wx.reLaunch({ url: backPath || '/pages/home/index' });
app.globalData.backPath = '';
},
handleProtool() {
this.setData({
@ -149,6 +151,7 @@ Page({ @@ -149,6 +151,7 @@ Page({
handleVisitor() {
if (app.globalData.isLogin !== 1) {
app.globalData.isLogin = 999;
app.globalData.backPath = '';
}
wx.reLaunch({
url: '/pages/home/index',

7
src/pages/search/index.ts

@ -65,10 +65,11 @@ Page({ @@ -65,10 +65,11 @@ Page({
wx.navigateBack();
},
handleDetail(e) {
const { id } = e.currentTarget.dataset;
app.waitLogin(false, true).then(() => {
const { id, cid } = e.currentTarget.dataset;
const backPath = `/pages/article/index?id=${id}&cid=${cid}`;
app.waitLogin(false, true, backPath).then(() => {
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
url: backPath,
});
});
},

9
src/pages/search/index.wxml

@ -23,7 +23,14 @@ @@ -23,7 +23,14 @@
/>
</view>
<view class="tip" wx:if="{{list.length}}">以下为搜到的内容</view>
<view class="card" wx:for="{{list}}" wx:key="index" bind:tap="handleDetail" data-id="{{item.BookId}}">
<view
class="card"
wx:for="{{list}}"
wx:key="index"
bind:tap="handleDetail"
data-id="{{item.BookId}}"
data-cid="{{item.ChapterId}}"
>
<image class="photo" mode="aspectFill" src="{{item.CoverUrl}}"></image>
<view class="c-container">
<view class="title">{{item.ChapterName}}</view>

3
typings/index.d.ts vendored

@ -8,9 +8,10 @@ interface IAppOption { @@ -8,9 +8,10 @@ interface IAppOption {
isLogin: 0 | 1 | 999;
isAnswer: '0' | '1';
scene: null | { [key: string]: any };
backPath: string;
};
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback;
waitLogin: (waitLoginState?: boolean, requireLogin?: boolean) => Promise<any>;
waitLogin: (waitLoginState?: boolean, requireLogin?: boolean, backPath?: string) => Promise<any>;
getMenuInfo: (arg0: WechatMiniprogram.Page.Instance<any, any>) => void;
getUserInfo: (arg0: WechatMiniprogram.Page.Instance<any, any>, arg1?: (arg0: any) => void) => void;
}

Loading…
Cancel
Save