diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/DateUtil.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/DateUtil.java index e0f92c8f..3219252f 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/DateUtil.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/DateUtil.java @@ -26,6 +26,9 @@ public class DateUtil { * @return 计算后的日志 */ public static Date addDate(Date date, int field, int amount) { + if (amount == 0) { + return date; + } Calendar c = Calendar.getInstance(); if (date != null) { c.setTime(date); diff --git a/mobile-web/src/api/promotion.js b/mobile-web/src/api/promotion.js index f5e1c9a5..f58154c0 100644 --- a/mobile-web/src/api/promotion.js +++ b/mobile-web/src/api/promotion.js @@ -15,5 +15,45 @@ export function getProductRecommendList() { return request({ url: '/promotion-api/users/product_recommend/list', method: 'get', + params: { + id, + } + }); +} + +// Coupon Template + +export function getCouponTemplate(id) { + return request({ + url: '/promotion-api/users/coupon/template/get', + method: 'get', + params: { + id, + } + }); +} + +export function doAddCouponCard(templateId) { + return request({ + url: '/promotion-api/users/coupon/card/add', + method: 'post', + params: { + templateId, + } + }); +} + + +// Coupon Card + +export function getCouponPage(status, pageNo, pageSize) { + return request({ + url: '/promotion-api/users/coupon/card/page', + method: 'get', + params: { + status, + pageNo, + pageSize + } }); } diff --git a/mobile-web/src/config/env.js b/mobile-web/src/config/env.js index c8859f77..ab335a08 100644 --- a/mobile-web/src/config/env.js +++ b/mobile-web/src/config/env.js @@ -1,12 +1,12 @@ /** * 配置编译环境和线上环境之间的切换 - * + * * baseUrl: 域名地址 * routerMode: 路由模式 * dataSources:数据源 */ -let baseUrl = ''; +let baseUrl = ''; let routerMode = 'hash'; let dataSources='local';//local=本地,其他值代表非本地 @@ -27,4 +27,4 @@ export { baseUrl, routerMode, dataSources, -} \ No newline at end of file +} diff --git a/mobile-web/src/config/request.js b/mobile-web/src/config/request.js index b4508258..1690d920 100644 --- a/mobile-web/src/config/request.js +++ b/mobile-web/src/config/request.js @@ -135,8 +135,8 @@ service.interceptors.request.use( const { target, prefix } = serviceRouter(config.url) let url = config.url = config.url.replace(`${prefix}`, target); // TODO 芋艿,这些 url 不用增加认证 token 。可能这么写,有点脏,后面看看咋优化下。 - if (url.indexOf('user-api/users/passport/mobile/send_register_code') != -1 - || url.indexOf('user-api/users/passport/mobile/register') != -1) { + if (url.indexOf('user-api/users/passport/mobile/send_register_code') !== -1 + || url.indexOf('user-api/users/passport/mobile/register') !== -1) { return config; } diff --git a/mobile-web/src/config/router.js b/mobile-web/src/config/router.js index 8cb14589..7c996059 100644 --- a/mobile-web/src/config/router.js +++ b/mobile-web/src/config/router.js @@ -1,6 +1,8 @@ import Vue from 'vue'; import Router from 'vue-router'; +import { getAccessToken } from '../utils/cache'; + Vue.use(Router); const routes = [ @@ -84,7 +86,8 @@ const routes = [ path: '/user/coupon', component: () => import('../page/user/coupon/list'), meta: { - title: '我的优惠券' + title: '我的优惠券', + requireAuth: true, } }, { @@ -192,6 +195,13 @@ const routes = [ title: '分类' } }, + { + path: '/coupon/fetch', + component: () => import('../page/coupon/fetch'), + meta: { + title: '优惠劵领取' + } + } ]; // add route path @@ -202,10 +212,23 @@ routes.forEach(route => { const router = new Router({ routes }); router.beforeEach((to, from, next) => { + // 判断是否需要认证 + const requireAuth = to.meta && to.meta.requireAuth; + if (requireAuth) { + if (!getAccessToken()) { // 未登陆 + next({ + path: '/login', + query: {redirect: to.fullPath} // 将跳转的路由path作为参数,登录成功后跳转到该路由 + }); + return; + } + } + // 处理标题 const title = to.meta && to.meta.title; if (title) { document.title = title; } + // 继续路由 next(); }); diff --git a/mobile-web/src/main.js b/mobile-web/src/main.js index ff8d752c..9577aa1c 100644 --- a/mobile-web/src/main.js +++ b/mobile-web/src/main.js @@ -7,6 +7,8 @@ import VueLazyload from 'vue-lazyload' import components from './config/components.js'; import { Dialog } from 'vant'; +import { formatDate } from './utils/date.js'; + Vue.use(components); Vue.use(VueLazyload); @@ -16,4 +18,10 @@ new Vue({ router, el: '#app', render: h => h(App) -}); \ No newline at end of file +}); + +Vue.filter('formatDate', function(date, pattern) { + if (date) { + return formatDate(date, pattern); + } +}); diff --git a/mobile-web/src/page/account/phonelogin.vue b/mobile-web/src/page/account/phonelogin.vue index 866404bc..6fe20cb6 100644 --- a/mobile-web/src/page/account/phonelogin.vue +++ b/mobile-web/src/page/account/phonelogin.vue @@ -73,8 +73,9 @@ export default { message: '登陆成功', beforeClose: function (action, done) { done(); - // TODO 芋艿,先暂时不做 callback - that.$router.push('/user/index'); + // TODO 芋艿,简单的 callback 后续完善 + let redirect = that.$route.query.redirect || '/user/index'; + that.$router.push(redirect); } }); }); diff --git a/mobile-web/src/page/coupon/fetch.vue b/mobile-web/src/page/coupon/fetch.vue new file mode 100644 index 00000000..ceff598e --- /dev/null +++ b/mobile-web/src/page/coupon/fetch.vue @@ -0,0 +1,54 @@ + + + + + + + 领取优惠劵 + + + + diff --git a/mobile-web/src/page/page/index.vue b/mobile-web/src/page/page/index.vue index d5046523..75f2669a 100644 --- a/mobile-web/src/page/page/index.vue +++ b/mobile-web/src/page/page/index.vue @@ -65,9 +65,9 @@ export default { } }, created:function(){ - GetPage().then(response=>{ - this.page=response; - }); + // GetPage().then(response=>{ + // this.page=response; + // }); }, mounted: function() { // 加载 Banner diff --git a/mobile-web/src/page/user/coupon/list.vue b/mobile-web/src/page/user/coupon/list.vue index ba2ed7e3..044ba9a6 100644 --- a/mobile-web/src/page/user/coupon/list.vue +++ b/mobile-web/src/page/user/coupon/list.vue @@ -6,7 +6,7 @@ center clearable placeholder="请输入优惠码" - + v-model="couponCode" > 兑换 @@ -16,41 +16,50 @@ - + - - {{item.Sign}} - {{item.Coupon}} - {{item.Sign}} + + ¥ + {{item.priceOff / 100}} + + + {{item.percentOff / 10.0}} + 折 - {{item.Condition}} + 满 {{item.priceAvailable}} 元可用 - {{item.Name}} + {{item.title}} - {{item.BeginDate}}-{{item.EndDate}} - + {{item.validStartTime | formatDate('yyyy-MM-dd')}} + ~ {{item.validEndTime | formatDate('yyyy-MM-dd')}} 立即使用 - - 详细信息 - - - + + + + + + + + + + + {{item.Info}} @@ -62,32 +71,35 @@ - + - - {{item.Sign}} - {{item.Coupon}} - {{item.Sign}} + + ¥ + {{item.priceOff / 100}} + + + {{item.percentOff / 10.0}} + 折 - {{item.Condition}} + 满 {{item.priceAvailable}} 元可用 - {{item.Name}} + {{item.title}} - {{item.BeginDate}}-{{item.EndDate}} - + {{item.validStartTime | formatDate('yyyy-MM-dd')}} + ~ {{item.validEndTime | formatDate('yyyy-MM-dd')}} @@ -97,34 +109,37 @@ - + - + - - {{item.Sign}} - {{item.Coupon}} - {{item.Sign}} + + ¥ + {{item.priceOff / 100}} + + + {{item.percentOff / 10.0}} + 折 - {{item.Condition}} + 满 {{item.priceAvailable}} 元可用 - {{item.Name}} + {{item.title}} - {{item.BeginDate}}-{{item.EndDate}} - + {{item.validStartTime | formatDate('yyyy-MM-dd')}} + ~ {{item.validEndTime | formatDate('yyyy-MM-dd')}} @@ -138,83 +153,131 @@