From 7fd8e0dd6c341759fcbb8ad62552328ac6c11509 Mon Sep 17 00:00:00 2001 From: sfmind Date: Sun, 10 Apr 2022 01:21:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2:=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=20=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=20?= =?UTF-8?q?=E7=99=BB=E5=BD=95=20=E6=B3=A8=E5=86=8C=E8=B4=A6=E5=8F=B7=20?= =?UTF-8?q?=E5=BF=98=E8=AE=B0=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81=202.?= =?UTF-8?q?=E5=BC=95=E5=85=A5vuex=20=E5=8A=A0=E5=85=A5http=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=B7=A5=E5=85=B7luch-request=E5=B9=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=AF=B7=E6=B1=82=E5=92=8C=E5=93=8D=E5=BA=94=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-app/.gitignore | 7 + yudao-ui-app/App.vue | 11 +- yudao-ui-app/app.scss | 52 +++ yudao-ui-app/common/api.js | 7 + yudao-ui-app/common/config.js | 3 + yudao-ui-app/common/mixin.js | 7 + yudao-ui-app/common/props.js | 2 + yudao-ui-app/index.html | 2 +- yudao-ui-app/main.js | 36 +- yudao-ui-app/pages.json | 29 +- .../pages/cart/{cart.nvue => cart.vue} | 0 .../category/{category.nvue => category.vue} | 0 yudao-ui-app/pages/forgot/forgot.vue | 182 ++++++++++ yudao-ui-app/pages/index/index.vue | 325 ++++++++++++++++++ yudao-ui-app/pages/login/login.vue | 149 ++++++++ .../{index/index.nvue => profile/profile.vue} | 3 +- yudao-ui-app/pages/register/register.vue | 144 ++++++++ yudao-ui-app/pages/user/user.nvue | 25 -- yudao-ui-app/pages/user/user.vue | 145 ++++++++ yudao-ui-app/store/index.js | 26 ++ .../u--text-price/u--text-price.vue | 59 ++++ yudao-ui-app/util/request/index.js | 13 + .../util/request/requestInterceptors.js | 14 + .../util/request/responseInterceptors.js | 17 + yudao-ui-app/vue.config.js | 10 + 25 files changed, 1212 insertions(+), 56 deletions(-) create mode 100644 yudao-ui-app/.gitignore create mode 100644 yudao-ui-app/app.scss create mode 100644 yudao-ui-app/common/api.js create mode 100644 yudao-ui-app/common/config.js create mode 100644 yudao-ui-app/common/mixin.js create mode 100644 yudao-ui-app/common/props.js rename yudao-ui-app/pages/cart/{cart.nvue => cart.vue} (100%) rename yudao-ui-app/pages/category/{category.nvue => category.vue} (100%) create mode 100644 yudao-ui-app/pages/forgot/forgot.vue create mode 100644 yudao-ui-app/pages/index/index.vue create mode 100644 yudao-ui-app/pages/login/login.vue rename yudao-ui-app/pages/{index/index.nvue => profile/profile.vue} (94%) create mode 100644 yudao-ui-app/pages/register/register.vue delete mode 100644 yudao-ui-app/pages/user/user.nvue create mode 100644 yudao-ui-app/pages/user/user.vue create mode 100644 yudao-ui-app/store/index.js create mode 100644 yudao-ui-app/uni_modules/uview-ui/components/u--text-price/u--text-price.vue create mode 100644 yudao-ui-app/util/request/index.js create mode 100644 yudao-ui-app/util/request/requestInterceptors.js create mode 100644 yudao-ui-app/util/request/responseInterceptors.js create mode 100644 yudao-ui-app/vue.config.js diff --git a/yudao-ui-app/.gitignore b/yudao-ui-app/.gitignore new file mode 100644 index 000000000..5823d4712 --- /dev/null +++ b/yudao-ui-app/.gitignore @@ -0,0 +1,7 @@ +/unpackage/dist/* +/unpackage/cache/* +/unpackage/release/* +/node_modules/* +/.idea/* +/.hbuilderx/ +/.vscode/ diff --git a/yudao-ui-app/App.vue b/yudao-ui-app/App.vue index cb4ef8126..35ba97f7f 100644 --- a/yudao-ui-app/App.vue +++ b/yudao-ui-app/App.vue @@ -15,11 +15,8 @@ diff --git a/yudao-ui-app/app.scss b/yudao-ui-app/app.scss new file mode 100644 index 000000000..954306e77 --- /dev/null +++ b/yudao-ui-app/app.scss @@ -0,0 +1,52 @@ +/* 页面公共scss */ +.container { + padding-top: var(--status-bar-height);//uni-app提供了状态栏高度的css变量--status-bar-height + background-color: $uni-bg-color; + box-sizing: border-box; + height: 100%; +} + +/* 布局间距 */ +.m-0-r { + margin: 0rpx; +} + +.mtb-0-r { + margin-top: 0rpx; + margin-bottom: 0rpx; +} + +.no-mlt { + margin-left: 0rpx; + margin-right: 0rpx; +} + +.mtb-30-r { + margin-top: 30rpx; + margin-bottom: 30rpx; +} + +.mlr-30-r { + margin-left: 30rpx; + margin-right: 30rpx; +} + +.mt-20-r {margin-top: 20rpx;} +.mt-30-r {margin-top: 30rpx;} +.mt-40-r {margin-top: 40rpx;} +.mt-50-r {margin-top: 50rpx;} + +.mb-20-r {margin-bottom: 20rpx;} +.mb-30-r {margin-bottom: 30rpx;} +.mb-40-r {margin-bottom: 40rpx;} +.mb-50-r {margin-bottom: 50rpx;} + +.ml-20-r {margin-left: 20rpx;} +.ml-30-r {margin-left: 30rpx;} +.ml-40-r {margin-left: 40rpx;} +.ml-50-r {margin-left: 50rpx;} + +.mr-20-r {margin-right: 20rpx;} +.mr-30-r {margin-right: 30rpx;} +.mr-40-r {margin-right: 40rpx;} +.mr-50-r {margin-right: 50rpx;} diff --git a/yudao-ui-app/common/api.js b/yudao-ui-app/common/api.js new file mode 100644 index 000000000..9c2e41e5e --- /dev/null +++ b/yudao-ui-app/common/api.js @@ -0,0 +1,7 @@ +const { http } = uni.$u + +/* index */ +// 获取滚动图数据 +export const getBannerData = params => http.get('/api/index', params) +// 获取滚动通知数据 +export const getNoticeData = params => http.get('/api/notice', params) diff --git a/yudao-ui-app/common/config.js b/yudao-ui-app/common/config.js new file mode 100644 index 000000000..ec3682f18 --- /dev/null +++ b/yudao-ui-app/common/config.js @@ -0,0 +1,3 @@ +module.exports = { + baseUrl: 'http://192.168.3.199:8086' +} diff --git a/yudao-ui-app/common/mixin.js b/yudao-ui-app/common/mixin.js new file mode 100644 index 000000000..b6a4eeee3 --- /dev/null +++ b/yudao-ui-app/common/mixin.js @@ -0,0 +1,7 @@ +export default { + data() { + return { + + } + } +} diff --git a/yudao-ui-app/common/props.js b/yudao-ui-app/common/props.js new file mode 100644 index 000000000..30f4924f4 --- /dev/null +++ b/yudao-ui-app/common/props.js @@ -0,0 +1,2 @@ +uni.$u.props.gap.bgColor = '#ffffff' +uni.$u.props.gap.height = '10' diff --git a/yudao-ui-app/index.html b/yudao-ui-app/index.html index c3ff205f6..03e5fc6e1 100644 --- a/yudao-ui-app/index.html +++ b/yudao-ui-app/index.html @@ -3,7 +3,7 @@ + + diff --git a/yudao-ui-app/pages/index/index.vue b/yudao-ui-app/pages/index/index.vue new file mode 100644 index 000000000..240603e00 --- /dev/null +++ b/yudao-ui-app/pages/index/index.vue @@ -0,0 +1,325 @@ + + + + + diff --git a/yudao-ui-app/pages/login/login.vue b/yudao-ui-app/pages/login/login.vue new file mode 100644 index 000000000..bbee7a876 --- /dev/null +++ b/yudao-ui-app/pages/login/login.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/yudao-ui-app/pages/index/index.nvue b/yudao-ui-app/pages/profile/profile.vue similarity index 94% rename from yudao-ui-app/pages/index/index.nvue rename to yudao-ui-app/pages/profile/profile.vue index d14e16907..f19c84d9e 100644 --- a/yudao-ui-app/pages/index/index.nvue +++ b/yudao-ui-app/pages/profile/profile.vue @@ -1,6 +1,6 @@ @@ -21,5 +21,4 @@ diff --git a/yudao-ui-app/pages/register/register.vue b/yudao-ui-app/pages/register/register.vue new file mode 100644 index 000000000..b82e4f8fc --- /dev/null +++ b/yudao-ui-app/pages/register/register.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/yudao-ui-app/pages/user/user.nvue b/yudao-ui-app/pages/user/user.nvue deleted file mode 100644 index d14e16907..000000000 --- a/yudao-ui-app/pages/user/user.nvue +++ /dev/null @@ -1,25 +0,0 @@ - - - - - diff --git a/yudao-ui-app/pages/user/user.vue b/yudao-ui-app/pages/user/user.vue new file mode 100644 index 000000000..6fc69669f --- /dev/null +++ b/yudao-ui-app/pages/user/user.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/yudao-ui-app/store/index.js b/yudao-ui-app/store/index.js new file mode 100644 index 000000000..f2d6d32d8 --- /dev/null +++ b/yudao-ui-app/store/index.js @@ -0,0 +1,26 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) // vue的插件机制 + +// Vuex.Store 构造器选项 +const store = new Vuex.Store({ + // 为了不和页面或组件的data中的造成混淆,state中的变量前面建议加上$符号 + state: { + // 用户信息 + $userInfo: { + id: '' + } + }, + mutations: { + + }, + actions: { + + }, + getters:{ + + } +}) + +export default store diff --git a/yudao-ui-app/uni_modules/uview-ui/components/u--text-price/u--text-price.vue b/yudao-ui-app/uni_modules/uview-ui/components/u--text-price/u--text-price.vue new file mode 100644 index 000000000..eb861ac72 --- /dev/null +++ b/yudao-ui-app/uni_modules/uview-ui/components/u--text-price/u--text-price.vue @@ -0,0 +1,59 @@ + + + + \ No newline at end of file diff --git a/yudao-ui-app/util/request/index.js b/yudao-ui-app/util/request/index.js new file mode 100644 index 000000000..6658821b6 --- /dev/null +++ b/yudao-ui-app/util/request/index.js @@ -0,0 +1,13 @@ +// 引入配置 +import config from '@/common/config' +// 初始化请求配置 +uni.$u.http.setConfig((defaultConfig) => { + /* defaultConfig 为默认全局配置 */ + defaultConfig.baseURL = config.baseUrl /* 根域名 */ + return defaultConfig +}) + +module.exports = (vm) => { + require('./requestInterceptors')(vm) + require('./responseInterceptors')(vm) +} diff --git a/yudao-ui-app/util/request/requestInterceptors.js b/yudao-ui-app/util/request/requestInterceptors.js new file mode 100644 index 000000000..e954479a4 --- /dev/null +++ b/yudao-ui-app/util/request/requestInterceptors.js @@ -0,0 +1,14 @@ +/** + * 请求拦截 + * @param {Object} http + */ +module.exports = (vm) => { + uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作 + // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{} + config.data = config.data || {} + // 可以在此通过vm引用vuex中的变量,具体值在vm.$store.state中 + // console.log(vm.$store.state); + return config + }, (config) => // 可使用async await 做异步操作 + Promise.reject(config)) +} diff --git a/yudao-ui-app/util/request/responseInterceptors.js b/yudao-ui-app/util/request/responseInterceptors.js new file mode 100644 index 000000000..0e437d78c --- /dev/null +++ b/yudao-ui-app/util/request/responseInterceptors.js @@ -0,0 +1,17 @@ +/** + * 响应拦截 + * @param {Object} http + */ +module.exports = (vm) => { + uni.$u.http.interceptors.response.use((res) => { + /* 对响应成功做点什么 可使用async await 做异步操作*/ + const data = res.data + /* + 可以根据业务情况做相应的处理 + */ + return res + }, (err) => { + /* 对响应错误做点什么 (statusCode !== 200)*/ + return Promise.reject(err) + }) +} \ No newline at end of file diff --git a/yudao-ui-app/vue.config.js b/yudao-ui-app/vue.config.js new file mode 100644 index 000000000..64a3fe5c1 --- /dev/null +++ b/yudao-ui-app/vue.config.js @@ -0,0 +1,10 @@ +module.exports = { + // 配置路径别名 + configureWebpack: { + devServer: { + // 调试时允许内网穿透,让外网的人访问到本地调试的H5页面 + disableHostCheck: true + } + } + // productionSourceMap: false, +}