diff --git a/doc/mobmall.md b/doc/mobmall.md index f3f8462a..0f44e1e0 100644 --- a/doc/mobmall.md +++ b/doc/mobmall.md @@ -23,7 +23,7 @@ litemall轻商城,是商城移动版本。 可以阅读3.1 -## 3.2 litemall-vue +## 5.2 litemall-vue 这里的代码基于[vant--mobile-mall](https://github.com/qianzhaoy/vant--mobile-mall) diff --git a/doc/project.md b/doc/project.md index b350d60b..da480805 100644 --- a/doc/project.md +++ b/doc/project.md @@ -74,7 +74,7 @@ litemall是一个简单的商场系统,基于现有的开源项目,重新实 * 地址列表、地址添加、地址删除 * 收藏、足迹、关于 -### 1.2.1 轻商城功能 +### 1.2.2 轻商城功能 **目前还在开发中,不稳定** diff --git a/litemall-vue/package.json b/litemall-vue/package.json index 484356d5..372f0e39 100644 --- a/litemall-vue/package.json +++ b/litemall-vue/package.json @@ -23,6 +23,8 @@ "vant": "^1.4.4", "vee-validate": "^2.1.4", "vue": "^2.5.17", + "js-cookie": "2.2.0", + "vuex": "3.0.1", "vue-router": "^3.0.1", "vuelidation": "^1.1.0" }, diff --git a/litemall-vue/src/api/goods.js b/litemall-vue/src/api/goods.js index c5a78b2c..e8a7e02d 100755 --- a/litemall-vue/src/api/goods.js +++ b/litemall-vue/src/api/goods.js @@ -1,4 +1,4 @@ -import request from '@/core/utils/request' +import request from '@/utils/request' // export const GOODS_CATEGORY = '/category'; export const GOODS_CATEGORY = '/wx/catalog/index'; diff --git a/litemall-vue/src/api/user.js b/litemall-vue/src/api/user.js index e983956f..3e6bb073 100755 --- a/litemall-vue/src/api/user.js +++ b/litemall-vue/src/api/user.js @@ -1,18 +1,44 @@ -// 登录 -export const USER_LOGIN = '/wx/auth/login'; -export const USER_LOGOUT = ''; - -// 用户信息 -export const USER_PROFILE = '/user-profile'; -export const USER_MODIFY_PASSWORD = ''; -export const USER_CHANGE_MOBILE = ''; - -// 验证码 -export const USER_SENDCODE = ''; - -// 地址 -export const ADDRESS = '/address'; -export const ADDRESS_DEFAULT = '/address-default'; - -// 收藏 -export const GOODS_COLLECT_LIST = '/moreGoods'; +// 登录 +export const USER_LOGIN = '/wx/auth/login'; +export const USER_LOGOUT = ''; + +// 用户信息 +export const USER_PROFILE = '/user-profile'; +export const USER_MODIFY_PASSWORD = ''; +export const USER_CHANGE_MOBILE = ''; + +// 验证码 +export const USER_SENDCODE = ''; + +// 地址 +export const ADDRESS = '/address'; +export const ADDRESS_DEFAULT = '/address-default'; + +// 收藏 +export const GOODS_COLLECT_LIST = '/moreGoods'; + +import request from '@/utils/request' + +export function loginByUsername(data) { + return request({ + url: '/wx/auth/login', + method: 'post', + data + }) +} + + +export function logout() { + return request({ + url: '/auth/logout', + method: 'post' + }) +} + +export function getUserInfo(token) { + return request({ + url: '/auth/info', + method: 'get', + params: { token } + }) +} \ No newline at end of file diff --git a/litemall-vue/src/assets/images/id_card_front.png b/litemall-vue/src/assets/images/id_card_front.png deleted file mode 100755 index 29fb37a3..00000000 Binary files a/litemall-vue/src/assets/images/id_card_front.png and /dev/null differ diff --git a/litemall-vue/src/assets/images/id_card_reverse.png b/litemall-vue/src/assets/images/id_card_reverse.png deleted file mode 100755 index 99a763ae..00000000 Binary files a/litemall-vue/src/assets/images/id_card_reverse.png and /dev/null differ diff --git a/litemall-vue/src/vue/components/Tabbar/index.vue b/litemall-vue/src/components/Tabbar/index.vue old mode 100755 new mode 100644 similarity index 94% rename from litemall-vue/src/vue/components/Tabbar/index.vue rename to litemall-vue/src/components/Tabbar/index.vue index 1b5fa45d..45c54343 --- a/litemall-vue/src/vue/components/Tabbar/index.vue +++ b/litemall-vue/src/components/Tabbar/index.vue @@ -1,88 +1,88 @@ - - - - {{tab.name}} - - - - - - + + + + {{tab.name}} + + + + + + diff --git a/litemall-vue/src/vue/components/_directive/scrollMore.js b/litemall-vue/src/components/_directive/scrollMore.js old mode 100755 new mode 100644 similarity index 94% rename from litemall-vue/src/vue/components/_directive/scrollMore.js rename to litemall-vue/src/components/_directive/scrollMore.js index 9571f9ca..a7ad5d63 --- a/litemall-vue/src/vue/components/_directive/scrollMore.js +++ b/litemall-vue/src/components/_directive/scrollMore.js @@ -1,113 +1,113 @@ -import { debounce } from 'lodash'; -import scroll from 'core/utils/scroll'; - -const CONTEXT = '$scrollArrow'; -const OFFSET = 30; - -// 绑定事件 -function startBind(el) { - const context = el[CONTEXT]; - - context.vm.$nextTick(() => { - if (scroll.isAttached(el)) { - doBindEvent.call(el[CONTEXT]); - } - }); -} - -// 绑定事件到元素上 -// 读取基本的控制变量 -function doBindEvent() { - if (this.el[CONTEXT].binded) { - return; - } - this.el[CONTEXT].binded = true; - - this.scrollEventListener = debounce(handleScrollEvent.bind(this), 100); - // this.scrollEventTarget = this.el; - - // var disabledExpr = this.el.getAttribute('waterfall-disabled'); - // var disabled = false; - // if (disabledExpr) { - // this.vm.$watch(disabledExpr, (value) => { - // this.disabled = value; - // this.scrollEventListener(); - // }); - // disabled = Boolean(this.vm[disabledExpr]); - // } - // this.disabled = disabled; - - const offset = this.el.getAttribute('scroll-offset'); - this.offset = Number(offset) || OFFSET; - this.el.addEventListener('scroll', this.scrollEventListener); - - // this.scrollEventListener(); -} - -// 处理滚动函数 -function handleScrollEvent() { - const element = this.el; - // 已被禁止的滚动处理 - // if (this.disabled) return; - - const targetScrollLeft = scroll.getScrollLeft(element); - const targetVisibleWidth = scroll.getVisibleWidth(element); - // 滚动元素可视区域下边沿到滚动元素元素最顶上 距离 - const targetRight = targetScrollLeft + targetVisibleWidth; - // 如果无元素高度,考虑为元素隐藏,直接返回 - if (!targetVisibleWidth) return; - - // 判断是否到了最右边 - const isRightOver = element.scrollWidth - targetRight < this.offset; - - // 判断是否到了最左边 - const isLeftOver = targetScrollLeft < this.offset; - - this.cb && - this.cb({ - target: element, - isRightOver, - isLeftOver - }); - - // // 判断是否到了顶 - // let needLoadMoreToUpper = targetScrollTop < this.offset; - // if (needLoadMoreToUpper) { - // this.cb.upper && this.cb.upper({ - // target: scrollEventTarget, - // top: targetScrollTop - // }); - // } -} - -// 确认何时绑事件监听函数 -function doCheckStartBind(el) { - const context = el[CONTEXT]; - - if (context.vm._isMounted) { - startBind(el); - } else { - context.vm.$on('hook:mounted', () => { - startBind(el); - }); - } -} - -export default { - bind(el, binding, vnode) { - if (!el[CONTEXT]) { - el[CONTEXT] = { - el, - vm: vnode.context, - cb: {} - }; - } - el[CONTEXT].cb = binding.value; - - doCheckStartBind(el); - }, - update(el) { - const context = el[CONTEXT]; - context.scrollEventListener && context.scrollEventListener(); - } -}; +import { debounce } from 'lodash'; +import scroll from '@/utils/scroll'; + +const CONTEXT = '$scrollArrow'; +const OFFSET = 30; + +// 绑定事件 +function startBind(el) { + const context = el[CONTEXT]; + + context.vm.$nextTick(() => { + if (scroll.isAttached(el)) { + doBindEvent.call(el[CONTEXT]); + } + }); +} + +// 绑定事件到元素上 +// 读取基本的控制变量 +function doBindEvent() { + if (this.el[CONTEXT].binded) { + return; + } + this.el[CONTEXT].binded = true; + + this.scrollEventListener = debounce(handleScrollEvent.bind(this), 100); + // this.scrollEventTarget = this.el; + + // var disabledExpr = this.el.getAttribute('waterfall-disabled'); + // var disabled = false; + // if (disabledExpr) { + // this.vm.$watch(disabledExpr, (value) => { + // this.disabled = value; + // this.scrollEventListener(); + // }); + // disabled = Boolean(this.vm[disabledExpr]); + // } + // this.disabled = disabled; + + const offset = this.el.getAttribute('scroll-offset'); + this.offset = Number(offset) || OFFSET; + this.el.addEventListener('scroll', this.scrollEventListener); + + // this.scrollEventListener(); +} + +// 处理滚动函数 +function handleScrollEvent() { + const element = this.el; + // 已被禁止的滚动处理 + // if (this.disabled) return; + + const targetScrollLeft = scroll.getScrollLeft(element); + const targetVisibleWidth = scroll.getVisibleWidth(element); + // 滚动元素可视区域下边沿到滚动元素元素最顶上 距离 + const targetRight = targetScrollLeft + targetVisibleWidth; + // 如果无元素高度,考虑为元素隐藏,直接返回 + if (!targetVisibleWidth) return; + + // 判断是否到了最右边 + const isRightOver = element.scrollWidth - targetRight < this.offset; + + // 判断是否到了最左边 + const isLeftOver = targetScrollLeft < this.offset; + + this.cb && + this.cb({ + target: element, + isRightOver, + isLeftOver + }); + + // // 判断是否到了顶 + // let needLoadMoreToUpper = targetScrollTop < this.offset; + // if (needLoadMoreToUpper) { + // this.cb.upper && this.cb.upper({ + // target: scrollEventTarget, + // top: targetScrollTop + // }); + // } +} + +// 确认何时绑事件监听函数 +function doCheckStartBind(el) { + const context = el[CONTEXT]; + + if (context.vm._isMounted) { + startBind(el); + } else { + context.vm.$on('hook:mounted', () => { + startBind(el); + }); + } +} + +export default { + bind(el, binding, vnode) { + if (!el[CONTEXT]) { + el[CONTEXT] = { + el, + vm: vnode.context, + cb: {} + }; + } + el[CONTEXT].cb = binding.value; + + doCheckStartBind(el); + }, + update(el) { + const context = el[CONTEXT]; + context.scrollEventListener && context.scrollEventListener(); + } +}; diff --git a/litemall-vue/src/vue/components/field-group/index.vue b/litemall-vue/src/components/field-group/index.vue old mode 100755 new mode 100644 similarity index 92% rename from litemall-vue/src/vue/components/field-group/index.vue rename to litemall-vue/src/components/field-group/index.vue index 0e8e8e1f..7cdad5b5 --- a/litemall-vue/src/vue/components/field-group/index.vue +++ b/litemall-vue/src/components/field-group/index.vue @@ -1,26 +1,26 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/litemall-vue/src/vue/components/field/index.vue b/litemall-vue/src/components/field/index.vue old mode 100755 new mode 100644 similarity index 94% rename from litemall-vue/src/vue/components/field/index.vue rename to litemall-vue/src/components/field/index.vue index e7e9a114..8cb3de15 --- a/litemall-vue/src/vue/components/field/index.vue +++ b/litemall-vue/src/components/field/index.vue @@ -1,104 +1,104 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/litemall-vue/src/vue/components/infinity-scroll/index.vue b/litemall-vue/src/components/infinity-scroll/index.vue similarity index 95% rename from litemall-vue/src/vue/components/infinity-scroll/index.vue rename to litemall-vue/src/components/infinity-scroll/index.vue index a1f1f6b2..7ad9beb7 100644 --- a/litemall-vue/src/vue/components/infinity-scroll/index.vue +++ b/litemall-vue/src/components/infinity-scroll/index.vue @@ -17,8 +17,8 @@ - - - + + + + + + + + + + + + + + + + {{iconJson.name}} + + + + + + + + + ¥ + {{coupon.discount}} 元 + + {{coupon.desc }} - {{coupon.tag}} + + + {{coupon.name}} + 有效期:{{coupon.days}} 天 + + + + + + + + + + + + + + + + + + + + + + {{newGood.name}} + ¥ {{newGood.retailPrice}} + + + + + + + + + + + + + + + + + + diff --git a/litemall-vue/src/views/items/list/index.vue b/litemall-vue/src/views/items/list/index.vue index 5c06240f..5979431c 100755 --- a/litemall-vue/src/views/items/list/index.vue +++ b/litemall-vue/src/views/items/list/index.vue @@ -63,11 +63,11 @@ - - - + + + + + + + + + 抱歉,店主还未上架商品 + + + + + + + diff --git a/litemall-vue/src/views/login/forget-reset/index.vue b/litemall-vue/src/views/login/forget-reset/index.vue index 77c9d457..b66cd4ba 100755 --- a/litemall-vue/src/views/login/forget-reset/index.vue +++ b/litemall-vue/src/views/login/forget-reset/index.vue @@ -1,57 +1,57 @@ - - - - - - 两次密码输入不一致 - - - 重置 - - - - - - - + + + + + + 两次密码输入不一致 + + + 重置 + + + + + + + diff --git a/litemall-vue/src/views/login/forget/index.vue b/litemall-vue/src/views/login/forget/index.vue index 6903d354..5c6acd0d 100755 --- a/litemall-vue/src/views/login/forget/index.vue +++ b/litemall-vue/src/views/login/forget/index.vue @@ -1,80 +1,80 @@ - - - - - - - - {{ +props.seconds || 60 }}秒后获取 - - 获取验证码 - - - - - 下一步 - - - - - - - + + + + + + + + {{ +props.seconds || 60 }}秒后获取 + + 获取验证码 + + + + + 下一步 + + + + + + + diff --git a/litemall-vue/src/views/login/login.vue b/litemall-vue/src/views/login/login.vue index 05a0e405..5ba0e8e6 100755 --- a/litemall-vue/src/views/login/login.vue +++ b/litemall-vue/src/views/login/login.vue @@ -50,12 +50,12 @@ - - + + + 我们将发送验证码到您的手机 + + + + 下一步 + + + + + + + + + diff --git a/litemall-vue/src/views/login/register-submit/index.vue b/litemall-vue/src/views/login/register-submit/index.vue index 217ef971..f01cef57 100755 --- a/litemall-vue/src/views/login/register-submit/index.vue +++ b/litemall-vue/src/views/login/register-submit/index.vue @@ -1,78 +1,78 @@ - - - - - - {{ +props.seconds || 60 }}秒后获取 - - 获取验证码 - - - - - - - 确定 - - - - - - - - + + + + + + {{ +props.seconds || 60 }}秒后获取 + + 获取验证码 + + + + + + + 确定 + + + + + + + + diff --git a/litemall-vue/src/views/order/tabbar-cart.vue b/litemall-vue/src/views/order/tabbar-cart.vue index 4be7adca..bffb17d3 100755 --- a/litemall-vue/src/views/order/tabbar-cart.vue +++ b/litemall-vue/src/views/order/tabbar-cart.vue @@ -1,311 +1,311 @@ - - - - - {{isEditor ? '完成' : '编辑'}} - - - - - - - - - - {{item.goodsName}} - - {{item.price * 100 | yuan}} - - - - - 添加日期 {{item.addTime}} - - - 删除 - - - - - 清除失效商品 - - - 您的购物车空空如也~ - - - 全选 - - - - - - - - + + + + + {{isEditor ? '完成' : '编辑'}} + + + + + + + + + + {{item.goodsName}} + + {{item.price * 100 | yuan}} + + + + + 添加日期 {{item.addTime}} + + + 删除 + + + + + 清除失效商品 + + + 您的购物车空空如也~ + + + 全选 + + + + + + + + diff --git a/litemall-vue/src/views/user/module-collect/index.vue b/litemall-vue/src/views/user/module-collect/index.vue index 3a81eb57..e3093908 100644 --- a/litemall-vue/src/views/user/module-collect/index.vue +++ b/litemall-vue/src/views/user/module-collect/index.vue @@ -40,13 +40,13 @@ - - + + + + + + + + + 合计: {{el.total_fee | yuan}}(含运费{{el.post_fee | yuan}}) + + + + + + + + + + + + diff --git a/litemall-vue/src/views/user/order-entity-list/index.vue b/litemall-vue/src/views/user/order-entity-list/index.vue index 209b5fca..02872b97 100644 --- a/litemall-vue/src/views/user/order-entity-list/index.vue +++ b/litemall-vue/src/views/user/order-entity-list/index.vue @@ -1,243 +1,243 @@ - - - - - - - - - 合计: {{el.actualPrice * 100 | yuan}}(含运费{{el.post_fee | yuan}}) - - - - - - - - - - - - + + + + + + + + + 合计: {{el.actualPrice * 100 | yuan}}(含运费{{el.post_fee | yuan}}) + + + + + + + + + + + + diff --git a/litemall-vue/src/views/user/refund-list/index.vue b/litemall-vue/src/views/user/refund-list/index.vue index f25dda45..95df86a2 100644 --- a/litemall-vue/src/views/user/refund-list/index.vue +++ b/litemall-vue/src/views/user/refund-list/index.vue @@ -1,156 +1,156 @@ - - - - - - - - - 合计: {{el.refund_fee | yuan}}(含运费{{el.refund_post_fee | yuan}}) - - - {{ el.status == 10 ? "撤销申请" : "查看详情"}} - - - - - - - - - - - + + + + + + + + + 合计: {{el.refund_fee | yuan}}(含运费{{el.refund_post_fee | yuan}}) + + + {{ el.status == 10 ? "撤销申请" : "查看详情"}} + + + + + + + + + + + diff --git a/litemall-vue/src/views/user/tabbar-user-header.vue b/litemall-vue/src/views/user/tabbar-user-header.vue index 53f5383f..fded15d7 100755 --- a/litemall-vue/src/views/user/tabbar-user-header.vue +++ b/litemall-vue/src/views/user/tabbar-user-header.vue @@ -1,93 +1,93 @@ - - - - - - - {{nickName}} - - - - - - + + + + + + + {{nickName}} + + + + + + diff --git a/litemall-vue/src/views/user/tabbar-user.vue b/litemall-vue/src/views/user/tabbar-user.vue index 4b52ad4b..b09521d7 100755 --- a/litemall-vue/src/views/user/tabbar-user.vue +++ b/litemall-vue/src/views/user/tabbar-user.vue @@ -1,68 +1,68 @@ - - - - - - - 退出当前账户 - - - - - - - + + + + + + + 退出当前账户 + + + + + + + diff --git a/litemall-vue/src/views/user/user-information-set/index.vue b/litemall-vue/src/views/user/user-information-set/index.vue index 051470d8..baf42485 100755 --- a/litemall-vue/src/views/user/user-information-set/index.vue +++ b/litemall-vue/src/views/user/user-information-set/index.vue @@ -41,8 +41,8 @@ - - + + + + + + + + + + + + 保存 + + + + + + + + diff --git a/litemall-vue/src/vue/event-bus/index.js b/litemall-vue/src/vue/event-bus/index.js deleted file mode 100644 index 45d98f06..00000000 --- a/litemall-vue/src/vue/event-bus/index.js +++ /dev/null @@ -1,21 +0,0 @@ -export default { - install(Vue) { - Vue.prototype.$bus = new Vue({ - data() { - return { - item_list: [] - }; - }, - created() { - this.$on('item_list', val => { - const isArr = Array.isArray(val); - if (isArr) { - this.item_list = val; - } else { - throw Error('item_list必须为数组'); - } - }); - } - }); - } -}; diff --git a/litemall-vue/src/vue/router/login.js b/litemall-vue/src/vue/router/login.js deleted file mode 100755 index 0bf74675..00000000 --- a/litemall-vue/src/vue/router/login.js +++ /dev/null @@ -1,48 +0,0 @@ -import asyncLoader from 'core/async-loader'; -const login = asyncLoader('login/login'); -const registerGetCode = asyncLoader('login/register-getCode'); -const registerSubmit = asyncLoader('login/register-submit'); -const registerStatus = asyncLoader('login/register-status'); -const forget = asyncLoader('login/forget'); -const forgetReset = asyncLoader('login/forget-reset'); -const forgetStatus = asyncLoader('login/forget-status'); - -export default [ - { - path: '/login', - name: 'login', - component: login - }, - { - path: '/login/registerGetCode', - name: 'registerGetCode', - component: registerGetCode - }, - { - path: '/login/registerSubmit', - name: 'registerSubmit', - component: registerSubmit - }, - { - path: '/login/registerStatus/:status', - name: 'registerStatus', - props: true, - component: registerStatus - }, - { - path: '/login/forget', - name: 'forget', - component: forget - }, - { - path: '/login/forget/reset', - name: 'forgetReset', - component: forgetReset - }, - { - path: '/login/forget/reset/:status', - name: 'forgetStatus', - props: true, - component: forgetStatus - } -]; diff --git a/litemall-vue/src/vue/router/order.js b/litemall-vue/src/vue/router/order.js deleted file mode 100755 index 09c65e3e..00000000 --- a/litemall-vue/src/vue/router/order.js +++ /dev/null @@ -1,47 +0,0 @@ -import asyncLoader from 'core/async-loader'; -const tab_cart = asyncLoader('order/tabbar-cart'); -const PlaceOrderEntity = asyncLoader('order/place-order-entity'); -const orderDetail = asyncLoader('order/orderDetail'); -const PlaceOrderVirtual = asyncLoader('order/place-order-virtual'); -const Payment = asyncLoader('order/payment'); -const PaymentStatus = asyncLoader('order/payment-status'); - -const Tabbar = () => - import(/* webpackChunkName: "Tabbar" */ '@/vue/components/Tabbar/'); - -export default [ - { - path: '/order', - name: 'cart', - meta: { - login: true - }, - components: { default: tab_cart, tabbar: Tabbar } - }, - { - path: '/order/placeOrderEntity', - name: 'placeOrderEntity', - component: PlaceOrderEntity - }, - { - path: '/order/orderDetail', - name: 'orderDetail', - component: orderDetail - }, - { - path: '/order/placeOrderVirtual', - name: 'placeOrderVirtual', - component: PlaceOrderVirtual - }, - { - path: '/order/payment', - name: 'payment', - component: Payment - }, - { - path: '/order/payment/:status', - name: 'paymentStatus', - component: PaymentStatus, - props: true - } -];
{{coupon.desc }} - {{coupon.tag}}
有效期:{{coupon.days}} 天