Authored by htoooth

fix params

... ... @@ -4,9 +4,9 @@
<div class="wrapper">
<div style="width: 67%; display: inline-block;">
<div>
<input ref="start" type="text" readonly="true" class="input-wrapper" :value="value.start_time" style="width: 40%;" placeholder="选择开始时间" @focus="onFocusStartTime" @blur="onBlurStartTime">
<input ref="start" type="text" readonly="true" class="input-wrapper" :value="value.start_time" style="width: 40%;" placeholder="选择开始时间" @focus="onFocusStartTime">
<span style="display: inline-block; width: 5%;">-</span>
<input ref="end" type="text" readonly="true" class="input-wrapper" :value="value.end_time" style="width: 40%;" placeholder="选择结束时间" @focus="onFocusEndTime" @blur="onBlurEndTime">
<input ref="end" type="text" readonly="true" class="input-wrapper" :value="value.expire_time" style="width: 40%;" placeholder="选择结束时间" @focus="onFocusEndTime">
</div>
</div>
... ... @@ -33,13 +33,13 @@ export default {
value: {
type: Object,
default() {
return {start_time: '', end_time: ''};
return {start_time: '', expire_time: '', noLimit: false};
}
}
},
data() {
return {
noLimitTime: true
noLimitTime: this.value.noLimit
};
},
methods: {
... ... @@ -59,11 +59,18 @@ export default {
},
selectStartTimeHandle(date, selectedVal) {
this.$refs.start.value = selectedVal.join('/');
},
onBlurStartTime() {
this.updateTime();
},
onFocusEndTime() {
if (this.noLimitTime) {
this.$createToast({
txt: '已设置无固定期限,不用设置结束时间',
type: 'warn',
mask: true,
time: 2000
}).show();
this.$refs.end.blur();
return;
}
... ... @@ -72,7 +79,7 @@ export default {
title: '选择结束时间',
min: new Date(1990, 7, 8),
max: new Date(2050, 9, 20),
value: this.value.end_time ? new Date(...this.value.start_time.split('/')) : new Date(),
value: this.value.expire_time ? new Date(...this.value.expire_time.split('/')) : new Date(),
onSelect: this.selectEndTimeHandle,
onCancel: null
});
... ... @@ -82,16 +89,25 @@ export default {
},
selectEndTimeHandle(data, selectedVal) {
this.$refs.end.value = selectedVal.join('/');
},
onBlurEndTime() {
this.updateTime();
},
updateTime() {
this.$emit('input', {
start_time: '',
end_time: ''
start_time: this.$refs.start.value,
expire_time: this.$refs.end.value,
noLimit: this.noLimitTime
});
}
},
watch: {
noLimitTime(newVal) {
if (newVal === false) {
this.$refs.end.value = '';
}
this.updateTime();
}
},
components: {
CInput: Input,
DatePicker,
... ... @@ -110,6 +126,4 @@ export default {
.input-wrapper {
display: inline-block;
}
</style>
... ...
<template>
<label class="container" @click="onClickLabel">
<label class="container" @click.stop.prevent="onClickLabel">
<span :class="classes"></span>
<span :class="labelClasses">{{label.text}}</span>
</label>
... ...
<template>
<CInput :label="label">
<slot>
<Upload :max="max" :multiple="multiple" :action="action">
<Upload
:max="max"
:multiple="multiple"
:action="action"
:simultaneous-uploads="1"
:value="file"
@file-submitted="fileAdd"
@file-error="fileError"
>
</Upload>
</slot>
... ... @@ -13,9 +21,19 @@
import Input from './input';
import {Upload} from 'cube-ui';
import {createNamespacedHelpers} from 'vuex';
const {mapState, mapActions, mapMutations} = createNamespacedHelpers('auth/auth');
export default {
name: 'CUpload',
props: {
value: {
type: Array,
default() {
return [];
}
},
label: {
type: String
}
... ... @@ -25,10 +43,32 @@ export default {
max: 1,
multiple: false,
action: {
url: '',
target: 'http://upload.qiniup.com/',
data: {
token: '',
key: ''
}
},
file: this.value
};
},
methods: {
fileAdd(file) {
this.action.data.token = this.token;
this.action.data.key = file.name;
},
fileError() {
this.$createToast({
txt: '上传失败,请重新上传',
type: 'error',
mask: true,
time: 2000
}).show();
},
},
computed: {
...mapState(['token'])
},
components: {
CInput: Input,
Upload
... ...
... ... @@ -84,7 +84,7 @@
<CUpload label="上传法人身份证反面照片" v-model="model.certReverseImage"></CUpload>
</FormItem>
</Form>
<div class="footer active">确认提交</div>
<div class="footer active" @click="onSubmit">确认提交</div>
</div>
</LayoutApp>
... ... @@ -100,6 +100,9 @@ import FormItem from '../components/form-item';
import Input from '../components/input';
import Upload from '../components/upload';
import DatePick from '../components/date-pick';
import {createNamespacedHelpers} from 'vuex';
const {mapState, mapActions, mapMutations} = createNamespacedHelpers('auth/auth');
export default {
... ... @@ -114,6 +117,7 @@ export default {
time: {
start_time: '',
expire_time: '',
noLimit: true
},
licenseOriginalImage: [],
licenseCopyImage: [],
... ... @@ -123,7 +127,13 @@ export default {
};
},
methods: {
onSubmit() {
console.log(this.model);
},
...mapActions(['fetchToken'])
},
mounted() {
this.fetchToken();
},
components: {
LayoutApp,
... ...
import * as Types from './types';
const TYPE = {notuse: 'notuse', use: 'use', overtime: 'overtime'};
export default {
async fetchYohoList({commit, state}, {type, filter = 0, refresh = false}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
if (!refresh) {
if (state.yohoList[type].page > state.yohoList[type].pageNum) {
return false;
}
}
const fetchPage = refresh ? 1 : state.yohoList[type].page + 1;
// 下一页的数据
const result = await this.$api.get('/api/coupon/yoho/list', {
type,
filter,
limit: 10,
page: fetchPage
});
if (result && result.code === 200) {
const data = {
type,
couponList: result.data.couponList ? result.data.couponList.map((i) => _handleCoupon(i, type)) : [],
pageNum: result.data.pageNum,
pageSize: result.data.pageSize,
total: result.data.total,
filterId: filter,
page: fetchPage,
refresh
function _url({name}) {
return `//cdn.yoho.cn/${name}`;
}
function _handleData(data) {
const result = {
businessType: data.businessType,
businessName: data.businessName,
socialCreditCode: data.socialCreditCode,
certName: data.certName,
certNo: data.certNo,
start_time: data.time.start_time,
expire_time: data.time.noLimit ? '0' : data.time.expire_time,
licenseOriginalImage: data.licenseOriginalImage.map(_url).join(''),
licenseCopyImage: data.licenseCopyImage.map(_url).join(''),
certFaceImage: data.certFaceImage.map(_url).join(''),
certReverseImage: data.certReverseImage.map(_url).join('')
};
if (type === TYPE.notuse) {
data.filter = result.data.filters;
}
commit(Types.FETCH_YOHO_COUPON_SUCCESS, data);
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
return result;
}
return result.data.couponList ? result.data.couponList.length !== 0 : false;
},
async fetchYohoNum({commit}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.get('/api/coupon/yoho/num', {});
export default {
async fetchToken({ commit }) {
const result = await this.$api.get('/getToken?type=yohocdn');
if (result && result.code === 200) {
commit(Types.FETCH_YOHO_COUPON_NUM_SUCCESS, result.data);
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
commit(Types.FETCH_UFO_UPLOAD_TOKEN_SUCCESS, { token: result.uptoken });
},
async fetchUfoList({commit}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
async saveAuth({ commit }, data) {
const result = await this.$api.post('/', _handleData(data));
const result = await this.$api.get('/api/coupon/ufo/list');
if (result && result.code === 200) {
commit(Types.FETCH_UFO_COUPON_SUCCESS, {
list: result.data.map(_handleUfoCoupon)
});
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
return result;
},
async getCouponCode({commit}, {code}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.post('/api/coupon/yoho/getcoupon', {
coupon_code: code
});
if (result && result.code === 200) {
commit(Types.FETCH_YOHO_COUPON_CODE_SUCCESS);
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
async authSave({ commit }) {
const result = await this.$api.get('/state');
return result || {};
return result;
}
};
... ...
import actions from './actions';
import mutations from './mutations';
function handleNum(n) {
return n > 99 ? '99+' : n;
}
export default function() {
return {
namespaced: true,
state: {
fetching: false,
token: false
},
actions,
mutations
... ...
import * as Types from './types';
export default {
[Types.FETCH_YOHO_COUPON_REQUEST](state) {
state.fetching = true;
},
[Types.FETCH_YOHO_COUPON_SUCCESS](state, {couponList, filter, type, pageNum, pageSize, total, filterId, page, refresh}) {
state.fetching = false;
const typeData = state.yohoList[type];
const list = typeData.couponList;
const newCouponList = refresh ? couponList : list.concat(couponList);
typeData.couponList = newCouponList;
typeData.pageNum = pageNum;
typeData.pageSize = pageSize;
typeData.total = total;
typeData.filterId = filterId;
typeData.page = page;
if (filter) {
state.filterList = filter;
}
},
[Types.FETCH_YOHO_COUPON_FAILED](state) {
state.fetching = false;
},
[Types.FETCH_YOHO_COUPON_NUM_SUCCESS](state, data) {
state.num = data;
},
[Types.FETCH_UFO_COUPON_SUCCESS](state, {list = []}) {
state.fetching = false;
state.ufoList = list;
[Types.FETCH_UFO_UPLOAD_TOKEN_SUCCESS](state, {token}) {
state.token = token;
}
};
... ...
export const FETCH_YOHO_COUPON_REQUEST = 'FETCH_YOHO_COUPON_REQUEST';
export const FETCH_YOHO_COUPON_FAILED = 'FETCH_YOHO_COUPON_FAILED';
export const FETCH_YOHO_COUPON_SUCCESS = 'FETCH_YOHO_COUPON_SUCCESS';
export const FETCH_YOHO_COUPON_NUM_SUCCESS = 'FETCH_YOHO_COUPON_NUM_SUCCESS';
export const FETCH_YOHO_COUPON_CODE_SUCCESS = 'FETCH_YOHO_COUPON_CODE_SUCCESS';
export const FETCH_UFO_COUPON_SUCCESS = 'FETCH_UFO_COUPON_SUCCESS';
export const FETCH_UFO_UPLOAD_TOKEN_SUCCESS = 'FETCH_UFO_UPLOAD_TOKEN_SUCCESS';
export const FETCH_UFO_SAVE_REQUEST = 'FETCH_UFO_SAVE_REQUEST';
export const FETCH_UFO_SAVE_SUCCESS = 'FETCH_UFO_SAVE_SUCCESS';
export const FETCH_UFO_SAVE_ERROR = 'FETCH_UFO_SAVE_ERROR';
... ...
... ... @@ -3,6 +3,7 @@ import Vuex from 'vuex';
import {createApi} from 'create-api';
import storeYoho from './yoho';
import storeUfo from './order';
import storeAuth from './auth';
Vue.use(Vuex);
... ... @@ -12,6 +13,7 @@ export function createStore(context) {
modules: {
yoho: storeYoho(),
ufo: storeUfo(),
auth: storeAuth()
},
strict: process.env.NODE_ENV !== 'production'
});
... ...
... ... @@ -72,5 +72,17 @@ module.exports = {
old_price: {type: Number},
num: {type: Number}
}
},
'/api/ufo/auth/save': {
ufo: true,
path: 'coupon',
params: {
}
},
'/api/ufo/auth/status': {
ufo: true,
path: 'coupon',
params: {
}
},
};
... ...
... ... @@ -78,10 +78,12 @@ exports.createApp = async(app) => {
const errorMiddleware = require('./doraemon/middleware/error-handler');
const ssrApiMiddleware = require('./doraemon/middleware/ssr-api');
const ssrRouteMiddleware = require('./doraemon/middleware/ssr');
const qiniuMiddleware = require('./doraemon/middleware/qiniu');
// YOHO 前置中间件
app.use(setYohoDataMiddleware);
app.use(userMiddleware);
app.get('/mapp/getToken', qiniuMiddleware.getToken);
app.use('/mapp', ssrApiMiddleware);
app.use(ssrRouteMiddleware.routers);
... ...
/**
* 七牛上传
* @author: chenfeng <feng.chen@yoho.cn>
* @date: 29/06/2017
*/
const qiniu = require('qiniu');
const qiniuConfig = global.yoho.config.qiniu;
const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn;
function getToken(req, res) {
let conf = qiniuConfig;
let type = req.query.type || '';
if (type.toLowerCase() === 'yohocdn') {
conf = qiniuYohoCdnConfig;
}
let mac = new qiniu.auth.digest.Mac(conf.ACCESS_KEY, conf.SECRET_KEY);
let options = {
scope: conf.BUCKET_NAME
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
res.json({
code: 200,
uptoken: uploadToken
});
}
module.exports = {
getToken
};
... ...
... ... @@ -44,6 +44,7 @@
"fastclick": "^1.0.6",
"lodash": "^4.17.11",
"lottie-web": "^5.4.2",
"qiniu": "^7.2.1",
"request-promise": "^4.2.2",
"serve-favicon": "^2.5.0",
"source-map": "^0.7.3",
... ...
This diff could not be displayed because it is too large.