| @@ -1,3 +0,0 @@ | |||
| # groupC | |||
| C端集团版 | |||
| @@ -24,6 +24,7 @@ App({ | |||
| //登陆 | |||
| userLogin(sceneAddress) { | |||
| console.log(sceneAddress) | |||
| let that = this; | |||
| // 登录 | |||
| wx.login({ | |||
| @@ -42,7 +43,7 @@ App({ | |||
| .then(res => { | |||
| wx.setStorageSync('openId',res.data.openId) | |||
| wx.setStorageSync('subMalls', JSON.parse(res.data.subMalls) ) | |||
| if (res.data && res.data.score) { | |||
| if (res.data && res.data.score) { | |||
| if (res.data.score != 0) { | |||
| that.globalData.score = res.data.score; | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| { | |||
| "pages": [ | |||
| "pages/users/users", | |||
| "pages/index/index", | |||
| "pages/location/location" | |||
| "pages/users/users", | |||
| "pages/location/location", | |||
| "pages/getuserinfo/index" | |||
| ], | |||
| "tabBar": { | |||
| "list": [ | |||
| @@ -14,6 +14,21 @@ var config = { | |||
| * banner | |||
| */ | |||
| bannerlist: "/wxCampaign/list", | |||
| /** | |||
| * 检查用户授权状态 | |||
| */ | |||
| checkUserStatus: "/user/checkUserStatus", | |||
| /** | |||
| * 授权个人信息 | |||
| * 和授权手机号 | |||
| * 和login页面 | |||
| * 页面的图标 | |||
| */ | |||
| marketicon: '/mall/getAppIcon', | |||
| /** | |||
| * 授权后获取用户的昵称,unionId等信息 | |||
| */ | |||
| getUserInfo: "/user/getUserInfo", | |||
| }, | |||
| }; | |||
| @@ -0,0 +1,85 @@ | |||
| const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' | |||
| var config = require("../../config/config.js"); | |||
| var app = getApp(); | |||
| const Http = require("../../utils/HttpBasics"); | |||
| Page({ | |||
| data: { | |||
| navigationBarHeight, | |||
| canIUse: wx.canIUse("button.open-type.getUserInfo"), | |||
| }, | |||
| onLoad: function(options) { | |||
| var that = this; | |||
| Http.get({ | |||
| url: config.api.marketicon, | |||
| data: { | |||
| appId: config.weapp.AppId | |||
| } | |||
| }).then(res => { | |||
| that.setData({ | |||
| mallImgUrl: res.data.mallImgUrl | |||
| }); | |||
| wx.setNavigationBarTitle({ | |||
| title: res.data.mallName | |||
| }) | |||
| }) | |||
| .catch(err => { | |||
| wx.showToast({ | |||
| title: err.errMsg, | |||
| icon: 'none', | |||
| duration: 2000, | |||
| mask: false | |||
| }); | |||
| }) | |||
| }, | |||
| backHome: function () { | |||
| wx.switchTab({ | |||
| url: '/pages/index/index', | |||
| }) | |||
| }, | |||
| bindGetUserInfo: function (e) { | |||
| let that = this; | |||
| var iv = e.detail.iv; | |||
| var encryptedData = e.detail.encryptedData; | |||
| wx.getUserInfo({ | |||
| success: function (res) { | |||
| Http.post({ | |||
| url: config.api.getUserInfo, | |||
| data: { | |||
| encryptedData: encryptedData, | |||
| iv: iv | |||
| } | |||
| }) | |||
| .then( | |||
| function (res) { | |||
| console.log("授权成功") | |||
| wx.switchTab({ | |||
| url: `/pages/users/users` | |||
| }) | |||
| }, | |||
| function (error) { | |||
| console.log(error) | |||
| wx.showToast({ | |||
| title: "请授权个人信息", | |||
| icon: "none" | |||
| }); | |||
| } | |||
| ) | |||
| .catch(err => { | |||
| wx.showToast({ | |||
| title: err.errMsg, | |||
| icon: 'none', | |||
| duration: 2000, | |||
| mask: false | |||
| }); | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| }); | |||
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "usingComponents": { | |||
| "navbar": "../../components/navbar/navbar" | |||
| } | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| <navbar home text="微信授权"></navbar> | |||
| <view class="login-body" style="padding-top:200rpx;"> | |||
| <view class="login-logo"> | |||
| <image src="{{mallImgUrl}}" mode='widthFix'></image> | |||
| </view> | |||
| <view class="title"> | |||
| <text>Hi , 请登录~</text> | |||
| <text>授权后,可以更好的体验我们哦~</text> | |||
| </view> | |||
| <view class="login-btn"> | |||
| <button open-type="getUserInfo" wx:if="{{canIUse}}" hover-class='active' class="login-btn-login" bindgetuserinfo="bindGetUserInfo">获取微信授权</button> | |||
| <view wx:else>微信用户登录</view> | |||
| <button hover-class='active' class="login-btn-login backHome" bindtap="backHome">取消</button> | |||
| </view> | |||
| </view> | |||
| @@ -0,0 +1,70 @@ | |||
| page{ | |||
| background: #fbfbfb; | |||
| } | |||
| .login-body { | |||
| padding-top: 106rpx; | |||
| display: flex; | |||
| flex-direction: column; | |||
| align-items: center; | |||
| justify-content: center; | |||
| } | |||
| .backHome{ | |||
| margin-top: 20rpx!important; | |||
| } | |||
| .login-logo { | |||
| width: 320rpx; | |||
| /* height: 320rpx; */ | |||
| padding-top: 70rpx; | |||
| } | |||
| .login-logo>image { | |||
| display: block; | |||
| width: 320rpx; | |||
| border-radius: 16rpx; | |||
| } | |||
| .login-btn { | |||
| padding-top: 120rpx; | |||
| width: 504rpx; | |||
| } | |||
| .txt { | |||
| display: block; | |||
| width: 300rpx; | |||
| height: 108rpx; | |||
| margin-top: 5.8%; | |||
| font-size: 30rpx; | |||
| color: #999; | |||
| line-height: 54rpx; | |||
| text-align: center; | |||
| } | |||
| .active{ | |||
| opacity: .6; | |||
| } | |||
| .login-btn .login-btn-login { | |||
| background: #1faf0c; | |||
| border-radius: 15rpx !important; | |||
| height: 94rpx !important; | |||
| line-height: 94rpx; | |||
| padding: 0 !important; | |||
| font-family: PingFangSC-Semibold !important; | |||
| font-size: 36rpx !important; | |||
| color: #FFFFFF !important; | |||
| letter-spacing: 0.75rpx !important; | |||
| text-align: center; | |||
| } | |||
| .title{ | |||
| margin-top: 30rpx; | |||
| } | |||
| .title text{ | |||
| display: block; | |||
| text-align: center; | |||
| } | |||
| .title text:nth-of-type(1){ | |||
| font-size: 38rpx; | |||
| font-weight: bold; | |||
| } | |||
| .title text:nth-of-type(2){ | |||
| font-size: 30rpx; | |||
| margin-top: 25rpx; | |||
| } | |||
| @@ -22,13 +22,14 @@ Page({ | |||
| * banner | |||
| */ | |||
| getBannerlist: function () { | |||
| // Http.setToken(app.globalData.token); | |||
| let that = this; | |||
| Http.get({ | |||
| url: config.api.bannerlist, | |||
| data: { | |||
| pageNum: 1, | |||
| pageSize: 7 | |||
| pageSize: 7, | |||
| token:app.globalData.token | |||
| } | |||
| }).then(res => { | |||
| @@ -2,6 +2,7 @@ | |||
| const imgurl = require("../../utils/imgurl"); | |||
| const Http = require("../../utils/HttpBasics"); | |||
| var config = require("../../config/config.js"); | |||
| let app = getApp(); | |||
| Page({ | |||
| /** | |||
| @@ -13,14 +14,33 @@ Page({ | |||
| // levelName: | |||
| }, | |||
| /* 判断是否授权*/ | |||
| checkUserStatus() { | |||
| Http.get({ | |||
| url: config.api.checkUserStatus, | |||
| data: { | |||
| token: app.globalData.token | |||
| } | |||
| }).then(res => { | |||
| // wx.navigateTo({ | |||
| // url: '/pages/edit/edit', | |||
| // }) | |||
| console.log("111") | |||
| }).catch(err => { | |||
| wx.navigateTo({ | |||
| url: `/pages/getuserinfo/index`, | |||
| }) | |||
| }) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| this.checkUserStatus() | |||
| }, | |||