Commit 5ecfc496 by 胡悦

添加手机号授权

1 parent 0339414d
...@@ -11,6 +11,7 @@ App({ ...@@ -11,6 +11,7 @@ App({
wx.$util = util wx.$util = util
wx.$router = router wx.$router = router
wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/' wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
wx.$appId = wx.getAccountInfoSync().miniProgram.appId
this.globalData.appId = wx.getAccountInfoSync().miniProgram.appId this.globalData.appId = wx.getAccountInfoSync().miniProgram.appId
const systemInfo = wx.getStorageSync('srcm_shopmall_system_info') const systemInfo = wx.getStorageSync('srcm_shopmall_system_info')
if (!systemInfo) wx.getSystemInfo({ if (!systemInfo) wx.getSystemInfo({
...@@ -31,12 +32,18 @@ App({ ...@@ -31,12 +32,18 @@ App({
code, code,
appId: _this.globalData.appId appId: _this.globalData.appId
}).then(res => { }).then(res => {
wx.$authStatus = res.code != 0 wx.$authStatus = res.code != 0
if (returnResponse) { if (returnResponse) {
console.log(res,' ====')
resolve(res) resolve(res)
} else { } else {
util.setSessionId(res.data.sessionId) util.setSessionId(res.data.sessionId)
const openId = res.data.openId
if(openId) {
// ...
// wx.$util.setUserInfo(data)
// return
}
if (res.code != -1) { if (res.code != -1) {
if (res.code == 0) { if (res.code == 0) {
util.setUserInfo(res.data) util.setUserInfo(res.data)
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
}, },
"usingComponents": { "usingComponents": {
"authorize": "components/Authorize/Authorize" "authorize": "components/Authorize/Authorize",
"phone-number": "components/PhoneNumber/PhoneNumber"
}, },
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"permission": { "permission": {
......
// components/Login/Login.js
import {
ssoApi
} from '../../api/api'
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
},
observers: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
// 获取手机号
getPhoneNumber ({detail}) {
console.log(detail)
getApp().login(true).then(({
data
}) => {
console.log(data, '----------')
// wx.$util.setSessionId(data.sessionId)
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') {
return
}
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
console.log('1111')
detail.sessionId = data.sessionId
console.log(detail);
ssoApi.authUserPhone(detail).then(({
data,
code
}) => {
console.log(data)
wx.$util.setUserInfo(data)
wx.$util.setSessionId(data.sessionId)
// 其他操作
})
}
})
},
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<button class="phone-number" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
<image class="icon-arrow" src="{{IMGURL}}home/icon-arrow.png"></image>
了解更多案例
<image class="icon-arrow" src="{{IMGURL}}home/icon-arrow.png"></image>
</button>
\ No newline at end of file \ No newline at end of file
/* 手机号授权 */
.phone-number {
display: flex;
align-items: center;
justify-content: center;
margin: 16rpx 48rpx;
color: #fff;
background: #5850FF;
background-image: linear-gradient(180deg, #4791FF 0%, #5850FF 100%, #643DFF 100%);
border-radius: 8rpx;
}
.icon-arrow {
width: 32rpx;
height: 32rpx;
}
.icon-arrow:first-child {
margin-right: 48rpx;
}
.icon-arrow:last-child {
margin-left: 48rpx;
}
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="user-info"> <view class="user-info">
<block wx:if="{{!showWechant}}"> <block wx:if="{{!showWechant}}">
<view class="user-company"> <view class="user-company">
<image class="company-logo" webp src="{{IMGURL}}home/logo.png"></image> <image class="company-logo" src="{{IMGURL}}home/logo.png"></image>
<text>汽车流通行业数字化运营服务商</text> <text>汽车流通行业数字化运营服务商</text>
</view> </view>
<view class="user-name"> <view class="user-name">
......
...@@ -38,7 +38,7 @@ Page({ ...@@ -38,7 +38,7 @@ Page({
// icon1: "icon-cooperation", // icon1: "icon-cooperation",
// }, // },
], ],
curTabIndex: 0, curTabIndex: 1,
// 0-员工,1-代理商 // 0-员工,1-代理商
customerType: 0, customerType: 0,
// 是否授权昵称 // 是否授权昵称
...@@ -267,4 +267,5 @@ Page({ ...@@ -267,4 +267,5 @@ Page({
} }
}) })
}, },
}); });
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<block wx:if="{{curTabIndex === 1 }}"> <block wx:if="{{curTabIndex === 1 }}">
<template is="menu" data="{{menuList, curIntroduceIndex, templateMethods, customerType}}"></template> <template is="menu" data="{{menuList, curIntroduceIndex, templateMethods, customerType}}"></template>
<block wx:if="{{curIntroduceIndex === 0}}"> <block wx:if="{{curIntroduceIndex === 0}}">
<template is="cube"></template> <template is="cube" data="{{IMGURL}}"></template>
</block> </block>
<block wx:elif="{{curIntroduceIndex === 1}}"> <block wx:elif="{{curIntroduceIndex === 1}}">
<template is="equity"></template> <template is="equity"></template>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</block> </block>
</view> </view>
<view wx:if="{{!hasUserInfo}}" class="user-profile" bindtap="getUserProfile"></view> <!-- <view wx:if="{{!hasUserInfo}}" class="user-profile" bindtap="getUserProfile"></view> -->
<!-- 服务咨询 --> <!-- 服务咨询 -->
<view bindtap="goConsult"> <view bindtap="goConsult">
<image mode="widthFix" class="icon-consult" webp src="{{IMGURL}}home/custom.png"></image> <image mode="widthFix" class="icon-consult" webp src="{{IMGURL}}home/custom.png"></image>
......
...@@ -104,7 +104,7 @@ page { ...@@ -104,7 +104,7 @@ page {
.main-bottom { .main-bottom {
background: #FFFFFF; background: #FFFFFF;
padding: 24rpx 0; padding-top: 24rpx;
flex: 1; flex: 1;
} }
/* 用户授权 */ /* 用户授权 */
...@@ -116,4 +116,25 @@ page { ...@@ -116,4 +116,25 @@ page {
bottom: 0; bottom: 0;
z-index: 2; z-index: 2;
background-color: transparent; background-color: transparent;
}
/* 手机号授权 */
.phone-number {
display: flex;
align-items: center;
justify-content: center;
margin: 16rpx 48rpx;
color: #fff;
background: #5850FF;
background-image: linear-gradient(180deg, #4791FF 0%, #5850FF 100%, #643DFF 100%);
border-radius: 8rpx;
}
.icon-arrow {
width: 32rpx;
height: 32rpx;
}
.icon-arrow:first-child {
margin-right: 48rpx;
}
.icon-arrow:last-child {
margin-left: 48rpx;
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
<view>智能线索</view> <view>智能线索</view>
<image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image> <image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image>
</view> </view>
<phone-number></phone-number>
</template> </template>
\ No newline at end of file \ No newline at end of file
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
<view>企微魔方</view> <view>企微魔方</view>
<image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image> <image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image>
</view> </view>
<phone-number></phone-number>
</template> </template>
\ No newline at end of file \ No newline at end of file
<template name="equity"> <template name="equity">
<view class="box-wrapper"> <view class="box-wrapper">
<view>广联数科</view> <view>数字化权益</view>
<image src="https://hzyly.com/upload/201908/26/201908261930139956.jpg"></image> <image class="m-t-md" src="https://hzyly.com/upload/201908/26/201908261930139956.jpg"></image>
</view> </view>
<phone-number></phone-number>
</template> </template>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!