实训第三天

建立相关文件夹与文件

app.json

{

"pages": [

"pages/index/index",

"pages/logs/logs",

"pages/aa/aa",

"pages/bb/bb",

"pages/mine/mine",

"pages/map/map"

],

"window": {

"backgroundTextStyle": "light",

"navigationBarBackgroundColor": "#ddd",

"navigationBarTitleText": "一剑天涯",

"navigationBarTextStyle": "white",

"enablePullDownRefresh": true,

"backgroundColor": "#000000"

},

"tabBar": {

"color": "#000000",

"selectedColor": "#6A5ACD",

"list": [

{

"pagePath": "pages/index/index",

"text": "首页",

"iconPath": "image/timg2.png",

"selectedIconPath": "image/timg.jpg"

},

{

"pagePath": "pages/map/map",

"text": "地图",

"iconPath": "image/aa.jpg",

"selectedIconPath": "image/aa2.jpg"

},

{

"pagePath": "pages/bb/bb",

"text": "购物车",

"iconPath": "image/buy1.png",

"selectedIconPath": "image/buy.jpg"

},

{

"pagePath": "pages/mine/mine",

"text": "我的",

"iconPath": "image/my1.jpg",

"selectedIconPath": "image/my2.png"

}

]

},

"sitemapLocation": "sitemap.json"

}

 

index.js

//index.js

//获取应用实例

const app = getApp()

 

Page({

data: {

ay:"你好",

name:"\名字:黑暗之魂3 全境封锁 古墓丽影\n 杀出重围:人类分裂 黑手党3",

flag:true,

imageurl:[{

url:"../../image/1.jpg"

}, {

url: "../../image/2.jpg"

}, {

url: "../../image/3.jpg"

}, {

url: "../../image/4.jpg"

}, {

url: "../../image/5.jpg"

},

],

obj:{

name:"华为mate20pro",

index:0,

price:5000,

},

index:"10"

},

ya:function(){

console.log(this.data.flag);

//更改属性

this.setData({

flag:!this.data.flag

})

},

onLoad: function () {

//获取手机信息

wx.getSystemInfo({

success: function (res) {

console.log(res)

},

})

}

})

 

index.wxml

<!--index.wxml-->

 

<swiper indicator-dots="true" indicator-color="#fff" indicator-active-color="#ff0000" autoplay="ture" circular="true" interval="5000" skip-hidden-item-layout="true">

<block wx:for="{{imageurl}}" wx:key="{{index}}">

<swiper-item>

<image src='{{item.url}}' style='width:100%;height:100%'></image>

</swiper-item>

</block>

</swiper>

<text id='{{id}}' wx:if="{{flag}}">{{ay}}</text>

<view class='name'><image src="../../image/name.jpg" style='width:87px;height:66px;' wx:if="{{!flag}}"></image></view>

<text wx:if="{{!flag}}">{{name}}</text>

<button bindtap='ya' style='width:30%'>点一点</button>

<view wx:for="{{imageurl}}" wx:key="{{i}}"

wx:for-index="i" wx:for-item="val">{{i}}{{val.url}}</view>

<template name="msgItem">

<view>

<text> {{index}}: {{msg}} </text>

<text> Time: {{time}} </text>

</view>

</template>

<text wx:if="{{index==10 ? true : false}}">序号 手机型号 价格</text>

<!--定义模板-->

<template name="model">

<view>

{{index}} {{name}}

<text>{{price}}</text>

</view>

</template>

<!--引用模板-->

<template is="model" data="{{...obj}}"></template>

<!--导入模板-->

<import src="../aa/aa.wxml"/>

<template is="aa" data="{{...obj}}"/>

 

index.wxss

/**index.wxss**/

.name{

display:flex;

justify-content: center;

 

}

在map.js中以下类加入

data: {

longitude:0,

latitude:0,

windowHeight: 0

},

onReady: function () {

console.log(this)

},

onShow: function () {

var _this = this;

wx.getLocation({

success: function(res) {

console.log(res)

_this.setData({

longitude: res.longitude,

latitude: res.latitude

})

}

})

wx.getSystemInfo({

success: function (res) {

console.log(res)

_this.setData({

windowHeight: res.windowHeight

})

},

})

},

 

map.wxml

<!--pages/map/map.wxml-->

<view >

<map longitude='{{longitude}}' latitude='{{latitude}}'

scale='14' style='width:100%;height:{{ windowHeight}}px'show-location="true"></map>

</view>

 

mine.js中改变

 

data: {

model:"",

system:"",

windowHeight:0 ,

windowWidth: 0

},

onLoad: function (options) {

console.log(this)

},

onReady: function () {

var _this = this;

wx.getSystemInfo({

success: function (res) {

console.log(res)

_this.setData({

model: res.model,

system: res.system,

windowHeight: res.windowHeight,

windowWidth: res.windowWidth

})

},

})

},

 

mine.wxml

<!--pages/mine/mine.wxml-->

<text>手机型号{{model}}\n</text>

<text>手机系统{{system}}\n</text>

<text>手机高度{{windowHeight}}px\n</text>

<text>手机宽度{{windowWidth}}px</text>

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值