@@ -22,23 +22,18 @@ App({ | |||||
// console.log("req",res); | // console.log("req",res); | ||||
this.globalData.token = res.token; | this.globalData.token = res.token; | ||||
Http.setToken(res.token) | Http.setToken(res.token) | ||||
Http.get({ | |||||
url: config.api.checkUserStatus, | |||||
data: { } | |||||
}).then(statusres => { | |||||
if (statusres.code == 11004) { | |||||
// 用户昵称未授权 | |||||
wx.redirectTo({ | |||||
url: '../getuserinfo/index', | |||||
}) | |||||
} | |||||
}) | |||||
}) | }) | ||||
// wx.request({ | |||||
// url: config.api.login, | |||||
// data: { | |||||
// appId: config.weapp.AppId, | |||||
// code: res.code, | |||||
// sceneAddress: that.globalData.sceneAddress, | |||||
// }, | |||||
// method: 'POST', | |||||
// success: (result) => { | |||||
// that.globalData.token = result.data.data.token; | |||||
// console.log(that.globalData.token) | |||||
// that.getUserInfo() | |||||
// that.getLocation() | |||||
// Http.setToken(result.data.data.token) | |||||
// } | |||||
// }) | |||||
} | } | ||||
}) | }) | ||||
@@ -1,3 +1,5 @@ | |||||
@import 'weui.wxss'; | |||||
@font-face { | @font-face { | ||||
font-family: 'iconfont'; /* project id 777313 */ | font-family: 'iconfont'; /* project id 777313 */ | ||||
src: url('//at.alicdn.com/t/font_777313_jq7td4d3uab.eot'); | src: url('//at.alicdn.com/t/font_777313_jq7td4d3uab.eot'); | ||||
@@ -18,6 +18,10 @@ var config = { | |||||
* 接口用途:授权后获取用户的手机号 | * 接口用途:授权后获取用户的手机号 | ||||
*/ | */ | ||||
getUserPhone: '/api/user/getUserPhone', | getUserPhone: '/api/user/getUserPhone', | ||||
/** | |||||
* 检查用户授权状态 | |||||
*/ | |||||
checkUserStatus: '/api/user/checkUserStatus', | |||||
/** | /** | ||||
* 优惠券查询 | * 优惠券查询 | ||||
*/ | */ | ||||
@@ -56,7 +56,7 @@ Page({ | |||||
if (res.payment > 0) { | if (res.payment > 0) { | ||||
return Http.post({ url: Http.config.api.payOrderCreate, data: { orderId: orderId } }) | return Http.post({ url: Http.config.api.payOrderCreate, data: { orderId: orderId } }) | ||||
} else { | } else { | ||||
// 免费卷 | |||||
// 免费券 | |||||
this.payOrderUpdate(orderId, "0", 1) // 支付成功 | this.payOrderUpdate(orderId, "0", 1) // 支付成功 | ||||
.then(res => { | .then(res => { | ||||
wx.showToast({ | wx.showToast({ | ||||
@@ -2,5 +2,5 @@ | |||||
"usingComponents": { | "usingComponents": { | ||||
}, | }, | ||||
"navigationBarTitleText": "卷详情" | |||||
"navigationBarTitleText": "券详情" | |||||
} | } |
@@ -0,0 +1,42 @@ | |||||
var config = require('../../config/config.js'); | |||||
var Common = require('../../common/common.js'); | |||||
var app = getApp(); | |||||
Page({ | |||||
data: { | |||||
canIUse: wx.canIUse('button.open-type.getPhoneNumber') | |||||
}, | |||||
onLoad: function (options) { | |||||
var that = this; | |||||
}, | |||||
getPhoneNumber: function (e) { | |||||
var that = this; | |||||
var iv = e.detail.iv; | |||||
var encryptedData = e.detail.encryptedData; | |||||
Common.getUserPhone(encryptedData, iv) | |||||
.then(function (res) { | |||||
console.log(res); | |||||
/** | |||||
* code:0 授权手机号成功 | |||||
* code:1 授权手机号失败 | |||||
*/ | |||||
if (res.data.code == 0) { | |||||
app.globalData.phone = res.data.phone; | |||||
wx.showToast({ | |||||
title: res.data.msg, | |||||
icon: "success", | |||||
success: function (res) { | |||||
wx.redirectTo({ | |||||
url: '../login/login', | |||||
}) | |||||
} | |||||
}) | |||||
} | |||||
else if (res.data.code == 1) { | |||||
wx.showToast({ | |||||
title: '请重新授权手机号', | |||||
icon: "none", | |||||
}) | |||||
} | |||||
}) | |||||
} | |||||
}) |
@@ -0,0 +1,3 @@ | |||||
{ | |||||
"navigationBarTitleText": "富茂链客" | |||||
} |
@@ -0,0 +1,5 @@ | |||||
<view class='registerd'> | |||||
<image src='http://f.cdn.cloudolphin.com/banner_logo.jpg' mode='widthFix'></image> | |||||
<button class="btn" hover-class='bg_color' wx:if="{{canIUse}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">授权手机号</button> | |||||
<view wx:else>请升级微信版本</view> | |||||
</view> |
@@ -0,0 +1,19 @@ | |||||
.registerd image { | |||||
display: block; | |||||
width: 100%; | |||||
} | |||||
.registerd button { | |||||
background: #9d285c; | |||||
border-radius: 10rpx; | |||||
color: #fff; | |||||
height: 84rpx; | |||||
line-height: 84rpx; | |||||
margin: 30rpx auto 0; | |||||
width: 93%; | |||||
font-size: 28rpx; | |||||
} | |||||
.bg_color { | |||||
opacity: 0.6; | |||||
} |
@@ -0,0 +1,40 @@ | |||||
var config = require('../../config/config.js'); | |||||
var Common = require('../../common/common.js'); | |||||
var app = getApp(); | |||||
Page({ | |||||
data: { | |||||
canIUse: wx.canIUse('button.open-type.getUserInfo') | |||||
}, | |||||
onLoad: function(options) { | |||||
var that = this; | |||||
}, | |||||
bindGetUserInfo: function(e) { | |||||
console.log(e); | |||||
var iv = e.detail.iv; | |||||
var encryptedData = e.detail.encryptedData; | |||||
console.log(iv) | |||||
console.log(encryptedData) | |||||
Common.getUserInfo(encryptedData, iv) | |||||
.then(res => { | |||||
console.log(res); | |||||
/** | |||||
* 1:用户拒绝授权 | |||||
* 0:用户同意授权 | |||||
*/ | |||||
if(res.data.code == 0){ | |||||
//返回主页 | |||||
wx.redirectTo({ | |||||
url: '../index/index', | |||||
}) | |||||
} | |||||
else if(res.data.code == 1){ | |||||
wx.showToast({ | |||||
title: '请授权个人信息', | |||||
icon:"none" | |||||
}) | |||||
} | |||||
}) | |||||
} | |||||
}) |
@@ -0,0 +1,3 @@ | |||||
{ | |||||
"navigationBarTitleText": "富茂链客" | |||||
} |
@@ -0,0 +1,7 @@ | |||||
<view class='userinfo'> | |||||
<!-- | |||||
<image src='http://f.cdn.cloudolphin.com/banner_logo.jpg' mode='widthFix'></image> | |||||
--> | |||||
<button class="weui-btn" hover-class='bg_color' wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">头像昵称授权登录</button> | |||||
<view wx:else>请升级微信版本</view> | |||||
</view> |
@@ -0,0 +1,19 @@ | |||||
.userinfo image { | |||||
display: block; | |||||
width: 100%; | |||||
} | |||||
.userinfo button { | |||||
background: #9d285c; | |||||
border-radius: 10rpx; | |||||
color: #fff; | |||||
height: 84rpx; | |||||
line-height: 84rpx; | |||||
margin: 30rpx auto 0; | |||||
width: 93%; | |||||
font-size: 28rpx; | |||||
} | |||||
.bg_color { | |||||
opacity: 0.6; | |||||
} |
@@ -23,4 +23,18 @@ Page({ | |||||
onReady: function () { | onReady: function () { | ||||
}, | }, | ||||
// 用户点击右上角分享 | |||||
onShareAppMessage: function () { | |||||
return { | |||||
title: '富茂链客', | |||||
desc: '分享个小程序,希望你喜欢', | |||||
success: function (res) { | |||||
wx.showToast({ | |||||
title: "分享成功", | |||||
duration: 1000, | |||||
icon: "success" | |||||
}) | |||||
} | |||||
} | |||||
} | |||||
}) | }) |
@@ -34,7 +34,7 @@ | |||||
<view class="user-btns"> | <view class="user-btns"> | ||||
<navigator url="/pages/coupons/index/index"> | <navigator url="/pages/coupons/index/index"> | ||||
<view class="user-btn app-border-bottom"> | <view class="user-btn app-border-bottom"> | ||||
<view>卷包</view> | |||||
<view>券包</view> | |||||
<view> | <view> | ||||
<text class="iconfont icon-right"></text> | <text class="iconfont icon-right"></text> | ||||
</view> | </view> | ||||