Commit 34f10d79 by YangChengYuan

修改冲突

parents db9466e2 2fe64962
// pages/me/vip/index.js // pages/me/vip/index.js
import api from '../../../utils/Api.js' import api from '../../../utils/Api.js'
import Wx from '../../../utils/Wx.js'
const app = getApp() const app = getApp()
const {
$Toast
} = require('../../../iview/base/index');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -13,7 +16,9 @@ Page({ ...@@ -13,7 +16,9 @@ Page({
vip_price: 49.9, vip_price: 49.9,
order: {}, order: {},
user: {} user: {},
visible1: false,
}, },
handleChange1({ handleChange1({
...@@ -44,6 +49,8 @@ Page({ ...@@ -44,6 +49,8 @@ Page({
getUserInfo: function() { getUserInfo: function() {
api.me.info().then(res => { api.me.info().then(res => {
if (!res.code) { if (!res.code) {
//授权手机号
this.dialogPhone(res.data)
app.globalData.userInfo = res.data app.globalData.userInfo = res.data
// 渲染数据 // 渲染数据
this.setData({ this.setData({
...@@ -53,6 +60,56 @@ Page({ ...@@ -53,6 +60,56 @@ Page({
}) })
}, },
/**
* 手机号授权弹窗
*/
dialogPhone: function(data) {
if (!data.phone) {
this.setData({
visible1: true
});
}
},
handlePhoneAuth: function(event) {
Wx.login().then(res => {
let encryptedData = event.detail.encryptedData
let iv = event.detail.iv
this.decodePhoneData(res.code, encryptedData, iv)
})
},
/**
* 解密手机号数据
*/
decodePhoneData: function(code, encryptedData, iv) {
let that = this
api.getPhoneNumber({
code: code,
encryptedData: encryptedData,
iv: iv
}).then(res => {
if (!res.code) {
that.setData({
visible1:false
})
$Toast({
content: '手机号授权成功',
type: 'success'
});
//更新下用户数据
that.getUserInfo()
} else {
$Toast({
content: '手机号授权失败',
type: 'error'
});
}
})
},
// 获取VIP单价 // 获取VIP单价
getVipPrice: function() { getVipPrice: function() {
api.me.vipPrice().then(res => { api.me.vipPrice().then(res => {
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
"i-col": "/iview/col/index", "i-col": "/iview/col/index",
"i-input-number": "/iview/input-number/index", "i-input-number": "/iview/input-number/index",
"i-button": "/iview/button/index", "i-button": "/iview/button/index",
"i-input": "/iview/input/index" "i-input": "/iview/input/index",
"i-modal": "/iview/modal/index",
"i-toast": "/iview/toast/index"
} }
} }
\ No newline at end of file
...@@ -21,15 +21,25 @@ ...@@ -21,15 +21,25 @@
</view> </view>
<!-- 用户输入的信息 --> <!-- 用户输入的信息 -->
<i-input i-class="right-align" value="" title="姓名" type="text" placeholder="请输入您的姓名" /> <!-- <i-input i-class="right-align" value="" title="姓名" type="text" placeholder="请输入您的姓名" />
<view class='phoneGive'> <view class='phoneGive'>
<text>手机号</text> <text>手机号</text>
<button>授权</button> <button>授权</button>
</view> </view>
<i-input i-class="right-align right-align-last" type="text" title="地址" placeholder="请输入您的地址" maxlength="50" /> <i-input i-class="right-align right-align-last" type="text" title="地址" placeholder="请输入您的地址" maxlength="50" /> -->
<i-row class='height'> <i-row class='height'>
<i-col span="20" offset='2' i-class="col-class"> <i-col span="20" offset='2' i-class="col-class">
<i-button bind:click="handleClick" type="primary" shape="circle" size="small">立即{{user.is_vip==1?'续费':'购买'}} ¥{{common.numFixed(vip_price*value1, 2)}}</i-button> <i-button bind:click="handleClick" type="primary" shape="circle" size="small">立即{{user.is_vip==1?'续费':'购买'}} ¥{{common.numFixed(vip_price*value1, 2)}}</i-button>
</i-col> </i-col>
</i-row> </i-row>
<!-- 授权弹窗 -->
<i-modal title="请授权手机号" visible="{{ visible1 }}" show-cancel="{{false}}" show-ok="{{false}}" action-mode="{{ vertical }}">
<view class="auth_phone_container">
<i-button i-class="btn_auth_phone" type="info" shape="circle" size="default" bindgetphonenumber="handlePhoneAuth" open-type="getPhoneNumber">授权</i-button>
</view>
</i-modal>
<!-- toast弹窗 -->
<i-toast id="toast" />
\ No newline at end of file
...@@ -96,3 +96,9 @@ page { ...@@ -96,3 +96,9 @@ page {
.color-orange { .color-orange {
color: #ff4200; color: #ff4200;
} }
/* 授权窗口 */
.auth_phone_container{
width: 80%;
margin: auto;
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.3.2", "libVersion": "2.3.2",
"appid": "wx1b834552a7d49bb3", "appid": "wx1b834552a7d49bb3",
"projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85%E4%BA%B2%E5%AD%90%E6%B8%B8(git)", "projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85",
"debugOptions": { "debugOptions": {
"hidedInDevtools": [] "hidedInDevtools": []
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment