actions.js
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import * as Types from './types';
function getUploadImgAbsoluteUrl(url, bucket = 'goodsimg') {
if (!url) {
return null;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/${bucket}`;
url = domain + url;
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
}
function _url({ name }) {
return getUploadImgAbsoluteUrl(name);
}
function _handleData(data) {
const result = {
business_type: data.businessType,
business_name: data.businessName,
social_credit_code: data.socialCreditCode,
cert_name: data.certName,
cert_no: data.certNo,
start_time: data.time.start_time,
expire_time: data.time.noLimit ? '0' : data.time.expire_time,
license_original_image: data.licenseOriginalImage.map(_url).join(''),
license_copy_image: data.licenseCopyImage.map(_url).join(''),
cert_face_image: data.certFaceImage.map(_url).join(''),
cert_reverse_image: data.certReverseImage.map(_url).join('')
};
return result;
}
export default {
async fetchToken({ commit }) {
const result = await this.$api.get('/getToken');
commit(Types.FETCH_UFO_UPLOAD_TOKEN_SUCCESS, { token: result.uptoken });
},
async saveLicense({ commit }, data) {
const result = await this.$api.post(
'/api/ufo/license/save',
_handleData(data)
);
return result;
},
async licenseStatus({ commit }) {
let result = await this.$api.get('/api/ufo/license/status');
if (result.code === 200) {
commit(Types.FETCH_UFO_STATUS_SUCCESS, {
status: result.data,
message: result.message
});
} else {
commit(Types.FETCH_UFO_STATUS_SUCCESS, { status: -1 });
}
},
async getStoreStatus({ commit }) {
let result = {};
try {
result = await this.$api.get('/api/ufo/store/status');
} catch (e) {
return result;
}
return result;
},
async createUfoProduct(params, data) {
return this.$api.post('/api/ufo/seller/create', {
brand: data.brand,
product_name: data.product_name,
price: data.price,
sale_time: data.sale_time,
product_code: data.product_code,
imageList: data.imageList.map(_url).join(',')
});
}
};