day 03 实习日志

一、学习内容

(一)学习微信小程序的API;

(二)学习怎么使用小程序的接口和方法;

(三)完成要求的模块;

 

二、课后习题

(一)在“我的页面”上获取昵称和头像,并显示出来。

源码:

.wxml:

.wss:

.userinfo {

position: relative;

width: 750rpx;

height: 320rpx;

color: #000000;

display: flex;

flex-direction: column;

align-items: center;

}

.userinfo-avatar {

overflow:hidden;

display: block;

width: 160rpx;

height: 160rpx;

margin: 20rpx;

margin-top: 50rpx;

border-radius: 50%;

border: 2px solid #fff;

box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);

}

.userinfo{

font-size: 20px;

background-color: #fff;

border-radius:50%;

}

程序结果:

day 03 实习日志_第1张图片

 

(二)在“我的页面”获取手机主要信息

源码:

.wxml:

手机型号:{{mobileModel}}

手机像素比:{{mobileePixelRatio}}

窗口宽度:{{windowWidth}}

窗口高度:{{windowHeight}}

微信设置的语言:{{language}}

微信版本号:{{version}}

 

.wxss:

.box{

display: flex;

flex-direction: column;

justify-content: space-between;

border:2px solid #000000;

}

 

.js

var app = getApp()

Page({

data: {

mobileModel: '',

mobileePixelRatio: '',

windowWidth: '',

windowHeight: '',

language: '',

version: ''

},

onLoad: function () {

var that = this;

wx.getSystemInfo({

success: function (res) {

that.setData({

mobileModel: res.model,

mobileePixelRatio: res.pixelRatio,

windowWidth: res.windowWidth,

windowHeight: res.windowHeight,

language: res.language,

version: res.version

})

}

})

}

})

程序结果:

day 03 实习日志_第2张图片

 

 

 

(三)把整个“地图”页面变成地图

源码:

.wxml

纬度:{{latitude}}

经度:{{longitude}}

地址:{{address}}

 

 

.wxss

page{

height: 100%;

}

.js

Page({

data: {

longitude: 0,

latitude: 0,

markers: [{

iconPath: "assets/icons/position2.png",

id: 0,

latitude: 21.1526,

longitude: 110.29754,

width: 30,

height: 30

}]

},

onLoad: function () {

console.log(this)

},

onReady: function () {

// console.log(this)

var _this = this;

wx.getLocation({

success: function (res) {

console.log(res);

_this.setData({

longitude: res.longitude,

latitude: res.latitude

})

}

})

 

}

})

程序结果:

day 03 实习日志_第3张图片

 

三、学习总结及心得

     在这一堂课中主要讲解了微信小程序的接口以及方法的使用,比如说地图,怎么引入地图,并放大和缩小。课下的作业是根据课堂上讲解的方法来完成的,有获取用户头像、用户名称等等,虽然有点多,但是基本都能实现,这需要的时间很多,不是每一个接口跟方法都是一接触就会的,而是要通过查找资料慢慢懂得。

你可能感兴趣的:(day 03 实习日志)