Authored by htoooth

fix post

... ... @@ -17,12 +17,12 @@
"license": "MIT",
"dependencies": {
"axios": "^0.15.3",
"iview": "^2.7.4",
"clipboard": "^1.5.12",
"iview": "^3.1.5",
"js-cookie": "^2.1.3",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuex": "^2.2.1",
"js-cookie": "^2.1.3",
"clipboard": "^1.5.12"
"vuex": "^2.2.1"
},
"devDependencies": {
"autoprefixer-loader": "^3.2.0",
... ... @@ -42,6 +42,8 @@
"iview-loader": "^1.0.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"node-sass": "^3.10.1",
"sass-loader": "^4.0.2",
"style-loader": "^0.19.1",
"url-loader": "^0.6.2",
"vue-hot-reload-api": "^2.2.4",
... ... @@ -51,8 +53,6 @@
"vue-template-compiler": "^2.2.1",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.2",
"webpack-merge": "^4.1.1",
"node-sass": "^3.10.1",
"sass-loader": "^4.0.2"
"webpack-merge": "^4.1.1"
}
}
... ...
... ... @@ -14,22 +14,26 @@ class Api {
return util.ajax.get(url, data).then(result => result.data);
}
_post(url, data, debug = false) {
_post(url, data, debug = false, json = false) {
if (debug) {
data = Object.assign({}, data, {
debug: 'XYZ'
});
url += '?debug=XYZ';
}
const params = json ? data : this._2params(data);
return util.ajax.post(url, params).then(result => {
return result.data;
});
}
_2params(data) {
const params = new URLSearchParams();
for (let i of Object.keys(data)) {
params.append(i, data[i]);
}
return util.ajax.post(url, params).then(result => {
return result.data;
});
return params;
}
}
... ...
... ... @@ -11,12 +11,12 @@ class ResourceApi extends Api {
}, true);
}
edit(data) {
editResource(data) {
return this._post('/ufoPlatform/resource/editResourceContentData', data, true);
}
editGoodsPool(data) {
return this._post('/ufoPlatform/resource/batchEditResourceGoodsPool', data, true);
return this._post('/ufoPlatform/resource/batchEditResourceGoodsPool', data, true, true);
}
}
... ...
... ... @@ -2,8 +2,10 @@ import Vue from 'vue';
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import emitter from './mixins/emitter';
import bus from './bus';
Vue.use(iView);
Vue.prototype.$bus = bus;
Vue.mixin(emitter);
... ... @@ -12,4 +14,4 @@ export default (App) => {
el: '#app',
render: h => h(App)
});
}
};
... ...
import App from './views/home/index.vue';
import createApp from './create-app'
import createApp from './create-app';
createApp(App)
\ No newline at end of file
createApp(App);
\ No newline at end of file
... ...
... ... @@ -10,7 +10,10 @@ class ResourceService extends Service {
info(id) {
return this.api.info(id).then(result => {
let {resGoodsPools, resContentInfos} = result.data;
// let {resGoodsPools, resContentInfos} = result.data;
let resGoodsPools = result.data.resGoodsPools;
let resContentInfos = result.data.resContentInfos;
resContentInfos.sort((a, b) => {
if (a.orderBy < b.orderBy) {
... ... @@ -32,6 +35,15 @@ class ResourceService extends Service {
return resContentInfos;
});
}
editGoodsPool(data) {
return this.api.editGoodsPool(data);
}
editResource(data) {
return this.api.editResource(data);
}
}
export default ResourceService;
\ No newline at end of file
... ...
... ... @@ -2,16 +2,27 @@
<div>
<table class="banner-table">
<tbody>
<tr v-for="(i,index) in value" :key="i.id">
<th>{{index}}</th>
<th> huangtao</th>
<tr v-for="(i,index) in value_" :key="i.imgId">
<th>{{+index + 1}}</th>
<th>
<Input/>
<Select>
<Option value="http">http://</Option>
<Option value="https">https://</Option>
</Select>
<file-upload></file-upload>
</th>
<th>
<Form>
<FormItem>
<Select>
<Option value="go.h5">H5网页</Option>
<Option value="go.ufo">商品列表页</Option>
<Option value="go.pool">商品池</Option>
</Select>
</FormItem>
<FormItem>
<Input/>
</FormItem>
</Form>
</th>
<th>
... ... @@ -28,11 +39,19 @@
</template>
<script>
import fileUpload from './file-upload';
export default {
props: ['value'],
props: {
value: {
type: Object,
default: {}
}
},
data() {
return {
value_: this.value
value_: this.handleData(this.value)
}
},
methods: {
... ... @@ -45,12 +64,45 @@ export default {
});
this.$emit('input', this.value_);
},
handleData(m) {
let keys = Object.keys(m);
keys.sort((a,b) => {
a = +a;
b = +b;
if (a > b) {
return 1
}
if (a < b) {
return -1
}
return 0;
})
let result = [];
for (const i of keys) {
let a = m[i];
console.log(a);
result.push(a)
}
return result;
}
},
watch: {
value(newVal) {
this.value_ = newVal
}
},
components: {
fileUpload
}
}
</script>
... ... @@ -65,7 +117,11 @@ export default {
.banner-table tr th {
height: 150px;
border: 1px solid #57a3f3;
border: 1px solid #dddee1;
}
tr:hover {
background-color: #ebf7ff;
}
</style>
... ...
... ... @@ -4,7 +4,7 @@
<img :src="imgUrl" alt="" srcset="" width="100%">
</select-comp>
<Modal
<Modal
v-model="show"
title="轮播图资源位"
>
... ... @@ -18,28 +18,17 @@ import selectComp from './select-comp';
import bannerEditor from './banner-editor';
export default {
props: {
imgUrl: {
type: String,
default () {
return require('assets/banner-img.png')
}
},
id: {
type: [Number, String]
}
},
props: ['data', 'resContentDataId'],
data() {
let allData = JSON.parse(this.data);
return {
imgUrl: require('assets/banner-img.png'),
show: false,
list: [{
id: 1,
}]
list: allData.data
}
},
methods: {
onClick() {
console.log('huangtao');
this.show = true;
}
},
... ...
<template>
<Upload ref="upload"
:id="id"
:action="action"
type="select"
:data="data"
:accept="accept"
:maxSize="maxSize"
:on-success="success"
:on-error="error"
:before-upload="beforeUpload">
<Button type="primary" icon="ios-cloud-upload-outline">上传文件</Button>
</Upload>
</template>
<script>
import _ from 'lodash';
export default {
name: 'file-upload',
props: {
action: {
type: String,
default: '/ufoPlatform/fileupload/uploadImage'
},
data: {
type: Object,
default: () => {
return {
bucket: 'yhb-img01'
};
}
},
accept: {
type: String,
default: 'image/png,image/jpeg,image/gif,image/jpg'
},
maxSize: {
type: Number,
default: 512 * 1024
},
id: {
type: Object,
default: () => {
return {};
}
}
},
data() {
return {};
},
methods: {
success(response) {
let files = [];
if (_.get(response, 'data.imagesList.length', 0)) {
files = response.data.imagesList;
}
this.$emit('on-success', this.id, files);
},
error(error) {
this.$Message.error('上传失败');
this.$emit('on-error', this.id, error);
},
beforeUpload() {
this.$refs.upload.clearFiles();
return true;
}
}
};
</script>
... ...
... ... @@ -2,10 +2,10 @@
<div>
<Form :model="formItem" :label-width="60">
<FormItem label="标题">
<Input v-model="formItem.input" placeholder="热门系列"></Input>
<Input v-model="formItem.input" placeholder="热门系列"/>
</FormItem>
<FormItem label="商品编码">
<Input v-model="formItem.ids" type="textarea" :rows="4" placeholder="多个商品以英文逗号分隔"></Input>
<Input v-model="formItem.ids" type="textarea" :rows="4" placeholder="多个商品以英文逗号分隔"/>
</FormItem>
<Alert type="warning">
... ... @@ -21,13 +21,22 @@
<script>
export default {
props: ['name', 'list'],
data() {
return {
formItem: {
input: '',
ids: ''
input: this.name,
ids: this.list.join(',')
}
}
},
watch: {
'formItem.input': function(newVal) {
this.$emit('update:name', newVal);
},
'formItem.ids': function(newVal) {
this.$emit('update:list', newVal.split(','));
}
}
}
</script>
... ...
... ... @@ -2,16 +2,17 @@
<div>
<selectComp :cb="onClick">
<div class="hot">
<div class="hot-title">热门系列</div>
<div class="hot-title">{{name}}</div>
<div class="hot-body">
<img src="~assets/item_bg.png" alt="" srcset="" class="hot-title" v-for="i in list" :key="i.id">
<img src="~assets/item_bg.png" alt="" srcset="" class="hot-image" v-for="i in list" :key="i.id">
</div>
</div>
</selectComp>
<Modal v-model="show" title="系列资源位">
<hot-editor></hot-editor>
<Modal v-model="show" title="系列资源位" @on-ok="onOk" @on-cancel="onCancel">
<hot-editor :name.sync="name" :list.sync="list"></hot-editor>
</Modal>
</div>
</template>
... ... @@ -19,31 +20,44 @@
<script>
import selectComp from './select-comp';
import hotEditor from './hot-editor';
import ResourceService from '@/service/resource-service';
export default {
name: 'hot',
props: {
list: {
type: Array,
default () {
return []
}
},
click: {
type: Boolean,
default () {
return false;
}
}
},
props: ['data', 'resContentDataId'],
data() {
let allData =JSON.parse(this.data);
return {
show: false
allData,
show: false,
name: allData.template_intro,
list: allData.data.split(','),
}
},
mounted() {
this.resourceService = new ResourceService();
},
methods: {
onClick() {
this.show = true;
},
onOk() {
this.allData.template_intro = this.name;
this.allData.data = this.list.join(',');
this.resourceService.editResource({
id: this.resContentDataId,
contentData: JSON.stringify(this.allData)
}).then(() => {
this.$bus.$emit('updated');
}).catch(() => {
this.$bus.$emit('updated');
})
},
onCancel() {
this.$bus.$emit('updated');
}
},
components: {
... ...
<template>
<div>
<div class="item">
<Form :model="formItem" :label-width="60">
<FormItem label="标题">
<Input v-model="formItem.input1" placeholder="标题"></Input>
</FormItem>
<FormItem label="more">
<Input v-model="formItem.input2" placeholder="跳转列表标题"></Input>
</FormItem>
<FormItem >
<Input v-model="formItem.input3" placeholder="请选择跳转列表"></Input>
</FormItem>
<FormItem >
<Input v-model="formItem.input4" placeholder="url"></Input>
</FormItem>
<FormItem label="商品编码">
<Input v-model="formItem.ids" type="textarea" :rows="4" placeholder="多个商品以英文逗号分隔"></Input>
</FormItem>
</Form>
<Form :model="formItem" :label-width="60">
<FormItem label="标题">
<Input v-model="formItem.input1" placeholder="标题"/>
</FormItem>
<FormItem label="more">
<Input v-model="formItem.input2" placeholder="跳转列表标题"/>
</FormItem>
<FormItem >
<Input v-model="formItem.input3" placeholder="请选择跳转列表"/>
</FormItem>
<FormItem >
<Input v-model="formItem.input4" placeholder="url"/>
</FormItem>
<FormItem label="商品编码">
<Input v-model="formItem.ids" type="textarea" :rows="4" placeholder="多个商品以英文逗号分隔"/>
</FormItem>
<Button >删除</Button>
</Form>
</div>
<Button>添加一组</Button>
<Button style="margin-top:20px">添加一组</Button>
</div>
</template>
... ... @@ -37,7 +39,23 @@ export default {
input3: '',
input4: '',
ids: ''
}
},
list: [{
category_name: '',
product_ids: '',
more_url: {
action: '',
}
}],
}
},
methods: {
onAddBtn() {
},
onDeleteBtn() {
}
}
}
... ... @@ -45,7 +63,14 @@ export default {
<style>
.item {
border: 1px solid gray;
border: 1px solid #dddee1;
padding-top: 30px;
padding-left: 20px;
padding-right: 20px;
margin-bottom: 20px;
}
.item:hover {
background-color: #ebf7ff;
}
</style>
... ...
... ... @@ -14,6 +14,7 @@
import selectComp from './select-comp';
import sortTabEditor from './sortTab-editor'
export default {
props: ['data', 'resContentDataId'],
data() {
return {
show: false
... ...
... ... @@ -2,7 +2,7 @@
<div>
<Form :label-width="100">
<FormItem :label="i.poolName" v-for="i in formItem" :key="i.id">
<Input :value="i.poolId" @input="onUpdate"/>
<Input :value="i.poolId" @input="(v) => {onUpdate(v, i)}"/>
</FormItem>
</Form>
</div>
... ... @@ -24,8 +24,9 @@ export default {
}
},
methods: {
onUpdate(i) {
console.log(i)
onUpdate(v, i) {
i.poolId = v
this.$emit('update:list', this.formItem)
}
},
mounted() {
... ...
<template>
<div>
<select-comp :cb="onClick">
<img src="~assets/floor-recommend.png" alt="" srcset="" width="100%">
</select-comp>
<select-comp :cb="onClick">
<img src="~assets/floor-recommend.png" alt="" srcset="" width="100%">
</select-comp>
<Modal v-model="show" title="商品池资源位">
<tab-editor :list.sync="data"></tab-editor>
</Modal>
<Modal
v-model="show"
title="商品池资源位"
@on-ok="onOk"
@on-cancel="onCancel"
>
<tab-editor :list.sync="data"></tab-editor>
</Modal>
</div>
</template>
<script>
import selectComp from './select-comp';
import tabEditor from './tab-editor';
import ResourceService from '@/service/resource-service';
export default {
name: 'tab',
props: ['data'],
... ... @@ -22,12 +29,27 @@ export default {
}
},
mounted() {
console.log(this.data);
this.resourceService = new ResourceService();
},
methods: {
onClick() {
this.show = true;
}
},
onOk() {
const updateVal = this.data.map((i) => {
return {
id: i.id,
poolId: i.poolId
}
})
this.resourceService.editGoodsPool(updateVal);
this.$bus.$emit('updated');
},
onCancel() {
this.$bus.$emit('updated');
},
},
components: {
selectComp,
... ...
... ... @@ -36,9 +36,13 @@
}
},
mounted() {
this.resId = util.getQueryString('id');
this.resId = util.getQueryString('id') || 1;
this.resourceService = new ResourceService();
this.init();
this.$bus.$on('updated', () => {
this.init();
})
},
methods: {
init() {
... ...
... ... @@ -10,10 +10,10 @@
</style>
<template>
<div class="index">
<miniapp title="UFO分类页" :bg="bg">
<miniapp title="UFO分类页">
<template>
<template v-for="i in list">
<smartfloor :item="i" :key="i.id"></smartfloor>
<smartfloor :item="i" :key="i.resContentId"></smartfloor>
<divide></divide>
</template>
</template>
... ... @@ -26,31 +26,28 @@
import divide from 'components/divide'
import util from '@/libs/util'
import ResourceApi from '@/api/resource-api'
import ResourceService from '@/service/resource-service'
export default {
data() {
return {
list: [{
id: 2,
type: 2
}, {
id: 4,
type: 4
}],
resId: null,
bg: require('assets/sort_title.png')
list: [],
resId: null
}
},
mounted() {
this.resId = util.getQueryString('id');
this.resourceApi = new ResourceApi();
this.resId = util.getQueryString('id') || 2;
this.resourceService = new ResourceService();
this.init();
this.$bus.$on('updated', () => {
this.init();
})
},
methods: {
init() {
this.resourceApi.info(this.resId).then(result => {
console.log(result);
this.resourceService.info(this.resId).then(result => {
this.list = result;
})
}
},
... ...
... ... @@ -48,7 +48,7 @@ module.exports = merge(webpackBaseConfig, {
devServer: {
openPage: 'index_home.html',
proxy: {
'/ufoPlatform/resource/**': {
'/ufoPlatform/**': {
target: 'http://java-ufo-platform.test3.ingress.dev.yohocorp.com',
changeOrigin: true
}
... ...
This diff could not be displayed because it is too large.