Pārlūkot izejas kodu

[c端小程序][新增]:用户nickName授权页面,手机号授权页面

tags/2.2.4
Stormeye.Wu pirms 6 gadiem
vecāks
revīzija
31de23b8d7
16 mainītis faili ar 178 papildinājumiem un 19 dzēšanām
  1. +11
    -16
      app.js
  2. +2
    -0
      app.wxss
  3. +4
    -0
      config/config.js
  4. +1
    -1
      pages/coupons/details/index.js
  5. +1
    -1
      pages/coupons/details/index.json
  6. +42
    -0
      pages/getphoneInfo/index.js
  7. +3
    -0
      pages/getphoneInfo/index.json
  8. +5
    -0
      pages/getphoneInfo/index.wxml
  9. +19
    -0
      pages/getphoneInfo/index.wxss
  10. +40
    -0
      pages/getuserinfo/index.js
  11. +3
    -0
      pages/getuserinfo/index.json
  12. +7
    -0
      pages/getuserinfo/index.wxml
  13. +19
    -0
      pages/getuserinfo/index.wxss
  14. +14
    -0
      pages/index/index.js
  15. +1
    -1
      pages/user/index.wxml
  16. +6
    -0
      weui.wxss

+ 11
- 16
app.js Parādīt failu

@@ -22,23 +22,18 @@ App({
// console.log("req",res);
this.globalData.token = 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)
// }
// })
}
})



+ 2
- 0
app.wxss Parādīt failu

@@ -1,3 +1,5 @@
@import 'weui.wxss';

@font-face {
font-family: 'iconfont'; /* project id 777313 */
src: url('//at.alicdn.com/t/font_777313_jq7td4d3uab.eot');


+ 4
- 0
config/config.js Parādīt failu

@@ -18,6 +18,10 @@ var config = {
* 接口用途:授权后获取用户的手机号
*/
getUserPhone: '/api/user/getUserPhone',
/**
* 检查用户授权状态
*/
checkUserStatus: '/api/user/checkUserStatus',
/**
* 优惠券查询
*/


+ 1
- 1
pages/coupons/details/index.js Parādīt failu

@@ -56,7 +56,7 @@ Page({
if (res.payment > 0) {
return Http.post({ url: Http.config.api.payOrderCreate, data: { orderId: orderId } })
} else {
// 免费
// 免费
this.payOrderUpdate(orderId, "0", 1) // 支付成功
.then(res => {
wx.showToast({


+ 1
- 1
pages/coupons/details/index.json Parādīt failu

@@ -2,5 +2,5 @@
"usingComponents": {
},
"navigationBarTitleText": "详情"
"navigationBarTitleText": "详情"
}

+ 42
- 0
pages/getphoneInfo/index.js Parādīt failu

@@ -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",
})
}
})
}
})

+ 3
- 0
pages/getphoneInfo/index.json Parādīt failu

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "富茂链客"
}

+ 5
- 0
pages/getphoneInfo/index.wxml Parādīt failu

@@ -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>

+ 19
- 0
pages/getphoneInfo/index.wxss Parādīt failu

@@ -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;
}

+ 40
- 0
pages/getuserinfo/index.js Parādīt failu

@@ -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"
})
}
})
}
})

+ 3
- 0
pages/getuserinfo/index.json Parādīt failu

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "富茂链客"
}

+ 7
- 0
pages/getuserinfo/index.wxml Parādīt failu

@@ -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>

+ 19
- 0
pages/getuserinfo/index.wxss Parādīt failu

@@ -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;
}

+ 14
- 0
pages/index/index.js Parādīt failu

@@ -23,4 +23,18 @@ Page({
onReady: function () {
},
// 用户点击右上角分享
onShareAppMessage: function () {
return {
title: '富茂链客',
desc: '分享个小程序,希望你喜欢',
success: function (res) {
wx.showToast({
title: "分享成功",
duration: 1000,
icon: "success"
})
}
}
}
})

+ 1
- 1
pages/user/index.wxml Parādīt failu

@@ -34,7 +34,7 @@
<view class="user-btns">
<navigator url="/pages/coupons/index/index">
<view class="user-btn app-border-bottom">
<view>包</view>
<view>包</view>
<view>
<text class="iconfont icon-right"></text>
</view>


+ 6
- 0
weui.wxss
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


Notiek ielāde…
Atcelt
Saglabāt