liujd 6 лет назад
Родитель
Сommit
208a53f3dd

+ 21 - 0
mobile-code/src/api/goods/index.js

@@ -113,3 +113,24 @@ export const categoryDelB = data => {
 export const categoryStatusB = data => {
 	return https.get('/category/change-status', data)
 }
+
+/** *
+ * 商品管理-运费设置 b
+ */
+export const freightSet = data => {
+	return https.get('/merchant/freight-setting', data)
+}
+
+/** *
+ * 商品管理-涨价设置 b
+ */
+export const getRise = data => {
+	return https.get('/goods/setting', data)
+}
+
+/** *
+ * 商品管理-更新涨价 b
+ */
+export const updateRise = data => {
+	return https.post('/goods/update-rise', data)
+}

+ 2 - 2
mobile-code/src/api/img-store/index.js

@@ -22,7 +22,7 @@ export const picAdd = data => {
 }
 
 /** *
- * 图库-上传成功后备注;修改备注;  b
+ * 图库-上传成功后备注;修改备注;修改价格;  b
  */
 export const picRemark = data => {
 	return https.post('/pic/remark', data)
@@ -43,7 +43,7 @@ export const picTop = data => {
 }
 
 /** *
- * 图库-置顶 b
+ * 图库-发到微信 b
  */
 export const picToWx = data => {
 	return https.post('/pic/send-to-wx', data)

+ 53 - 45
mobile-code/src/components/app-uploader.vue

@@ -1,18 +1,17 @@
 <template>
 	<view>
 		<div class="upload-box">
-			<ul>
-				<li class="list_img" v-for="(item,index) in showImgList" :key="index"
-					:style="{ width: size + 'rpx', height: size + 'rpx' }">
-					<view class="iconfont icondelete" @click="delImg(index)"></view>
-					<image :src="item" @click="viewImg(item)"
-						   :style="{ width: size + 'rpx', height: size + 'rpx' }" :mode="imgMode" ></image>
-				</li>
-				<li v-if="showImgList.length < num" class="uploadImg" @click="chooseImage"
-					:style="{ width: size + 'rpx', height: size + 'rpx' }">
-					<view class="iconfont icontupiantianjia"></view>
-				</li>
-			</ul>
+			<slot>
+				<ul>
+					<li class="list_img" v-for="(item,index) in showImgList" :key="index" :style="{ width: size + 'rpx', height: size + 'rpx' }">
+						<view class="iconfont icondelete" @click="delImg(index)"></view>
+						<img :src="item" @click="viewImg(item)" :style="{ width: size + 'rpx', height: size + 'rpx' }" :mode="imgMode" />
+					</li>
+					<li v-if="showImgList.length < num" class="uploadImg" @click="chooseImage" :style="{ width: size + 'rpx', height: size + 'rpx' }">
+						<view class="iconfont icontupiantianjia"></view>
+					</li>
+				</ul>
+			</slot>
 		</div>
 	</view>
 </template>
@@ -23,7 +22,7 @@ export default {
 	props: {
 		// 传入的图片数组
 		imgList: {
-		    type: Array,
+			type: Array,
 			default: () => []
 		},
 		manualDel: {
@@ -65,11 +64,13 @@ export default {
 			type: Boolean,
 			default: false
 		},
-		multiple: { // 是否多图上传
+		multiple: {
+			// 是否多图上传
 			type: Boolean,
 			default: true
 		},
-		disabled: {  // 是否只读
+		disabled: {
+			// 是否只读
 			type: Boolean,
 			default: false
 		},
@@ -77,11 +78,16 @@ export default {
 		imgMode: {
 			type: String,
 			default: 'scaleToFill'
+		},
+		uploadPicApi: {
+			type: Function,
+			default: uploadPic
 		}
 	},
 	data() {
 		return {
-		    showImgList: [],
+			resultData: {},
+			showImgList: [],
 			base64ImgList: [],
 			xssarr: ['data:', 'text', 'txt', 'html', 'js', 'css', 'json', 'exe', 'sql', 'xml', 'doc', 'docx']
 		}
@@ -111,16 +117,18 @@ export default {
 			await that.blobToBase64(tempFilePaths)
 			await that.autoUploadImg()
 			await that.postMsg()
+			return this.showImgList
 		},
 
 		postMsg() {
 			this.$emit('update:imgList', this.showImgList)
 			this.$emit('chooseImage', this.showImgList)
+			this.$emit('resultData', this.resultData)
 		},
 
 		autoUploadImg() {
-		    let that = this
-		    let base64ImgList = that.base64ImgList
+			let that = this
+			let base64ImgList = that.base64ImgList
 			let params = {}
 			if (base64ImgList.length === 1) {
 				params['file[content]'] = base64ImgList[0]
@@ -130,16 +138,15 @@ export default {
 				})
 			}
 			return new Promise((resolve, reject) => {
-				uploadPic({
+				this.uploadPicApi({
 					...params,
 					relative_path: 1
 				}).then(res => {
-					if (res.status === 'success') {
-						that.showImgList = [
-						    ...that.showImgList,
-							...res.data.image_url.reverse()
-						]
-						this.$emit('currentUpload', res.data.image_url.reverse())
+					if (res.code === 1) {
+						let imgArr = [res.data.url]
+						that.showImgList = [...that.showImgList, ...imgArr]
+						that.resultData = res.data
+						this.$emit('currentUpload', imgArr)
 						this.$emit('getResult', that.showImgList)
 						resolve(that.showImgList)
 					} else {
@@ -184,7 +191,7 @@ export default {
 				// #endif
 			}
 		},
-		 WEIXINb64(blob) {
+		WEIXINb64(blob) {
 			return new Promise((resolve, reject) => {
 				uni.getFileSystemManager().readFile({
 					filePath: blob, // 选择图片返回的相对路径
@@ -206,20 +213,22 @@ export default {
 					'Access-Control-Allow-Origin': '*',
 					'Content-Type': 'text/plain'
 				}),
-				'mode': 'no-cors'
-			}).then(data => {
-				const blob = data.blob()
-				return blob
-			}).then(async(blob) => {
-				let reader = new FileReader()
-				reader.readAsDataURL(blob)
-				return await new Promise((res, reg) => {
-					reader.onloadend = function() {
-						const data = reader.result
-						res(data)
-					}
-				})
+				mode: 'no-cors'
 			})
+				.then(data => {
+					const blob = data.blob()
+					return blob
+				})
+				.then(async blob => {
+					let reader = new FileReader()
+					reader.readAsDataURL(blob)
+					return await new Promise((res, reg) => {
+						reader.onloadend = function() {
+							const data = reader.result
+							res(data)
+						}
+					})
+				})
 		},
 
 		// 上传图片
@@ -252,7 +261,7 @@ export default {
 
 			for (let i = 0; i < tempFiles.length; i++) {
 				// 大于1.5m就不让上传
-				let fileSize =	tempFiles[i].size
+				let fileSize = tempFiles[i].size
 				if (fileSize > 1024 * 1024 * 1.5) {
 					uni.showToast({
 						title: '过滤不能大于1.5m的文件',
@@ -318,14 +327,13 @@ export default {
 			uni.compressImage({
 				src: image,
 				quality: 80,
-				complete: res => {
-				}
+				complete: res => {}
 			})
 		}
 	},
 	watch: {
 		imgList(val) {
-		    console.log('监听')
+			console.log('监听')
 			this.showImgList = [...val]
 		}
 	}
@@ -366,8 +374,8 @@ export default {
 					right: 0;
 					bottom: 0;
 					color: #fff;
-					padding:  0 2px;
-					background-color: rgba(0, 0, 0, .45);
+					padding: 0 2px;
+					background-color: rgba(0, 0, 0, 0.45);
 				}
 			}
 		}

+ 40 - 5
mobile-code/src/pages/goodsManage/freight.vue

@@ -3,27 +3,62 @@
 		<div class="module-com new_wrap">
 			<div class="module-det">
 				<div>
-					<input type="text" class="setting-inp" />
+					<input type="text" v-model="form.first" class="setting-inp" />
 					<span>公里内免运费,超过 5 公里每增加1公里,</span>
 				</div>
 				<div>
 					<span>运费增加</span>
-					<input type="text" class="setting-inp" />
+					<input type="text" v-model="form.add" class="setting-inp" />
 					<span>元。</span>
 				</div>
 			</div>
 		</div>
-		<div class="admin-button-com blue big">确认</div>
+		<div class="admin-button-com blue big" @click="confirmFn">确认</div>
 	</div>
 </template>
 
 <script>
+import { mapGetters, mapState } from 'vuex'
+import { getUser } from '@/utils/auth'
+import { freightSet } from '@/api/goods'
 export default {
 	name: 'setting-freight',
 	data() {
-		return {}
+		return {
+			form: {
+				first: 0,
+				add: 0
+			}
+		}
+	},
+	computed: {
+		...mapGetters({ userInfo: 'getUser' })
 	},
-	methods: {}
+	onLoad() {},
+	mounted() {
+		this.init()
+	},
+	watch: {
+		userInfo() {
+			if (!this.$util.isEmpty(this.userInfo)) {
+				this.form.first = this.userInfo.extend.freightFirst
+				this.form.add = this.userInfo.extend.freightAdd
+			}
+		}
+	},
+	methods: {
+		init() {
+			getUser().then(res => {
+				this.form.first = this.userInfo.extend.freightFirst
+				this.form.add = this.userInfo.extend.freightAdd
+			})
+		},
+		confirmFn() {
+			freightSet(this.form).then(res => {
+				this.$msg('修改成功!')
+			})
+		}
+	}
 }
 </script>
 

+ 40 - 4
mobile-code/src/pages/goodsManage/goods-name.vue

@@ -3,31 +3,67 @@
 		<!-- 商品 -->
 		<div class="prompt-text">客户想买此商品,但没价格,请设置</div>
 		<div class="img-wrap">
-			<img class="goods-img" src="../../static/images/logout.png" mode="widthFix" alt="商品图片" />
+			<img class="goods-img" :src="data.imgUrl" mode="widthFix" alt="商品图片" />
 		</div>
 		<!-- 信息 -->
 		<div class="input-line-wrap">
 			<tui-list-cell class="line-cell" :hover="false">
 				<div class="tui-title">名称</div>
-				<input placeholder-class="phcolor" class="tui-input" name="phone" placeholder="请输入" maxlength="50" type="number" />
+				<input placeholder-class="phcolor" v-model="form.name" class="tui-input" name="name" placeholder="请输入" type="text" />
 			</tui-list-cell>
 			<tui-list-cell class="line-cell" :hover="false">
 				<div class="tui-title">价格</div>
-				<input placeholder-class="phcolor" class="tui-input" name="phone" placeholder="请输入" maxlength="50" type="number" />
+				<input placeholder-class="phcolor" v-model="form.price" class="tui-input" name="price" placeholder="请输入" maxlength="50" type="number" />
 				<div class="tui-prompt">元</div>
 			</tui-list-cell>
 		</div>
 		<!-- button -->
-		<button class="admin-button-com blue big confirm-btn">确定</button>
+		<button class="admin-button-com blue big confirm-btn" @click="confirmFn">确定</button>
 	</div>
 </template>
 
 <script>
 import TuiListCell from '@/components/plugin/list-cell'
+// api
+import { getDetB, picRemark } from '@/api/img-store'
 export default {
 	name: 'goods-name-setting',
 	components: {
 		TuiListCell
+	},
+	data() {
+		return {
+			data: {},
+			form: {
+				picIdList: [],
+				price: 0,
+				name: '',
+				categoryIdList: []
+			}
+		}
+	},
+	onLoad() {
+		this.init()
+	},
+	methods: {
+		init() {
+			this._getDet()
+		},
+		_getDet() {
+			getDetB({ id: this.option.id }).then(res => {
+				if (this.$util.isEmpty(res.data)) return
+				this.data = res.data
+				Object.keys(this.form).forEach((i, index) => {
+					this.form[i] = res.data[i]
+				})
+				console.log(this.form)
+			})
+		},
+		confirmFn() {
+			picRemark(this.form).then(res => {
+				this.$msg('修改成功!')
+			})
+		}
 	}
 }
 </script>

+ 141 - 36
mobile-code/src/pages/goodsManage/img-store.vue

@@ -27,7 +27,7 @@
 			<block v-if="!$util.isEmpty(list.data)">
 				<div class="list" v-for="(item, index) in list.data" :key="index">
 					<div class="list-img">
-						<img :src="item.imgUrl" alt mode="widthFix" />
+						<img :src="item.imgUrl" alt="商品图片" mode="widthFix" />
 					</div>
 					<div class="list-det">
 						<div class="app-size-28">{{ item.name }}</div>
@@ -42,18 +42,23 @@
 						</div>
 					</div>
 				</div>
+				<!-- 操作 -->
+				<operate-module v-show="operateShow" :top="operateTop" :right="operateRight" :btnData="btnData" />
 			</block>
 			<block v-else>
 				<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
 			</block>
 		</div>
+		<app-uploader :multiple="false" ref="appUploader" :uploadPicApi="picAdd" @resultData="chooseImage" :imgList.sync="form.picIdList">
+			<span></span>
+		</app-uploader>
 		<!-- button -->
 		<div class="app-footer">
 			<button class="admin-button-com middle default" @click="$util.pageTo('/pages/goodsManage/category')">查看分类</button>
-			<button class="admin-button-com middle blue">新增</button>
+			<button class="admin-button-com middle blue" @click="$refs.appUploader.chooseImage()">新增</button>
 		</div>
 		<!-- 图片上传成功弹窗! -->
-		<modal-module :show="settingModal" :custom="true" @cancel="modalCancel" @click="modalClick" padding="30rpx 30rpx">
+		<modal-module :show="settingModal" :custom="true" width="92%" @cancel="modalCancel" @click="modalClick" padding="30rpx 30rpx">
 			<template>
 				<div class="upload-confirm-wrap">
 					<!--  -->
@@ -65,7 +70,9 @@
 					<div class="sel-wrap">
 						<div class="sel-tit">选择分类(可多选)</div>
 						<div class="sel-btn">
-							<button class="admin-button-com" :class="[index == 2 ? 'default' : '']" v-for="(item, index) in selBtnData" :key="index">{{ item.name }}</button>
+							<block v-for="(item, index) in categoryData" :key="index">
+								<button class="admin-button-com" :class="[form.categoryIdList.includes(item.id) ? '' : 'default']" @click="selCategoryFn(item)">{{ item.categoryName || '暂无' }}</button>
+							</block>
 						</div>
 					</div>
 					<!-- 输入框 -->
@@ -73,25 +80,27 @@
 						<div class="inp-list-line">
 							<div class="line-label">售价</div>
 							<div class="line-input">
-								<input type="text" class="inp-input" placeholder="填价格,图片可当商品卖(选填)" />
+								<input type="text" v-model="form.price" class="inp-input" placeholder="填价格,图片可当商品卖(选填)" />
 								<div class="inp-prompt">元</div>
 							</div>
 						</div>
 						<div class="inp-list-line">
 							<div class="line-label">名称</div>
 							<div class="line-input">
-								<input type="text" class="inp-input" placeholder="选填" />
+								<input type="text" v-model="form.name" class="inp-input" placeholder="选填" />
 							</div>
 						</div>
 					</div>
 					<!-- button -->
 					<div class="redeem-btn">
 						<button class="admin-button-com default big" @click="modalCancel">取消</button>
-						<button class="admin-button-com blue big">确定</button>
+						<button class="admin-button-com blue big" @click="saveFn">确定</button>
 					</div>
 				</div>
 			</template>
 		</modal-module>
+		<!-- 删除提示 -->
+		<modal-module :show="delModal" @cancel="modalCancel" @click="delModalClick" content="确定删除该广告吗?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
 	</div>
 </template>
 
@@ -100,51 +109,83 @@ import { mapGetters } from 'vuex'
 import ModalModule from '@/components/plugin/modal'
 import DropdownList from '@/components/plugin/dropdown-list'
 import AppWrapperEmpty from '@/components/app-wrapper-empty'
+import AppUploader from '@/components/app-uploader'
+import OperateModule from '@/pages/admin/components/module/operate'
 import { list } from '@/mixins'
 // api
 import { getCategory } from '@/utils/config'
-import { getListB } from '@/api/img-store'
+import { getListB, picRemark, picAdd, picDel, picTop } from '@/api/img-store'
 export default {
 	name: 'image-store',
 	components: {
 		ModalModule,
 		DropdownList,
-		AppWrapperEmpty
+		AppWrapperEmpty,
+		AppUploader,
+		OperateModule
 	},
 	mixins: [list],
 	data() {
 		return {
+			picAdd: picAdd,
+			listHei: 76,
+			// modal
+			imgList: [],
+			form: {
+				picIdList: [],
+				price: '',
+				name: '',
+				categoryIdList: []
+			},
 			dropdownShow: false,
 			settingModal: false,
-			// modal 选择分类
-			selBtnData: [
-				{
-					name: '花束/花盒'
-				},
-				{
-					name: '花篮'
-				},
-				{
-					name: '散花'
-				},
+			// ==
+			delModal: false,
+			// operate
+			operateIndex: null,
+			operateShow: false,
+			operateData: {},
+			operateTop: 0,
+			operateRight: 30,
+			btnData: [
 				{
-					name: '绿树'
+					text: '编辑',
+					icon: 'iconbianji',
+					click: () => {
+						this.modalCancel()
+						this.form.picIdList = [this.operateData.id]
+						this.settingModal = true
+					}
 				},
 				{
-					name: '永生花'
+					text: '置顶',
+					icon: 'iconxiajia',
+					click: () => {
+						picTop({ id: this.operateData.id }).then(res => {
+							this.operateCloseFn()
+							this.$msg('置顶成功!')
+							setTimeout(() => {
+								this.resetList()
+								this._list()
+							}, 1000)
+						})
+					}
 				},
 				{
-					name: '婚车/手捧'
+					text: '删除',
+					icon: 'iconshanchu1',
+					click: () => {
+						this.delModal = true
+					}
 				},
 				{
-					name: '其它'
+					text: '分享',
+					icon: 'iconfenxiang1',
+					click: () => {
+						this.delModal = true
+					}
 				}
-			],
-			// operate
-			operateIndex: null,
-			operateShow: false,
-			operateData: {},
-			operateTop: 0
+			]
 		}
 	},
 	computed: {
@@ -154,6 +195,13 @@ export default {
 		this.init()
 	},
 	methods: {
+		// 获取高度
+		getListHei(dom) {
+			let listDom = uni.createSelectorQuery().select(dom)
+			listDom.boundingClientRect(data => {
+				this.listHei = data.height
+			}).exec()
+		},
 		async init() {
 			getCategory()
 			this._list()
@@ -164,10 +212,61 @@ export default {
 				page: this.list.page
 			}).then(res => {
 				this.completes(res)
+				setTimeout(() => {
+					this.getListHei('.list')
+				}, 1000)
+			})
+		},
+		saveFn() {
+			picRemark(this.form).then(res => {
+				this.$msg('操作成功!')
+				this.modalCancel()
+				this.operateCancle()
+				setTimeout(() => {
+					this.resetList()
+					this._list()
+				}, 1000)
 			})
 		},
+		// 操作
+		selCategoryFn(item) {
+			let index = this.form.categoryIdList.findIndex(e => e == item.id)
+			if (index == -1) {
+				this.form.categoryIdList.push(item.id)
+			} else {
+				this.form.categoryIdList.splice(index, 1)
+			}
+		},
+		// 图片上传成功
+		chooseImage(e) {
+			console.log('图片上传成功', e)
+			this.form.picIdList = [e.id]
+			this.settingModal = true
+		},
 		modalCancel() {
+			this.delModal = false
 			this.settingModal = false
+			this.form = {
+				picIdList: [],
+				price: '',
+				name: '',
+				categoryIdList: []
+			}
+		},
+		delModalClick(e) {
+			if (e.index === 0) {
+				this.modalCancel()
+			} else {
+				picDel({ id: this.operateData.id }).then(res => {
+					this.modalCancel()
+					this.operateCancle()
+					this.$msg('删除成功!')
+					setTimeout(() => {
+						this.resetList()
+						this._list()
+					}, 1000)
+				})
+			}
 		},
 		// operate
 		operateFn(item, index) {
@@ -177,7 +276,9 @@ export default {
 				this.operateData = item
 				this.operateIndex = index
 				this.operateShow = true
-				this.operateTop = (index + 1) * 191
+				this.operateTop = (index + 1) * (this.listHei + 10)
+				let rightIndex = (index + 1) % 3
+				this.operateRight = rightIndex == 0 ? 20 : rightIndex == 1 ? 348 : 160
 			}
 		},
 		operateCancle() {
@@ -239,11 +340,15 @@ export default {
 	.list-wrap {
 		@include disFlex(flex-start, flex-start);
 		flex-wrap: wrap;
+		position: relative;
 		.list {
 			width: 30%;
 			margin-left: 2.5%;
 			margin-bottom: 20px;
 			background-color: #fff;
+			.list-img {
+				min-width: 224px;
+			}
 			.list-det {
 				padding: 10px;
 				& > div {
@@ -284,15 +389,15 @@ export default {
 				flex-wrap: wrap;
 				padding: 10px 0 40px;
 				.admin-button-com {
-					width: 170px;
-					margin-left: 20px;
+					// width: 170px;
+					margin-right: 20px;
 					margin-top: 20px;
 					padding-top: 16px;
 					padding-bottom: 16px;
 					border-radius: 4px;
-					&:nth-child(3n + 1) {
-						margin-left: 0;
-					}
+					// &:nth-child(3n + 1) {
+					// 	margin-left: 0;
+					// }
 				}
 			}
 		}

+ 1 - 1
mobile-code/src/static/css/common.scss

@@ -282,7 +282,7 @@ body {
         left: -18px;
         padding: 20px;
         .iconcaozuojihuo {
-            color: $mainColor;
+            color: $mainColor !important;
         }
     }
 }