├── README.md
├── app.js
├── app.json
├── app.wxss
├── image
├── arrowright.png
├── icon64_appwx_logo.png
├── pause.png
├── play.png
├── plus.png
├── record.png
├── stop.png
├── trash.png
├── up.png
├── wechat.png
├── wechatHL.png
└── wechatHL_blue.png
├── pages
├── API
│ ├── animation
│ │ ├── animation.js
│ │ ├── animation.json
│ │ ├── animation.wxml
│ │ └── animation.wxss
│ ├── background-audio
│ │ ├── background-audio.js
│ │ ├── background-audio.json
│ │ ├── background-audio.wxml
│ │ └── background-audio.wxss
│ ├── canvas
│ │ ├── canvas.js
│ │ ├── canvas.json
│ │ ├── canvas.wxml
│ │ └── canvas.wxss
│ ├── common
│ │ ├── footer.wxml
│ │ └── header.wxml
│ ├── download-file
│ │ ├── download-file.js
│ │ ├── download-file.json
│ │ ├── download-file.wxml
│ │ └── download-file.wxss
│ ├── file
│ │ ├── file.js
│ │ ├── file.json
│ │ ├── file.wxml
│ │ └── file.wxss
│ ├── generate.sh
│ ├── get-location
│ │ ├── format-location.js
│ │ ├── get-location.js
│ │ ├── get-location.json
│ │ ├── get-location.wxml
│ │ └── get-location.wxss
│ ├── get-network-type
│ │ ├── get-network-type.js
│ │ ├── get-network-type.json
│ │ ├── get-network-type.wxml
│ │ └── get-network-type.wxss
│ ├── get-system-info
│ │ ├── get-system-info.js
│ │ ├── get-system-info.json
│ │ ├── get-system-info.wxml
│ │ └── get-system-info.wxss
│ ├── get-user-info
│ │ ├── get-user-info.js
│ │ ├── get-user-info.json
│ │ ├── get-user-info.wxml
│ │ └── get-user-info.wxss
│ ├── image
│ │ ├── image.js
│ │ ├── image.json
│ │ ├── image.wxml
│ │ └── image.wxss
│ ├── index
│ │ ├── index.js
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── login
│ │ ├── login.js
│ │ ├── login.json
│ │ ├── login.wxml
│ │ └── login.wxss
│ ├── navigation-bar-loading
│ │ ├── navigation-bar-loading.js
│ │ ├── navigation-bar-loading.json
│ │ ├── navigation-bar-loading.wxml
│ │ └── navigation-bar-loading.wxss
│ ├── navigator
│ │ ├── navigator.js
│ │ ├── navigator.json
│ │ ├── navigator.wxml
│ │ └── navigator.wxss
│ ├── on-accelerometer-change
│ │ ├── on-accelerometer-change.js
│ │ ├── on-accelerometer-change.json
│ │ ├── on-accelerometer-change.wxml
│ │ └── on-accelerometer-change.wxss
│ ├── on-compass-change
│ │ ├── on-compass-change.js
│ │ ├── on-compass-change.json
│ │ ├── on-compass-change.wxml
│ │ └── on-compass-change.wxss
│ ├── open-location
│ │ ├── open-location.js
│ │ ├── open-location.json
│ │ ├── open-location.wxml
│ │ └── open-location.wxss
│ ├── pull-down-refresh
│ │ ├── pull-down-refresh.js
│ │ ├── pull-down-refresh.json
│ │ ├── pull-down-refresh.wxml
│ │ └── pull-down-refresh.wxss
│ ├── request-payment
│ │ ├── request-payment.js
│ │ ├── request-payment.json
│ │ ├── request-payment.wxml
│ │ └── request-payment.wxss
│ ├── request
│ │ ├── request.js
│ │ ├── request.json
│ │ ├── request.wxml
│ │ └── request.wxss
│ ├── set-navigation-bar-title
│ │ ├── set-navigation-bar-title.js
│ │ ├── set-navigation-bar-title.json
│ │ ├── set-navigation-bar-title.wxml
│ │ └── set-navigation-bar-title.wxss
│ ├── storage
│ │ ├── storage.js
│ │ ├── storage.json
│ │ ├── storage.wxml
│ │ └── storage.wxss
│ ├── upload-file
│ │ ├── upload-file.js
│ │ ├── upload-file.json
│ │ ├── upload-file.wxml
│ │ └── upload-file.wxss
│ ├── voice
│ │ ├── voice.js
│ │ ├── voice.json
│ │ ├── voice.wxml
│ │ └── voice.wxss
│ └── web-socket
│ │ ├── web-socket.js
│ │ ├── web-socket.json
│ │ ├── web-socket.wxml
│ │ └── web-socket.wxss
├── component
│ ├── component-pages
│ │ ├── wx-action-sheet
│ │ │ ├── wx-action-sheet.js
│ │ │ ├── wx-action-sheet.wxml
│ │ │ └── wx-action-sheet.wxss
│ │ ├── wx-audio
│ │ │ ├── wx-audio.js
│ │ │ └── wx-audio.wxml
│ │ ├── wx-button
│ │ │ ├── wx-button.js
│ │ │ ├── wx-button.wxml
│ │ │ └── wx-button.wxss
│ │ ├── wx-checkbox
│ │ │ ├── wx-checkbox.js
│ │ │ ├── wx-checkbox.wxml
│ │ │ └── wx-checkbox.wxss
│ │ ├── wx-form
│ │ │ ├── wx-form.js
│ │ │ ├── wx-form.wxml
│ │ │ └── wx-form.wxss
│ │ ├── wx-icon
│ │ │ ├── wx-icon.js
│ │ │ ├── wx-icon.wxml
│ │ │ └── wx-icon.wxss
│ │ ├── wx-image
│ │ │ ├── wx-image.js
│ │ │ ├── wx-image.wxml
│ │ │ └── wx-image.wxss
│ │ ├── wx-input
│ │ │ ├── wx-input.js
│ │ │ ├── wx-input.wxml
│ │ │ └── wx-input.wxss
│ │ ├── wx-label
│ │ │ ├── wx-label.js
│ │ │ ├── wx-label.wxml
│ │ │ └── wx-label.wxss
│ │ ├── wx-mask
│ │ │ ├── wx-mask.js
│ │ │ └── wx-mask.wxml
│ │ ├── wx-modal
│ │ │ ├── wx-modal.js
│ │ │ └── wx-modal.wxml
│ │ ├── wx-navigator
│ │ │ ├── navigate.js
│ │ │ ├── navigate.wxml
│ │ │ ├── redirect.js
│ │ │ ├── redirect.wxml
│ │ │ ├── wx-navigator.js
│ │ │ ├── wx-navigator.wxml
│ │ │ └── wx-navigator.wxss
│ │ ├── wx-picker
│ │ │ ├── wx-picker.js
│ │ │ ├── wx-picker.wxml
│ │ │ └── wx-picker.wxss
│ │ ├── wx-progress
│ │ │ ├── wx-progress.js
│ │ │ ├── wx-progress.wxml
│ │ │ └── wx-progress.wxss
│ │ ├── wx-radio
│ │ │ ├── wx-radio.js
│ │ │ ├── wx-radio.wxml
│ │ │ └── wx-radio.wxss
│ │ ├── wx-scroll-view
│ │ │ ├── wx-scroll-view.js
│ │ │ ├── wx-scroll-view.wxml
│ │ │ └── wx-scroll-view.wxss
│ │ ├── wx-slide-tab
│ │ │ ├── wx-slide-tab.js
│ │ │ ├── wx-slide-tab.wxml
│ │ │ └── wx-slide-tab.wxss
│ │ ├── wx-slider
│ │ │ ├── wx-slider.js
│ │ │ └── wx-slider.wxml
│ │ ├── wx-swiper
│ │ │ ├── wx-swiper.js
│ │ │ ├── wx-swiper.wxml
│ │ │ └── wx-swiper.wxss
│ │ ├── wx-switch
│ │ │ ├── wx-switch.js
│ │ │ └── wx-switch.wxml
│ │ ├── wx-text
│ │ │ ├── wx-text.js
│ │ │ └── wx-text.wxml
│ │ ├── wx-toast
│ │ │ ├── wx-toast.js
│ │ │ └── wx-toast.wxml
│ │ ├── wx-video
│ │ │ ├── wx-video.js
│ │ │ └── wx-video.wxml
│ │ └── wx-view
│ │ │ ├── wx-view.js
│ │ │ ├── wx-view.wxml
│ │ │ └── wx-view.wxss
│ ├── index.js
│ ├── index.wxml
│ ├── index.wxss
│ ├── navigation-pages
│ │ ├── controller
│ │ │ ├── controller.js
│ │ │ └── controller.wxml
│ │ ├── form
│ │ │ ├── form.js
│ │ │ └── form.wxml
│ │ ├── media
│ │ │ ├── media.js
│ │ │ └── media.wxml
│ │ └── view
│ │ │ ├── view.js
│ │ │ └── view.wxml
│ └── resources
│ │ ├── arrow.png
│ │ ├── kind
│ │ ├── canvas.png
│ │ ├── content.png
│ │ ├── form.png
│ │ ├── interact.png
│ │ ├── map.png
│ │ ├── media.png
│ │ ├── nav.png
│ │ └── view.png
│ │ └── pic.jpg
├── index
│ ├── index.js
│ ├── index.wxml
│ ├── index.wxss
│ ├── resources
│ │ ├── arrow.png
│ │ ├── kind
│ │ │ ├── canvas.png
│ │ │ ├── content.png
│ │ │ ├── form.png
│ │ │ ├── interact.png
│ │ │ ├── map.png
│ │ │ ├── media.png
│ │ │ ├── nav.png
│ │ │ └── view.png
│ │ └── pic.jpg
│ └── view
│ │ ├── info-detail.js
│ │ ├── info-detail.wxml
│ │ ├── info-detail.wxss
│ │ ├── info-list.js
│ │ ├── info-list.wxml
│ │ └── info-list.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
└── main
│ ├── main.js
│ ├── main.wxml
│ └── main.wxss
└── utils
└── util.js
/README.md:
--------------------------------------------------------------------------------
1 | # WeApp-VR-Video
2 | 微信小程序——vr视频资源推荐
3 |
4 | 
5 |
6 | 这周,你被微信小程序刷屏了吗? 反正本猿被刷屏了~~~~本猿最先看到微信小程序相关的文章,应该是冯大辉老师的[「微信公众号来了」](http://mp.weixin.qq.com/s?__biz=MjM5ODIyMTE0MA==&mid=2650968689&idx=1&sn=c27c74226fe4d500ff552abc46b62812&chksm=bd38364a8a4fbf5ca2fd32caa15799a160e90295abc56a1b874d8ce14c85614b32a2cb846291&scene=0#wechat_redirect), 据MAC君透露,这篇文章寥寥几百字,一天内阅读量过百万。。。这是要全猿开发微信小程序的节奏撒!!
7 | 本猿表示绝不能落伍,于是趁着周末,开始微信小程序开发之旅!各位猿们,上车咯~
8 |
9 |
10 | 
11 |
12 | 一言不合就上效果图哈,辣这个demo是肿么做出来的咧?莫急莫急,且听本猿慢慢道来哈~
13 |
14 | **环境搭建**
15 | -----------------
16 | 开发微信小程序,首先肯定是搭建环境啦,你可以选择根据github上的这个[repo](https://github.com/gavinkwoe/weapp-ide-crack)进行下载安装,也可以下载这个[压缩包](https://pan.baidu.com/s/1o7KJkUm),快速完成安装哈,这个安装包里有如下文件:
17 | 
18 |
19 | 接下来的步骤是:
20 | (**Update: 已经不用做下面这三个步骤啦,直接进repo链接下载最新的9.0版,直接安装哈**)
21 |
22 | * 安装wechat_web_devtools_0.7.0_x64,并用它跟手机微信实现登录
23 | * 覆盖安装wechat_web_devtools_0.9.092100_x64
24 | * 将weapp-ide-crack-master文件夹中的三个文件,放到安装程序目录对应的地方:
25 | * 微信web开发者工具\package.nw\app\dist\components\create\createstep.js
26 |
27 | * 微信web开发者工具\package.nw\app\dist\stroes\projectStores.js
28 |
29 | * 微信web开发者工具\package.nw\app\dist\weapp\appservice\asdebug.js
30 |
31 | 
32 |
33 | 做完上述步骤,就可以愉快的打开微信的IDE啦~
34 |
35 | 
36 |
37 | 接下来,就是程序员的惯例:helloworld!
38 |
39 | 
40 | 创建项目,填好相关input选项,点击添加项目,搞定!
41 |
42 | 
43 |
44 | 太简单?没错,就是这么简单,哈哈,如果要复杂点,用IDE打开本猿提供的压缩包中的webapp-demo。
45 |
46 | 
47 |
48 | 它提供了所有组件和API的使用范例,如下图:
49 |
50 | 
51 |
52 | 相信玩过react native的童鞋一定会觉得似曾相识,没错,这个DEMO就像react native官方提供的UIExplorer一样哈!通过这个demo,我们就可以照着做一个DEMO啦。
53 |
54 | **代码结构概览分析**
55 | -------------------
56 |
57 | 搭完环境,就可以愉快的码代码了,我们先来看下刚新建项目的代码结构:
58 | 
59 |
60 | 我们先关注根目录下最主要的三个文件:
61 | 
62 |
63 | app.js我们暂时不需要改,首先配置好app.json,要点如下:
64 | * 将你要建立的page路径加到pages配置项上
65 | * 配置window配置项上的标题栏颜色 / 风格 / 内容等
66 | * 配置tabbar配置项上的内容 / icon等
67 | * 设置debug配置项,方便打log
68 |
69 | ```js
70 | {
71 | "pages":[
72 | "pages/index/index",
73 | "pages/index/view/info-list",
74 | "pages/index/view/info-detail",
75 | "pages/logs/logs",
76 | ],
77 | "window":{
78 | "backgroundTextStyle":"light",
79 | "navigationBarBackgroundColor": "#4DBBFF",
80 | "navigationBarTitleText": "微信VR视频资源推荐",
81 | "navigationBarTextStyle":"white"
82 | },
83 | "tabBar": {
84 | "color": "#dddddd",
85 | "selectedColor": "#4DBBFF",
86 | "borderStyle": "white",
87 | "backgroundColor": "#ffffff",
88 | "list": [{
89 | "pagePath": "pages/index/index",
90 | "iconPath": "image/wechat.png",
91 | "selectedIconPath": "image/wechatHL_blue.png",
92 | "text": "首页"
93 | }, {
94 | "pagePath": "pages/index/view/info-list",
95 | "iconPath": "image/wechat.png",
96 | "selectedIconPath": "image/wechatHL_blue.png",
97 | "text": "VR列表"
98 | }]
99 | },
100 | "networkTimeout": {
101 | "request": 10000,
102 | "connectSocket": 10000,
103 | "uploadFile": 10000,
104 | "downloadFile": 10000
105 | },
106 | "debug": true
107 | }
108 |
109 | ```
110 | 至于app.wxss, 如果多个页面中的样式有重复,需要复用,可以在app.wxss上写哈~~
111 |
112 | 接下来就写页面啦,通过app.json,大家可以看出,我总共就三个page而已哈(另外一个自带的,log记录之类的,忽略)
113 | 
114 |
115 | 我们先来了解下page的生命周期回调函数:
116 |
117 | | 命令 |描述 |
118 | | ------------- |:-------------: |
119 | |onLoad | 生命周期函数--监听页面加载 |
120 | |onReady | 生命周期函数--监听页面渲染完成 |
121 | |onShow | 生命周期函数--监听页面显示 |
122 | |onHide | 生命周期函数--监听页面隐藏 |
123 | |onUnload | 生命周期函数--监听页面卸载 |
124 |
125 | 在写这三个page时,主要用到了三个组件,第一个是swiper,也就是滑动面板,代码如下:
126 | ```js
127 | //index.wxml
128 |
129 |
130 |
132 |
133 |
134 |
135 |
136 | {{item.article.title}}
137 |
138 |
139 |
140 |
141 |
142 |
143 | i
144 |
145 | //index.js
146 | get_vr_swiper_info: function() {
147 | console.log('get_vr_info')
148 | var swiper_offset = parseInt( 800 * Math.random() );
149 | var that = this
150 |
151 | wx.request({
152 | url: API_URL + swiper_offset,
153 |
154 | success: function(response) {
155 | that.setData({
156 | swiper_list: response.data.result
157 | })
158 | }
159 |
160 | });
161 | }
162 | ```
163 | 第二个是可滚动视图scrollview,代码如下
164 | ```js
165 | //index.wxml
166 |
167 |
168 |
169 |
170 |
171 |
172 | {{item.article.title}}
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 | //index.js
183 | upper: function(e) {
184 | console.log(e)
185 | },
186 | lower: function(e) {
187 | console.log(e)
188 | },
189 | scroll: function(e) {
190 | console.log(e)
191 | },
192 | scrollToTop: function(e) {
193 | this.setAction({
194 | scrollTop: 0
195 | })
196 | },
197 | tap: function(e) {
198 | for (var i = 0; i < order.length; ++i) {
199 | if (order[i] === this.data.toView) {
200 | this.setData({
201 | toView: order[i + 1],
202 | scrollTop: (i + 1) * 200
203 | })
204 | break
205 | }
206 | }
207 | },
208 | tapMove: function(e) {
209 | this.setData({
210 | scrollTop: this.data.scrollTop + 10
211 | })
212 | },
213 |
214 | ```
215 | 第三个是navigator,负责页面间的跳转,代码上面其实也有了,主要就是声明好标签,并写上url路径就行啦。
216 | ```js
217 |
218 |
219 | ```
220 |
221 | 另外还需要了解三个主要接口:
222 |
223 | * wx.request()
224 | * wx.setStorage()
225 | * wx.getStorage()
226 |
227 | ```js
228 | wx.request({
229 | url: API_URL + vr_list_offset,
230 | success: function(response) {
231 | that.setData({
232 | vr_list: response.data.result
233 | })
234 | }
235 | });
236 |
237 | wx.setStorage({
238 | key:"vr_list",
239 | data:that.data.vr_list
240 | });
241 |
242 | wx.getStorage({
243 | key:'vr_list',
244 | success:function(res){
245 | console.log(res.data);
246 | }
247 | });
248 | ```
249 | 了解完这几个点之后,就可以动手做一个基础的demo啦,祝各位好运撒!
250 |
251 | **开发观感**
252 | -----------
253 |
254 | 1. 本猿之前也玩过react native,据我粗浅的理解,微信小程序的DEMO搭建相对RN会容易些,开发效率更高,但当前的[API文档](http://wxopen.notedown.cn/)太过简陋了,相关的组件描述也太少。
255 |
256 | 2. IDE有待改进,还木有linux环境,不嗨森!!BTW,强烈建议支持VIM
257 |
258 | 3. navigator实现page间的跳转,但缺少能跳转并传递对象的方法啊,难道只能通过setStorage()? 还是我没找到??
259 |
260 | 4. 组件少了点啊,木有webview,木有iframe~~~
261 |
262 | **相关参考**
263 | ----------
264 | [微信公众平台 |小程序 API文档](http://wxopen.notedown.cn)
265 |
266 | [微信小应用资源汇总整理](https://github.com/Aufree/awesome-wechat-weapp);
267 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this;
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo;
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | });
25 | }
26 | },
27 | globalData:{
28 | userInfo:null
29 | }
30 | })
31 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/index/view/info-list",
5 | "pages/index/view/info-detail",
6 | "pages/logs/logs",
7 | "pages/component/index",
8 |
9 |
10 | "pages/component/navigation-pages/controller/controller",
11 | "pages/component/navigation-pages/form/form",
12 | "pages/component/navigation-pages/media/media",
13 | "pages/component/navigation-pages/view/view",
14 | "pages/component/component-pages/wx-action-sheet/wx-action-sheet",
15 | "pages/component/component-pages/wx-audio/wx-audio",
16 | "pages/component/component-pages/wx-button/wx-button",
17 | "pages/component/component-pages/wx-checkbox/wx-checkbox",
18 | "pages/component/component-pages/wx-form/wx-form",
19 | "pages/component/component-pages/wx-icon/wx-icon",
20 | "pages/component/component-pages/wx-image/wx-image",
21 | "pages/component/component-pages/wx-input/wx-input",
22 | "pages/component/component-pages/wx-mask/wx-mask",
23 | "pages/component/component-pages/wx-modal/wx-modal",
24 | "pages/component/component-pages/wx-navigator/wx-navigator",
25 | "pages/component/component-pages/wx-progress/wx-progress",
26 | "pages/component/component-pages/wx-radio/wx-radio",
27 | "pages/component/component-pages/wx-scroll-view/wx-scroll-view",
28 | "pages/component/component-pages/wx-slider/wx-slider",
29 | "pages/component/component-pages/wx-switch/wx-switch",
30 | "pages/component/component-pages/wx-text/wx-text",
31 | "pages/component/component-pages/wx-toast/wx-toast",
32 | "pages/component/component-pages/wx-video/wx-video",
33 | "pages/component/component-pages/wx-view/wx-view",
34 | "pages/component/component-pages/wx-swiper/wx-swiper",
35 | "pages/component/component-pages/wx-slide-tab/wx-slide-tab",
36 | "pages/component/component-pages/wx-label/wx-label",
37 | "pages/component/component-pages/wx-navigator/navigate",
38 | "pages/component/component-pages/wx-navigator/redirect",
39 | "pages/component/component-pages/wx-picker/wx-picker",
40 |
41 | "pages/API/index/index",
42 | "pages/API/storage/storage",
43 |
44 | "pages/API/login/login",
45 | "pages/API/get-user-info/get-user-info",
46 | "pages/API/request-payment/request-payment",
47 |
48 | "pages/API/set-navigation-bar-title/set-navigation-bar-title",
49 | "pages/API/navigation-bar-loading/navigation-bar-loading",
50 | "pages/API/navigator/navigator",
51 | "pages/API/pull-down-refresh/pull-down-refresh",
52 | "pages/API/animation/animation",
53 |
54 | "pages/API/get-network-type/get-network-type",
55 | "pages/API/get-system-info/get-system-info",
56 | "pages/API/on-compass-change/on-compass-change",
57 |
58 | "pages/API/request/request",
59 | "pages/API/web-socket/web-socket",
60 | "pages/API/upload-file/upload-file",
61 | "pages/API/download-file/download-file",
62 |
63 |
64 | "pages/API/image/image",
65 | "pages/API/voice/voice",
66 | "pages/API/file/file",
67 | "pages/API/on-accelerometer-change/on-accelerometer-change",
68 | "pages/API/canvas/canvas",
69 | "pages/API/background-audio/background-audio",
70 |
71 | "pages/API/get-location/get-location",
72 | "pages/API/open-location/open-location"
73 | ],
74 | "window":{
75 | "backgroundTextStyle":"light",
76 | "navigationBarBackgroundColor": "#4DBBFF",
77 | "navigationBarTitleText": "微信VR视频资源推荐",
78 | "navigationBarTextStyle":"white"
79 | },
80 | "tabBar": {
81 | "color": "#dddddd",
82 | "selectedColor": "#4DBBFF",
83 | "borderStyle": "white",
84 | "backgroundColor": "#ffffff",
85 | "list": [{
86 | "pagePath": "pages/index/index",
87 | "iconPath": "image/wechat.png",
88 | "selectedIconPath": "image/wechatHL_blue.png",
89 | "text": "首页"
90 | }, {
91 | "pagePath": "pages/index/view/info-list",
92 | "iconPath": "image/wechat.png",
93 | "selectedIconPath": "image/wechatHL_blue.png",
94 | "text": "VR列表"
95 | }]
96 | },
97 | "networkTimeout": {
98 | "request": 10000,
99 | "connectSocket": 10000,
100 | "uploadFile": 10000,
101 | "downloadFile": 10000
102 | },
103 | "debug": true
104 | }
105 |
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | /**
3 | .container {
4 | height: 100%;
5 | display: flex;
6 | flex-direction: column;
7 | align-items: center;
8 | justify-content: space-between;
9 | padding: 200rpx 0;
10 | box-sizing: border-box;
11 | }
12 | **/
13 |
14 | page {
15 | background-color: #fbf9fe;
16 | height: 100%;
17 | }
18 | .container {
19 | display: flex;
20 | flex-direction: column;
21 | min-height: 100%;
22 | justify-content: space-between;
23 | }
24 | .page-header {
25 | display: flex;
26 | font-size: 32rpx;
27 | color: #aaa;
28 | justify-content: center;
29 | margin-top: 50rpx;
30 | }
31 | .page-header-text {
32 | padding: 20rpx 40rpx;
33 | border-bottom: 1px solid #ccc;
34 | }
35 |
36 | .page-body {
37 | width: 100%;
38 | display: flex;
39 | flex-direction: column;
40 | align-items: center;
41 | flex-grow: 1;
42 | overflow-x: hidden;
43 | }
44 | .page-body-wrapper {
45 | margin-top: 100rpx;
46 | display: flex;
47 | flex-direction: column;
48 | align-items: center;
49 | width: 100%;
50 | }
51 | .page-body-wrapper form {
52 | width: 100%;
53 | }
54 | .page-body-wording {
55 | text-align: center;
56 | padding: 200rpx 100rpx;
57 | }
58 | .page-body-info {
59 | display: flex;
60 | flex-direction: column;
61 | align-items: center;
62 | background-color: #fff;
63 | margin-bottom: 50rpx;
64 | width: 100%;
65 | padding: 50rpx 0 150rpx 0;
66 | }
67 | .page-body-title {
68 | margin-bottom: 100rpx;
69 | font-size: 32rpx;
70 | }
71 | .page-body-text {
72 | font-size: 30rpx;
73 | line-height: 26px;
74 | color: #ccc;
75 | }
76 | .page-body-text-small {
77 | font-size: 24rpx;
78 | color: #000;
79 | margin-bottom: 100rpx;
80 | }
81 | .page-body-form {
82 | width: 100%;
83 | background-color: #fff;
84 | display: flex;
85 | flex-direction: column;
86 | width: 100%;
87 | border: 1px solid #eee;
88 | }
89 | .page-body-form-item {
90 | display: flex;
91 | align-items: center;
92 | margin-left: 10rpx;
93 | border-bottom: 1px solid #eee;
94 | height: 80rpx;
95 | }
96 | .page-body-form-key {
97 | width: 180rpx;
98 | }
99 | .page-body-form-value {
100 | flex-grow: 1;
101 | }
102 |
103 | .page-body-form-picker {
104 | display: flex;
105 | justify-content: space-between;
106 | height: 100rpx;
107 | align-items: center;
108 | font-size: 36rpx;
109 | margin-left: 20rpx;
110 | padding-right: 20rpx;
111 | border-bottom: 1px solid #eee;
112 | }
113 | .page-body-form-picker-value {
114 | color: #ccc;
115 | }
116 |
117 | .page-body-buttons {
118 | width: 100%;
119 | }
120 | .page-body-button {
121 | margin: 25rpx;
122 | }
123 | .page-body-button image {
124 | width: 150rpx;
125 | height: 150rpx;
126 | }
127 | .page-footer {
128 | text-align: center;
129 | color: #1aad19;
130 | font-size: 24rpx;
131 | margin: 20rpx 0;
132 | }
133 |
134 | .green{
135 | color: #09BB07;
136 | }
137 | .red{
138 | color: #F76260;
139 | }
140 | .blue{
141 | color: #10AEFF;
142 | }
143 | .yellow{
144 | color: #FFBE00;
145 | }
146 | .gray{
147 | color: #C9C9C9;
148 | }
149 |
150 | .strong{
151 | font-weight: bold;
152 | }
153 |
154 | .bc_green{
155 | background-color: #09BB07;
156 | }
157 | .bc_red{
158 | background-color: #F76260;
159 | }
160 | .bc_blue{
161 | background-color: #10AEFF;
162 | }
163 | .bc_yellow{
164 | background-color: #FFBE00;
165 | }
166 | .bc_gray{
167 | background-color: #C9C9C9;
168 | }
169 |
170 | .tc{
171 | text-align: center;
172 | }
173 |
174 | .page input{
175 | padding: 10px 15px;
176 | background-color: #fff;
177 | }
178 | checkbox, radio{
179 | margin-right: 5px;
180 | }
181 |
182 | .btn-area{
183 | padding: 0 15px;
184 | }
185 | .btn-area button{
186 | margin-top: 10px;
187 | margin-bottom: 10px;
188 | }
189 |
190 | .page {
191 | min-height: 100%;
192 | flex: 1;
193 | background-color: #FBF9FE;
194 | font-size: 16px;
195 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
196 | overflow: hidden;
197 | }
198 | .page__hd{
199 | padding: 40px;
200 | }
201 | .page__title{
202 | display: block;
203 | font-size: 20px;
204 | }
205 | .page__desc{
206 | margin-top: 5px;
207 | font-size: 14px;
208 | color: #888888;
209 | }
210 |
211 | .section{
212 | margin-bottom: 40px;
213 | }
214 | .section_gap{
215 | padding: 0 15px;
216 | }
217 | .section__title{
218 | margin-bottom: 8px;
219 | padding-left: 15px;
220 | padding-right: 15px;
221 | }
222 | .section_gap .section__title{
223 | padding-left: 0;
224 | padding-right: 0;
225 | }
226 | .section__ctn{
227 |
228 | }
--------------------------------------------------------------------------------
/image/arrowright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/arrowright.png
--------------------------------------------------------------------------------
/image/icon64_appwx_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/icon64_appwx_logo.png
--------------------------------------------------------------------------------
/image/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/pause.png
--------------------------------------------------------------------------------
/image/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/play.png
--------------------------------------------------------------------------------
/image/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/plus.png
--------------------------------------------------------------------------------
/image/record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/record.png
--------------------------------------------------------------------------------
/image/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/stop.png
--------------------------------------------------------------------------------
/image/trash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/trash.png
--------------------------------------------------------------------------------
/image/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/up.png
--------------------------------------------------------------------------------
/image/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/wechat.png
--------------------------------------------------------------------------------
/image/wechatHL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/wechatHL.png
--------------------------------------------------------------------------------
/image/wechatHL_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/image/wechatHL_blue.png
--------------------------------------------------------------------------------
/pages/API/animation/animation.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onReady: function () {
3 | this.animation = wx.createAnimation()
4 |
5 | },
6 | rotate: function () {
7 | this.animation.rotate(Math.random() * 720 - 360).step()
8 | this.setData({ animation: this.animation.export() })
9 | },
10 | scale: function () {
11 | this.animation.scale(Math.random() * 2).step()
12 | this.setData({ animation: this.animation.export() })
13 | },
14 | translate: function () {
15 | this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
16 | this.setData({ animation: this.animation.export() })
17 | },
18 | skew: function () {
19 | this.animation.skew(Math.random() * 90, Math.random() * 90).step()
20 | this.setData({ animation: this.animation.export() })
21 | },
22 | rotateAndScale: function () {
23 | this.animation.rotate(Math.random() * 720 - 360)
24 | .scale(Math.random() * 2)
25 | .step()
26 | this.setData({ animation: this.animation.export() })
27 | },
28 | rotateThenScale: function () {
29 | this.animation.rotate(Math.random() * 720 - 360).step()
30 | .scale(Math.random() * 2).step()
31 | this.setData({ animation: this.animation.export() })
32 | },
33 | all: function () {
34 | this.animation.rotate(Math.random() * 720 - 360)
35 | .scale(Math.random() * 2)
36 | .translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
37 | .skew(Math.random() * 90, Math.random() * 90)
38 | .step()
39 | this.setData({ animation: this.animation.export() })
40 | },
41 | allInQueue: function () {
42 | this.animation.rotate(Math.random() * 720 - 360).step()
43 | .scale(Math.random() * 2).step()
44 | .translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
45 | .skew(Math.random() * 90, Math.random() * 90).step()
46 | this.setData({ animation: this.animation.export() })
47 | },
48 | reset: function () {
49 | this.animation.rotate(0, 0)
50 | .scale(1)
51 | .translate(0, 0)
52 | .skew(0, 0)
53 | .step({ duration: 0 })
54 | this.setData({ animation: this.animation.export() })
55 | }
56 | })
57 |
--------------------------------------------------------------------------------
/pages/API/animation/animation.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "动画"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/animation/animation.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/API/animation/animation.wxss:
--------------------------------------------------------------------------------
1 | .page-body-wrapper {
2 | flex-grow: 1;
3 | }
4 | .animation-element-wrapper {
5 | display: block;
6 | margin-bottom: 100rpx;
7 | }
8 | .animation-element {
9 | width: 200rpx;
10 | height: 200rpx;
11 | background-color: #1AAD19;
12 | }
13 | .animation-buttons {
14 | padding: 50rpx 50rpx 10rpx;
15 | border-top: 1px solid #ccc;
16 | display: flex;
17 | flex-grow: 1;
18 | overflow-y: scroll;
19 | flex-direction: row;
20 | flex-wrap: wrap;
21 | width: 100%;
22 | height: 400rpx;
23 | box-sizing: border-box;
24 | }
25 | .animation-button {
26 | width: 290rpx;
27 | margin: 20rpx auto;
28 | }
29 | .animation-button-reset {
30 | width: 610rpx;
31 | margin: 20rpx auto;
32 | }
33 |
--------------------------------------------------------------------------------
/pages/API/background-audio/background-audio.js:
--------------------------------------------------------------------------------
1 | var util = require('../../../utils/util.js')
2 | var dataUrl = 'http://ws.stream.qqmusic.qq.com/C100001wmp4t06stlC.m4a?fromtag=38'
3 | Page({
4 | onLoad: function () {
5 | var that = this
6 | wx.onBackgroundAudioStop(function () {
7 | that.setData({
8 | playing: false,
9 | playTime: 0,
10 | formatedPlayTime: '00:00:00'
11 | })
12 | })
13 | },
14 | data: {
15 | playing: false,
16 | playTime: 0,
17 | formatedPlayTime: '00:00:00'
18 | },
19 | play: function (res) {
20 | var that = this
21 | wx.playBackgroundAudio({
22 | dataUrl: dataUrl,
23 | title: 'Lost Stars',
24 | coverImgUrl: 'http://y.gtimg.cn/music/photo_new/T002R150x150M000000Jhxf24CFL06.jpg?max_age=2592000',
25 | complete: function (res) {
26 | that.setData({
27 | playing: true
28 | })
29 | }
30 | })
31 | this._enableInterval()
32 | },
33 | seek: function (e) {
34 | clearInterval(this.updateInterval)
35 | var that = this
36 | wx.seekBackgroundAudio({
37 | position: e.detail.value,
38 | complete: function () {
39 | // 实际会延迟两秒左右才跳过去
40 | setTimeout(function () {
41 | that._enableInterval()
42 | }, 2000)
43 | }
44 | })
45 | },
46 | pause: function () {
47 | var that = this
48 | wx.pauseBackgroundAudio({
49 | success: function () {
50 | that.setData({
51 | playing: false
52 | })
53 | }
54 | })
55 | },
56 | stop: function () {
57 | var that = this
58 | wx.stopBackgroundAudio({
59 | success: function (res) {
60 | that.setData({
61 | playing: false,
62 | playTime: 0,
63 | formatedPlayTime: util.formatTime(0)
64 | })
65 | }
66 | })
67 | },
68 | _enableInterval: function () {
69 | var that = this
70 | update()
71 | this.updateInterval = setInterval(update, 500)
72 | function update() {
73 | wx.getBackgroundAudioPlayerState({
74 | success: function (res) {
75 | that.setData({
76 | playTime: res.currentPosition,
77 | formatedPlayTime: util.formatTime(res.currentPosition + 1)
78 | })
79 | }
80 | })
81 | }
82 | },
83 | onUnload: function () {
84 | clearInterval(this.updateInterval)
85 | }
86 | })
87 |
--------------------------------------------------------------------------------
/pages/API/background-audio/background-audio.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "背景音乐"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/background-audio/background-audio.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{formatedPlayTime}}
10 |
11 |
12 | 00:00
13 | 04:29
14 |
15 |
16 | 离开应用后音乐也可保持播放
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/pages/API/background-audio/background-audio.wxss:
--------------------------------------------------------------------------------
1 | .page-body-wrapper {
2 | margin-top: 0;
3 | }
4 | .page-body-info {
5 | padding-bottom: 50rpx;
6 | }
7 | .time-big {
8 | font-size: 60rpx;
9 | margin: 20rpx;
10 | }
11 | .slider {
12 | width: 650rpx;
13 | }
14 | .play-time {
15 | font-size: 28rpx;
16 | width: 700rpx;
17 | padding: 20rpx 0;
18 | display: flex;
19 | justify-content: space-between;
20 | box-sizing: border-box;
21 | }
22 | .page-body-buttons {
23 | display: flex;
24 | justify-content: space-around;
25 | margin-top: 100rpx;
26 | }
27 | .page-body-button {
28 | width: 250rpx;
29 | text-align: center;
30 | }
31 |
--------------------------------------------------------------------------------
/pages/API/canvas/canvas.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onReady: function () {
3 | this.position = {
4 | x: 150,
5 | y: 150,
6 | vx: 2,
7 | vy: 2
8 | }
9 |
10 | this.drawBall()
11 | this.interval = setInterval(this.drawBall, 17)
12 | },
13 | drawBall: function () {
14 | var p = this.position
15 | p.x += p.vx
16 | p.y += p.vy
17 | if (p.x >= 300) {
18 | p.vx = -2
19 | }
20 | if (p.x <= 7) {
21 | p.vx = 2
22 | }
23 | if (p.y >= 300) {
24 | p.vy = -2
25 | }
26 | if (p.y <= 7) {
27 | p.vy = 2
28 | }
29 |
30 | var context = wx.createContext()
31 |
32 | ball(p.x, 150)
33 | ball(150, p.y)
34 | ball(300 - p.x, 150)
35 | ball(150, 300 - p.y)
36 | ball(p.x, p.y)
37 | ball(300 - p.x, 300 - p.y)
38 | ball(p.x, 300 - p.y)
39 | ball(300 - p.x, p.y)
40 |
41 |
42 | wx.drawCanvas({
43 | canvasId: 'canvas',
44 | actions: context.getActions()
45 | })
46 |
47 | function ball(x, y) {
48 | context.beginPath(0)
49 | context.arc(x, y, 5, 0, Math.PI * 2)
50 | context.setFillStyle('#1aad19')
51 | context.setStrokeStyle('rgba(1,1,1,0)')
52 | context.fill()
53 | context.stroke()
54 | }
55 | },
56 | onUnload: function () {
57 | clearInterval(this.interval)
58 | }
59 | })
60 |
--------------------------------------------------------------------------------
/pages/API/canvas/canvas.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "创建画布"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/canvas/canvas.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/API/canvas/canvas.wxss:
--------------------------------------------------------------------------------
1 | .canvas {
2 | width: 305px;
3 | height: 305px;
4 | background-color: #fff;
5 | }
6 |
--------------------------------------------------------------------------------
/pages/API/common/footer.wxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/pages/API/common/header.wxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/pages/API/download-file/download-file.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/API/download-file/download-file.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "下载文件"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/download-file/download-file.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 搭建好自己的后台服务器后,可以将服务器上的图片视频等资源下载到手机上。
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/API/download-file/download-file.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/download-file/download-file.wxss
--------------------------------------------------------------------------------
/pages/API/file/file.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | tempFilePath: '',
4 | savedFilePath: wx.getStorageSync('savedFilePath') || '',
5 | dialog: {
6 | hidden: true
7 | }
8 | },
9 | chooseImage: function () {
10 | var that = this
11 | wx.chooseImage({
12 | count: 1,
13 | success: function (res) {
14 | that.setData({
15 | tempFilePath: res.tempFilePaths[0]
16 | })
17 | }
18 | })
19 | },
20 | saveFile: function () {
21 | if (this.data.tempFilePath.length > 0) {
22 | var that = this
23 | wx.saveFile({
24 | tempFilePath: this.data.tempFilePath,
25 | success: function (res) {
26 | that.setData({
27 | savedFilePath: res.savedFilePath
28 | })
29 | wx.setStorageSync('savedFilePath', res.savedFilePath)
30 | that.setData({
31 | dialog: {
32 | title: '保存成功',
33 | content: '下次进入应用时,此文件仍可用',
34 | hidden: false
35 | }
36 | })
37 | },
38 | fail: function (res) {
39 | that.setData({
40 | dialog: {
41 | title: '保存失败',
42 | content: '应该是有 bug 吧',
43 | hidden: false
44 | }
45 | })
46 | }
47 | })
48 | }
49 | },
50 | clear: function () {
51 | wx.setStorageSync('savedFilePath', '')
52 | this.setData({
53 | tempFilePath: '',
54 | savedFilePath: ''
55 | })
56 | },
57 | confirm: function () {
58 | this.setData({
59 | 'dialog.hidden': true
60 | })
61 | }
62 | })
63 |
--------------------------------------------------------------------------------
/pages/API/file/file.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "文件"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/file/file.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 请选择图片
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | {{dialog.content}}
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/pages/API/file/file.wxss:
--------------------------------------------------------------------------------
1 | .image {
2 | width: 300rpx;
3 | height: 300rpx;
4 | }
5 | .image-plus {
6 | width: 150rpx;
7 | height: 150rpx;
8 | border: 1px solid #bbb;
9 | }
10 |
--------------------------------------------------------------------------------
/pages/API/generate.sh:
--------------------------------------------------------------------------------
1 | mkdir $1
2 | touch $1/$1.js
3 | touch $1/$1.wxss
4 | touch $1/$1.wxml
5 | touch $1/$1.json
6 |
--------------------------------------------------------------------------------
/pages/API/get-location/format-location.js:
--------------------------------------------------------------------------------
1 | function formatLocation(longitude, latitude) {
2 | longitude = longitude.toFixed(2)
3 | latitude = latitude.toFixed(2)
4 |
5 | return {
6 | longitude: longitude.toString().split('.'),
7 | latitude: latitude.toString().split('.')
8 | }
9 | }
10 |
11 | module.exports = formatLocation
12 |
--------------------------------------------------------------------------------
/pages/API/get-location/get-location.js:
--------------------------------------------------------------------------------
1 | var formatLocation = require('./format-location.js')
2 |
3 | Page({
4 | data: {
5 | hasLocation: false,
6 | },
7 | getLocation: function () {
8 | var that = this
9 | wx.getLocation({
10 | success: function (res) {
11 | console.log(res)
12 | that.setData({
13 | hasLocation: true,
14 | location: formatLocation(res.longitude, res.latitude)
15 | })
16 | }
17 | })
18 | },
19 | clear: function () {
20 | this.setData({
21 | hasLocation: false
22 | })
23 | }
24 | })
25 |
--------------------------------------------------------------------------------
/pages/API/get-location/get-location.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "获取位置"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/get-location/get-location.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 当前位置经纬度
11 |
12 | 未获取
13 |
14 |
15 |
16 | E{{location.longitude[0]}}°{{location.longitude[1]}}′
17 | N{{location.latitude[0]}}°{{location.latitude[1]}}′
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/pages/API/get-location/get-location.wxss:
--------------------------------------------------------------------------------
1 | .page-body-text-small {
2 | font-size: 24rpx;
3 | color: #000;
4 | margin-bottom: 100rpx;
5 | }
6 | .page-body-text-location {
7 | display: flex;
8 | font-size: 50rpx;
9 | }
10 | .page-body-text-location text {
11 | margin: 10rpx;
12 | }
13 |
--------------------------------------------------------------------------------
/pages/API/get-network-type/get-network-type.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | hasNetworkType: false
4 | },
5 | getNetworkType: function () {
6 | var that = this
7 | wx.getNetworkType({
8 | success: function (res) {
9 | console.log(res)
10 | that.setData({
11 | hasNetworkType: true,
12 | networkType: res.subtype || res.networkType
13 | })
14 | that.update()
15 | }
16 | })
17 | },
18 | clear: function () {
19 | this.setData({
20 | hasNetworkType: false,
21 | networkType: ''
22 | })
23 | }
24 | })
25 |
--------------------------------------------------------------------------------
/pages/API/get-network-type/get-network-type.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "获取手机网络状态"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/get-network-type/get-network-type.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 网络状态
11 |
12 | 未获取
13 | 点击绿色按钮可获取网络状态
14 |
15 |
16 | {{networkType}}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/API/get-network-type/get-network-type.wxss:
--------------------------------------------------------------------------------
1 | .page-body-text-network-type {
2 | font-size: 80rpx;
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/get-system-info/get-system-info.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | systemInfo: {}
4 | },
5 | getSystemInfo: function () {
6 | var that = this
7 | wx.getSystemInfo({
8 | success: function (res) {
9 | that.setData({
10 | systemInfo: res
11 | })
12 | that.update()
13 | }
14 | })
15 | }
16 | })
17 |
--------------------------------------------------------------------------------
/pages/API/get-system-info/get-system-info.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "获取手机系统信息"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/get-system-info/get-system-info.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | 手机型号
12 |
13 |
14 |
15 | 微信语言
16 |
17 |
18 |
19 | 微信版本
20 |
21 |
22 |
23 | 屏幕宽度
24 |
25 |
26 |
27 | 屏幕高度
28 |
29 |
30 |
31 | DPI
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/pages/API/get-system-info/get-system-info.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/get-system-info/get-system-info.wxss
--------------------------------------------------------------------------------
/pages/API/get-user-info/get-user-info.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | Page({
3 | data: {
4 | hasUserInfo: false
5 | },
6 | getUserInfo: function () {
7 | var that = this
8 |
9 | if (app.globalData.hasLogin === false) {
10 | wx.login({
11 | success: _getUserInfo
12 | })
13 | } else {
14 | _getUserInfo()
15 | }
16 |
17 | function _getUserInfo() {
18 | wx.getUserInfo({
19 | success: function (res) {
20 | that.setData({
21 | hasUserInfo: true,
22 | userInfo: res.userInfo
23 | })
24 | that.update()
25 | }
26 | })
27 | }
28 | },
29 | clear: function () {
30 | this.setData({
31 | hasUserInfo: false,
32 | userInfo: {}
33 | })
34 | }
35 | })
36 |
--------------------------------------------------------------------------------
/pages/API/get-user-info/get-user-info.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "获取用户信息"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/get-user-info/get-user-info.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 用户信息
11 |
12 | 未获取
13 | 点击绿色按钮可获取用户头像及昵称
14 |
15 |
16 |
17 | {{userInfo.nickName}}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/API/get-user-info/get-user-info.wxss:
--------------------------------------------------------------------------------
1 | .userinfo-avatar {
2 | border-radius: 128rpx;
3 | width: 128rpx;
4 | height: 128rpx;
5 | }
6 | .userinfo-nickname {
7 | margin-top: 20rpx;
8 | font-size: 38rpx;
9 | }
10 |
--------------------------------------------------------------------------------
/pages/API/image/image.js:
--------------------------------------------------------------------------------
1 | var sourceType = [ ['camera'], ['album'], ['camera', 'album'] ]
2 | var sizeType = [ ['compressed'], ['original'], ['compressed', 'original'] ]
3 |
4 | Page({
5 | data: {
6 | sourceTypeIndex: 0,
7 | sourceType: ['拍照', '相册', '拍照或相册'],
8 |
9 | sizeTypeIndex: 0,
10 | sizeType: ['压缩', '原图', '压缩或原图'],
11 |
12 | countIndex: 0,
13 | count: [1, 2, 3, 4, 5, 6, 7, 8, 9]
14 | },
15 | sourceTypeChange: function (e) {
16 | this.setData({
17 | sourceTypeIndex: e.detail.value
18 | })
19 | },
20 | sizeTypeChange: function (e) {
21 | this.setData({
22 | sizeTypeIndex: e.detail.value
23 | })
24 | },
25 | countChange: function (e) {
26 | this.setData({
27 | countIndex: e.detail.value
28 | })
29 | },
30 | chooseImage: function () {
31 | var that = this
32 | wx.chooseImage({
33 | sourceType: sourceType[this.data.sourceTypeIndex],
34 | sizeType: sizeType[this.data.sizeTypeIndex],
35 | count: this.data.count[this.data.countIndex],
36 | success: function (res) {
37 | console.log(res)
38 | that.setData({
39 | imageList: res.tempFilePaths
40 | })
41 | }
42 | })
43 | },
44 | previewImage: function (e) {
45 | var current = e.target.dataset.src
46 |
47 | wx.previewImage({
48 | current: current,
49 | urls: this.data.imageList
50 | })
51 | }
52 | })
53 |
--------------------------------------------------------------------------------
/pages/API/image/image.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "图片"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/image/image.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/pages/API/image/image.wxss:
--------------------------------------------------------------------------------
1 | .images-wrapper {
2 | padding: 20rpx;
3 | background-color: #fff;
4 | margin-top: 20rpx;
5 | }
6 | .images-wrapper-text {
7 | font-size: 28rpx;
8 | }
9 | .images-list {
10 | display: flex;
11 | margin-top: 20rpx;
12 | flex-wrap: wrap;
13 | }
14 | .images-image {
15 | width: 150rpx;
16 | height: 150rpx;
17 | margin: 10rpx;
18 | }
19 | .images-image-plus {
20 | border: 1px solid #999;
21 | }
22 |
--------------------------------------------------------------------------------
/pages/API/index/index.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | menuList: [{
4 | name: '基础能力',
5 | APIList: [{
6 | zhName: '微信登录',
7 | enName: 'login',
8 | url: '../login/login'
9 | }, {
10 | zhName: '获取用户信息',
11 | enName: 'getUserInfo',
12 | url: '../get-user-info/get-user-info'
13 | }, {
14 | zhName: '发起支付',
15 | enName: 'RequestPayment',
16 | url: '../request-payment/request-payment'
17 | }],
18 | opened: false
19 | }, {
20 | name: '界面跳转、监听和加载',
21 | opened: false,
22 | APIList: [{
23 | zhName: '设置界面标题',
24 | enName: 'setNavigationBarTitle',
25 | url: '../set-navigation-bar-title/set-navigation-bar-title'
26 | }, {
27 | zhName: '标题栏加载动画',
28 | enName: 'navigationBarLoading',
29 | url: '../navigation-bar-loading/navigation-bar-loading'
30 | }, {
31 | zhName: '页面跳转',
32 | enName: 'navigateTo, navigateBack, redirectTo',
33 | url: '../navigator/navigator'
34 | }, {
35 | zhName: '下拉刷新',
36 | enName: 'pullDownRefresh',
37 | url: '../pull-down-refresh/pull-down-refresh'
38 | }, {
39 | zhName: '创建动画',
40 | enName: 'createAnimation',
41 | url: '../animation/animation'
42 | }, {
43 | zhName: '创建绘画',
44 | enName: 'createContext',
45 | url: '../canvas/canvas'
46 | }]
47 | }, {
48 | name: '设备相关',
49 | opened: false,
50 | APIList: [{
51 | zhName: '获取手机网络状态',
52 | enName: 'getNetworkType',
53 | url: '../get-network-type/get-network-type'
54 | }, {
55 | zhName: '获取手机系统信息',
56 | enName: 'getSystemInfo',
57 | url: '../get-system-info/get-system-info'
58 | }, {
59 | zhName: '监听重力感应数据',
60 | enName: 'onAccelerometerChange',
61 | url: '../on-accelerometer-change/on-accelerometer-change'
62 | }, {
63 | zhName: '监听罗盘数据',
64 | enName: 'onCompassChange',
65 | url: '../on-compass-change/on-compass-change'
66 | }]
67 | }, {
68 | name: '网络相关',
69 | opened: false,
70 | APIList: [{
71 | zhName: '发起一个请求',
72 | enName: 'request',
73 | url: '../request/request'
74 | }, {
75 | zhName: 'Web Socket',
76 | enName: 'Web Socket',
77 | url: '../web-socket/web-socket'
78 | }, {
79 | zhName: '上传文件',
80 | enName: 'Upload File',
81 | url: '../upload-file/upload-file'
82 | }, {
83 | zhName: '下载文件',
84 | enName: 'Download File',
85 | url: '../download-file/download-file'
86 | }]
87 | }, {
88 | name: '多媒体',
89 | opened: false,
90 | APIList: [{
91 | zhName: '图片',
92 | enName: 'chooseImage/previewImage',
93 | url: '../image/image'
94 | }, {
95 | zhName: '录音',
96 | enName: 'start/stopRecord, play/pause/stopVoice',
97 | url: '../voice/voice'
98 | }, {
99 | zhName: '背景音频',
100 | enName: 'play/pause/stopAudio',
101 | url: '../background-audio/background-audio'
102 | }, {
103 | zhName: '文件',
104 | enName: 'saveFile',
105 | url: '../file/file'
106 | }]
107 | }, {
108 | name: '数据',
109 | opened: false,
110 | url: '../storage/storage'
111 | }, {
112 | name: '地理位置',
113 | opened: false,
114 | APIList: [{
115 | zhName: '获取当前位置',
116 | enName: 'getLocation',
117 | url: '../get-location/get-location'
118 | }, {
119 | zhName: '使用原生地图查看位置',
120 | enName: 'openLocation',
121 | url: '../open-location/open-location'
122 | }]
123 | }]
124 | },
125 | tapMenuItem: function (e) {
126 | var menuItem = this.data.menuList[parseInt(e.currentTarget.id)]
127 | if (menuItem.url) {
128 | wx.navigateTo({ url: menuItem.url })
129 | } else {
130 | var changeData = {}
131 | var opened = menuItem.opened
132 |
133 | changeData['menuList[' + e.currentTarget.id + '].opened'] = !opened
134 | this.setData(changeData)
135 | }
136 | }
137 | })
138 |
--------------------------------------------------------------------------------
/pages/API/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
33 |
34 |
--------------------------------------------------------------------------------
/pages/API/index/index.wxss:
--------------------------------------------------------------------------------
1 | .header {
2 | padding: 40px;
3 | }
4 | .title {
5 | font-size: 30px;
6 | }
7 | .desc {
8 | margin-top: 5px;
9 | color: #888888;
10 | font-size: 14px;
11 | line-height: 1.4;
12 | }
13 | .menu-list {
14 | display: flex;
15 | flex-direction: column;
16 | background-color: #fbf9fe;
17 | }
18 | .menu-item {
19 | color: #000000;
20 | display: flex;
21 | background-color: #fff;
22 | margin: 10rpx 40rpx;
23 | flex-direction: column;
24 | }
25 | .menu-item-main {
26 | display: flex;
27 | height: 100rpx;
28 | padding: 20rpx;
29 | border-radius: 10rpx;
30 | align-items: center;
31 | font-size: 32rpx;
32 | justify-content: space-between;
33 | }
34 | .menu-item-arrow {
35 | width: 32rpx;
36 | height: 32rpx;
37 | transition: 400ms;
38 | }
39 | .menu-item-arrow.open {
40 | transform: rotate(-90deg);
41 | }
42 | .menu-item-arrow.close {
43 | transform: rotate(90deg);
44 | }
45 | .menu-item-arrow.url {
46 | transform: rotate(0deg);
47 | }
48 |
49 | .menu-item-api-list {
50 | transition: 200ms;
51 | height: auto;
52 | border-top: 1px solid #d8d8d8;
53 | }
54 | .menu-item-api-list.close {
55 | display: none;
56 | height: 0;
57 | }
58 | .menu-item-api-item {
59 | display: flex;
60 | justify-content: space-between;
61 | height: 80rpx;
62 | padding: 20rpx 20rpx 20rpx 0;
63 | margin-left: 20rpx;
64 | align-items: center;
65 | border-top: 1px solid #f0f0f0;
66 | }
67 | .menu-item-api-item-text {
68 | display: flex;
69 | flex-direction: column;
70 | justify-content: space-between;
71 | height: 100%;
72 | }
73 | .menu-item-api-item-text-zhname {
74 | font-size: 30rpx;
75 | }
76 | .menu-item-api-item-text-enname {
77 | font-size: 26rpx;
78 | color: #6b6b6b;
79 | }
80 | .menu-item-api-item-arrow {
81 | width: 32rpx;
82 | height: 32rpx;
83 | }
84 |
--------------------------------------------------------------------------------
/pages/API/login/login.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | Page({
3 | onLoad: function () {
4 | this.setData({
5 | hasLogin: app.globalData.hasLogin
6 | })
7 | },
8 | data: {},
9 | login: function () {
10 | var that = this
11 | wx.login({
12 | success: function (res) {
13 | app.globalData.hasLogin = true
14 | that.setData({
15 | hasLogin: true
16 | })
17 | that.update()
18 | }
19 | })
20 | }
21 | })
22 |
--------------------------------------------------------------------------------
/pages/API/login/login.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "微信登录"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/login/login.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 已登录
11 | 每个微信号中仅需登录 1 次,后续每次进入页面即可根据微信 id 自动拉取用户信息
12 |
13 |
14 | 每个微信号中仅需登录一次
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/pages/API/login/login.wxss:
--------------------------------------------------------------------------------
1 | .page-body-wrapper {
2 | margin-top: 200rpx;
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | justify-content: center;
7 | width: 100%;
8 | padding: 0 50rpx;
9 | box-sizing: border-box;
10 | }
11 | .page-body-title {
12 | font-size: 60rpx;
13 | /*TODO 使用 rpx */
14 | line-height: 100px;
15 | }
16 | .page-body-text {
17 | color: #bbb;
18 | font-size: 28rpx;
19 | /*TODO 使用 rpx */
20 | line-height: 20px;
21 | margin: 0 0 100rpx 0;
22 | text-align: center;
23 | }
24 | .page-body-button {
25 | width: 100%;
26 | }
27 |
--------------------------------------------------------------------------------
/pages/API/navigation-bar-loading/navigation-bar-loading.js:
--------------------------------------------------------------------------------
1 | Page({
2 | showNavigationBarLoading: function () {
3 | wx.showNavigationBarLoading()
4 | },
5 | hideNavigationBarLoading: function () {
6 | wx.hideNavigationBarLoading()
7 | }
8 | })
9 |
--------------------------------------------------------------------------------
/pages/API/navigation-bar-loading/navigation-bar-loading.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "标题栏加载动画"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/navigation-bar-loading/navigation-bar-loading.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pages/API/navigation-bar-loading/navigation-bar-loading.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/navigation-bar-loading/navigation-bar-loading.wxss
--------------------------------------------------------------------------------
/pages/API/navigator/navigator.js:
--------------------------------------------------------------------------------
1 | Page({
2 | navigateTo: function () {
3 | wx.navigateTo({ url: './navigator' })
4 | },
5 | navigateBack: function () {
6 | wx.navigateBack()
7 | },
8 | redirectTo: function () {
9 | wx.redirectTo({ url: './navigator' })
10 | }
11 | })
12 |
--------------------------------------------------------------------------------
/pages/API/navigator/navigator.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "页面跳转"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/navigator/navigator.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pages/API/navigator/navigator.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/navigator/navigator.wxss
--------------------------------------------------------------------------------
/pages/API/on-accelerometer-change/on-accelerometer-change.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onReady: function () {
3 | this.drawBigBall()
4 | var that = this
5 |
6 | this.position = {
7 | x: 151,
8 | y: 151,
9 | vx: 0,
10 | vy: 0,
11 | ax: 0,
12 | ay: 0
13 | }
14 | wx.onAccelerometerChange(function (res) {
15 | that.setData({
16 | x: res.x.toFixed(2),
17 | y: res.y.toFixed(2),
18 | z: res.z.toFixed(2)
19 | })
20 | that.position.ax = Math.sin(res.x * Math.PI / 2)
21 | that.position.ay = -Math.sin(res.y * Math.PI / 2)
22 | //that.drawSmallBall()
23 | })
24 |
25 | this.interval = setInterval(function () {
26 | that.drawSmallBall()
27 | }, 17)
28 |
29 | },
30 | drawBigBall: function () {
31 | var context = wx.createContext()
32 | context.beginPath(0)
33 | context.arc(151, 151, 140, 0, Math.PI * 2)
34 | context.setFillStyle('#ffffff')
35 | context.setStrokeStyle('#aaaaaa')
36 | context.fill()
37 | context.stroke()
38 | wx.drawCanvas({
39 | canvasId: 'big-ball',
40 | actions: context.getActions()
41 | })
42 | },
43 | drawSmallBall: function () {
44 | var p = this.position
45 | var strokeStyle = 'rgba(1,1,1,0)'
46 |
47 | p.x = p.x + p.vx
48 | p.y = p.y + p.vy
49 | p.vx = p.vx + p.ax
50 | p.vy = p.vy + p.ay
51 |
52 | if (Math.sqrt(Math.pow(Math.abs(p.x) - 151, 2) + Math.pow(Math.abs(p.y) - 151, 2)) >= 115) {
53 | if (p.x > 151 && p.vx > 0) {
54 | p.vx = 0
55 | }
56 | if (p.x < 151 && p.vx < 0) {
57 | p.vx = 0
58 | }
59 | if (p.y > 151 && p.vy > 0) {
60 | p.vy = 0
61 | }
62 | if (p.y < 151 && p.vy < 0) {
63 | p.vy = 0
64 | }
65 | strokeStyle = '#ff0000'
66 | }
67 |
68 | var context = wx.createContext()
69 | context.beginPath(0)
70 | context.arc(p.x, p.y, 15, 0, Math.PI * 2)
71 | context.setFillStyle('#1aad19')
72 | context.setStrokeStyle(strokeStyle)
73 | context.fill()
74 | context.stroke()
75 | wx.drawCanvas({
76 | canvasId: 'small-ball',
77 | actions: context.getActions()
78 | })
79 | },
80 | data: {
81 | x: 0,
82 | y: 0,
83 | z: 0
84 | },
85 | onUnload: function () {
86 | clearInterval(this.interval)
87 | }
88 | })
89 |
--------------------------------------------------------------------------------
/pages/API/on-accelerometer-change/on-accelerometer-change.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "监听重力感应数据"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/on-accelerometer-change/on-accelerometer-change.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 旋转手机即可移动以下小球
10 |
11 |
12 |
13 |
14 |
15 | X: {{x}}
16 | Y: {{y}}
17 | Z: {{z}}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/pages/API/on-accelerometer-change/on-accelerometer-change.wxss:
--------------------------------------------------------------------------------
1 | .page-body-xyz {
2 | display: flex;
3 | justify-content: space-around;
4 | width: 700rpx;
5 | margin-top: 50rpx;
6 | box-sizing: border-box;
7 | }
8 | .page-body-canvas {
9 | width: 302px;
10 | height: 302px;
11 | position: relative;
12 | }
13 | .page-body-ball {
14 | position: absolute;
15 | top: 0;
16 | left: 0;
17 | width: 302px;
18 | height: 302px;
19 | }
20 | .page-body-title {
21 | font-size: 50rpx;
22 | width: 250rpx;
23 | }
24 |
--------------------------------------------------------------------------------
/pages/API/on-compass-change/on-compass-change.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | direction: 0
4 | },
5 | onReady: function () {
6 | var that = this
7 | wx.onCompassChange(function (res) {
8 | that.setData({
9 | direction: parseInt(res.direction)
10 | })
11 | })
12 | }
13 | })
14 |
--------------------------------------------------------------------------------
/pages/API/on-compass-change/on-compass-change.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "监听罗盘数据"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/on-compass-change/on-compass-change.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 选中手机即可获取方位信息
10 |
11 | {{direction}}
12 | o
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/pages/API/on-compass-change/on-compass-change.wxss:
--------------------------------------------------------------------------------
1 | .direction {
2 | margin-top: 100rpx;
3 | display: flex;
4 | }
5 | .direction-value {
6 | font-size: 200rpx;
7 | }
8 | .direction-degree {
9 | font-size: 40rpx;
10 | }
11 |
--------------------------------------------------------------------------------
/pages/API/open-location/open-location.js:
--------------------------------------------------------------------------------
1 | Page({
2 | openLocation: function (e) {
3 | console.log(e)
4 | var value = e.detail.value
5 | console.log(value)
6 | wx.openLocation({
7 | longitude: Number(value.longitude),
8 | latitude: Number(value.latitude),
9 | name: value.name,
10 | address: value.address
11 | })
12 | }
13 | })
14 |
--------------------------------------------------------------------------------
/pages/API/open-location/open-location.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看位置"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/open-location/open-location.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/API/open-location/open-location.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/open-location/open-location.wxss
--------------------------------------------------------------------------------
/pages/API/pull-down-refresh/pull-down-refresh.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onPullDownRefresh: function () {
3 | console.log('onPullDownRefresh', new Date())
4 | },
5 | stopPullDownRefresh: function () {
6 | wx.stopPullDownRefresh({
7 | complete: function (res) {
8 | console.log(res, new Date())
9 | }
10 | })
11 | }
12 | })
13 |
--------------------------------------------------------------------------------
/pages/API/pull-down-refresh/pull-down-refresh.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "下拉刷新",
3 | "enablePullDownRefresh": true
4 | }
5 |
--------------------------------------------------------------------------------
/pages/API/pull-down-refresh/pull-down-refresh.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 下滑页面即可刷新
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/pages/API/pull-down-refresh/pull-down-refresh.wxss:
--------------------------------------------------------------------------------
1 | .page-body-info {
2 | background-color: transparent;
3 | }
4 | .page-body-buttons button {
5 | color: #21c932;
6 | margin: 0 100rpx;
7 | }
8 | .page-body-buttons button:after {
9 | border-color: #21c932;
10 | }
11 |
--------------------------------------------------------------------------------
/pages/API/request-payment/request-payment.js:
--------------------------------------------------------------------------------
1 | Page({
2 | })
3 |
--------------------------------------------------------------------------------
/pages/API/request-payment/request-payment.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "发起支付"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/request-payment/request-payment.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 自主接入微信支付后,可以让用户在页面上快捷完成下单购买。
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pages/API/request-payment/request-payment.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/request-payment/request-payment.wxss
--------------------------------------------------------------------------------
/pages/API/request/request.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/API/request/request.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "网络请求"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/request/request.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 搭建好自己的后台服务器后,可以跟服务器互通数据,为用户提供个性化服务。
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pages/API/request/request.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/request/request.wxss
--------------------------------------------------------------------------------
/pages/API/set-navigation-bar-title/set-navigation-bar-title.js:
--------------------------------------------------------------------------------
1 | Page({
2 | setNaivgationBarTitle: function (e) {
3 | var title = e.detail.value.title
4 | console.log(title)
5 | wx.setNavigationBarTitle({
6 | title: title
7 | })
8 | }
9 | })
10 |
--------------------------------------------------------------------------------
/pages/API/set-navigation-bar-title/set-navigation-bar-title.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "设置页面标题"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/set-navigation-bar-title/set-navigation-bar-title.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/pages/API/set-navigation-bar-title/set-navigation-bar-title.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/set-navigation-bar-title/set-navigation-bar-title.wxss
--------------------------------------------------------------------------------
/pages/API/storage/storage.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | toast: {
4 | hidden: true
5 | }
6 | },
7 | submitForm: function (e) {
8 | var type = e.detail.target.id
9 | var key = e.detail.value.key
10 | var data = e.detail.value.data
11 |
12 | if (key.length === 0 && type !== 'clear') {
13 | this.setData({
14 | key: key,
15 | data: data,
16 | 'toast.hidden': false,
17 | 'toast.content': 'key 不能为空'
18 | })
19 | } else if (type === 'get' && key.length > 0) {
20 | this.setData({
21 | key: key,
22 | data: wx.getStorageSync(key),
23 | 'toast.hidden': false,
24 | 'toast.content': '读取数据成功'
25 | })
26 | } else if (type === 'set' && key.length > 0) {
27 | wx.setStorageSync(key, data)
28 | this.setData({
29 | key: key,
30 | data: data,
31 | 'toast.hidden': false,
32 | 'toast.content': '存储数据成功'
33 | })
34 | } else if (type === 'clear') {
35 | wx.clearStorageSync()
36 | this.setData({
37 | key: '',
38 | data: '',
39 | 'toast.hidden': false,
40 | 'toast.content': '清除数据成功'
41 | })
42 | }
43 | },
44 | toastChange: function () {
45 | this.setData({
46 | 'toast.hidden': true
47 | })
48 | }
49 | })
50 |
--------------------------------------------------------------------------------
/pages/API/storage/storage.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "数据存储"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/storage/storage.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
22 |
23 |
24 |
25 | {{toast.content}}
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/API/storage/storage.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/storage/storage.wxss
--------------------------------------------------------------------------------
/pages/API/upload-file/upload-file.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/API/upload-file/upload-file.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "上传文件"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/upload-file/upload-file.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 搭建好自己的后台服务器后,可以将手机上的图片视频等资源上传到服务器上。
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/API/upload-file/upload-file.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/upload-file/upload-file.wxss
--------------------------------------------------------------------------------
/pages/API/voice/voice.js:
--------------------------------------------------------------------------------
1 | var util = require('../../../utils/util.js')
2 | var playTimeInterval
3 |
4 | Page({
5 | data: {
6 | recording: false,
7 | playing: false,
8 | hasRecord: false,
9 | recordTime: 0,
10 | playTime: 0,
11 | formatedRecordTime: '00:00:00',
12 | formatedPlayTime: '00:00:00'
13 | },
14 | startRecord: function () {
15 | this.setData({ recording: true })
16 |
17 | var that = this
18 | var interval = setInterval(function () {
19 | that.data.recordTime += 1
20 | that.setData({
21 | formatedRecordTime: util.formatTime(that.data.recordTime)
22 | })
23 | }, 1000)
24 | wx.startRecord({
25 | success: function (res) {
26 | that.setData({
27 | hasRecord: true,
28 | tempFilePath: res.tempFilePath,
29 | formatedPlayTime: util.formatTime(that.data.playTime)
30 | })
31 | },
32 | complete: function () {
33 | that.setData({ recording: false })
34 | clearInterval(interval)
35 | }
36 | })
37 | },
38 | stopRecord: function () {
39 | wx.stopRecord()
40 | },
41 | playVoice: function () {
42 | var that = this
43 | playTimeInterval = setInterval(function () {
44 | that.data.playTime += 1
45 | that.setData({
46 | playing: true,
47 | formatedPlayTime: util.formatTime(that.data.playTime)
48 | })
49 | }, 1000)
50 | wx.playVoice({
51 | filePath: this.data.tempFilePath,
52 | success: function () {
53 | clearInterval(playTimeInterval)
54 | that.data.playTime = 0
55 | that.setData({
56 | playing: false,
57 | formatedPlayTime: util.formatTime(that.data.playTime)
58 | })
59 | }
60 | })
61 | },
62 | pauseVoice: function () {
63 | clearInterval(playTimeInterval)
64 | wx.pauseVoice()
65 | this.setData({
66 | playing: false
67 | })
68 | },
69 | stopVoice: function () {
70 | clearInterval(playTimeInterval)
71 | this.data.playTime = 0
72 | this.setData({
73 | playing: false,
74 | formatedPlayTime: util.formatTime(this.data.playTime)
75 | })
76 | wx.stopVoice()
77 | },
78 | clear: function () {
79 | this.data.recordTime = 0
80 | this.data.playTime = 0
81 | this.setData({
82 | hasRecord: false,
83 | tempFilePath: '',
84 | formatedRecordTime: util.formatTime(0)
85 | })
86 | }
87 | })
88 |
--------------------------------------------------------------------------------
/pages/API/voice/voice.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "录音"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/voice/voice.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{formatedRecordTime}}
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | {{formatedRecordTime}}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | {{formatedPlayTime}}
38 | {{formatedRecordTime}}
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | {{formatedPlayTime}}
54 | {{formatedRecordTime}}
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/pages/API/voice/voice.wxss:
--------------------------------------------------------------------------------
1 | .page-body-wrapper {
2 | justify-content: space-between;
3 | flex-grow: 1;
4 | margin-bottom: 300rpx;
5 | }
6 | .page-body-time {
7 | display: flex;
8 | flex-direction: column;
9 | align-items: center;
10 | }
11 | .time-big {
12 | font-size: 60rpx;
13 | margin: 20rpx;
14 | }
15 | .time-small {
16 | font-size: 30rpx;
17 | }
18 |
19 | .page-body-buttons {
20 | display: flex;
21 | justify-content: space-around;
22 | }
23 | .page-body-button {
24 | width: 250rpx;
25 | text-align: center;
26 | }
27 | .button-stop-record {
28 | width: 110rpx;
29 | height: 110rpx;
30 | border: 20rpx solid #fff;
31 | background-color: #f55c23;
32 | border-radius: 130rpx;
33 | margin: 0 auto;
34 | }
35 |
--------------------------------------------------------------------------------
/pages/API/web-socket/web-socket.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/API/web-socket/web-socket.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Web Socket"
3 | }
4 |
--------------------------------------------------------------------------------
/pages/API/web-socket/web-socket.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 搭建好自己的后台服务器后,可以跟服务器建立持久连接,实现即时聊天等功能。
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/API/web-socket/web-socket.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/API/web-socket/web-socket.wxss
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-action-sheet/wx-action-sheet.js:
--------------------------------------------------------------------------------
1 | var items = ['item1', 'item2', 'item3', 'item4']
2 | var pageObject = {
3 | data: {
4 | actionSheetHidden: true,
5 | actionSheetItems: items
6 | },
7 | actionSheetTap: function(e) {
8 | this.setData({
9 | actionSheetHidden: !this.data.actionSheetHidden
10 | })
11 | },
12 | actionSheetChange: function(e) {
13 | this.setData({
14 | actionSheetHidden: !this.data.actionSheetHidden
15 | })
16 | }
17 | }
18 |
19 | for (var i = 0; i < items.length; ++i) {
20 | (function(itemName) {
21 | pageObject['bind' + itemName] = function(e) {
22 | console.log('click' + itemName, e)
23 | }
24 | })(items[i])
25 | }
26 |
27 | Page(pageObject)
28 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-action-sheet/wx-action-sheet.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | action-sheet
4 | action-sheet
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{item}}
12 |
13 | 取消
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-action-sheet/wx-action-sheet.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | .cancel {
3 | color: white;
4 | background: #303F9F;
5 | }
6 | .item {
7 | color: black;
8 | background: #C5CAE9;
9 | }*/
10 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-audio/wx-audio.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | audioAction: {
4 | method: 'pause'
5 | }
6 | },
7 | audioPlayed: function(e) {
8 | console.log('audio is played')
9 | }
10 | })
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-audio/wx-audio.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | audio
4 | 音频
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-button/wx-button.js:
--------------------------------------------------------------------------------
1 | var types = ['default', 'primary', 'warn']
2 | var pageObject = {
3 | data: {
4 | defaultSize: 'default',
5 | primarySize: 'default',
6 | warnSize: 'default',
7 | disabled: false,
8 | plain: false,
9 | loading: false
10 | },
11 | setDisabled: function(e) {
12 | this.setData({
13 | disabled: !this.data.disabled
14 | })
15 | },
16 | setPlain: function(e) {
17 | this.setData({
18 | plain: !this.data.plain
19 | })
20 | },
21 | setLoading: function(e) {
22 | this.setData({
23 | loading: !this.data.loading
24 | })
25 | }
26 | }
27 |
28 | for (var i = 0; i < types.length; ++i) {
29 | (function(type) {
30 | pageObject[type] = function(e) {
31 | var key = type + 'Size'
32 | var changedData = {}
33 | changedData[key] =
34 | this.data[key] === 'default' ? 'mini' : 'default'
35 | this.setData(changedData)
36 | }
37 | })(types[i])
38 | }
39 |
40 | Page(pageObject)
41 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-button/wx-button.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | button
4 | 按钮
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-button/wx-button.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/component-pages/wx-button/wx-button.wxss
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-checkbox/wx-checkbox.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | items: [
4 | {name: 'USA', value: '美国'},
5 | {name: 'CHN', value: '中国', checked: 'true'},
6 | {name: 'BRA', value: '巴西'},
7 | {name: 'JPN', value: '日本'},
8 | {name: 'ENG', value: '英国'},
9 | {name: 'FRA', value: '法国'},
10 | ]
11 | },
12 | checkboxChange: function(e) {
13 | console.log('checkbox发生change事件,携带value值为:', e.detail.value)
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-checkbox/wx-checkbox.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | checkbox
4 | 多选框
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-checkbox/wx-checkbox.wxss:
--------------------------------------------------------------------------------
1 | .checkbox{
2 | display: block;
3 | margin-bottom: 10px;
4 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-form/wx-form.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | pickerHidden: true,
4 | chosen: ''
5 | },
6 | pickerConfirm: function(e) {
7 | this.setData({
8 | pickerHidden: true
9 | })
10 | this.setData({
11 | chosen: e.detail.value
12 | })
13 | },
14 | pickerCancel: function(e) {
15 | this.setData({
16 | pickerHidden: true
17 | })
18 | },
19 | pickerShow: function(e) {
20 | this.setData({
21 | pickerHidden: false
22 | })
23 | },
24 | formSubmit: function(e) {
25 | console.log('form发生了submit事件,携带数据为:', e.detail.value)
26 | },
27 | formReset: function(e) {
28 | console.log('form发生了reset事件,携带数据为:', e.detail.value)
29 | this.setData({
30 | chosen: ''
31 | })
32 | }
33 | })
34 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-form/wx-form.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | form
4 | 表单
5 |
6 |
39 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-form/wx-form.wxss:
--------------------------------------------------------------------------------
1 | wx-button {
2 | margin-top: 10px;
3 | margin-bottom: 10px;
4 | }
5 | wx-label {
6 | display: block;
7 | margin-top: 5px;
8 | }
9 | .picker-text {
10 | margin-left: 10px;
11 | position: relative;
12 | }
13 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-icon/wx-icon.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | iconSize: [20, 30, 40, 50, 60, 70],
4 | iconColor: [
5 | 'red', 'orange', 'yellow', 'green', 'rgb(0,255,255)', 'blue', 'purple'
6 | ],
7 | iconType: [
8 | 'success', 'info', 'warn', 'waiting', 'safe_success', 'safe_warn',
9 | 'success_circle', 'success_no_circle', 'waiting_circle', 'circle', 'download',
10 | 'info_circle', 'cancel', 'search', 'clear'
11 | ]
12 | }
13 | })
14 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-icon/wx-icon.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | icon
4 | icon图标
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-icon/wx-icon.wxss:
--------------------------------------------------------------------------------
1 | .group{
2 | flex-direction: row;
3 | align-items: center;
4 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-image/wx-image.js:
--------------------------------------------------------------------------------
1 | Page({
2 | imageError: function(e) {
3 | console.log('image3发生error事件,携带值为', e.detail.errMsg)
4 | }
5 | })
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-image/wx-image.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | image
4 | 图片
5 |
6 |
7 |
8 | local image
9 |
10 |
11 |
12 |
13 |
14 | internet image
15 |
16 |
18 |
19 |
20 |
21 | error image
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-image/wx-image.wxss:
--------------------------------------------------------------------------------
1 | .section__ctn{
2 | text-align: center;
3 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-input/wx-input.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | focus:false,
4 | inputValue:""
5 | },
6 | bindButtonTap:function(){
7 | this.setData({
8 | focus:true
9 | })
10 | },
11 | bindKeyInput:function(e){
12 | this.setData({
13 | inputValue:e.detail.value
14 | })
15 | },
16 | bindReplaceInput:function(e){
17 | var value = e.detail.value;
18 | var pos = e.detail.cursor;
19 | if(pos != -1){
20 | //光标在中间
21 | var left = e.detail.value.slice(0,pos);
22 | //计算光标的位置
23 | pos = left.replace(/11/g,'2').length;
24 | }
25 |
26 | //直接返回对象,可以对输入进行过滤处理,同时可以控制光标的位置
27 | return {
28 | value:value.replace(/11/g,'2'),
29 | cursor:pos
30 | }
31 |
32 | //或者直接返回字符串,光标在最后边
33 | //return value.replace(/11/g,'2'),
34 | },
35 | bindHideKeyboard:function(e){
36 | if(e.detail.value === "123"){
37 | //收起键盘
38 | wx.hideKeyboard();
39 | }
40 | }
41 | })
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-input/wx-input.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | input
4 | 输入框
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 你输入的是:{{inputValue}}
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-input/wx-input.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/component-pages/wx-input/wx-input.wxss
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-label/wx-label.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | checkboxItems: [
4 | {name: 'USA', value: '美国'},
5 | {name: 'CHN', value: '中国', checked: 'true'},
6 | {name: 'BRA', value: '巴西'},
7 | {name: 'JPN', value: '日本', checked: 'true'},
8 | {name: 'ENG', value: '英国'},
9 | {name: 'FRA', value: '法国'},
10 | ],
11 | radioItems: [
12 | {name: 'USA', value: '美国'},
13 | {name: 'CHN', value: '中国', checked: 'true'},
14 | {name: 'BRA', value: '巴西'},
15 | {name: 'JPN', value: '日本'},
16 | {name: 'ENG', value: '英国'},
17 | {name: 'FRA', value: '法国'},
18 | ],
19 | hidden: false
20 | },
21 | checkboxChange: function(e) {
22 | var checked = e.detail.value
23 | var changed = {}
24 | for (var i = 0; i < this.data.checkboxItems.length; i ++) {
25 | if (checked.indexOf(this.data.checkboxItems[i].name) !== -1) {
26 | changed['checkboxItems['+i+'].checked'] = true
27 | } else {
28 | changed['checkboxItems['+i+'].checked'] = false
29 | }
30 | }
31 | this.setData(changed)
32 | },
33 | radioChange: function(e) {
34 | var checked = e.detail.value
35 | var changed = {}
36 | for (var i = 0; i < this.data.radioItems.length; i ++) {
37 | if (checked.indexOf(this.data.radioItems[i].name) !== -1) {
38 | changed['radioItems['+i+'].checked'] = true
39 | } else {
40 | changed['radioItems['+i+'].checked'] = false
41 | }
42 | }
43 | this.setData(changed)
44 | },
45 | tapEvent: function(e) {
46 | console.log('按钮被点击')
47 | }
48 | })
49 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-label/wx-label.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | label
4 | 标签
5 |
6 |
7 |
8 | 表单组件在label内
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 | label用for标识表单组件
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | 绑定button
32 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | label内有多个时选中第一个
42 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-label/wx-label.wxss:
--------------------------------------------------------------------------------
1 | .label-1, .label-2{
2 | margin-bottom: 15px;
3 | }
4 |
5 | .label-4_text{
6 | text-align: center;
7 | margin-top: 15px;
8 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-mask/wx-mask.js:
--------------------------------------------------------------------------------
1 | var pageData = {}
2 | var maskNum = 4
3 | pageData.data = {}
4 | for(var i = 1; i <= maskNum; ++i) {
5 | pageData.data[`hidden${i}`] = true;
6 |
7 | (function(index) {
8 | pageData[`tap${index}`] = function(e) {
9 | var obj = {}
10 | obj[`hidden${index}`] = false
11 | this.setData(obj)
12 | }
13 | pageData[`mask${index}`] = function(e) {
14 | var obj = {}
15 | obj[`hidden${index}`] = true
16 | this.setData(obj)
17 | }
18 | })(i);
19 | }
20 | Page(pageData)
21 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-mask/wx-mask.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | mask
4 | 遮罩
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-modal/wx-modal.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | modalHidden: true,
4 | modalHidden2: true
5 | },
6 | modalTap: function(e) {
7 | this.setData({
8 | modalHidden: false
9 | })
10 | },
11 | modalChange: function(e) {
12 | this.setData({
13 | modalHidden: true
14 | })
15 | },
16 | modalTap2: function(e) {
17 | this.setData({
18 | modalHidden2: false
19 | })
20 | },
21 | modalChange2: function(e) {
22 | this.setData({
23 | modalHidden2: true
24 | })
25 | },
26 | })
27 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-modal/wx-modal.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | modal
4 | 模式对话框
5 |
6 |
7 |
8 | 这是对话框的内容。
9 |
10 |
11 |
12 | 没有标题没有取消的对话框
13 | 内容可以插入节点
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/navigate.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onLoad: function(options) {
3 | console.log(options)
4 | this.setData({
5 | title: options.title
6 | })
7 | }
8 | })
9 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/navigate.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{title}}
4 | 这是新建的页面,点击左上角返回回到之前页面
5 |
6 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/redirect.js:
--------------------------------------------------------------------------------
1 | Page({
2 | onLoad: function(options) {
3 | console.log(options)
4 | this.setData({
5 | title: options.title
6 | })
7 | }
8 | })
9 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/redirect.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{title}}
4 | 这是当前页,点击左上角返回回到上级菜单
5 |
6 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/wx-navigator.js:
--------------------------------------------------------------------------------
1 | Page({})
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/wx-navigator.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | navigator
4 | 导航栏
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-navigator/wx-navigator.wxss:
--------------------------------------------------------------------------------
1 | .navigator-hover button{
2 | background-color:blue;
3 | }
4 | .other-navigator-hover button{
5 | background-color:red;
6 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-picker/wx-picker.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | array:["中国","美国","巴西","日本"],
4 | index:0,
5 | date:"2016-09-01",
6 | time:"12:01"
7 | },
8 | bindPickerChange: function(e) {
9 | console.log('picker发送选择改变,携带值为', e.detail.value)
10 | this.setData({
11 | index: e.detail.value
12 | })
13 | },
14 | bindDateChange:function(e){
15 | this.setData({
16 | date:e.detail.value
17 | })
18 | },
19 | bindTimeChange:function(e){
20 | this.setData({
21 | time:e.detail.time
22 | })
23 | }
24 | })
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-picker/wx-picker.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | picker
4 | 选择器
5 |
6 |
7 |
8 | 地区选择器
9 |
10 |
11 | 当前选择:{{array[index]}}
12 |
13 |
14 |
15 |
16 | 时间选择器
17 |
18 |
19 | 当前选择: {{time}}
20 |
21 |
22 |
23 |
24 |
25 | 日期选择器
26 |
27 |
28 | 当前选择: {{date}}
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-picker/wx-picker.wxss:
--------------------------------------------------------------------------------
1 | .picker{
2 | padding: 13px;
3 | background-color: #FFFFFF;
4 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-progress/wx-progress.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-progress/wx-progress.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | progress
4 | 进度条
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-progress/wx-progress.wxss:
--------------------------------------------------------------------------------
1 | progress{
2 | margin-bottom: 30px;
3 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-radio/wx-radio.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | items: [
4 | {name: 'USA', value: '美国'},
5 | {name: 'CHN', value: '中国', checked: 'true'},
6 | {name: 'BRA', value: '巴西'},
7 | {name: 'JPN', value: '日本'},
8 | {name: 'ENG', value: '英国'},
9 | {name: 'FRA', value: '法国'},
10 | ]
11 | },
12 | radioChange: function(e) {
13 | console.log('radio发生change事件,携带value值为:', e.detail.value)
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-radio/wx-radio.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | radio
4 | 单选框
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-radio/wx-radio.wxss:
--------------------------------------------------------------------------------
1 | .radio {
2 | display: block;
3 | margin-bottom: 10px;
4 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-scroll-view/wx-scroll-view.js:
--------------------------------------------------------------------------------
1 | var order = ['green', 'red', 'yellow', 'blue', 'green']
2 | Page({
3 | data: {
4 | toView: "green"
5 | },
6 | upper: function(e) {
7 | console.log(e)
8 | },
9 | lower: function(e) {
10 | console.log(e)
11 | },
12 | scroll: function(e) {
13 | console.log(e)
14 | },
15 | scrollToTop: function(e) {
16 | this.setAction({
17 | scrollTop: 0
18 | })
19 | },
20 | tap: function(e) {
21 | for (var i = 0; i < order.length; ++i) {
22 | if (order[i] === this.data.toView) {
23 | this.setData({
24 | toView: order[i + 1],
25 | scrollTop: (i + 1) * 200
26 | })
27 | break
28 | }
29 | }
30 | },
31 | tapMove: function(e) {
32 | this.setData({
33 | scrollTop: this.data.scrollTop + 10
34 | })
35 | }
36 | })
37 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-scroll-view/wx-scroll-view.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | scroll-view
4 | 可滚动视图区域。
5 |
6 |
7 |
8 | vertical scroll
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | horizontal scroll
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-scroll-view/wx-scroll-view.wxss:
--------------------------------------------------------------------------------
1 | .scroll-view_H{
2 | white-space: nowrap;
3 | }
4 | .scroll-view-item{
5 | height: 200px;
6 | }
7 | .scroll-view-item_H{
8 | display: inline-block;
9 | width: 100%;
10 | height: 200px;
11 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-slide-tab/wx-slide-tab.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | texts: [
4 | '这是第1个tab\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n嘻嘻,到底了',
5 | '这是第2个tab\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n嘻嘻,到底了',
6 | '这是第3个tab\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n嘻嘻,到底了'
7 | ]
8 | },
9 | tabchange: function(e){
10 | console.log('现在跳转到了第 ' + e.detail.current + ' 个tab')
11 | }
12 | })
13 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-slide-tab/wx-slide-tab.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | slide-tab
4 | slide-tab
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{item}}
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-slide-tab/wx-slide-tab.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/component-pages/wx-slide-tab/wx-slide-tab.wxss
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-slider/wx-slider.js:
--------------------------------------------------------------------------------
1 | var pageData = {}
2 | for(var i = 1; i < 5; ++i) {
3 | (function (index) {
4 | pageData[`slider${index}change`] = function(e) {
5 | console.log(`slider${index}发生change事件,携带值为`, e.detail.value)
6 | }
7 | })(i);
8 | }
9 | Page(pageData)
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-slider/wx-slider.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | slider
4 | 滑块
5 |
6 |
7 |
8 | 设置step
9 |
10 |
11 |
12 |
13 |
14 |
15 | 显示当前value
16 |
17 |
18 |
19 |
20 |
21 |
22 | 设置最小/最大值
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-swiper/wx-swiper.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | background: ['green', 'red', 'yellow'],
4 | indicatorDots: true,
5 | vertical: false,
6 | autoplay: false,
7 | interval: 3000,
8 | duration: 1000
9 | },
10 | changeIndicatorDots: function (e) {
11 | this.setData({
12 | indicatorDots: !this.data.indicatorDots
13 | })
14 | },
15 | changeVertical: function (e) {
16 | this.setData({
17 | vertical: !this.data.vertical
18 | })
19 | },
20 | changeAutoplay: function (e) {
21 | this.setData({
22 | autoplay: !this.data.autoplay
23 | })
24 | },
25 | intervalChange: function (e) {
26 | this.setData({
27 | interval: e.detail.value
28 | })
29 | },
30 | durationChange: function (e) {
31 | this.setData({
32 | duration: e.detail.value
33 | })
34 | }
35 | })
36 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-swiper/wx-swiper.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | swiper
4 | swiper
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | duration
24 |
25 | interval
26 |
27 |
28 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-swiper/wx-swiper.wxss:
--------------------------------------------------------------------------------
1 | .swiper-item{
2 | display: block;
3 | height: 150px;
4 | }
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-switch/wx-switch.js:
--------------------------------------------------------------------------------
1 | var pageData = {
2 | data: {
3 | switch1Checked: true,
4 | switch2Checked: false,
5 | switch1Style: '',
6 | switch2Style: 'text-decoration: line-through'
7 | }
8 | }
9 | for(var i = 1; i <= 2; ++i) {
10 | (function(index) {
11 | pageData[`switch${index}Change`] = function(e) {
12 | console.log(`switch${index}发生change事件,携带值为`, e.detail.value)
13 | var obj = {}
14 | obj[`switch${index}Checked`] = e.detail.value
15 | this.setData(obj)
16 | obj = {}
17 | obj[`switch${index}Style`] = e.detail.value ? '' : 'text-decoration: line-through'
18 | this.setData(obj)
19 | }
20 | })(i)
21 | }
22 | Page(pageData)
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-switch/wx-switch.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | switch
4 | 开关
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-text/wx-text.js:
--------------------------------------------------------------------------------
1 | var initData = 'this is first line\nthis is second line'
2 | Page({
3 | data: {
4 | text: initData
5 | },
6 | extraLine: [],
7 | add: function(e) {
8 | this.extraLine.push('other line')
9 | this.setData({
10 | text: initData + '\n' + this.extraLine.join('\n')
11 | })
12 | },
13 | remove: function(e) {
14 | if (this.extraLine.length > 0) {
15 | this.extraLine.pop()
16 | this.setData({
17 | text: initData + '\n' + this.extraLine.join('\n')
18 | })
19 | }
20 | }
21 | })
22 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-text/wx-text.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | text
4 | 文字标签
5 |
6 |
7 |
8 | {{text}}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-toast/wx-toast.js:
--------------------------------------------------------------------------------
1 | var toastNum = 3
2 | var pageData = {}
3 | pageData.data = {}
4 | for(var i = 0; i <= toastNum; ++i) {
5 | pageData.data['toast'+i+'Hidden'] = true;
6 | (function (index) {
7 | pageData['toast'+index+'Change'] = function(e) {
8 | var obj = {}
9 | obj['toast'+index+'Hidden'] = true;
10 | this.setData(obj)
11 | }
12 | pageData['toast'+index+'Tap'] = function(e) {
13 | var obj = {}
14 | obj['toast'+index+'Hidden'] = false
15 | this.setData(obj)
16 | }
17 | })(i)
18 | }
19 | Page(pageData)
20 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-toast/wx-toast.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | toast
4 | toast提示
5 |
6 |
7 |
8 |
9 |
10 | 默认
11 |
12 |
13 |
14 |
15 |
16 | 设置icon
17 |
18 |
19 |
20 |
21 |
22 | 设置duration
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-video/wx-video.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | src:""
4 | },
5 | bindButtonTap:function(){
6 | var that = this;
7 | wx.chooseVideo({
8 | sourceType:['album','camera'],
9 | maxDuration:60,
10 | camera:['front','back'],
11 | success:function(res){
12 | that.setData({
13 | src:res.tempFilePath
14 | })
15 | }
16 | })
17 | },
18 | videoErrorCallback: function (e) {
19 | console.log('视频错误信息:');
20 | console.log(e.detail.errMsg);
21 | }
22 | })
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-video/wx-video.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | video
4 | 视频
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-view/wx-view.js:
--------------------------------------------------------------------------------
1 | Page({})
2 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-view/wx-view.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | view
4 | 弹性框模型分为弹性容器以及弹性项目。当组件的display为flex或inline-flex时,该组件则为弹性容器,弹性容器的子组件为弹性项目。
5 |
6 |
7 |
8 | flex-direction: row
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | flex-direction: column
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | justify-content: flex-start
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | justify-content: flex-end
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | justify-content: center
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | justify-content: space-between
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | justify-content: space-around
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | align-items: flex-end
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | align-items: center
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/pages/component/component-pages/wx-view/wx-view.wxss:
--------------------------------------------------------------------------------
1 | .flex-wrp{
2 | height: 100px;
3 | display:flex;
4 | background-color: #FFFFFF;
5 | }
6 | .flex-item{
7 | width: 100px;
8 | height: 100px;
9 | }
--------------------------------------------------------------------------------
/pages/component/index.js:
--------------------------------------------------------------------------------
1 | var pageData = {},
2 | type = [
3 | 'view', 'content', 'form', 'interact', 'nav', 'media', 'map', 'canvas'
4 | ];
5 |
6 | pageData.widgetsToggle = function (e) {
7 | var id = e.currentTarget.id, data = {};
8 | for (var i = 0, len = type.length; i < len; ++i) {
9 | data[type[i] + 'Show'] = false;
10 | }
11 | data[id + 'Show'] = !this.data[id + 'Show'];
12 | this.setData(data);
13 | };
14 |
15 | Page(pageData);
--------------------------------------------------------------------------------
/pages/component/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 小程序组件
4 | 这是展示小程序组件的DEMO。
5 |
6 |
7 |
8 |
9 |
10 |
11 | 内容分区
12 |
13 |
14 |
15 |
16 | view
17 |
18 |
19 |
20 |
21 | scroll-view
22 |
23 |
24 |
25 |
26 | swiper
27 |
28 |
29 |
30 |
31 |
32 |
33 | 内容
34 |
35 |
36 |
37 |
38 | text
39 |
40 |
41 |
42 |
43 | icon
44 |
45 |
46 |
47 |
48 | mask
49 |
50 |
51 |
52 |
53 | toast
54 |
55 |
56 |
57 |
58 | progress
59 |
60 |
61 |
62 |
63 |
64 |
65 | 表单组件
66 |
67 |
68 |
69 |
70 | button
71 |
72 |
73 |
74 |
75 | checkbox
76 |
77 |
78 |
79 |
80 | form
81 |
82 |
83 |
84 |
85 | input
86 |
87 |
88 |
89 |
90 | label
91 |
92 |
93 |
94 |
95 | picker
96 |
97 |
98 |
99 |
100 | radio
101 |
102 |
103 |
104 |
105 | slider
106 |
107 |
108 |
109 |
110 | switch
111 |
112 |
113 |
114 |
115 |
116 |
117 | 交互组件
118 |
119 |
120 |
121 |
122 | action-sheet
123 |
124 |
125 |
126 |
127 | modal
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | 导航
136 |
137 |
138 |
139 |
140 | navigator
141 |
142 |
143 |
144 |
145 |
146 |
147 | 媒体
148 |
149 |
150 |
151 |
152 |
153 | image
154 |
155 |
156 |
157 |
158 | audio
159 |
160 |
161 |
162 |
163 | video
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/pages/component/index.wxss:
--------------------------------------------------------------------------------
1 | .index{
2 | background-color: #FBF9FE;
3 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
4 | flex: 1;
5 | min-height: 100%;
6 | font-size: 16px;
7 | }
8 | .head{
9 | padding: 40px;
10 | }
11 | .body{
12 | padding-left: 15px;
13 | padding-right: 15px;
14 | overflow: hidden;
15 | }
16 | .title{
17 | font-size: 30px;
18 | }
19 | .desc{
20 | margin-top: 5px;
21 | color: #888888;
22 | font-size: 14px;
23 | }
24 |
25 | .widgets__item{
26 | margin-top: 10px;
27 | margin-bottom: 10px;
28 | background-color: #FFFFFF;
29 | overflow: hidden;
30 | border-radius: 2px;
31 | cursor: pointer;
32 | }
33 | .widgets__info{
34 | display: flex;
35 | padding: 20px;
36 | align-items: center;
37 | flex-direction: row;
38 | }
39 | .widgets__info_show{
40 | opacity: .4;
41 | }
42 | .widgets__info-name{
43 | flex: 1;
44 | }
45 | .widgets__info-img{
46 | width: 30px;
47 | height: 30px;
48 | }
49 |
50 | .widgets__list{
51 | display: none;
52 | }
53 | .widgets__list_show{
54 | display: block;
55 | }
56 | /*
57 | .widgets__list{
58 | height: 0;
59 | overflow: hidden;
60 | }
61 | .widgets__list_show{
62 | height: auto;
63 | }
64 | .widgets__list-inner{
65 | opacity: 0;
66 | transform: translateY(-50%);
67 | transition: .3s;
68 | }
69 | .widgets__list-inner_show{
70 | opacity: 1;
71 | transform: translateY(0);
72 | }
73 | */
74 |
75 | .widget{
76 | position: relative;
77 | padding-top: 13px;
78 | padding-bottom: 13px;
79 | padding-left: 20px;
80 | padding-right: 20px;
81 | }
82 | .widget__arrow{
83 | position: absolute;
84 | top: 14px;
85 | right: 22px;
86 | width: 8px;
87 | height: 16px;
88 | }
89 | .widget__line{
90 | content: " ";
91 | position: absolute;
92 | left: 20px;
93 | bottom: 0;
94 | right: 20px;
95 | height: 1rpx;
96 | background-color: #DFDFDF;
97 | }
--------------------------------------------------------------------------------
/pages/component/navigation-pages/controller/controller.js:
--------------------------------------------------------------------------------
1 | var components = [
2 | 'action-sheet', 'button', 'searchbar', 'modal', 'navigator', 'drawer'
3 | ]
4 | var pageData = {}
5 | for(var i = 0; i < components.length; ++i) {
6 | (function (index) {
7 | pageData[components[index]] = function(e) {
8 | var url = '../../component-pages/wx-' + components[index] + '/wx-' + components[index]
9 | wx.navigateTo({url: url})
10 | }
11 | })(i);
12 | }
13 | Page(pageData)
--------------------------------------------------------------------------------
/pages/component/navigation-pages/controller/controller.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/component/navigation-pages/form/form.js:
--------------------------------------------------------------------------------
1 | var components = [
2 | 'checkbox', 'radio', 'form','selector', 'switch', 'slider', 'input', 'label', 'picker'
3 | ]
4 | var pageData = {}
5 | for(var i = 0; i < components.length; ++i) {
6 | (function (index) {
7 | pageData[components[index]] = function(e) {
8 | var url = '../../component-pages/wx-' + components[index] + '/wx-' + components[index]
9 | wx.navigateTo({url: url})
10 | }
11 | })(i);
12 | }
13 | Page(pageData)
--------------------------------------------------------------------------------
/pages/component/navigation-pages/form/form.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/component/navigation-pages/media/media.js:
--------------------------------------------------------------------------------
1 | var components = [
2 | 'image', 'audio', 'video'
3 | ]
4 | var pageData = {}
5 | for(var i = 0; i < components.length; ++i) {
6 | (function (index) {
7 | pageData[components[index]] = function(e) {
8 | var url = '../../component-pages/wx-' + components[index] + '/wx-' + components[index]
9 | wx.navigateTo({url: url})
10 | }
11 | })(i)
12 | }
13 | Page(pageData)
--------------------------------------------------------------------------------
/pages/component/navigation-pages/media/media.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/pages/component/navigation-pages/view/view.js:
--------------------------------------------------------------------------------
1 | var components = [
2 | 'progress', 'toast', 'scroll-view', 'text', 'view', 'mask', 'icon', 'spinner', 'swiper', 'slide-tab'
3 | ]
4 | var pageData = {}
5 | for(var i = 0; i < components.length; ++i) {
6 | (function (index) {
7 | pageData[components[index]] = function(e) {
8 | var url = '../../component-pages/wx-' + components[index] + '/wx-' + components[index]
9 | wx.navigateTo({url: url})
10 | }
11 | })(i)
12 | }
13 | Page(pageData)
14 |
--------------------------------------------------------------------------------
/pages/component/navigation-pages/view/view.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/component/resources/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/arrow.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/canvas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/canvas.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/content.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/form.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/interact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/interact.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/map.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/media.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/media.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/nav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/nav.png
--------------------------------------------------------------------------------
/pages/component/resources/kind/view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/kind/view.png
--------------------------------------------------------------------------------
/pages/component/resources/pic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/component/resources/pic.jpg
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | var app = getApp()
4 | var SWIPER_INFO_URL = 'http://www.vrhouzi.com/api/v1/videos?num=6&offset='
5 | var VR_INFO_URL = 'http://www.vrhouzi.com/api/v1/videos?num=30&offset='
6 |
7 | Page({
8 | data: {
9 | background: ['green', 'red', 'yellow', 'black'],
10 | indicatorDots: true,
11 | vertical: false,
12 | autoplay: true,
13 | interval: 3000,
14 | duration: 500,
15 | toView: "green",
16 | vr_list: {},
17 | swiper_list:{}
18 | },
19 |
20 | //事件处理函数
21 | bindViewTap: function() {
22 | wx.navigateTo({
23 | url: '../logs/logs'
24 | })
25 | },
26 |
27 | get_vr_swiper_info: function() {
28 | console.log('get_vr_info')
29 | var swiper_offset = parseInt( 800 * Math.random() );
30 | var that = this
31 |
32 | wx.request({
33 | url: SWIPER_INFO_URL + swiper_offset,
34 | success: function(response) {
35 | that.setData({
36 | swiper_list: response.data.result
37 | })
38 | }
39 |
40 | });
41 | },
42 |
43 | get_vr_list_info: function() {
44 | console.log('get_vr_list_info')
45 | var vr_list_offset = parseInt( 600 * Math.random() );
46 | var that = this
47 | wx.request({
48 | url: VR_INFO_URL + vr_list_offset,
49 | success: function(response) {
50 | that.setData({
51 | vr_list: response.data.result
52 | })
53 | }
54 | });
55 |
56 | },
57 |
58 | save_info_list2storage: function() {
59 | var that = this
60 | console.log(this.data.vr_list)
61 | console.log(that.data.swiper_list)
62 | var handler = setInterval(function(){
63 | if (that.data.vr_list == null) return
64 |
65 | wx.setStorage({
66 | key:"vr_list",
67 | data:that.data.vr_list
68 | });
69 |
70 | wx.getStorage({
71 | key:'vr_list',
72 | success:function(res){
73 | console.log(res.data);
74 | console.log("!!!!!!!!!!!!")
75 | }
76 | });
77 |
78 |
79 | wx.setStorage({
80 | key:"swiper_list",
81 | data:that.data.swiper_list
82 | });
83 |
84 | wx.getStorage({
85 | key:'swiper_list',
86 | success:function(res){
87 | console.log(res.data);
88 | console.log("!!!!!!!!!!!!")
89 | }
90 | });
91 |
92 | clearInterval(handler)
93 |
94 | },500);
95 | },
96 |
97 | onLoad: function () {
98 | console.log('onLoad')
99 | var that = this
100 | //调用应用实例的方法获取全局数据
101 | app.getUserInfo(function(userInfo){
102 | //更新数据
103 | that.setData({
104 | userInfo:userInfo
105 | })
106 | that.update()
107 | })
108 | this.get_vr_swiper_info()
109 | this.get_vr_list_info()
110 | },
111 |
112 | onReady: function () {
113 |
114 | this.save_info_list2storage()
115 | },
116 |
117 | /* scroll view */
118 | upper: function(e) {
119 | console.log(e)
120 | },
121 | lower: function(e) {
122 | console.log(e)
123 | },
124 | scroll: function(e) {
125 | console.log(e)
126 | },
127 | scrollToTop: function(e) {
128 | this.setAction({
129 | scrollTop: 0
130 | })
131 | },
132 | tap: function(e) {
133 | for (var i = 0; i < order.length; ++i) {
134 | if (order[i] === this.data.toView) {
135 | this.setData({
136 | toView: order[i + 1],
137 | scrollTop: (i + 1) * 200
138 | })
139 | break
140 | }
141 | }
142 | },
143 | tapMove: function(e) {
144 | this.setData({
145 | scrollTop: this.data.scrollTop + 10
146 | })
147 | },
148 |
149 | widgetsToggle: function (e) {
150 | console.log("click!!");
151 | }
152 |
153 | })
154 |
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 | {{item.article.title}}
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | {{item.article.title}}
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .swiper-item{
3 | display: block;
4 | height: 100%;
5 | width: 100%;
6 | }
7 |
8 | .swiper_nav{
9 | height: 100%;
10 | width:100%;
11 | position: relative;
12 | top: -40px;
13 | }
14 |
15 | .swiper_img{
16 | height: 200px;
17 | width: 100%;
18 | }
19 | .swiper_txt{
20 | display: flex;
21 | justify-content:center;
22 | color:floralwhite;
23 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif Georgia;
24 | font-size: 18px;
25 | font-weight:bolder;
26 | position: relative;
27 | top: 200px;
28 | background-color:darkgray;
29 | background: rgba(0, 0, 0, 0.5);
30 | padding-bottom: 30px;
31 | }
32 | /*
33 | .page__bd{
34 | padding-top:5%;
35 | }
36 | */
37 | .scroll-view_H{
38 | white-space: nowrap;
39 | }
40 | .scroll-view-item{
41 | height: 100px;
42 | }
43 | .scroll-view-item_H{
44 | display: inline-block;
45 | width: 100%;
46 | height: 200px;
47 | }
48 |
49 | .widgets__item{
50 | margin-top: 10px;
51 | margin-bottom: 10px;
52 | background-color: #FFFFFF;
53 | overflow: hidden;
54 | border-radius: 2px;
55 | cursor: pointer;
56 | width: 100%;
57 | height: 100%;
58 | padding-bottom: 3%;
59 | }
60 | .widgets__info{
61 | display: flex;
62 | padding: 20px;
63 | align-items: center;
64 | flex-direction: row;
65 | }
66 | .widgets__info_show{
67 | opacity: .4;
68 | }
69 | .widgets__info-name{
70 | flex: 1;
71 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
72 | font-size: 16px;
73 | font-weight: bolder;
74 | }
75 | .widgets__info-icon{
76 | width: 30px;
77 | height: 30px;
78 | }
79 | .widgets__info-img{
80 | display: flex;
81 | justify-content:center;
82 | margin: 0 auto;
83 | width: 95%;
84 | height: 150px;
85 | }
86 | .widgets {
87 | position: relative;
88 | bottom: 25px;
89 | }
90 | .widgets__list{
91 | display: none;
92 | }
93 | .widgets__list_show{
94 | display: block;
95 | }
96 |
97 | .widget{
98 | position: relative;
99 | padding-top: 13px;
100 | padding-bottom: 13px;
101 | padding-left: 20px;
102 | padding-right: 20px;
103 | }
104 | .widget__arrow{
105 | position: absolute;
106 | top: 14px;
107 | right: 22px;
108 | width: 8px;
109 | height: 16px;
110 | }
111 | .widget__line{
112 | content: " ";
113 | position: absolute;
114 | left: 20px;
115 | bottom: 0;
116 | right: 20px;
117 | height: 1rpx;
118 | background-color: #DFDFDF;
119 | }
--------------------------------------------------------------------------------
/pages/index/resources/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/arrow.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/canvas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/canvas.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/content.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/form.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/interact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/interact.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/map.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/media.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/media.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/nav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/nav.png
--------------------------------------------------------------------------------
/pages/index/resources/kind/view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/kind/view.png
--------------------------------------------------------------------------------
/pages/index/resources/pic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesonHuang/WeApp-VR-Video/f47cc966c2f6bf517edc703c6a44237c380108b9/pages/index/resources/pic.jpg
--------------------------------------------------------------------------------
/pages/index/view/info-detail.js:
--------------------------------------------------------------------------------
1 |
2 | const app = getApp()
3 |
4 | const INFO_URL = "http://www.vrhouzi.com/api/v1/videos/"
5 |
6 | Page({
7 | onLoad: function(options) {
8 | console.log(options)
9 | this.setData({
10 | title: options.title,
11 | id:options.id,
12 | req_type:options.req_type,
13 | toast2Hidden: true
14 | })
15 | var that = this
16 | console.log(this.data.req_type)
17 |
18 | wx.request({
19 | url: INFO_URL + that.data.id,
20 | success: function(response) {
21 | console.log(response.data.result)
22 | that.setData({
23 | info_detail: response.data.result
24 | })
25 | }
26 | });
27 | },
28 | onReady: function() {
29 | wx.setNavigationBarTitle({title: this.data.title});
30 | },
31 |
32 | toast2Tap: function() {
33 | this.setData({
34 | toast2Hidden: false
35 | })
36 |
37 | },
38 |
39 | toast2Change: function() {
40 | this.setData({
41 | toast2Hidden: true
42 | })
43 | },
44 |
45 | widgetsToggle: function() {
46 | var that = this
47 | console.log("click!!" + that.data.info_detail.article.download)
48 | wx.downloadFile({
49 | url: that.data.info_detail.article.download,
50 | type: 'video',
51 | success:function(res){
52 | console.log("success");
53 | console.log(res.tempFilePath);
54 | },
55 | fail: function(res) {
56 | console.log("fail");
57 | console.log(res);
58 | }
59 | })
60 | }
61 |
62 | })
63 |
--------------------------------------------------------------------------------
/pages/index/view/info-detail.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 时长:{{info_detail.article.duration}}| 大小:{{info_detail.article.size}}| 标签:{{info_detail.article.tags}}
5 | 影片详情:
6 | {{info_detail.article.desc}}
7 |
8 | 下载成功
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pages/index/view/info-detail.wxss:
--------------------------------------------------------------------------------
1 | .navigator-hover button{
2 | background-color:blue;
3 | }
4 | .other-navigator-hover button{
5 | background-color:red;
6 | }
7 |
8 | .info-view {
9 |
10 | }
11 |
12 | .info-img {
13 | width:100%;
14 | height: 200px;
15 | }
16 | .info-tag{
17 | margin: 0 auto;
18 | display: flex;
19 | justify-content: center;
20 | font-size: 14px;
21 | color: #cccccc;
22 | }
23 | .info-detail-title {
24 | margin: 20px auto;
25 | display: block;
26 | font-size: 24px;
27 | font-weight: bolder;
28 | }
29 |
30 | .info-detail-con {
31 | display:block;
32 | color:#B5B5B5;
33 | margin-bottom:4%;
34 | }
35 |
--------------------------------------------------------------------------------
/pages/index/view/info-list.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | //http://www.vrhouzi.com/api/v1/videos?num=1
4 | var app = getApp()
5 | var VR_INFO_URL = 'http://www.vrhouzi.com/api/v1/videos?num=30&offset='
6 |
7 | Page({
8 | data: {
9 |
10 | },
11 |
12 | //事件处理函数
13 | bindViewTap: function() {
14 | wx.navigateTo({
15 | url: '../logs/logs'
16 | })
17 | },
18 |
19 | get_vr_list_info: function() {
20 | console.log('get_vr_list_info')
21 | var vr_list_offset = parseInt( 600 * Math.random() );
22 | var that = this
23 | wx.request({
24 | url: VR_INFO_URL + vr_list_offset,
25 |
26 | success: function(response) {
27 | console.log(response.data.result)
28 | that.setData({
29 | vr_list: response.data.result
30 | })
31 | console.log(that.data.vr_list)
32 | }
33 |
34 | });
35 | },
36 |
37 | onLoad: function () {
38 | console.log('onLoad')
39 | var that = this
40 | //调用应用实例的方法获取全局数据
41 | app.getUserInfo(function(userInfo){
42 | //更新数据
43 | that.setData({
44 | userInfo:userInfo
45 | })
46 | that.update()
47 | })
48 | this.get_vr_list_info()
49 | },
50 |
51 |
52 |
53 | widgetsToggle: function (e) {
54 | console.log("click!!");
55 | }
56 |
57 | })
58 |
--------------------------------------------------------------------------------
/pages/index/view/info-list.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{item.article.title}}
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/pages/index/view/info-list.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .swiper-item{
3 | display: block;
4 | height: 100%;
5 | width: 100%;
6 | }
7 |
8 | .swiper_nav{
9 | height: 100%;
10 | width:100%;
11 | position: relative;
12 | top: -40px;
13 | }
14 |
15 | .swiper_img{
16 | height: 200px;
17 | width: 100%;
18 | }
19 | .swiper_txt{
20 | display: flex;
21 | justify-content:center;
22 | color:floralwhite;
23 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif Georgia;
24 | font-size: 18px;
25 | font-weight:bolder;
26 | position: relative;
27 | top: 290px;
28 | background-color:darkgray;
29 | background: rgba(0, 0, 0, 0.5);
30 | padding-bottom: 30px;
31 | }
32 | /*
33 | .page__bd{
34 | padding-top:5%;
35 | }
36 | */
37 | .scroll-view_H{
38 | white-space: nowrap;
39 | }
40 | .scroll-view-item{
41 | height: 100px;
42 | }
43 | .scroll-view-item_H{
44 | display: inline-block;
45 | width: 100%;
46 | height: 200px;
47 | }
48 |
49 | .widgets__item{
50 | margin-top: 10px;
51 | margin-bottom: 10px;
52 | background-color: #FFFFFF;
53 | overflow: hidden;
54 | border-radius: 2px;
55 | cursor: pointer;
56 | width: 100%;
57 | height: 100%;
58 | padding-bottom: 3%;
59 | padding-top: 3%;
60 | }
61 | .widgets__info{
62 | display: flex;
63 | padding: 20px;
64 | align-items: center;
65 | flex-direction: row;
66 | }
67 | .widgets__info_show{
68 | opacity: .4;
69 | }
70 | .widgets__info-name{
71 | flex: 1;
72 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
73 | font-size: 16px;
74 | font-weight: bolder;
75 | margin-left: 2%;
76 | display: flex;
77 | justify-content: center;
78 | }
79 | .widgets__info-icon{
80 | width: 30px;
81 | height: 30px;
82 | }
83 | .widgets__info-img{
84 | display: flex;
85 | justify-content:center;
86 | margin: 0 auto;
87 | width: 95%;
88 | height: 150px;
89 | }
90 | .widgets__item_comment {
91 | width: 100%;
92 | height: 10px;
93 | }
94 | .widgets__comment_icon {
95 | float: right;
96 | width: 18px;
97 | height: 18px;
98 | position: relative;
99 | right: 5px;
100 | top: 10px;
101 | margin: 2%;
102 | }
103 |
104 | .widgets__list{
105 | display: none;
106 | }
107 | .widgets__list_show{
108 | display: block;
109 | }
110 |
111 | .widget{
112 | position: relative;
113 | padding-top: 13px;
114 | padding-bottom: 13px;
115 | padding-left: 20px;
116 | padding-right: 20px;
117 | }
118 | .widget__arrow{
119 | position: absolute;
120 | top: 14px;
121 | right: 22px;
122 | width: 8px;
123 | height: 16px;
124 | }
125 | .widget__line{
126 | content: " ";
127 | position: absolute;
128 | left: 20px;
129 | bottom: 0;
130 | right: 20px;
131 | height: 1rpx;
132 | background-color: #DFDFDF;
133 | }
--------------------------------------------------------------------------------
/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | var util = require('../../utils/util.js')
2 | Page({
3 | data: {
4 | logs: []
5 | },
6 | onLoad: function () {
7 | this.setData({
8 | logs: (wx.getStorageSync('logs') || []).map(function (log) {
9 | return util.formatTime(new Date(log))
10 | })
11 | })
12 | }
13 | })
14 |
--------------------------------------------------------------------------------
/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/pages/main/main.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | Page({
3 | data: {
4 | motto: 'Hello WeApp',
5 | userInfo: {}
6 | },
7 | onButtonTap: function() {
8 | wx.navigateTo({
9 | url: '../logs/logs'
10 | })
11 | },
12 | onLoad: function () {
13 | console.log('onLoad')
14 | var that = this
15 | //登录
16 | wx.login({
17 | success: function () {
18 | wx.getUserInfo({
19 | success: function (res) {
20 | that.setData({userInfo: res.userInfo})
21 | that.update()
22 | }
23 | })
24 | },
25 | fail: function (res) {
26 | console.log(res)
27 | }
28 | });
29 | }
30 | })
31 |
--------------------------------------------------------------------------------
/pages/main/main.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{userInfo.nickName}}
6 |
7 |
8 | {{motto}}
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/main/main.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 | .userinfo {
12 | display: flex;
13 | flex-direction: column;
14 | align-items: center;
15 | }
16 | .userinfo-avatar {
17 | width: 128rpx;
18 | height: 128rpx;
19 | margin: 20rpx;
20 | border-radius: 50%;
21 | }
22 | .userinfo-nickname {
23 | color: #aaa;
24 | }
25 |
--------------------------------------------------------------------------------
/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds();
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------