(2020.9.1 已终止)
前端测试效果:
部分代码:
<!-- index wxml -->
<view class="contain">
<view class="mod">
<view>
<block>
<navigator wx:for="{{nav}}" open-type="{{item.opty}}" url="{{item.purl}}">
<image src="{{picurl}}{{item.img}}" />
</navigator>
</block>
</view>
<view>
<block>
<text wx:for="{{nav}}">{{item.name}}</text>
</block>
</view>
</view>
<view class=""></view>
</view>
/* index js */
Page({
data: {
picurl: "http://58.87.127.76/imgs/", //已失效
nav: [
{
opty: "switchTab",
purl: "/pages/surrounding/index",
img: "驿站位置.png",
name:"驿站位置"
},
{
opty: "navigate",
purl: "/pages/video/index",
img: "视频专栏.png",
name:"视频专栏"
},
{
opty: "navigate",
purl: "/pages/ask/index",
img: "智能问答.png",
name:"智能问答"
},
{
opty: "navigate",
purl: "/pages/vip/index",
img: "会员精选.png",
name:"会员精选"
}
]
}
});
<!-- surrounding wxml -->
<view class="contain">
<view>
<swiper autoplay="{{true}}" circular="{{true}}" indicator-dots="{{true}}" indicator-active-color="#666ccc">
<swiper-item>
<navigator>
<image mode="widthFix" src="" />
</navigator>
</swiper-item>
<swiper-item>
<navigator>
<image mode="widthFix" src="" />
</navigator>
</swiper-item>
</swiper>
</view>
<view class="map">
<map id="myMap" show-location class="myMap"/>
<view class="op">
<button bindtap="moveToLocation" class="bt" style="width:250rpx">当前位置</button>
<button bindtap="includePoints" class="bt" style="width:250rpx">移动标注</button>
</view>
</view>
</view>
/* surrounding js */
Page({
onReady: function (e) {
this.mapCtx = wx.createMapContext('myMap')
},
moveToLocation: function () {
this.mapCtx.moveToLocation()
},
includePoints: function() {
this.mapCtx.includePoints({
padding: [10],
points: [{
latitude:0,
longitude:0,
}, {
latitude:0,
longitude:0,
}]
})
}
})
<!-- user wxml -->
<view class="user">
<view wx:if="{{islogout}}">
<button plain="{{true}}" type="primary" bindgetuserinfo="handleGetUserInfo" open-type="getUserInfo">登录</button>
</view>
<view wx:elif="{{islogout?false:true}}">
<navigator url="/pages/vip/index" class="info">
<image class="userpic" src="{{userinfo.avatarUrl}}" />
<text class="username">{{userinfo.nickName}}</text>
</navigator>
<view class="operations">
<view class="line"></view>
<navigator wx:for="{{op}}" url="{{item.path}}">
<image src="{{picurl}}{{item.img}}" />{{item.name}}
</navigator>
</view>
<button bindtap="logOut">退出</button>
</view>
</view>
/* user js */
Page({
/**
* 页面的初始数据
*/
data: {
picurl: "http://58.87.127.760/imgs/", //已失效
op:[
{
path: "/pages/collection/index",
img: "收藏.png",
name: "收藏"
},
{
path: "/pages/notice/index",
img: "通知.png",
name: "通知"
},
{
path: "/pages/support/index",
img: "客服.png",
name: "客服"
}
],
islogout:true,
userinfo:{}
},
handleGetUserInfo(e){
const {userInfo} = e.detail;
wx.setStorageSync("userinfo", userInfo);
this.setData({
islogout:false
})
},
onShow() {
const userinfo=wx.getStorageSync("userinfo");
this.setData({userinfo})
},
logOut() {
this.setData({
islogout:true
//
})
}
})