Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
dev
/
zhiliang-light-mp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c5e7bb74
authored
2019-08-15 18:30:22 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
no message
1 parent
a3892636
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
11 deletions
src/app.js
src/http/api.js
src/pages/user-center/user-center.js
src/pages/webview/webview.js
src/pages/webview/webview.json
src/pages/webview/webview.wxml
src/router/index.js
src/app.js
View file @
c5e7bb7
...
...
@@ -28,6 +28,7 @@ App({
tlMemberCode
:
""
,
giftInfo
:
null
,
// 来自 gift-shop
addressEditInfo
:
null
,
// 编辑时的临时对象
// postMessageData: null,
},
//重写分享方法
share
:
function
()
{
...
...
src/http/api.js
View file @
c5e7bb7
...
...
@@ -35,6 +35,7 @@ module.exports = {
signInfo
:
'/sign/info'
,
// post 签到信息 用户注册接口
sign
:
'/sign'
,
// post 签到动作 用户注册接口
signRecord
:
'/sign/record'
,
// post 签到记录 用户注册接口
saveOpenid
:
'/member/save/subscription/openid'
,
//保存 openid
areaQuery
:
'https://api.k.wxpai.cn/bizproxy/kdapi/area'
,
// post 区域查询
...
...
src/pages/user-center/user-center.js
View file @
c5e7bb7
...
...
@@ -25,13 +25,58 @@ Page({
},
onShow
()
{
this
.
initData
();
},
onLoad
(
options
)
{
// app.router.push({
// path: "webview"
// })
},
initData
()
{
this
.
queryMember
().
then
((
result
)
=>
{
this
.
querySignInfo
();
let
subscriptionOpenid
=
result
.
subscriptionOpenid
;
if
(
subscriptionOpenid
)
{
// member表 已有openid 继续流程
this
.
querySignInfo
();
}
else
{
// member表无openid ,重h5授权回来的local拿,成功就继续往下走
this
.
querySaveOpenid
().
then
((
result
)
=>
{
this
.
queryMember
().
then
((
result
)
=>
{
this
.
querySignInfo
();
})
}).
catch
((
err
)
=>
{
// 如果均没有,则去h5授权
app
.
router
.
push
({
path
:
"webview"
})
});
}
});
},
/**
* 保存openid
*/
querySaveOpenid
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
openid
=
app
.
store
.
getItem
(
"openid"
);
if
(
openid
)
{
app
.
post
({
toast
:
false
,
url
:
app
.
api
.
saveOpenid
,
data
:
{
subscriptionOpenid
:
openid
}
}).
then
((
result
)
=>
{
console
.
log
(
"result:"
,
result
);
app
.
store
.
clear
(
"openid"
);
resolve
();
}).
catch
((
err
)
=>
{
reject
();
});
}
else
{
reject
();
}
});
},
...
...
@@ -157,7 +202,7 @@ Page({
this
.
setData
({
userInfo
:
result
})
resolve
();
resolve
(
result
);
})
});
},
...
...
src/pages/webview/webview.js
View file @
c5e7bb7
...
...
@@ -2,24 +2,48 @@ let app = getApp();
Page
({
data
:
{
isShow
:
false
,
// 控制组件显示隐藏
url
:
''
url
:
''
,
message
:
"-"
,
},
onShareAppMessage
(
options
)
{
return
{
title
:
'title'
,
path
:
this
.
url
,
success
:
function
(
res
)
{
// that.web_url = return_url
// 转发成功
wx
.
showToast
({
title
:
"转发成功"
,
icon
:
'success'
,
duration
:
2000
})
},
fail
:
function
(
res
)
{
// 转发失败
}
}
},
onLoad
(
options
=
{})
{
let
url
=
options
.
url
;
url
=
"https://k.wxpai.cn/IdgW/index.html"
console
.
log
(
"url:"
,
url
);
if
(
url
)
{
this
.
setData
({
url
:
url
,
isShow
:
true
})
}
else
{
wx
.
showToast
({
title
:
'未找到页面地址'
,
title
:
'none'
,
});
//
wx.showToast({
//
title: '未找到页面地址',
//
title: 'none',
//
});
}
},
onBindMessage
(
e
)
{
console
.
log
(
"webview message:"
,
e
);
let
postMessageData
=
e
.
detail
.
data
[
0
]
let
openid
=
postMessageData
.
openid
;
app
.
store
.
setItem
(
"openid"
,
openid
);
}
})
...
...
src/pages/webview/webview.json
View file @
c5e7bb7
{
"navigationBarTitleText"
:
"webview
"
"navigationBarTitleText"
:
"加载中
"
}
...
...
src/pages/webview/webview.wxml
View file @
c5e7bb7
<view class="loading-wrap">
<view class="loading">
<view class="icon"></view>
<view class="text">
加载中...
</view>
<view class="text">
{{message}}
</view>
</view>
</view>
<!-- <view class="message">{{message}}</view> -->
<web-view wx:if="{{isShow}}" src="{{url}}" bindload="loadSucc" bindmessage="onBindMessage" />
...
...
src/router/index.js
View file @
c5e7bb7
...
...
@@ -19,6 +19,7 @@ const routerPath = {
signInRecord
:
'/pages/sign-in-record/sign-in-record'
,
// 签到记录
rank
:
'/pages/rank/rank'
,
// 排行榜
rankGift
:
'/pages/rank-gift/rank-gift'
,
// 排行榜奖励
webview
:
'/pages/webview/webview'
,
example
:
'/pages/example/example'
,
more
:
'/pages/more/more'
,
}
...
...
Please
register
or
sign in
to post a comment