@@ -2,34 +2,50 @@ | |||
App({ | |||
onLaunch: function () { | |||
// 展示本地存储能力 | |||
var logs = wx.getStorageSync('logs') || [] | |||
// var logs = wx.getStorageSync('logs') || [] | |||
// logs.unshift(Date.now()) | |||
wx.setStorageSync('logs', logs) | |||
// wx.setStorageSync('logs', logs) | |||
// 登录 | |||
wx.login({ | |||
success: res => { | |||
// 发送 res.code 到后台换取 openId, sessionKey, unionId | |||
// console.log(res) | |||
wx.request({ | |||
url: '', | |||
data: { | |||
code: res.code | |||
} | |||
}) | |||
console.log(res) | |||
if (res.code){ | |||
wx.request({ | |||
url: 'https://laomenkuang.jiyou-tech.com/apiWx/openid', | |||
header: { | |||
code: res.code | |||
}, | |||
success: e => { | |||
console.log(e) | |||
if (e.data.code == 200) { | |||
this.globalData.openId = e.data.data.openid; | |||
this.globalData.session_key = e.data.data.session_key; | |||
this.globalData.token = e.data.data.token; | |||
wx.setStorageSync('openid', e.data.data.openid) | |||
wx.setStorageSync('session_key', e.data.data.session_key) | |||
wx.setStorageSync('token', e.data.data.token) | |||
} | |||
} | |||
}) | |||
} else { | |||
console.log("登陆失败" + res.errMsg) | |||
} | |||
} | |||
}) | |||
// 获取用户信息 | |||
wx.getSetting({ | |||
success: res => { | |||
// console.log(res) | |||
console.log(res) | |||
if (res.authSetting['scope.userInfo']) { | |||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | |||
wx.getUserInfo({ | |||
success: res => { | |||
success: e => { | |||
// 可以将 res 发送给后台解码出 unionId | |||
this.globalData.userInfo = res.userInfo | |||
this.globalData.userInfo = e.userInfo | |||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||
// 所以此处加入 callback 以防止这种情况 | |||
if (this.userInfoReadyCallback) { | |||
@@ -38,23 +54,30 @@ App({ | |||
} | |||
}) | |||
}else{ | |||
// wx.redirectTo({ | |||
// url: '/pages/register/register' | |||
// }) | |||
wx.authorize({ | |||
scope: 'scope.record', | |||
success() { | |||
// 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 | |||
wx.startRecord() | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
}, | |||
globalData: { | |||
userInfo: null | |||
userInfo: null, | |||
openId:"", | |||
session_key:"", | |||
token:"", | |||
userInfo:"", | |||
}, | |||
request:function(url,data,type){//接口调用 | |||
wxRequest:function(url,data){//接口调用 | |||
wx.request({ | |||
url: url, | |||
data: data, | |||
type:type, | |||
header: { | |||
'content-type': 'application/json' // 默认值 | |||
openid: this.globalData.openId | |||
}, | |||
success(res) { | |||
console.log(res.data) |
@@ -1,5 +1,5 @@ | |||
/**app.wxss**/ | |||
.container { | |||
/* .container { | |||
height: 100%; | |||
display: flex; | |||
flex-direction: column; | |||
@@ -7,4 +7,4 @@ | |||
justify-content: space-between; | |||
padding: 200rpx 0; | |||
box-sizing: border-box; | |||
} | |||
} */ |
@@ -4,7 +4,6 @@ const app = getApp() | |||
Page({ | |||
data: { | |||
swiperHig:0, | |||
content: ["../images/smallTicket.jpg", "../images/smallTicket.jpg", "../images/smallTicket.jpg"], | |||
allData:[ | |||
@@ -12,12 +11,7 @@ Page({ | |||
}, | |||
//事件处理函数 | |||
onLoad: function () { | |||
var wid = wx.getSystemInfoSync().windowWidth; | |||
var hig = wid * (843 / 750) | |||
console.log(hig) | |||
this.setData({ | |||
swiperHig: (hig+40)+"px", | |||
}); | |||
}, | |||
skipPage:function(){ | |||
var arr = {"name":"小明","age":20}; |
@@ -11,7 +11,7 @@ | |||
<text class="user-motto">{{motto}}</text> | |||
</view> --> | |||
<image class="buyBg" src="../images/buyBg.jpg" style="height:{{swiperHig}}"></image> | |||
<image class="buyBg" src="../images/buyBg.jpg"></image> | |||
<swiper duration="500" next-margin="70rpx"> | |||
<block wx:for="{{content}}" wx:key="*this"> |
@@ -1,7 +1,14 @@ | |||
/**index.wxss**/ | |||
.buyBg{ | |||
page{ | |||
height: 100%; | |||
} | |||
.container{ | |||
width: 100%; | |||
/* height: 843rpx; */ | |||
height: 100%; | |||
} | |||
.buyBg{ | |||
width: 890rpx; | |||
height: 1000rpx; | |||
position: fixed; | |||
top:0; | |||
left: 0; |
@@ -17,7 +17,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
}, | |||
/** |
@@ -1,5 +1,5 @@ | |||
<!--pages/register/register.wxml--> | |||
<view> | |||
<view class="all"> | |||
<image class="registerBg" src="../images/registerBg.jpg"></image> | |||
<view class="import"> | |||
<view class="phoneView"> |
@@ -1,7 +1,15 @@ | |||
/* pages/register/register.wxss */ | |||
page{ | |||
height:100%; | |||
} | |||
.all{ | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.registerBg{ | |||
width: 100%; | |||
height: 1379rpx; | |||
height: 100%; | |||
position: fixed; | |||
top: 0; | |||
left: 0; |
@@ -9,8 +9,16 @@ | |||
"postcss": true, | |||
"minified": true, | |||
"newFeature": true, | |||
"coverView": true, | |||
"autoAudits": false, | |||
"coverView": true | |||
"checkInvalidKey": true, | |||
"checkSiteMap": true, | |||
"uploadWithSourceMap": true, | |||
"babelSetting": { | |||
"ignore": [], | |||
"disablePlugins": [], | |||
"outputPath": "" | |||
} | |||
}, | |||
"compileType": "miniprogram", | |||
"libVersion": "2.10.2", | |||
@@ -84,13 +92,13 @@ | |||
"query": "", | |||
"scene": null | |||
}, | |||
{ | |||
"id": 0, | |||
"name": "注册", | |||
"pathName": "pages/register/register", | |||
"query": "", | |||
"scene": null | |||
} | |||
{ | |||
"id": 0, | |||
"name": "注册", | |||
"pathName": "pages/register/register", | |||
"query": "", | |||
"scene": null | |||
} | |||
] | |||
} | |||
} |