Commit e39e5184 by chenwq

领取红包,授权登陆

1 parent debeaf15
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"pages/tab/mine/index", "pages/tab/mine/index",
"pages/tab/strategy/index", "pages/tab/strategy/index",
"pages/webView/webView", "pages/webView/webView",
"pages/Login/Login" "pages/Login/Login",
"pages/crowdfunding/blank/blank"
], ],
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation" "getLocation"
...@@ -113,7 +114,9 @@ ...@@ -113,7 +114,9 @@
"pages": [ "pages": [
"pages/index/index" "pages/index/index"
], ],
"plugins": {} "plugins": {
}
}, },
{ {
"root": "packageStrategy", "root": "packageStrategy",
......
import { couponsApi, shopmallApi, ssoApi } from '~/api/index' const navStyle = 'background-color: transparent;'
import USER from '~/api/usersApi/index' const navTitleStyle = "font-weight: 600; font- size: 34rpx; color: #000000;"
import { defaultMerchantId } from '~/api/env/index' import environment from '~/api/env/index'
Page({ Page({
data: { data: {
IMGURL: wx.p.IMGURL, IMGURL: wx.p.IMGURL,
freeDay: 0, freeDay: 0,
paddingH: 86, paddingH: 86,
textpadding: 508, textpadding: 508,
showAuthBtn: true showAuthBtn: true,
navStyle,
navTitleStyle,
imgList: new Array(3),
authStatus: true,
hasUserInfo: false
}, },
navbarReady(e) {
let { height, statusBarHeight } = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight,
tabBoxStyle: `height: ${height}px`,
statusBarHeight,
navigationBarHeight: height
})
},
/**微信登录 */
async getPhoneNumber({
detail
}) {
try {
if (detail.errMsg && ['authorized', 'deny'].findIndex(e => detail.errMsg.toLowerCase().includes(e)) != -1) return
if (!detail?.code) throw '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
wx.p.wxApi.showLoading()
const {
code,
data,
message
} = await wx.p.api.userApi.authUserPhone(detail, this.sessionId)
wx.hideLoading()
if (code == '0') this.customerLoginCallBack(data)
else throw message
} catch (error) {
console.log(error)
this.showTips(error || '服务不可用')
setTimeout(() => {
this.onLoad()
}, 1500)
}
},
showTips(message) {
wx.p.wxApi.showToast(typeof message == 'string' ? message : '请同意以下用户协议')
},
customerLoginCallBack(data) {
wx.$LoginStatus = false
wx.p.storage.set('userInfo', data)
wx.p.storage.set('sessionId', data.sessionId)
let { nickName, headImgUrl } = data
this.setData({
userInfo: data,
authStatus: false
})
console.log(data, 'data--')
if (nickName || headImgUrl) {
this.setData({
hasUserInfo: true
})
}
},
async jumpAuthUserInfo() {
this.authFlag = true
const {
domain,
index
} = environment,
// redirectUrl = `${domain}/wx-oauth`,
redirectUrl = `https://scrm.glsx.com.cn/wx-oauth`,
// redirectUrl = 'http://scrm.dev.glsx.com.cn/wx-oauth',
// 云商 wx1cf40dc91c28a7fd ,glsxtest02 wx56bed167ad463f70
appid = 'wx56bed167ad463f70',
wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
console.log(redirectUrl, appid)
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(wxUrl)}`,
})
},
toPostFreeCard(merchantId, phone, userInfo) { toPostFreeCard(merchantId, phone, userInfo) {
let para = { let para = {
merchantId, merchantId,
phone phone
} }
couponsApi.tolqFreecard(para).then(res => { wx.p.api.couponsApi.tolqFreecard(para).then(res => {
wx.hideLoading() wx.hideLoading()
const { errId, code, message } = res const { errId, code, message } = res
if ((code == -1 && errId == 20313) || (code == -1 && errId == 20322)) { if ((code == -1 && errId == 20313) || (code == -1 && errId == 20322)) {
...@@ -36,165 +114,43 @@ Page({ ...@@ -36,165 +114,43 @@ Page({
} }
} }
let temp = encodeURIComponent(JSON.stringify(bindInfo)) let temp = encodeURIComponent(JSON.stringify(bindInfo))
//埋点 wx.p.storage.set('bindInfo', temp)
let trackobj = { wx.p.router.reLaunch('/pages/tab/equity/index');
...this.data.tempOptions,
phone: para.phone
}
if (this.data.tempOptions) {
wx.p.util.reportData(trackobj, false, true)
}
wx.$storage.set('bindInfo', temp)
wx.$router.reLaunch('/pages/tab/shopMall/index?tabIndex=1', { notIntercept: true })
})
},
toGetFreeCardDay(merchantId) {
couponsApi
.getFreeCardDay({
merchantId
})
.then(res => {
if (res) {
this.setData({
freeDay: res.freeDay || 0
})
}
})
},
tofreeReceive() {
if(this.op){
wx.$api.showLoading()
this.freeLogin()
return
}
let { loginInfo } = this.data
let { merchantId, phone } = loginInfo
if (!phone) {
return
}
wx.$api.showLoading()
this.toPostFreeCard(merchantId, phone, loginInfo)
},
login() {
USER.login().then(res => {
if (res.data) {
console.log(res.data)
let { phone, sessionId } = res.data
wx.$authStatus = phone ? false : true
if (res.data.isLogin) {
wx.p.util.setUserInfo(res.data)
wx.p.util.setSessionId(res.data.sessionId)
this.handlerCustomerId()
}
this.setData({
loginInfo: res.data,
showAuthBtn: phone ? false : true,
sessionId
})
}
}) })
}, },
getPhoneNumber({ detail }) { async tofreeReceive() {
const { sessionId } = this.data // 先判断登录
if (!sessionId) return const loginStatus = await wx.p.router.intercept()
USER.authUserPhone(detail, sessionId).then(({ data, code, message }) => { if (loginStatus) return
wx.hideLoading()
if (code == '0') { const userInfo = wx.p.storage.get('userInfo')
wx.$authStatus = false let { merchantId, phone } = userInfo
wx.p.util.setUserInfo(data) wx.p.wxApi.showLoading()
wx.p.util.setSessionId(data.sessionId) this.toPostFreeCard(merchantId, phone, userInfo)
let { merchantId, phone } = data
this.toPostFreeCard(merchantId, phone, data)
this.handlerCustomerId()
} else wx.p.wxApi.showToast(message)
})
}, },
onLoad(options) {
async onLoad(options) {
let system = wx.getSystemInfoSync() let system = wx.getSystemInfoSync()
const authStatus = await wx.p.router.intercept(false)
// const { merchantId } = wx.p.storage.get('merchant_info')
// this.toGetFreeCardDay(merchantId)
wx.p.wxApi.showLoading()
const { const {
merchantId data,
} = wx.p.storage.get('merchant_info') code
let newMerchantId = merchantId || defaultMerchantId } = await wx.p.api.userApi.login()
if (code == '0') this.customerLoginCallBack(data)
if (options && options.scene) { if (data) this.sessionId = data.sessionId
this.getLiveActivityId(decodeURIComponent(options.scene)) wx.hideLoading()
} else {
this.toGetFreeCardDay(newMerchantId)
this.login()
}
this.setData({ this.setData({
paddingH: system.windowHeight * 0.11, paddingH: system.windowHeight * 0.11,
textpadding: system.windowHeight * 0.31 textpadding: system.windowHeight * 0.31,
authStatus
}) })
// 埋点---定保 if (!authStatus) {
if (options.activity_id) { this.data.userInfo
this.data.tempOptions = options
wx.p.util.reportData(options, true, false)
} }
}, },
// 获取scene
getLiveActivityId(str) {
shopmallApi
.getLiveActivityId({
id: str.split('=')[1]
})
.then(({ code, data }) => {
if (code == 0) {
let op = {}
data.scene.split('&').map(item => {
const [key, val] = item.split('=')
op[key] = val
})
if (op.merchantId) wx.$storage.set('srcm_shopmall_merchant_id', op.merchantId)
if (op.openId) {
wx.setStorageSync('showServicesMerchantId', op.merchantId);
wx.$eventbus.emit('SERVICES', true)
this.phone = op.phone
this.merchantId = op.merchantId
this.setData({
showAuthBtn: false,
})
this.op = op
} else {
this.login()
}
this.toGetFreeCardDay(op.merchantId)
}
})
},
// 客户id
handlerCustomerId() {
let customerId = wx.$storage.get('srcm_shopmall_customer_id')
if (customerId) USER.updataCustomerPhone()
},
freeLogin() {
let op = this.op
// wx.clearStorageSync();
ssoApi.loginByOpenId({
openId: op.openId
}).then(({
code,
data,
message
}) => {
wx.$authStatus = code != 0
if (code == '0') {
wx.p.util.setUserInfo(data)
wx.p.util.setSessionId(data.sessionId)
wx.$authStatus = false
this.sessionId = data.sessionId
this.toPostFreeCard(op.merchantId, op.phone, data)
// wx.$storage.set('srcm_shopmall_merchant_id', op.merchantId)
// wx.setStorageSync('showServicesMerchantId', op.merchantId);
// wx.$eventbus.emit('SERVICES', true)
// wx.$storage.set('bindInfo', temp)
// wx.$router.reLaunch('/pages/tab/shopMall/index?tabIndex=1', { notIntercept: true })
} else {
wx.p.wxApi.showToast(message || '系统异常')
}
})
},
onUnload: function () { onUnload: function () {
wx.p.util.customerbehavior(2)
} }
}) })
/* packageEquity/pages/freecard/freecard.wxss */
\ No newline at end of file \ No newline at end of file
/* packageEquity/pages/freecard/freecard.wxss */
.navigation-bar {
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
.bg-iamge {
width: 100%;
position: absolute;
left: 0;
top: 0;
// z-index: -1;
.image-class {
background-color: #fff;
width: 100%;
height: 488rpx;
}
.img-card {
position: absolute;
bottom: 0;
// left: calc((100vw - 630rpx) /2);
left: 4%;
width: 630rpx;
height: 288rpx;
}
}
.box {
padding-top: 32rpx;
.card-free {
width: 100vw;
height: 654rpx;
margin-bottom: 32rpx;
}
.equity-box {
padding: 0 20rpx 32rpx;
.img-equity {
width: 100%;
height: 202rpx;
}
}
}
.card-btn {
position: relative;
box-sizing: border-box;
width: 100vw;
padding: 20rpx 32rpx;
color: #fff;
.tips {
position: absolute;
top: 0;
right: 32rpx;
width: 170rpx;
height: 48rpx;
line-height: 48rpx;
background: #F5222D;
border-radius: 24rpx 24rpx 24rpx 4rpx;
text-align: center;
font-size: 26rpx;
}
.btn-defalut {
width: 100%;
height: 96rpx;
line-height: 96rpx;
text-align: center;
font-size: 36rpx;
background-image: linear-gradient(94deg, #3972E2 0%, #2255D1 56%, #173EC5 100%);
border-radius: 48rpx;
color: #fff;
}
}
\ No newline at end of file \ No newline at end of file
<view class="freecard_container" style="padding-bottom:{{paddingH}}rpx;box-sizing: border-box;"> <!-- <view class="navigation-bar"> -->
<image webp class="bgIcon"src="{{IMGURL}}equity/freecard_bg_icon.png?v={{img_version}}" /> <navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" showBack="{{true}}" navTitleStyle="{{navTitleStyle}}" page-title="领取会员卡">领取会员卡</navigation-bar>
<view class="wrapper2" style="top:{{textpadding}}rpx"> <!-- </view> -->
<view class="dayText"> <view class="bg-iamge" style="height: calc({{statusBarHeight + navigationBarHeight + 110}}px);">
{{freeDay}} <glsx-image src="equity/bg-card.png" class="image-class" />
<text class="mintext">天</text> <glsx-image src="equity/card.png" class="img-card" />
</view>
<image webp class="bottomIcon" mode="widthFix" src="{{IMGURL}}equity/mini_new_freecard_icon_text.png?v={{img_version}}" />
</view>
<view class="wrapper1">
<!-- <view class="btnText" bind:tap="tofreeReceive">免费领取</view> -->
<block wx:if="{{showAuthBtn}}">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="auth-button"></button>
</block>
<image webp bind:tap="tofreeReceive" webp class="bottomIcon animaiton" mode="widthFix" src="{{IMGURL}}equity/freecard_btn_icon_new.png?v={{img_version}}" />
</view>
<view style="height:22rpx"></view>
<view class="wrapper1">
<image webp class="bottomIcon" webp mode="widthFix" src="{{IMGURL}}equity/new_freecard_icon.png?v={{img_version}}" />
</view>
</view> </view>
<services/> <scroll-view class="box" scroll-y style="margin-top:calc({{statusBarHeight + navigationBarHeight + 110}}px);" refresher-enabled="{{false}}">
<glsx-image class="card-free" src="equity/card-free.png" />
<view class="equity-box" wx:for="{{imgList}}" wx:key="index">
<glsx-image class="img-equity" src="equity/card-{{index}}.png" />
</view>
<view class="card-btn isFullSucreen">
<view class="tips">限时领红包</view>
<button wx:if="{{authStatus}}" open-type="getPhoneNumber" catchgetphonenumber="getPhoneNumber" class="text-center btn-defalut">登陆</button>
<button wx:elif="{{!hasUserInfo}}" catchtap="jumpAuthUserInfo" class="text-center btn-defalut">头像昵称</button>
<view wx:else>
<view class="btn-defalut" bindtap="tofreeReceive">免费领取</view>
</view>
</view>
</scroll-view>
<glsx-privacy appletName="车生活助手"></glsx-privacy> <glsx-privacy appletName="车生活助手"></glsx-privacy>
\ No newline at end of file \ No newline at end of file
.freecard_container {
width: 100%;
height: 100vh;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
}
.bgIcon {
width: 100%;
height: 100%;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.wrapper1 {
box-sizing: border-box;
padding: 0 52rpx 0 54rpx;
width: 100%;
position: relative;
z-index: 100;
}
.wrapper2 {
box-sizing: border-box;
padding: 0 78rpx 0 96rpx;
position: absolute;
left: 0;
right: 0;
top: 238rpx;
width: 100%;
z-index: 100;
}
.auth-button {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
opacity: 0;
z-index: 102;
}
.btnText {
position: absolute;
left: 50%;
bottom: 30rpx;
transform: translate(-50%, 0);
font-size: 44rpx;
font-weight: 600;
color: #FD6037;
letter-spacing: 2rpx;
z-index: 101;
}
.dayText {
font-size: 80rpx;
font-weight: 600;
color: #FFF8E4;
text-shadow: 0rpx 4rpx 8rpx #E3612C;
position: absolute;
left: 265rpx;
bottom: 70rpx;
display: flex;
align-items: center;
justify-content: center;
width: 180rpx;
}
.mintext {
font-size: 56rpx;
font-weight: 600;
color: #FFF8E4;
text-shadow: 0rpx 4rpx 8rpx #E3612C;
margin-left: 10rpx;
margin-top: 8rpx;
}
.bottomIcon {
width: 100%;
/* height: 414rpx; */
}
.animaiton {
animation: scaleDrew 2.5s infinite;
}
@keyframes scaleDrew {
/* 定义关键帧、scaleDrew是需要绑定到选择器的关键帧名称 */
0% {
transform: scale(1);
}
25% {
transform: scale(0.9);
}
50% {
transform: scale(1);
}
75% {
transform: scale(0.9);
}
}
\ No newline at end of file \ No newline at end of file
// pages/crowdfunding/blank/blank.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options, '///')
wx.p.router.back(res => {
console.log(res, 'res---')
res.setData({
url: options.userProfile
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/crowdfunding/blank/blank.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/crowdfunding/blank/blank.wxml-->
<text>pages/crowdfunding/blank/blank.wxml</text>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!