├── .babelrc ├── .gitignore ├── LICENSE ├── README.md ├── app ├── app.js ├── components │ ├── search.vue │ └── weex-marquee.vue ├── mixins.js ├── native-router.js ├── pages │ ├── index.vue │ └── product │ │ ├── detail.vue │ │ └── list.vue ├── style │ └── main.css └── web-router.js ├── build ├── webpack.extend.config.js ├── webpack.native.config.js └── webpack.web.config.js ├── data ├── guess.json └── index.json ├── extend ├── README.md ├── components │ └── searchbox.vue ├── index.js └── modules │ └── nativeEvent.js ├── index.html └── package.json /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] , 3 | "plugins": [ 4 | ["transform-object-rest-spread", { "useBuiltIns": true }] 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by IDE 2 | .idea/ 3 | *.iml 4 | .DS_Store 5 | 6 | # Created by Builder 7 | dist 8 | 9 | # Node 10 | logs 11 | *.log 12 | npm-debug.log* 13 | node_modules 14 | .npm -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xiazhou-weex # 2 | a demo for weex project 3 | 4 | ## Install(安装) ## 5 | ```bash 6 | $ git clone https://github.com/dongnaebi/xiazhou-weex.git 7 | $ cd your path 8 | $ npm install 9 | ``` 10 | 11 | ## Build and Serve(构建并运行服务) ## 12 | ```bash 13 | $ npm run build 14 | $ npm run build:weex #extend 15 | $ npm run serve #localhost:8080 16 | ``` 17 | 18 | ## Preview(预览) ## 19 | 20 | #### preview in web(浏览器中) #### 21 | [http://xiazhou.me/example/xiazhou-weex/#/](http://xiazhou.me/example/xiazhou-weex/#/) 22 | 23 | #### preview in weex playground(playground中) #### 24 | ![http://xiazhou.me/example/xiazhou-weex/dist/index.js](http://xiazhou.me/example/xiazhou-weex/qrcode.png) 25 | 26 | ## Documentation(文档) ## 27 | [http://xiazhou.me/tags/3139533465.html](http://xiazhou.me/tags/3139533465.html) 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/2/7. 3 | */ 4 | import vueRouter from 'vue-router' 5 | 6 | Vue.use(vueRouter); 7 | 8 | import routes from './web-router' 9 | const router = new vueRouter({ 10 | //mode: 'hash', 11 | routes 12 | }); 13 | 14 | new Vue({ 15 | el:'#root', 16 | router 17 | }); 18 | -------------------------------------------------------------------------------- /app/components/search.vue: -------------------------------------------------------------------------------- 1 | 2 | 16 | 61 | -------------------------------------------------------------------------------- /app/components/weex-marquee.vue: -------------------------------------------------------------------------------- 1 | 5 | 12 | -------------------------------------------------------------------------------- /app/mixins.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/1/23. 3 | */ 4 | import weexVueRouter from 'weex-vue-router' 5 | import routes from './native-router'//web端的路由在web-router里定义,在app.js里引用 6 | Vue.use(weexVueRouter,{routes,weex}); 7 | 8 | export default { 9 | data() { 10 | return { 11 | rpx: 1, 12 | apiDomain:'', 13 | android:weex.config.env.platform.toLowerCase()=='android', 14 | ios:weex.config.env.platform.toLowerCase()=='ios', 15 | web:weex.config.env.platform.toLowerCase()=='web' 16 | } 17 | }, 18 | created() { 19 | let self=this; 20 | let env = weex.config.env; 21 | let rWidth=env.deviceWidth; 22 | env.deviceWidth > 828 && (rWidth = env.deviceWidth / 3 * 2); 23 | self.rpx = 750 / rWidth; 24 | //self.apiDomain='http://xiazhou.me/example/xiazhou-weex'; 25 | if(!self.web){ 26 | self.apiDomain='http://192.168.31.241:8080';//替换成你电脑的IP,并保证手机能访问到电脑(连同一个wifi就好啦) 27 | } 28 | }, 29 | methods: { 30 | request(opt) { 31 | const stream = weex.requireModule('stream'); 32 | const self = this; 33 | let defaultOption = { 34 | type: "get", 35 | url: "", 36 | data: {}, 37 | async: true, 38 | timeout: 20000, 39 | dataType: "json" 40 | }; 41 | let option = self.extendObject(defaultOption, opt); 42 | return new Promise((resolve, reject) => { 43 | stream.fetch({ 44 | method: option.type, 45 | url: self.apiDomain+option.url, 46 | type: option.dataType, 47 | //headers:{'content-type': 'application/json'}, 48 | body: option.data 49 | }, (response) => { 50 | if (response.ok) { 51 | resolve(response.data); 52 | } else { 53 | reject(response) 54 | } 55 | }, () => {}) 56 | }) 57 | }, 58 | jump(url) { 59 | /*链接有三种情况: 60 | * /product/20408.html 开发者定义跳转 61 | * http://xiazhou.me/#/product/20408.html?from=banner 运维添加的链接 62 | * http://xiazhou.me/blog/670.html?from=banner#tabs1 原生页面,一般native端都会做链接截取跳转对应页面 63 | * */ 64 | if (!url || (url.indexOf('http') != 0 && url.indexOf('/') != 0)) { 65 | console.warn(url + "为非法的链接"); 66 | return; 67 | } 68 | const self = this; 69 | //const nativeEvent = weex.requireModule('nativeEvent');//native端必须扩展这个模块才能正常运行 70 | let go = to => { 71 | self.$router.push(to); 72 | }; 73 | url.indexOf('/') == 0 && go(url); //开发者定义跳转 74 | url.indexOf('http') == 0 && url.indexOf('/#/') > 0 && go(url.substr(url.indexOf('#') + 1)); //运维添加的链接 75 | //url.indexOf('http') == 0 && url.indexOf('/#/') == -1 && nativeEvent.skip(url); //原生页面//native端必须扩展这个模块才能正常运行 76 | }, 77 | extendObject(p, c) {//依赖了babel-plugin-transform-object-rest-spread,其实可以用Object.assign()替代,但是这里要以p为准,p不存在则传入的c无效 78 | function isEmptyObject(e) { 79 | var t; 80 | for (t in e) 81 | return !1; 82 | return !0 83 | } 84 | var p = p || {}; 85 | var t = isEmptyObject(p) && c ? c : p; 86 | for (let i in p) { 87 | if (typeof p[i] === 'object' && p[i] != null) { 88 | t[i] = this.extendObject(p[i], c[i]); 89 | } else { 90 | for (var j in c) { 91 | i == j && (t[i] = c[j]); 92 | } 93 | } 94 | } 95 | return t; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/native-router.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zhouz on 2017/2/12. 3 | */ 4 | const basePath='http://192.168.31.241:8080/dist';//替换成你电脑的IP,并保证手机能访问到电脑(连同一个wifi就好啦) 5 | //const basePath='http://xiazhou.me/example/xiazhou-weex/dist'; 6 | export default [ 7 | {path:'/',component:basePath+'/index.js'}, 8 | {path:'/list/:id',component:basePath+'/product/list.js'}, 9 | {path:'/product/:id',component:basePath+'/product/detail.js'} 10 | ]; -------------------------------------------------------------------------------- /app/pages/index.vue: -------------------------------------------------------------------------------- 1 | 2 | 21 | 84 | -------------------------------------------------------------------------------- /app/pages/product/detail.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /app/pages/product/list.vue: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /app/style/main.css: -------------------------------------------------------------------------------- 1 | .black{ color: #333 } 2 | .black-bg { background-color: #333 } 3 | .grey-6 { color: #666 } 4 | .grey-6-bg { background-color: #666 } 5 | .grey-9 { color: #999 } 6 | .grey-9-bg { background-color: #999 } 7 | .grey-d { color: #ddd } 8 | .grey-d-bg { background-color: #ddd } 9 | .grey-f{ color: #f5f5f5 } 10 | .grey-f-bg { background-color: #f5f5f5 } 11 | .light { color: #fff } 12 | .light-bg { background-color: #fff } 13 | .red { color: #e12e2e } 14 | .red-bg { background-color: #e12e2e } 15 | .orange{ color: #f60 } 16 | .orange-bg { background-color: #f60 } 17 | .yellow { color: #fbcb30 } 18 | .yellow-bg { background-color: #fbcb30 } 19 | .green { color: #8fd14c } 20 | .green-bg { background-color: #8fd14c } 21 | .blue { color: #3caaff } 22 | .blue-bg { background-color: #3caaff } 23 | .pink { color: #fb5c9b } 24 | .pink-bg { background-color: #fb5c9b } 25 | .purple { color: #a776d9 } 26 | .purple-bg { background-color: #a776d9 } 27 | 28 | .font-36 { font-size: 36px } 29 | .font-32 { font-size: 32px } 30 | .font-30 { font-size: 30px } 31 | .font-28 { font-size: 28px } 32 | .font-26 { font-size: 26px } 33 | .font-24 { font-size: 24px } 34 | .font-22 { font-size: 22px } 35 | .font-20 { font-size: 20px } 36 | .text-center { text-align:center;} 37 | .normal { font-weight: normal } 38 | .bold { font-weight: bold } 39 | .ellipsis {lines:1; text-overflow: ellipsis;} 40 | 41 | .relative { position: relative } 42 | .absolute { position: absolute } 43 | .fixed { position: fixed } 44 | .sticky{ position: sticky} 45 | .margin { margin: 20px } 46 | .margin-top { margin-top: 20px } 47 | .margin-right { margin-right: 20px } 48 | .margin-bottom { margin-bottom: 20px } 49 | .margin-left { margin-left: 20px } 50 | .padding { padding: 20px } 51 | .padding-top { padding-top: 20px } 52 | .padding-right { padding-right: 20px } 53 | .padding-bottom { padding-bottom: 20px } 54 | .padding-left { padding-left: 20px } 55 | .border-top{border-top-width:1px;border-color:#dfdfdf} 56 | .border-bottom{border-bottom-width:1px;border-color:#dfdfdf} 57 | .border-left{border-left-width:1px;border-color:#dfdfdf} 58 | .border-right{border-right-width:1px;border-color:#dfdfdf} 59 | 60 | .row{flex-direction: row;} 61 | .col{flex-direction: column;} 62 | .flex-wrap{flex-wrap:wrap} 63 | /*主轴对齐方式*/ 64 | .justify-start{justify-content:flex-start;} 65 | .justify-end{justify-content:flex-end;} 66 | .justify-center {justify-content:center;} 67 | .justify-between {justify-content:space-between;} 68 | .justify-around {justify-content:space-around;} 69 | /*侧轴对齐方式*/ 70 | .align-start {align-items:flex-start;} 71 | .align-end {align-items:flex-end;} 72 | .align-center {align-items:center;} 73 | .align-baseline {align-items:baseline;} 74 | .align-stretch {align-items:stretch;} 75 | /*主轴换行时行在侧轴的对齐方式,必须定义flex-wrap为换行*/ 76 | .content-start {align-content:flex-start;} 77 | .content-end {align-content:flex-end;} 78 | .content-center {align-content:center;} 79 | .content-between {align-content:space-between;} 80 | .content-around {align-content:space-around;} 81 | .content-stretch {align-content:stretch;} 82 | /*允许子元素收缩*/ 83 | .child-grow { flex-grow: 1;}/*允许拉伸*/ 84 | .child-shrink {flex-shrink: 1;}/*允许收缩*/ 85 | .child-average {flex:1;}/*平均分布,兼容旧版必须给宽度*/ 86 | .child-first { order: 1;}/*排第一个*/ 87 | /*子元素在侧轴的对齐方式*/ 88 | .child-align-start {align-self:flex-start;} 89 | .child-align-end {align-self:flex-end;} 90 | .child-align-center {align-self:center;} 91 | .child-align-baseline {align-self:baseline;} 92 | .child-align-stretch {align-self:stretch;} 93 | 94 | .full-screen{position: absolute;top:0;right:0;bottom:0;left:0;width:750px;} 95 | -------------------------------------------------------------------------------- /app/web-router.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/2/8. 3 | */ 4 | 5 | import index from './pages/index.vue' 6 | import list from './pages/product/list.vue' 7 | const detail = resolve => require(['./pages/product/detail.vue'], resolve); 8 | 9 | const routes = [ 10 | { path: '/', component: index }, 11 | { path: '/list/:id', component: list }, 12 | { path: '/product/:id', component: detail } 13 | ]; 14 | export default routes -------------------------------------------------------------------------------- /build/webpack.extend.config.js: -------------------------------------------------------------------------------- 1 | require('webpack'); 2 | 3 | module.exports ={ 4 | entry: { 5 | 'weex':'./extend/index.js' 6 | }, 7 | output: { 8 | path: 'dist', 9 | filename:"[name].bundle.js" 10 | }, 11 | module: { 12 | loaders: [ 13 | { 14 | test: /\.js(\?[^?]+)?$/, 15 | loader: 'babel' 16 | }, { 17 | test: /\.vue(\?[^?]+)?$/, 18 | loaders: ['vue'] 19 | } 20 | ] 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /build/webpack.native.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/2/7. 3 | */ 4 | var webpack = require('webpack') 5 | var path = require('path'); 6 | var fs = require('fs'); 7 | 8 | var bannerPlugin = new webpack.BannerPlugin( 9 | '// { "framework": "Vue" }\n', 10 | { raw: true } 11 | ) 12 | 13 | var entry = {}; 14 | var outPath="dist"; 15 | 16 | function walk(root,dir) { 17 | var directory = path.join(__dirname, root, dir); 18 | fs.readdirSync(directory) 19 | .forEach(function (file) { 20 | var fullpath = path.join(directory, file); 21 | var stat = fs.statSync(fullpath); 22 | if (stat.isFile() && path.extname(fullpath) === '.vue') { 23 | //dir.substr(6)是在dist里去掉pages这层文件夹 24 | var name = path.join(outPath, dir.substr(6), path.basename(file, '.vue')); 25 | entry[name] = fullpath + '?entry=true' 26 | } else if (stat.isDirectory()) { 27 | var subdir = path.join(dir, file); 28 | walk(root,subdir) 29 | } 30 | }) 31 | } 32 | walk('../app','/pages'); 33 | module.exports = { 34 | entry:entry, 35 | output: { 36 | path: '', 37 | filename: '[name].js' 38 | }, 39 | node: { 40 | global: true 41 | }, 42 | module: { 43 | loaders: [ 44 | { 45 | test: /\.vue(\?[^?]+)?$/, 46 | loaders: ['weex'] 47 | }, 48 | { 49 | test:/\.js(\?[^?]+)?$/, 50 | loader: 'babel', 51 | } 52 | ] 53 | }, 54 | plugins: [bannerPlugin] 55 | }; -------------------------------------------------------------------------------- /build/webpack.web.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/2/7. 3 | */ 4 | var path = require('path'); 5 | var fs = require('fs'); 6 | 7 | module.exports = { 8 | entry: { 9 | 'app': path.resolve('app', 'app.js') 10 | }, 11 | output: { 12 | path: 'dist', 13 | filename: '[name].js', 14 | //publicPath: 'http://xiazhou.me/example/xiazhou-weex/dist/', 15 | publicPath: '/dist/', 16 | }, 17 | node: { 18 | global: true 19 | }, 20 | module: { 21 | loaders: [ 22 | { 23 | test: /\.vue(\?[^?]+)?$/, 24 | loaders: ['vue'] 25 | }, 26 | { 27 | test:/\.js(\?[^?]+)?$/, 28 | loader: 'babel', 29 | } 30 | ] 31 | } 32 | }; -------------------------------------------------------------------------------- /data/guess.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": 1, 3 | "msg": "", 4 | "data": [ 5 | {"name":"才猜猜啊次啊按时"}, 6 | {"name":"2222222222"}, 7 | {"name":"33333333333333"}, 8 | {"name":"44444444444444"} 9 | ] 10 | } -------------------------------------------------------------------------------- /data/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "status":1, 3 | "msg":"", 4 | "data":{ 5 | "hotSearch":"iPhone 7 plus", 6 | "cartCount":5, 7 | "banner": [ 8 | { 9 | "img": "https://m.360buyimg.com/mobilecms/s720x322_jfs/t4354/297/493834931/122954/880e0cfd/58b562a0N4ea3b277.jpg!q70.jpg", 10 | "link": "http://localhost:8080/#/list/1" 11 | }, 12 | { 13 | "img": "https://m.360buyimg.com/mobilecms/s720x322_jfs/t4366/295/783385718/45577/cf586a1a/58b9447aN2863a38b.jpg!q70.jpg", 14 | "link": "http://localhost:8080/#/list/2" 15 | }, 16 | { 17 | "img": "https://m.360buyimg.com/mobilecms/s720x322_jfs/t4216/187/637595821/61135/d315e23e/58b7badaN584fab4c.jpg!q70.jpg", 18 | "link": "http://localhost:8080/#/list/3" 19 | }, 20 | { 21 | "img": "https://img11.360buyimg.com/da/jfs/t2896/28/3840126831/67394/18252cff/5799810bN93e72158.jpg", 22 | "link": "http://localhost:8080/#/list/4" 23 | } 24 | ], 25 | "menu": { 26 | "bg": "", 27 | "item": [ 28 | { 29 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3664/66/52394080/14046/acfe1fa3/57fdae81Ne7ddbab9.png", 30 | "link": "http://localhost:8080/#/list/1?from=nav1", 31 | "text": "京东超市" 32 | }, 33 | { 34 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3286/167/1907269933/15789/da204cbe/57d53f16Nf3431cbd.png", 35 | "link": "http://localhost:8080/#/list/2?from=nav2#a", 36 | "text": "全球购" 37 | }, 38 | { 39 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3208/285/1806438443/12227/e35aa8d/57d5407cN0d6adf20.png", 40 | "link": "http://localhost:8080/#/list/3#bbb", 41 | "text": "服装城" 42 | }, 43 | { 44 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3187/207/2269822667/14681/29321e2c/57de58ecN0eede46f.png", 45 | "link": "http://localhost:8080/#/list/4?from=nav4&v=1", 46 | "text": "生鲜" 47 | }, 48 | { 49 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3136/365/2063682730/11309/c3ce0c78/57d9443eN68c52b40.png", 50 | "link": "http://localhost:8080/#/list/5", 51 | "text": "火车票" 52 | }, 53 | { 54 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t4105/300/1053186796/16252/41a7dc9/5865fff4Ne543a0fe.png", 55 | "link": "http://localhost:8080/#/product/4546?from=nav5", 56 | "text": "充值中心" 57 | }, 58 | { 59 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3424/278/301037516/11616/98748707/58096edbNcd05f66b.png", 60 | "link": "http://localhost:8080/#/product/4546", 61 | "text": "会赚钱" 62 | }, 63 | { 64 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t4300/339/400935198/15697/87158a44/58b40a24N54bf9d3a.png", 65 | "link": "http://localhost:8080/#/product/4546", 66 | "text": "领券" 67 | }, 68 | { 69 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3199/169/1818813995/12570/62402b0d/57d54364Needc47cd.png", 70 | "link": "http://localhost:8080/#/product/4546", 71 | "text": "物流查询" 72 | }, 73 | { 74 | "img": "https://m.360buyimg.com/mobilecms/s80x80_jfs/t3211/295/1824792746/12749/a74e2524/57d543ebN25337ef2.png", 75 | "link": "http://localhost:8080/#/product/4546", 76 | "text": "我的关注" 77 | } 78 | ] 79 | }, 80 | "news": [ 81 | { 82 | "id": 12416, 83 | "text": "女人节,服饰鞋包跨店铺3件8折!" 84 | }, 85 | { 86 | "id": 12416, 87 | "text": "泰格豪雅中超独家首发领券减四千" 88 | }, 89 | { 90 | "id": 12416, 91 | "text": "女人节,服饰鞋包跨店铺3件8折!" 92 | }, 93 | { 94 | "id": 12416, 95 | "text": "泰格豪雅中超独家首发领券减四千" 96 | } 97 | ], 98 | "tabBar":[ 99 | { 100 | "img":"//st.360buyimg.com/m/images/index/a-home.png", 101 | "selectImg": "//st.360buyimg.com/m/images/index/a-home.png", 102 | "text": "", 103 | "link": "" 104 | }, 105 | { 106 | "img":"//st.360buyimg.com/m/images/index/n-catergry.png", 107 | "selectImg": "//st.360buyimg.com/m/images/index/a-home.png", 108 | "text": "", 109 | "link": "" 110 | }, 111 | { 112 | "img":"//st.360buyimg.com/m/images/index/n-find.png", 113 | "selectImg": "//st.360buyimg.com/m/images/index/a-home.png", 114 | "text": "", 115 | "link": "" 116 | }, 117 | { 118 | "img":"//st.360buyimg.com/m/images/index/n-cart.png", 119 | "selectImg": "//st.360buyimg.com/m/images/index/a-home.png", 120 | "text": "", 121 | "link": "" 122 | }, 123 | { 124 | "img":"//st.360buyimg.com/m/images/index/n-me.png", 125 | "selectImg": "//st.360buyimg.com/m/images/index/a-home.png", 126 | "text": "", 127 | "link": "" 128 | } 129 | ] 130 | } 131 | } -------------------------------------------------------------------------------- /extend/README.md: -------------------------------------------------------------------------------- 1 | 该目录为web端扩展目录 2 | 3 | - 组件扩展用.vue文件,并在main.js里注册 4 | - module扩展用.js文件,并在main.js里注册 -------------------------------------------------------------------------------- /extend/components/searchbox.vue: -------------------------------------------------------------------------------- 1 | 4 | 9 | -------------------------------------------------------------------------------- /extend/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/1/19. 3 | */ 4 | import "weex-vue-render" 5 | import searchbox from './components/searchbox.vue' 6 | import nativeEvent from './modules/nativeEvent' 7 | 8 | Vue.component('searchbox', searchbox);//安装组件 9 | 10 | weex.registerModule('nativeEvent',nativeEvent);//安装模块 11 | 12 | -------------------------------------------------------------------------------- /extend/modules/nativeEvent.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ebi on 2017/1/19. 3 | */ 4 | const nativeEvent = { 5 | skip (url) { 6 | window.location.href=url; 7 | } 8 | }; 9 | export default nativeEvent -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | xiazhou-weex demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 |
22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xiazhou-weex", 3 | "version": "1.0.0", 4 | "description": "xiazhou.me weex教程demo", 5 | "main": "index.js", 6 | "scripts": { 7 | "build:weex": "webpack --config build/webpack.extend.config.js", 8 | "build:web": "webpack --config build/webpack.web.config.js", 9 | "build:native": "webpack --config build/webpack.native.config.js", 10 | "build": "npm run build:web&npm run build:native", 11 | "serve": "serve -p 8080", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "engines": { 15 | "node": ">=4.0" 16 | }, 17 | "keywords": [ 18 | "weex", 19 | "vue", 20 | "虾粥" 21 | ], 22 | "author": "贤子", 23 | "license": "ISC", 24 | "dependencies": { 25 | "vue": "^2.1.10", 26 | "vue-router": "^2.3.0", 27 | "weex-vue-render": "^0.2.0", 28 | "weex-vue-router": "^0.0.4" 29 | }, 30 | "devDependencies": { 31 | "babel-core": "^6.20.0", 32 | "babel-loader": "^6.2.9", 33 | "babel-plugin-transform-object-rest-spread": "^6.20.2", 34 | "babel-preset-es2015": "^6.18.0", 35 | "serve": "^1.4.0", 36 | "css-loader": "^0.26.1", 37 | "vue-loader": "^10.3.0", 38 | "webpack": "^1.14.0", 39 | "weex-loader": "^0.4.4" 40 | } 41 | } 42 | --------------------------------------------------------------------------------