https://github.com/iflycn/vr_wechat
Blues VR - 微信小程序版
https://github.com/iflycn/vr_wechat
krpano miniprogram vr weui
Last synced: 7 months ago
JSON representation
Blues VR - 微信小程序版
- Host: GitHub
- URL: https://github.com/iflycn/vr_wechat
- Owner: iflycn
- Created: 2018-01-08T16:27:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T02:32:39.000Z (over 7 years ago)
- Last Synced: 2023-02-28T14:32:45.293Z (over 2 years ago)
- Topics: krpano, miniprogram, vr, weui
- Language: JavaScript
- Homepage: https://github.com/iflycn/vr_wechat
- Size: 126 KB
- Stars: 27
- Watchers: 1
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BLUES VR for WeChat
全景图片浏览微信小程序,支持 VR 模式。
## 依赖
基于 `WeUI`、`krpano` 实现。## 关键代码
### 获取全景图列表
```html{{item.type}}
{{item.title}}
New
...
```
```javascript
// pages/index/index.jsdata: {
pano_type: []
},onLoad: function (options) {
var that = this;
wx.request({
url: "url",
success: function (res) {
console.log("[res.data]: %o", res.data);
that.setData({
pano_type: res.data.pano
})
}
});
}
```
### 加入/移除收藏
```html...
```
```javascript
// pages/index/index.jsjoinFavorite: function (e) {
var id = e.currentTarget.dataset.id, favorites = wx.getStorageSync("favorites") || [], i = favorites.indexOf(id);
wx.showModal({
title: i < 0 ? "加入收藏" : "移出收藏",
content: "将“" + e.currentTarget.dataset.title + "”" + (i < 0 ? "加入" : "移出") + "个人收藏?",
confirmText: i < 0 ? "加入" : "移出",
cancelText: "取消",
success: function (res) {
if (res.confirm) {
i < 0 ? favorites.unshift(id) : favorites.splice(i, 1);
wx.setStorageSync("favorites", favorites);
console.log("[favorites]: %o", favorites);
}
}
});
}
```
### 获取收藏列表
```html
{{favorites_list[i][1]}}
...
```
```javascript
// pages/my_favorites/my_favorites.jsdata: {
favorites_list: []
},onLoad: function (options) {
var that = this;
wx.request({
url: "url",
success: function (res) {
var favorites_list = [], favorites = wx.getStorageSync("favorites") || [];
for (var i = 0; i < res.data.pano.length; i++) {
for (var j = 0; j < res.data.pano[i].list.length; j++) {
favorites.indexOf(res.data.pano[i].list[j].id) >= 0 && favorites_list.push([res.data.pano[i].list[j].id, res.data.pano[i].list[j].title]);
};
};
console.log("[favorites_list]: %o", favorites_list);
that.setData({
favorites_list: favorites_list
})
}
});
}
```## 嵌入 H5
详见 [https://github.com/iflycn/vr](https://github.com/iflycn/vr)