From 7fd8e0dd6c341759fcbb8ad62552328ac6c11509 Mon Sep 17 00:00:00 2001 From: sfmind Date: Sun, 10 Apr 2022 01:21:21 +0800 Subject: [PATCH] 1.静态页面: 首页 个人中心 登录 注册账号 忘记重置密码 2.引入vuex 加入http请求工具luch-request并设置请求和响应过滤器 --- 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 | 30 ++++++++++++++---------------- yudao-ui-app/pages.json | 29 +++++++++++++++++++++++++++-- yudao-ui-app/pages/cart/cart.nvue | 24 ------------------------ yudao-ui-app/pages/cart/cart.vue | 24 ++++++++++++++++++++++++ yudao-ui-app/pages/category/category.nvue | 24 ------------------------ yudao-ui-app/pages/category/category.vue | 24 ++++++++++++++++++++++++ yudao-ui-app/pages/forgot/forgot.vue | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-app/pages/index/index.nvue | 25 ------------------------- yudao-ui-app/pages/index/index.vue | 325 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-app/pages/login/login.vue | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-app/pages/profile/profile.vue | 24 ++++++++++++++++++++++++ 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 ++++++++++++++++++++++++++ yudao-ui-app/uni_modules/uview-ui/components/u--text-price/u--text-price.vue | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-app/util/request/index.js | 13 +++++++++++++ yudao-ui-app/util/request/requestInterceptors.js | 14 ++++++++++++++ yudao-ui-app/util/request/responseInterceptors.js | 17 +++++++++++++++++ yudao-ui-app/vue.config.js | 10 ++++++++++ 28 files changed, 1280 insertions(+), 124 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 delete mode 100644 yudao-ui-app/pages/cart/cart.nvue create mode 100644 yudao-ui-app/pages/cart/cart.vue delete mode 100644 yudao-ui-app/pages/category/category.nvue create mode 100644 yudao-ui-app/pages/category/category.vue create mode 100644 yudao-ui-app/pages/forgot/forgot.vue delete mode 100644 yudao-ui-app/pages/index/index.nvue create mode 100644 yudao-ui-app/pages/index/index.vue create mode 100644 yudao-ui-app/pages/login/login.vue create mode 100644 yudao-ui-app/pages/profile/profile.vue 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 0000000..5823d47 --- /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 cb4ef81..35ba97f 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 0000000..954306e --- /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 0000000..9c2e41e --- /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 0000000..ec3682f --- /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 0000000..b6a4eee --- /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 0000000..30f4924 --- /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 c3ff205..03e5fc6 100644 --- a/yudao-ui-app/index.html +++ b/yudao-ui-app/index.html @@ -3,7 +3,7 @@ - - diff --git a/yudao-ui-app/pages/cart/cart.vue b/yudao-ui-app/pages/cart/cart.vue new file mode 100644 index 0000000..793da35 --- /dev/null +++ b/yudao-ui-app/pages/cart/cart.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/yudao-ui-app/pages/category/category.nvue b/yudao-ui-app/pages/category/category.nvue deleted file mode 100644 index 793da35..0000000 --- a/yudao-ui-app/pages/category/category.nvue +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/yudao-ui-app/pages/category/category.vue b/yudao-ui-app/pages/category/category.vue new file mode 100644 index 0000000..793da35 --- /dev/null +++ b/yudao-ui-app/pages/category/category.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/yudao-ui-app/pages/forgot/forgot.vue b/yudao-ui-app/pages/forgot/forgot.vue new file mode 100644 index 0000000..d8c4154 --- /dev/null +++ b/yudao-ui-app/pages/forgot/forgot.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/yudao-ui-app/pages/index/index.nvue b/yudao-ui-app/pages/index/index.nvue deleted file mode 100644 index d14e169..0000000 --- a/yudao-ui-app/pages/index/index.nvue +++ /dev/null @@ -1,25 +0,0 @@ - - - - - diff --git a/yudao-ui-app/pages/index/index.vue b/yudao-ui-app/pages/index/index.vue new file mode 100644 index 0000000..240603e --- /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 0000000..bbee7a8 --- /dev/null +++ b/yudao-ui-app/pages/login/login.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/yudao-ui-app/pages/profile/profile.vue b/yudao-ui-app/pages/profile/profile.vue new file mode 100644 index 0000000..f19c84d --- /dev/null +++ b/yudao-ui-app/pages/profile/profile.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/yudao-ui-app/pages/register/register.vue b/yudao-ui-app/pages/register/register.vue new file mode 100644 index 0000000..b82e4f8 --- /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 d14e169..0000000 --- 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 0000000..6fc6966 --- /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 0000000..f2d6d32 --- /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 0000000..eb861ac --- /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 0000000..6658821 --- /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 0000000..e954479 --- /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 0000000..0e437d7 --- /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 0000000..64a3fe5 --- /dev/null +++ b/yudao-ui-app/vue.config.js @@ -0,0 +1,10 @@ +module.exports = { + // 配置路径别名 + configureWebpack: { + devServer: { + // 调试时允许内网穿透,让外网的人访问到本地调试的H5页面 + disableHostCheck: true + } + } + // productionSourceMap: false, +} -- libgit2 0.21.4