哦吼吼 6 years ago
parent
commit
7fe198d4e7

+ 4 - 1
admin-update/src/config/env.js

@@ -6,6 +6,9 @@ const env = process.env;
 // 路由模式
 const routerMode = 'hash';
 
+// 图片host
+const imgHostUrl = `${window.location.protocol}//img.${getFirstHost()}.com`;
+
 // 请求地址
 const baseUrl = (() => {
 	let proxy = getUrlParam('proxy');
@@ -31,4 +34,4 @@ const baseUrl = (() => {
 // 阿里字体图标库 https://at.alicdn.com/t/**.css
 const iconfontUrl = ``;
 
-export { env, routerMode, baseUrl, iconfontUrl };
+export { env, routerMode, baseUrl, iconfontUrl, imgHostUrl };

+ 4 - 1
admin-update/src/config/s-env.js

@@ -4,6 +4,9 @@ import { getUrlParam, getFirstHost } from '@/cool/utils';
 // 路由模式
 const routerMode = 'hash';
 
+// 图片host
+const imgHostUrl = `${window.location.protocol}//img.${getFirstHost()}.com`;
+
 // 请求地址
 const baseUrl = (function() {
 	let proxy = getUrlParam('proxy');
@@ -29,4 +32,4 @@ const baseUrl = (function() {
 // 阿里字体图标库 https://at.alicdn.com/t/**.css
 const iconfontUrl = ``;
 
-export { routerMode, baseUrl, iconfontUrl };
+export { routerMode, baseUrl, iconfontUrl, imgHostUrl };

+ 48 - 22
admin-update/src/cool/components/upload/index.vue

@@ -10,6 +10,9 @@
 			:headers="{
 				token: token
 			}"
+			name="content"
+			:on-change="getFile"
+			:auto-upload="false"
 			:action="action"
 			:show-file-list="false"
 			:on-success="
@@ -133,35 +136,31 @@ export default {
 		},
 
 		onSuccess(res, file, item) {
-			const { code, data, message } = res;
+			const { url, smallUrl, shortUrl } = res;
 			const { multiple } = this.props;
 
-			if (code == 1000) {
-				item.loading = false;
+			// item.loading = false;
 
-				if (multiple) {
-					if (item.url) {
-						item.url = data;
-					} else {
-						this.list.push({
-							url: data
-						});
-					}
+			if (multiple) {
+				if (item.url) {
+					item.url = smallUrl;
 				} else {
-					this.list = [
-						{
-							url: data
-						}
-					];
+					this.list.push({
+						url: smallUrl
+					});
 				}
+			} else {
+				this.list = [
+					{
+						url: smallUrl
+					}
+				];
+			}
 
-				this.callback();
+			this.callback();
 
-				if (this.props && this.props['on-success']) {
-					this.props['on-success'](res, file);
-				}
-			} else {
-				this.onError(message);
+			if (this.props && this.props['on-success']) {
+				this.props['on-success'](res, file);
 			}
 		},
 
@@ -178,6 +177,33 @@ export default {
 		removeFile(i) {
 			this.list.splice(i, 1);
 			this.callback();
+		},
+
+		//
+		getFile(file, fileList) {
+			this.getBase64(file.raw).then(res => {
+				// this.list = res;
+				this.$service.common.uploadImg({ content: res }).then(subRes => {
+					console.log('subRes', subRes);
+					this.onSuccess(subRes);
+				});
+			});
+		},
+		getBase64(file) {
+			return new Promise(function(resolve, reject) {
+				let reader = new FileReader();
+				let imgResult = '';
+				reader.readAsDataURL(file);
+				reader.onload = function() {
+					imgResult = reader.result;
+				};
+				reader.onerror = function(error) {
+					reject(error);
+				};
+				reader.onloadend = function() {
+					resolve(imgResult);
+				};
+			});
 		}
 	}
 };

+ 5 - 0
admin-update/src/pages/layout/slider/index.vue

@@ -41,6 +41,11 @@ export default {
 			subIndex: 0
 		};
 	},
+	watch: {
+		$route(to, from) {
+			this.init();
+		}
+	},
 	computed: {
 		...mapGetters(['menuGroup']),
 		subData() {

+ 14 - 0
admin-update/src/service/common/index.js

@@ -15,6 +15,20 @@ export class CommonService extends BaseService {
 		};
 	}
 
+	/**
+	 * 文件上传
+	 *
+	 * @returns
+	 * @memberof CommonService
+	 */
+	uploadImg(data) {
+		return this.request({
+			url: '/upload/save-img',
+			method: 'POST',
+			data: data
+		});
+	}
+
 	/**
 	 * sass平台登录
 	 *

+ 4 - 3
admin-update/src/service/goods/index.js

@@ -14,7 +14,7 @@ export class GoodsService extends BaseService {
 	// 商品管理-涨价设置 b
 	getAutoPrice(data) {
 		return this.request({
-			url: '/goods/setting',
+			url: '/setting',
 			params: data
 		});
 	}
@@ -22,8 +22,9 @@ export class GoodsService extends BaseService {
 	// 商品管理-更新涨价 b
 	setAutoPrice(data) {
 		return this.request({
-			url: '/goods/update-rise',
-			params: data
+			url: '/update-rise',
+			method: 'POST',
+			data: data
 		});
 	}
 }

+ 8 - 0
admin-update/src/service/single/index.js

@@ -57,6 +57,14 @@ export class SingleService extends BaseService {
 			data: data
 		});
 	}
+
+	// 商品管理-运费设置 b
+	setFreight(data) {
+		return this.request({
+			url: '/merchant/freight-setting',
+			params: data
+		});
+	}
 }
 
 export default new SingleService();

+ 10 - 1
admin-update/src/utils/util.js

@@ -18,6 +18,14 @@ const isEmpty = val => {
 	return false;
 };
 
+const getShortUrl = url => {
+	if (isEmpty(url)) return '';
+	let startIndex = url.indexOf('/uploads');
+	let endIndex = url.indexOf('_small');
+	let urlArr = url.split('.');
+	return url.substring(startIndex, endIndex) + '.' + urlArr[urlArr.length - 1];
+};
+
 // 是否为数组
 const isArray = arr => {
 	return typeof arr == 'object' && arr.constructor == Array;
@@ -134,5 +142,6 @@ export default {
 	isEmpty,
 	parse,
 	$checkName,
-	$formatDate
+	$formatDate,
+	getShortUrl
 };

+ 44 - 27
admin-update/src/views/goods/auto-price.vue

@@ -1,33 +1,46 @@
 <template>
 	<div class="app-content auto-price-wrap">
 		<el-form :model="form" :rules="rules" ref="form" label-width="100px" class="demo-form">
-			<el-form-item label="开启自动涨价" prop="name">
-				<el-switch v-model="form.delivery"></el-switch>
+			<el-form-item label="开启自动涨价" prop="riseSwitch">
+				<el-switch
+					v-model="form.riseSwitch"
+					active-value="1"
+					inactive-value="0"
+				></el-switch>
 			</el-form-item>
-			<el-form-item label="要涨价节日" prop="name">
+			<el-form-item label="要涨价节日" prop="festIdList">
 				<el-checkbox
-					v-model="form.status"
-					label="七夕节"
+					v-model="form.festIdList"
+					:label="item.id"
 					border
-					v-for="(item, index) in 4"
-					:key="index"
+					v-for="(item, index) in festData"
+					:key="item.id"
 					size="small"
-				></el-checkbox>
+					>{{ item.name }}</el-checkbox
+				>
 			</el-form-item>
-			<el-form-item label="涨价方式" prop="resource">
-				<el-radio-group v-model="form.resource">
-					<el-radio label="按百分比"></el-radio>
-					<el-radio label="按金额"></el-radio>
+			<el-form-item label="涨价方式" prop="riseType">
+				<el-radio-group v-model="form.riseType">
+					<el-radio label="0">按百分比</el-radio>
+					<el-radio label="1">按金额</el-radio>
 				</el-radio-group>
 			</el-form-item>
-			<template v-if="true">
-				<el-form-item label="比例" prop="resource">
-					<el-input v-model="form.name" placeholder="涨价10%,请输入10"></el-input>
+			<template v-if="form.riseType == 0">
+				<el-form-item label="比例" prop="riseAmount">
+					<el-input
+						v-model="form.riseAmount"
+						style="width: 250px"
+						placeholder="涨价10%,请输入10"
+					></el-input>
 				</el-form-item>
 			</template>
 			<template v-else>
-				<el-form-item label="金额" prop="resource">
-					<el-input v-model="form.name" placeholder="涨价80元请输入80"></el-input>
+				<el-form-item label="金额" prop="riseAmount">
+					<el-input
+						v-model="form.riseAmount"
+						style="width: 250px"
+						placeholder="涨价80元请输入80"
+					></el-input>
 				</el-form-item>
 			</template>
 			<el-form-item>
@@ -36,7 +49,7 @@
 				</div>
 			</el-form-item>
 			<el-form-item>
-				<el-button @click="resetForm('form')">重置</el-button>
+				<!-- <el-button @click="resetForm('form')">重置</el-button> -->
 				<el-button type="primary" @click="submitForm('form')">保存</el-button>
 			</el-form-item>
 		</el-form>
@@ -44,6 +57,7 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex';
 export default {
 	name: 'auto-price',
 	data() {
@@ -57,6 +71,9 @@ export default {
 			rules: {}
 		};
 	},
+	computed: {
+		...mapGetters({ festData: 'getFestival' })
+	},
 	mounted() {
 		this.init();
 	},
@@ -74,15 +91,15 @@ export default {
 			});
 		},
 		setPrice() {
-			if (this.form.festIdList.length == 0) {
-				this.$message.error('请先选择节日!');
-				return false;
-			}
-			if (!this.form.riseAmount) {
-				this.$message.error('请先输入比例或者金额!');
-				return false;
-			}
-			this.$service.goods.getAutoPrice(this.form).then(res => {
+			// if (this.form.festIdList.length == 0) {
+			// 	this.$message.error('请先选择节日!');
+			// 	return false;
+			// }
+			// if (!this.form.riseAmount) {
+			// 	this.$message.error('请先输入比例或者金额!');
+			// 	return false;
+			// }
+			this.$service.goods.setAutoPrice(this.form).then(res => {
 				this.$message.error('更新成功!');
 			});
 		},

+ 16 - 2
admin-update/src/views/goods/category.vue

@@ -1,6 +1,16 @@
 <template>
 	<div class="app-list-content">
 		<cl-crud class="liu-crud-wrap" @load="onLoad">
+			<template #table-column-img="{scope}">
+				<div>
+					<cl-avatar
+						shape="square"
+						:size="40"
+						:src="scope.row.img | default_avatar"
+						:style="{ margin: 'auto' }"
+					></cl-avatar>
+				</div>
+			</template>
 			<template #table-column-status="{scope}"
 				><el-switch
 					v-model="scope.row.status"
@@ -67,6 +77,7 @@
 </template>
 
 <script>
+import { imgHostUrl } from '@/config/env';
 export default {
 	name: 'goods-category',
 	data() {
@@ -100,6 +111,9 @@ export default {
 			});
 		},
 		addOrModifyFn() {
+			let form = {};
+			form = JSON.parse(JSON.stringify(this.adForm));
+			form.img = this.$util.getShortUrl(form.img);
 			let host = null;
 			if (this.addOrModify == 1) {
 				host = () => {
@@ -109,7 +123,7 @@ export default {
 				host = () => {
 					return this.$service.category.update({
 						categoryId: this.modifyData.id,
-						...this.form
+						form
 					});
 				};
 			}
@@ -120,7 +134,7 @@ export default {
 			});
 		},
 		confirmFn() {
-			this.addOrModify();
+			this.addOrModifyFn();
 		},
 		resetForm() {
 			this.$refs['adForm'].resetFields();

+ 36 - 13
admin-update/src/views/goods/freight-set.vue

@@ -1,44 +1,67 @@
 <template>
 	<div class="app-content setting-freight-wrap">
-		<el-form
-			:model="ruleForm"
-			:rules="rules"
-			ref="ruleForm"
-			label-width="10px"
-			class="demo-ruleForm"
-		>
+		<el-form :model="form" :rules="rules" ref="form" label-width="10px" class="demo-form">
 			<el-form-item>
 				<div class="flex-center">
-					<el-input v-model="ruleForm.name" style="width: 150px"></el-input>
+					<el-input v-model="form.first" style="width: 150px"></el-input>
 					<div class="prompt-text">
 						<!-- <i class="el-icon-warning" style="margin-right: 4px"></i> -->
 						<span>公里内免运费,超过 5 公里每增加1公里,运费增加</span>
 					</div>
-					<el-input v-model="ruleForm.name" style="width: 150px"></el-input>
+					<el-input v-model="form.add" style="width: 150px"></el-input>
 				</div>
 			</el-form-item>
 			<el-form-item>
-				<el-button @click="resetForm('ruleForm')">重置</el-button>
-				<el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
+				<el-button @click="resetForm('form')">重置</el-button>
+				<el-button type="primary" @click="submitForm('form')">保存</el-button>
 			</el-form-item>
 		</el-form>
 	</div>
 </template>
 
 <script>
+import { mapGetters } from 'vuex';
 export default {
 	name: 'setting-freight',
 	data() {
 		return {
-			ruleForm: {},
+			form: {
+				first: '',
+				add: ''
+			},
 			rules: {}
 		};
 	},
+	computed: {
+		...mapGetters({ shopInfo: 'shopInfo' })
+	},
+	watch: {
+		shopInfo() {
+			if (!this.$util.isEmpty(this.shopInfo)) {
+				this.form.first = this.shopInfo.extend.freightFirst;
+				this.form.add = this.shopInfo.extend.freightAdd;
+			}
+		}
+	},
+	mounted() {
+		this.init();
+	},
 	methods: {
+		init() {
+			if (!this.$util.isEmpty(this.shopInfo)) {
+				this.form.first = this.shopInfo.extend.freightFirst;
+				this.form.add = this.shopInfo.extend.freightAdd;
+			}
+		},
+		_updateFn() {
+			this.$service.single.setFreight(this.form).then(res => {
+				this.$message.success('更新成功!');
+			});
+		},
 		submitForm(formName) {
 			this.$refs[formName].validate(valid => {
 				if (valid) {
-					alert('submit!');
+					this._updateFn();
 				} else {
 					console.log('error submit!!');
 					return false;