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