Commit db55fc7b by 高淑倩

add: 首页支付授权弹框

parent a52b17e5
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
] ]
} }
], ],
"usingComponents": {
"authorization-modal": "/component/authorization-modal/authorization-modal"
},
"window": { "window": {
"backgroundTextStyle": "dark", "backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#fff",
......
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
} }
} }
\ No newline at end of file
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
} }
} }
\ No newline at end of file
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
} }
} }
\ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
"component": true, "component": true,
"onReachBottomDistance": 0, "onReachBottomDistance": 0,
"usingComponents": { "usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
} }
} }
\ No newline at end of file
...@@ -26,34 +26,3 @@ ...@@ -26,34 +26,3 @@
isAuthorizationType="{{isAuthorizationType}}" isAuthorizationType="{{isAuthorizationType}}"
isAuthorizationActiveText="{{isAuthorizationActiveText}}" isAuthorizationActiveText="{{isAuthorizationActiveText}}"
/> />
<!--<view class="pic-nav">
<view
wx:for="{{picNav}}"
wx:key="{{index}}"
wx:for-item="item"
class="nav-block"
style="width: {{imagewidth}}px;height: {{imageheight}}px;"
>
<image
wx:if="{{baseImgUrl}}"
class="pic-img"
style="width: {{imagewidth}}px;height: {{imageheight}}px;"
src="{{baseImgUrl}}{{item.imageUrl}}"
data-appid="{{item.link.appid}}"
data-path="{{item.link.url}}"
data-link="{{item.link}}"
data-item="{{item}}"
bindload="imageLoad"
bindtap='preview'
/>
</view>
</view>
<authorization-modal
isAuthorization='{{isAuthorization}}'
bind:activeTocard="activeTocard"
isAuthorizationType="{{isAuthorizationType}}"
isAuthorizationActiveText="{{isAuthorizationActiveText}}"
/>
-->
// component/plus/plus.js // component/plus/plus.js
const wxService = require('../../utils/wxService') const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
Component({ Component({
/** /**
...@@ -13,6 +14,10 @@ Component({ ...@@ -13,6 +14,10 @@ Component({
plusBgi:{ plusBgi:{
type: Object, type: Object,
value: null value: null
},
currentHasUserInfo:{
type: Boolean,
type: false
} }
}, },
...@@ -22,11 +27,59 @@ Component({ ...@@ -22,11 +27,59 @@ Component({
data: { data: {
currentTab:'999' currentTab:'999'
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
_getUserInfo(res = {}) {
const userInfo = res.detail || {}
console.log('userInfo',userInfo)
// 先授权再领卡
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then( (data = {} ) => {
const {token} = data
wx.setStorageSync('_accreditUserInfo', userInfo)
wx.hideNavigationBarLoading()
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data) // 缓存用户信息
this.setUserInfo() // 判断有无开卡
}).catch(err=> {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
}
},
setUserInfo () {
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
// 跳转
const urls = getCurrentPages()
setTimeout(() => {
const item = urls[0].options
if (item.route) {
try {
const options = JSON.parse(item.options)
wxService.router(`/${item.route}`).search(options).replace()
} catch (e) {
wxService.router('/pages/userCenter/userCenter').replace()
}
} else {
wxService.router('/pages/userCenter/userCenter').replace()
}
}, 200)
},
switchNav(e){ switchNav(e){
this.setData({ this.setData({
currentTab: e.currentTarget.dataset.current, currentTab: e.currentTarget.dataset.current,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
data-btnText="{{navItem.buttonText}}" data-btnText="{{navItem.buttonText}}"
data-id="{{navItem.id}}" data-id="{{navItem.id}}"
bindtap="switchNav" bindtap="switchNav"
style="{{currentTab == idx ? 'background-image: url('+ plusBgi.activeUrl +');' : 'background-image: url('+ plusBgi.inactiveUrl +');'}}" style="{{currentTab == idx ? 'background-image: url('+ plusBgi.activeUrl +');' : 'background-image: url('+ plusBgi.inactiveUrl +');'}}"
> >
<view class="plus-choose"> <view class="plus-choose">
<text>每月仅¥{{navItem.price / navItem.duration * 30}}</text> <text>每月仅¥{{navItem.price / navItem.duration * 30}}</text>
...@@ -36,10 +36,25 @@ ...@@ -36,10 +36,25 @@
</block> </block>
</scroll-view> </scroll-view>
<view class="pay"> <view class="pay">
<button class="btn btn-primary" bindtap="payPlus"> <!--微信授权-->
<text>立即支付</text> <block wx:if="{{!currentHasUserInfo}}">
<text>¥158</text> <button
</button> bindgetuserinfo="_getUserInfo"
data-jflag="false"
open-type='getUserInfo'
class='btn btn-primary'
hover-class="btn-hover"
>
<text>{{currentHasUserInfo}}立即支付</text>
<text>¥158</text>
</button>
</block>
<block wx:else>
<button class="btn btn-primary" bindtap="payPlus">
<text>{{currentHasUserInfo}}立即支付</text>
<text>¥158</text>
</button>
</block>
</view> </view>
</view> </view>
...@@ -75,6 +75,7 @@ wxService.page({ ...@@ -75,6 +75,7 @@ wxService.page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
console.log('0this.data.currentHasUserInfo', this.data.currentHasUserInfo)
// 取会员卡号 // 取会员卡号
const baseUserInfo = wx.getStorageSync('_baseUserInfo') const baseUserInfo = wx.getStorageSync('_baseUserInfo')
const cardMember = wx.getStorageSync('_cardMember') const cardMember = wx.getStorageSync('_cardMember')
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"person-center": "/component/personCenter/personCenter", "person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav", "pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom", "bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"tab-sort": "/component/tabSort/tabSort", "tab-sort": "/component/tabSort/tabSort",
"announcement": "/component/announcement/announcement", "announcement": "/component/announcement/announcement",
"icon-swiper": "/component/iconSwiper/iconSwiper", "icon-swiper": "/component/iconSwiper/iconSwiper",
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
"attention": "/component/attention/attention", "attention": "/component/attention/attention",
"guide-page-modal": "/component/guidePageModal/guidePageModal", "guide-page-modal": "/component/guidePageModal/guidePageModal",
"bottom-tabs": "/component/bottomTabs/bottomTabs", "bottom-tabs": "/component/bottomTabs/bottomTabs",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"plus": "/component/plus/plus" "plus": "/component/plus/plus"
} }
} }
\ No newline at end of file
...@@ -27,10 +27,9 @@ ...@@ -27,10 +27,9 @@
<attention focus-wx="{{pItem.focusWx}}" /> <attention focus-wx="{{pItem.focusWx}}" />
</view> </view>
<view class="" wx:if="{{pItem.type == 9}}"> <view class="" wx:if="{{pItem.type == 9}}">
<plus sku-list="{{skuVOList}}" plus-bgi="{{pItem.plus}}"/> <plus sku-list="{{skuVOList}}" plus-bgi="{{pItem.plus}}" currentHasUserInfo="{{currentHasUserInfo}}"/>
</view> </view>
</block> </block>
</view> </view>
<authorization-modal isAuthorization='{{isAuthorization}}' />
<guide-page-modal show="{{guidePageModalShow}}" /> <guide-page-modal show="{{guidePageModalShow}}" />
<!--<authorization-modal isAuthorization='{{isAuthorization}}'/>-->
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"person-center": "/component/personCenter/personCenter", "person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav", "pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom", "bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"tab-sort": "/component/tabSort/tabSort", "tab-sort": "/component/tabSort/tabSort",
"announcement": "/component/announcement/announcement", "announcement": "/component/announcement/announcement",
"icon-swiper": "/component/iconSwiper/iconSwiper", "icon-swiper": "/component/iconSwiper/iconSwiper",
......
...@@ -33,5 +33,4 @@ ...@@ -33,5 +33,4 @@
<!--goHome--> <!--goHome-->
<go-home wx:if="{{goHome}}"/> <go-home wx:if="{{goHome}}"/>
</view> </view>
<authorization-modal isAuthorization='{{isAuthorization}}' />
<guide-page-modal show="{{guidePageModalShow}}" /> <guide-page-modal show="{{guidePageModalShow}}" />
...@@ -100,12 +100,15 @@ class WXService extends Http { ...@@ -100,12 +100,15 @@ class WXService extends Http {
duration: 2000 duration: 2000
}) })
} else { } else {
this.reLogin() // 重新登陆之前判断是否登陆过 重新登陆
const baseUserInfo = this.getBaseUserInfo()
if (baseUserInfo) {
this.reLogin()
return false
}
} }
} else if (res.msg && res.msg.indexOf('请重新授权') > -1) { } else if (res.msg && res.msg.indexOf('请重新授权') > -1) {
wx.setStorageSync('reLoginErr', true) wx.setStorageSync('reLoginErr', true)
// wxService.router(`/pages/userCenter/userCenter`).replace()
console.log("授权跳转")
wxService.router(`/pages/userCenter/userCenter`).back() wxService.router(`/pages/userCenter/userCenter`).back()
} }
}) })
...@@ -220,7 +223,8 @@ class WXService extends Http { ...@@ -220,7 +223,8 @@ class WXService extends Http {
}) })
} else if (res.data.data.isMember === '1') { } else if (res.data.data.isMember === '1') {
let baseUserInfo = this.getBaseUserInfo() let baseUserInfo = this.getBaseUserInfo()
let newBaseUserInfo = { ...baseUserInfo, let newBaseUserInfo = {
...baseUserInfo,
...res.data.data ...res.data.data
} }
this.baseUserInfo = newBaseUserInfo this.baseUserInfo = newBaseUserInfo
...@@ -245,7 +249,7 @@ class WXService extends Http { ...@@ -245,7 +249,7 @@ class WXService extends Http {
} }
//生成触点对象Id //生成触点对象Id
getTentacleContent(tentacleInfo){ getTentacleContent(tentacleInfo) {
return this.post('/marketing/tentacleContent/getTentacleContent', tentacleInfo).then((res) => { return this.post('/marketing/tentacleContent/getTentacleContent', tentacleInfo).then((res) => {
let data = res.data.data let data = res.data.data
return Promise.resolve(data); return Promise.resolve(data);
...@@ -255,8 +259,8 @@ class WXService extends Http { ...@@ -255,8 +259,8 @@ class WXService extends Http {
} }
//根据触点对象id获取触点对象信息 //根据触点对象id获取触点对象信息
getTentacleContentByTentacleId(tentacleId){ getTentacleContentByTentacleId(tentacleId) {
this.post('/marketing/tentacleContent/getTentacleContent', { tentacleId: tentacleId}).then((res) => { this.post('/marketing/tentacleContent/getTentacleContent', { tentacleId: tentacleId }).then((res) => {
let data = res.data.data let data = res.data.data
let TENTACLE_CONTENT = { let TENTACLE_CONTENT = {
id: data.id, id: data.id,
...@@ -267,7 +271,7 @@ class WXService extends Http { ...@@ -267,7 +271,7 @@ class WXService extends Http {
} }
let storageObj = { let storageObj = {
memberId : '', memberId: '',
obj: TENTACLE_CONTENT obj: TENTACLE_CONTENT
} }
...@@ -281,9 +285,9 @@ class WXService extends Http { ...@@ -281,9 +285,9 @@ class WXService extends Http {
}) })
} }
//更新本地触点对象信息 //更新本地触点对象信息
updateLocalTentacleInfo(){ updateLocalTentacleInfo() {
//先获取本地触点对象信息 //先获取本地触点对象信息
let tentacleInfo = wx.getStorageSync('TENTACLE_CONTENT'); let tentacleInfo = wx.getStorageSync('TENTACLE_CONTENT');
//获取从种草详情商品购买时存储的临时触点对象信息 //获取从种草详情商品购买时存储的临时触点对象信息
...@@ -297,18 +301,18 @@ class WXService extends Http { ...@@ -297,18 +301,18 @@ class WXService extends Http {
* *
*/ */
//判断tentacleInfo是否为空 //判断tentacleInfo是否为空
if (!tentacleInfo){ if (!tentacleInfo) {
wx.setStorageSync('TENTACLE_CONTENT', tempTentacleInfo); wx.setStorageSync('TENTACLE_CONTENT', tempTentacleInfo);
return ; return;
} }
//tentacleInfo 不为空 //tentacleInfo 不为空
//判断先获取本地触点对象信息 中memberid 是否为空 //判断先获取本地触点对象信息 中memberid 是否为空
let memberId = tentacleInfo.memberId; let memberId = tentacleInfo.memberId;
// 若memberId 为空 表示从分享过来的链接 此时不能更新wx.getStorageSync('TENTACLE_CONTENT') 信息 // 若memberId 为空 表示从分享过来的链接 此时不能更新wx.getStorageSync('TENTACLE_CONTENT') 信息
if (!memberId){ if (!memberId) {
return ; return;
} }
//不为空 则表示 之前从种草详情中的商品直接购买过 直接更新本地TENTACLE_CONTENT //不为空 则表示 之前从种草详情中的商品直接购买过 直接更新本地TENTACLE_CONTENT
wx.setStorageSync('TENTACLE_CONTENT', tempTentacleInfo); wx.setStorageSync('TENTACLE_CONTENT', tempTentacleInfo);
} }
...@@ -327,7 +331,7 @@ class WXService extends Http { ...@@ -327,7 +331,7 @@ class WXService extends Http {
scrollOffset() { scrollOffset() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.createSelectorQuery().selectViewport().scrollOffset(function(res) { wx.createSelectorQuery().selectViewport().scrollOffset(function (res) {
resolve(res) resolve(res)
}).exec() }).exec()
}) })
...@@ -367,7 +371,7 @@ class WXService extends Http { ...@@ -367,7 +371,7 @@ class WXService extends Http {
}) })
} }
getNavBarBackGroundColor(fc,bgc) { getNavBarBackGroundColor(fc, bgc) {
wx.setNavigationBarColor({ wx.setNavigationBarColor({
frontColor: fc, frontColor: fc,
backgroundColor: bgc, backgroundColor: bgc,
...@@ -378,6 +382,62 @@ class WXService extends Http { ...@@ -378,6 +382,62 @@ class WXService extends Http {
}) })
} }
handlerPage(page) {
const AccreditWhitePages = [
'pages/welcome/welcome'
] // 免授权页面白名单
const _self = this
const app = _self.getApp()
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
if (baseUserInfo && baseUserInfo.isMember === '1') {
app.globalData.openCard = true
}
return new Promise((resolve, reject) => {
let accreditUserInfo = wx.getStorageSync('_accreditUserInfo')
if (app.globalData.openCard && accreditUserInfo) {
resolve()
return false
}
if (AccreditWhitePages.indexOf(page.route) > -1) {
resolve()
} else if (accreditUserInfo) {
getAppUserInfo().then(() => {
if (this.lock) {
return false
}
if ((!baseUserInfo || baseUserInfo.isMember !== '1') && needOpenCard()) {
reject({ state: 1 })
_self.lock = false
} else {
_self.lock = false
resolve()
}
}).catch((res) => {
reject()
})
} else {
reject({ state: 1 })
}
}).catch((err) => {
if (err && err.state === 1) {
const modifyMottoRoute = [
"pos/express/pages/orderList/orderList",
"pos/express/pages/confirm/confirm"
]
let router = '/pages/welcome/welcome';
if (modifyMottoRoute.indexOf(page.route) > -1) {
page.options.motto = 'express';
}
wxService.router('/pages/welcome/welcome').search({
route: `${page.route}`,
options: JSON.stringify(page.options)
}).replace()
}
return Promise.reject()
})
}
// handlerPage (page) { // handlerPage (page) {
// const AccreditWhitePages = [ // const AccreditWhitePages = [
...@@ -454,53 +514,66 @@ class WXService extends Http { ...@@ -454,53 +514,66 @@ class WXService extends Http {
page(config) { page(config) {
const _self = this const _self = this
// 当前是否有用户信息
config.data.currentHasUserInfo = false;
// 当前页面是否需要授权
config.data.currentPageRequireAuth = false;
const CONFIG_PAPGE = { const CONFIG_PAPGE = {
onLoad: function(...args) { onLoad: function (...args) {
const page = this const page = this
_self.initAppGlobalDataSync() _self.initAppGlobalDataSync()
//修改参数 //修改参数
let pageIsFromShare = false, tentacleId = null; let pageIsFromShare = false, tentacleId = null;
args.forEach(item => { args.forEach(item => {
if(item['t']){ if (item['t']) {
pageIsFromShare = true; pageIsFromShare = true;
tentacleId = Integer.digit(item['t'],64,10); tentacleId = Integer.digit(item['t'], 64, 10);
if (item['i']){ if (item['i']) {
item['id'] = Integer.digit(item['i'], 64, 10); item['id'] = Integer.digit(item['i'], 64, 10);
} }
} }
}); });
console.log('--------', args)
//如果打开的是分享界面则进行触点对象信息请求并存储到本地 放到后续的header中 //如果打开的是分享界面则进行触点对象信息请求并存储到本地 放到后续的header中
if (pageIsFromShare){ if (pageIsFromShare) {
//调用接口 //调用接口
_self.getTentacleContentByTentacleId(tentacleId); _self.getTentacleContentByTentacleId(tentacleId);
} }
config.onLoad && config.onLoad.apply(page, args); config.onLoad && config.onLoad.apply(page, args);
}, },
onShow: function(...args) { onShow: function (...args) {
const page = this const page = this
_self.currentPage = page _self.currentPage = page
config.onShow && config.onShow.apply(page, args) config.onShow && config.onShow.apply(page, args)
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
if (baseUserInfo) {
page.setData({
currentHasUserInfo: true
});
} else {
page.setData({
currentHasUserInfo: false
});
}
}, },
onReady: function(...args) { onReady: function (...args) {
config.onReady && config.onReady.apply(this, args) config.onReady && config.onReady.apply(this, args)
}, },
onHide: function(...args) { onHide: function (...args) {
const page = this const page = this
config.onHide && config.onHide.apply(this, args) config.onHide && config.onHide.apply(this, args)
// page.setData({
// currentHasUserInfo: false
// });
}, },
onUnload: function(...args) { onUnload: function (...args) {
config.onUnload && config.onUnload.apply(this, args) config.onUnload && config.onUnload.apply(this, args)
}, },
onPageScroll: function(...args) { onPageScroll: function (...args) {
config.onPageScroll && config.onPageScroll.apply(this, args) config.onPageScroll && config.onPageScroll.apply(this, args)
}, },
onShareAppMessage: function(...args) { onShareAppMessage: function (...args) {
const page = this const page = this
const baseUserInfo = wx.getStorageSync('_baseUserInfo') const baseUserInfo = wx.getStorageSync('_baseUserInfo')
let openId = '' let openId = ''
...@@ -570,7 +643,7 @@ class WXService extends Http { ...@@ -570,7 +643,7 @@ class WXService extends Http {
fail: (res) => { fail: (res) => {
reject(res) reject(res)
}, },
complete: () => {} complete: () => { }
}) })
}) })
} }
...@@ -579,7 +652,7 @@ class WXService extends Http { ...@@ -579,7 +652,7 @@ class WXService extends Http {
const _self = this const _self = this
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
if (!openCardLister) { if (!openCardLister) {
openCardLister = cEvent.on('openCardSuccess', function(data) { openCardLister = cEvent.on('openCardSuccess', function (data) {
openCardLister = null openCardLister = null
resolve(data) resolve(data)
}) })
...@@ -606,11 +679,11 @@ class WXService extends Http { ...@@ -606,11 +679,11 @@ class WXService extends Http {
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: 'wxeb490c6f9b154ef9', // 固定为此 appid,不可改动 appId: 'wxeb490c6f9b154ef9', // 固定为此 appid,不可改动
extraData: options, // 包括 encrypt_card_id, outer_str, biz三个字段,须从 step3 中获得的链接中获取参数 extraData: options, // 包括 encrypt_card_id, outer_str, biz三个字段,须从 step3 中获得的链接中获取参数
success: function(data) { success: function (data) {
console.log('navigateToMiniProgram success data is %o', data) console.log('navigateToMiniProgram success data is %o', data)
_self.lock = false _self.lock = false
}, },
fail: function(data) { fail: function (data) {
console.log('navigateToMiniProgram fail data is %o', data) console.log('navigateToMiniProgram fail data is %o', data)
this.router('/pages/userCenter/userCenter') this.router('/pages/userCenter/userCenter')
// this.router('/pages/welcome/welcome') // this.router('/pages/welcome/welcome')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment