From 72a29af788d858893434db34059d7091b534ce35 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Thu, 11 Jun 2020 09:34:23 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=95=86=E5=9F=8E=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/shop/recommend/index.vue | 101 +++++++++++++++++++ components/shop/seckill/index.vue | 71 ++++++++++++++ components/shop/seckill/item.vue | 63 ++++++++++++ components/shop/shop-item/index.vue | 29 ++++++ pages.json | 7 ++ pages/shop/index.vue | 146 ++++++++++++++++++++++++++++ 6 files changed, 417 insertions(+) create mode 100644 components/shop/recommend/index.vue create mode 100644 components/shop/seckill/index.vue create mode 100644 components/shop/seckill/item.vue create mode 100644 components/shop/shop-item/index.vue create mode 100644 pages/shop/index.vue diff --git a/components/shop/recommend/index.vue b/components/shop/recommend/index.vue new file mode 100644 index 0000000..4c38bbb --- /dev/null +++ b/components/shop/recommend/index.vue @@ -0,0 +1,101 @@ + + + \ No newline at end of file diff --git a/components/shop/seckill/index.vue b/components/shop/seckill/index.vue new file mode 100644 index 0000000..fdf87ac --- /dev/null +++ b/components/shop/seckill/index.vue @@ -0,0 +1,71 @@ + + + \ No newline at end of file diff --git a/components/shop/seckill/item.vue b/components/shop/seckill/item.vue new file mode 100644 index 0000000..f5af869 --- /dev/null +++ b/components/shop/seckill/item.vue @@ -0,0 +1,63 @@ + + + \ No newline at end of file diff --git a/components/shop/shop-item/index.vue b/components/shop/shop-item/index.vue new file mode 100644 index 0000000..899b3b8 --- /dev/null +++ b/components/shop/shop-item/index.vue @@ -0,0 +1,29 @@ + + + \ No newline at end of file diff --git a/pages.json b/pages.json index b05f907..07d58d8 100644 --- a/pages.json +++ b/pages.json @@ -545,6 +545,13 @@ "navigationBarTitleText": "首页", "navigationStyle": "custom" } + }, + { + "path": "pages/shop/index", + "style": { + "navigationBarTitleText": "首页", + "navigationStyle": "custom" + } } ], "tabBar": { diff --git a/pages/shop/index.vue b/pages/shop/index.vue new file mode 100644 index 0000000..e316bf2 --- /dev/null +++ b/pages/shop/index.vue @@ -0,0 +1,146 @@ + + + \ No newline at end of file From 16d586a50ba9e67d2c699fc409903124a2fbdf55 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Thu, 11 Jun 2020 09:42:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=A0=E9=99=A4tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pages.json b/pages.json index 240b4a8..d7768a6 100644 --- a/pages.json +++ b/pages.json @@ -676,35 +676,6 @@ } } ], - "tabBar": { - "color": "#999999", - "selectedColor": "#FF780F", - "backgroundColor": "#ffffff", - "fontSize": "12", - "iconWidth": "20", - "spacing": "7", - "list": [{ - "pagePath": "pages/index/index", - "iconPath": "static/image/home.png", - "selectedIconPath": "static/image/home2.png", - "text": "首页" - }, { - "pagePath": "pages/API/index", - "iconPath": "static/image/mall.png", - "selectedIconPath": "static/image/mall2.png", - "text": "商城" - }, { - "pagePath": "pages/API/index", - "iconPath": "static/image/message.png", - "selectedIconPath": "static/image/message2.png", - "text": "消息" - }, { - "pagePath": "pageE/mine/MineIndex", - "iconPath": "static/image/mine.png", - "selectedIconPath": "static/image/mine2.png", - "text": "我的" - }] - }, "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "uni-app", From 55238876a8f973c120bd96fc77c9299edbb3b9e7 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Thu, 11 Jun 2020 16:12:04 +0800 Subject: [PATCH 3/6] shop --- components/shop/group/index.vue | 66 ++++++++++++++++++++++++++ components/shop/group/item.vue | 47 +++++++++++++++++++ components/shop/list/index.vue | 15 ++++++ components/shop/youhq/index.vue | 72 ++++++++++++++++++++++++++++ components/shop/youhq/item.vue | 83 +++++++++++++++++++++++++++++++++ pages/shop/index.vue | 18 ++++++- 6 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 components/shop/group/index.vue create mode 100644 components/shop/group/item.vue create mode 100644 components/shop/list/index.vue create mode 100644 components/shop/youhq/index.vue create mode 100644 components/shop/youhq/item.vue diff --git a/components/shop/group/index.vue b/components/shop/group/index.vue new file mode 100644 index 0000000..bae48f7 --- /dev/null +++ b/components/shop/group/index.vue @@ -0,0 +1,66 @@ + + + \ No newline at end of file diff --git a/components/shop/group/item.vue b/components/shop/group/item.vue new file mode 100644 index 0000000..cac3f6e --- /dev/null +++ b/components/shop/group/item.vue @@ -0,0 +1,47 @@ + + + \ No newline at end of file diff --git a/components/shop/list/index.vue b/components/shop/list/index.vue new file mode 100644 index 0000000..a6a3aff --- /dev/null +++ b/components/shop/list/index.vue @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/components/shop/youhq/index.vue b/components/shop/youhq/index.vue new file mode 100644 index 0000000..ac25922 --- /dev/null +++ b/components/shop/youhq/index.vue @@ -0,0 +1,72 @@ + + + \ No newline at end of file diff --git a/components/shop/youhq/item.vue b/components/shop/youhq/item.vue new file mode 100644 index 0000000..f9a6923 --- /dev/null +++ b/components/shop/youhq/item.vue @@ -0,0 +1,83 @@ + + + \ No newline at end of file diff --git a/pages/shop/index.vue b/pages/shop/index.vue index e316bf2..f90124e 100644 --- a/pages/shop/index.vue +++ b/pages/shop/index.vue @@ -41,20 +41,27 @@ - + + + + \ No newline at end of file diff --git a/components/shop/list/item.vue b/components/shop/list/item.vue new file mode 100644 index 0000000..23be604 --- /dev/null +++ b/components/shop/list/item.vue @@ -0,0 +1,49 @@ + + + \ No newline at end of file diff --git a/pages/shop/index.vue b/pages/shop/index.vue index f90124e..e348895 100644 --- a/pages/shop/index.vue +++ b/pages/shop/index.vue @@ -45,6 +45,7 @@ + + \ No newline at end of file diff --git a/pageB/components/sdetails/tloos.vue b/pageB/components/sdetails/tloos.vue new file mode 100644 index 0000000..05ff9aa --- /dev/null +++ b/pageB/components/sdetails/tloos.vue @@ -0,0 +1,55 @@ + + + \ No newline at end of file diff --git a/pageB/components/sdetails/youhuiitem.vue b/pageB/components/sdetails/youhuiitem.vue new file mode 100644 index 0000000..9d12710 --- /dev/null +++ b/pageB/components/sdetails/youhuiitem.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/pageB/components/sdetails/youhuiquan.vue b/pageB/components/sdetails/youhuiquan.vue new file mode 100644 index 0000000..44ffe75 --- /dev/null +++ b/pageB/components/sdetails/youhuiquan.vue @@ -0,0 +1,27 @@ + + + \ No newline at end of file diff --git a/pageB/sdetails/index.vue b/pageB/sdetails/index.vue new file mode 100644 index 0000000..904587f --- /dev/null +++ b/pageB/sdetails/index.vue @@ -0,0 +1,113 @@ + + + \ No newline at end of file diff --git a/pages.json b/pages.json index d7768a6..c143e1e 100644 --- a/pages.json +++ b/pages.json @@ -56,6 +56,17 @@ } } }, + { + "path": "sdetails/index", + "style": { + "navigationBarTitleText": "商品详情", + "app-plus":{ + "titleNView":{ + "backgroundColor":"#ffffff" + } + } + } + }, { "path": "search/index", "style": { From 71cd101d97406efc3a5bcd29051b7cf365ad7f4b Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Mon, 15 Jun 2020 10:00:14 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/shop.js | 10 ++++++ common/api/user.js | 10 ++++++ common/http.api.js | 16 ++++++++++ common/http.interceptor.js | 62 ++++++++++++++++++++++++++++++++++++++ main.js | 7 +++++ pages/index/index.vue | 8 +++++ static/js/http.js | 1 + 7 files changed, 114 insertions(+) create mode 100644 common/api/shop.js create mode 100644 common/api/user.js create mode 100644 common/http.api.js create mode 100644 common/http.interceptor.js create mode 100644 static/js/http.js diff --git a/common/api/shop.js b/common/api/shop.js new file mode 100644 index 0000000..bc51f99 --- /dev/null +++ b/common/api/shop.js @@ -0,0 +1,10 @@ +export default { + init(vm){ + return { + postlogn({id,name}){ + return vm.$u.get('url',{id,name}); + } + } + } + +} \ No newline at end of file diff --git a/common/api/user.js b/common/api/user.js new file mode 100644 index 0000000..036d2e4 --- /dev/null +++ b/common/api/user.js @@ -0,0 +1,10 @@ +export default { + init(vm){ + return { + getlogn({id,name}){ + return vm.$u.get('popArticles'); + } + } + } + +} \ No newline at end of file diff --git a/common/http.api.js b/common/http.api.js new file mode 100644 index 0000000..0761798 --- /dev/null +++ b/common/http.api.js @@ -0,0 +1,16 @@ + +// 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分: +// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F +import shop from "./api/shop" +import user from "./api/user" + +const install = (Vue, vm) => { + let userapi = user.init(vm) + let shopapi = shop.init(vm) + // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 + vm.$u.api = {...userapi,...shopapi}; +} + +export default { + install +} diff --git a/common/http.interceptor.js b/common/http.interceptor.js new file mode 100644 index 0000000..45ec848 --- /dev/null +++ b/common/http.interceptor.js @@ -0,0 +1,62 @@ +const install = (Vue, vm) => { + // 此为自定义配置参数,具体参数见上方说明 + Vue.prototype.$u.http.setConfig({ + baseUrl: 'https://luyuan.tk/api', + loadingText: '努力加载中~', + loadingTime: 800 + // ...... + }); + + // 请求拦截,配置Token等参数 + Vue.prototype.$u.http.interceptor.request = (config) => { + // 引用token + // 方式一,存放在vuex的token,假设使用了uView封装的vuex方式 + // 见:https://uviewui.com/components/globalVariable.html + // config.header.token = vm.token; + + // 方式二,如果没有使用uView封装的vuex方法,那么需要使用$store.state获取 + // config.header.token = vm.$store.state.token; + + // 方式三,如果token放在了globalData,通过getApp().globalData获取 + // config.header.token = getApp().globalData.username; + + // 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的 + // 所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值 + // const token = uni.getStorageSync('token'); + // config.header.token = token; + // config.header.Token = 'xxxxxx'; + + // 可以对某个url进行特别处理,此url参数为this.$u.get(url)中的url值 + // if(config.url == '/user/login') config.header.noToken = true; + // 最后需要将config进行return + return config; + // 如果return一个false值,则会取消本次请求 + // if(config.url == '/user/rest') return false; // 取消某次请求 + } + + // // 响应拦截,判断状态码是否通过 + // Vue.prototype.$u.http.interceptor.response = (res) => { + // if(res.code == 200) { + // // res为服务端返回值,可能有code,result等字段 + // // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到 + // // 如果配置了originalData为true,请留意这里的返回值 + // return res.result; + // } else if(res.code == 201) { + // // 假设201为token失效,这里跳转登录 + // vm.$u.toast('验证失败,请重新登录'); + // setTimeout(() => { + // // 此为uView的方法,详见路由相关文档 + // vm.$u.route('/pages/user/login') + // }, 1500) + // return false; + // } else { + // // 如果返回false,则会调用Promise的reject回调, + // // 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中,res为服务端的返回值 + // return false; + // } + // } +} + +export default { + install +} diff --git a/main.js b/main.js index dc6b511..bce4f0b 100644 --- a/main.js +++ b/main.js @@ -8,4 +8,11 @@ App.mpType = 'app' const app = new Vue({ ...App }) +// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用 +import httpInterceptor from '@/common/http.interceptor.js' +Vue.use(httpInterceptor, app) + +// http接口API集中管理引入部分 +import httpApi from '@/common/http.api.js' +Vue.use(httpApi, app) app.$mount() diff --git a/pages/index/index.vue b/pages/index/index.vue index 764365a..00ccb41 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -196,6 +196,14 @@ export default { this.num = a } } + }, + onLoad(){ + this.$u.api.getlogn({ + id:1, + name:2 + }).then((res)=>{ + console.log(res) + }) } } \ No newline at end of file diff --git a/static/js/http.js b/static/js/http.js new file mode 100644 index 0000000..fa5bec7 --- /dev/null +++ b/static/js/http.js @@ -0,0 +1 @@ +let baseurl = "";