liujd 6 лет назад
Родитель
Сommit
30c5dbcfa8

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

@@ -64,3 +64,52 @@ export const shortUrlB = data => {
 export const sendShortUrlB = data => {
 	return https.get('/goods/send-short-url', data)
 }
+
+/** *
+ * 商品用途-列表(无分页) b
+ */
+export const usageListB = data => {
+	return https.get('/usage/list', data)
+}
+
+/** *
+ * 商品分类-列表(无分页) b
+ */
+export const categoryListB = data => {
+	return https.get('/category/list', data)
+}
+
+/** *
+ * 商品分类-查看 b
+ */
+export const categoryDetB = data => {
+	return https.get('/category/detail', data)
+}
+
+/** *
+ * 商品分类-添加 b
+ */
+export const categoryAddB = data => {
+	return https.post('/category/add', data)
+}
+
+/** *
+ * 商品分类-更新 b
+ */
+export const categoryUpdateB = data => {
+	return https.post('/category/update', data)
+}
+
+/** *
+ * 商品分类-更新 b
+ */
+export const categoryDelB = data => {
+	return https.get('/category/delete', data)
+}
+
+/** *
+ * 商品分类-启用停用 b
+ */
+export const categoryStatusB = data => {
+	return https.get('/category/change-status', data)
+}

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

@@ -0,0 +1,50 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+/** *
+ * 图库-列表 b
+ */
+export const getListB = data => {
+	return https.get('/pic/list', data)
+}
+
+/** *
+ * 图库-查看 b
+ */
+export const getDetB = data => {
+	return https.get('/pic/detail', data)
+}
+
+/** *
+ * 图库-上传图片 b
+ */
+export const picAdd = data => {
+	return https.post('/pic/add', data)
+}
+
+/** *
+ * 图库-上传成功后备注;修改备注;  b
+ */
+export const picRemark = data => {
+	return https.post('/pic/remark', data)
+}
+
+/** *
+ * 图库-删除 b
+ */
+export const picDel = data => {
+	return https.post('/pic/delete', data)
+}
+
+/** *
+ * 图库-置顶 b
+ */
+export const picTop = data => {
+	return https.post('/pic/top', data)
+}
+
+/** *
+ * 图库-置顶 b
+ */
+export const picToWx = data => {
+	return https.post('/pic/send-to-wx', data)
+}

+ 1 - 1
mobile-code/src/mixins/list.js

@@ -44,7 +44,7 @@ export default {
 		},
 		completes(res, listKey) {
 			this.list.loading = false
-			if (res.status !== 'success') {
+			if (res.code !== 1) {
 				this.list.finished = true
 			}
 			this.list.data = this.list.page === 1

+ 2 - 2
mobile-code/src/pages/ad/list.vue

@@ -133,7 +133,7 @@ export default {
 			uni.stopPullDownRefresh()
 		}
 	},
-	onLoad: function() {
+	onLoad() {
 		this.init()
 	},
 	methods: {
@@ -157,7 +157,7 @@ export default {
 		},
 		// 操作按钮
 		operateFn(item, index) {
-			if (this.operateShow) {
+			if (this.operateIndex == index) {
 				this.operateCloseFn()
 			} else {
 				this.operateData = item

+ 6 - 2
mobile-code/src/pages/admin/components/module/operate-line.vue

@@ -1,6 +1,6 @@
 <template>
 	<div class="operate-line-module" :class="[isModify ? 'witer' : 'back']" :style="{bottom: bottom + 'rpx', left: left + 'rpx'}">
-		<div class="operate-list" :style="{height: listHei + 'rpx'}" v-for="(item, index) in btnData" :key="index" @click="clickFn(index)">
+		<div class="operate-list" :style="{height: listHei + 'rpx'}" v-for="(item, index) in btnData" :key="index" @click="clickFn(item, index)">
 			<div v-if="isModify" class="icon-del" @click.stop="delFn(index)">
 				<i class="iconfont iconguanbi"></i>
 			</div>
@@ -47,7 +47,11 @@ export default {
 		delFn(index) {
 			this.$emit('del', index + 1)
 		},
-		clickFn(index) {
+		clickFn(item, index) {
+			if (item.click) {
+				item.click()
+				return false
+			}
 			this.$emit('clickFn', index + 1)
 		}
 	}

+ 212 - 40
mobile-code/src/pages/goodsManage/category.vue

@@ -2,40 +2,48 @@
 	<div class="app-content">
 		<!-- list -->
 		<div class="list-wrap">
-			<div class="list" v-for="(item, index) in 10" :key="index">
-				<div class="list-index">1</div>
-				<div class="list-img">
-					<img src="../../static/images/extension.png" alt mode="center" />
-				</div>
-				<div class="list-det">
-					<div class="app-size-28 app-color-0">天使美人</div>
-					<div>红色</div>
-					<div class="list-operate">
-						<div class="operate-det">
-							<span>商品数: 19</span>
-							<span>销量: 1982</span>
-						</div>
-						<div class="operate-icon-wrap">
-							<div class="operate-icon">
-								<i class="iconfont" :class="[ index == 0 ? 'iconcaozuojihuo' : 	'iconcaozuo']"></i>
+			<block v-if="!$util.isEmpty(list.data)">
+				<div class="list" v-for="(item, index) in list.data" :key="index">
+					<div class="list-index">{{ item.inTurn }}</div>
+					<div class="list-img">
+						<img :src="item.img" alt="分类图" mode="center" />
+					</div>
+					<div class="list-det">
+						<div class="app-size-28 app-color-0">{{ item.categoryName || '暂无' }}</div>
+						<div>{{ item.description || '暂无' }}</div>
+						<div class="list-operate">
+							<div class="operate-det">
+								<span>商品数: {{ item.goodsNum }}</span>
+								<span>销量: {{ item.sold }}</span>
+								<span :style="{color: item.status == 1 ? '#049E2C' : '#ff6900'}">{{ item.status == 1? '启用' : '禁用' }}</span>
+							</div>
+							<div class="operate-icon-wrap" @click="operateFn(item, index)">
+								<div class="operate-icon">
+									<i class="iconfont" :class="[ index == operateIndex ? 'iconcaozuojihuo' : 	'iconcaozuo']"></i>
+								</div>
 							</div>
 						</div>
 					</div>
 				</div>
-			</div>
+				<!-- operate -->
+				<operate-module v-show="operateShow" :top="operateTop" :right="30" :btnData="btnData" />
+			</block>
+			<block v-else>
+				<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
+			</block>
 		</div>
 		<!-- button -->
 		<div class="app-footer">
-			<button class="admin-button-com middle blue" @click="$util.pageTo('/pages/goodsManage/add')">添加分类</button>
+			<button class="admin-button-com middle blue" @click="addCategoryFn">添加分类</button>
 		</div>
 		<!-- modify -->
-		<modal-module :show="modifyModal" @cancel="modalCancel" @click="modalClick" title="编辑" padding="30rpx 30rpx">
+		<modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="modifyModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
 			<template v-slot:content>
 				<div class="app-modal-input-wrap modify-modal">
 					<div class="inp-list-line">
 						<div class="line-label">分类名称</div>
 						<div class="line-input">
-							<input type="text" :adjust-position="false" class="inp-input" placeholder="填价格,图片可当商品卖(选填)" />
+							<input type="text" v-model="modifyForm.categoryName" :adjust-position="false" class="inp-input" placeholder="填价格,图片可当商品卖(选填)" />
 						</div>
 					</div>
 					<div class="inp-list-line">
@@ -47,20 +55,20 @@
 					<div class="inp-list-line">
 						<div class="line-label">排序</div>
 						<div class="line-input">
-							<input type="text" :adjust-position="false" class="inp-input" placeholder="默认排序最新在前面" />
+							<input type="text" v-model="modifyForm.inTurn" :adjust-position="false" class="inp-input" placeholder="默认排序最新在前面" />
 						</div>
 					</div>
 					<div class="inp-list-line switch-wrap">
 						<div class="line-label">启用状态</div>
 						<div class="line-input flex-strat">
-							<switch checked @change="switchChangeFn" />
+							<switch :checked="modifyForm.status == '0' ? false : true" @change="switchChangeFn" />
 						</div>
 					</div>
 				</div>
 			</template>
 		</modal-module>
-		<!-- operate -->
-		<operate-module v-show="true" :top="176" :right="30" :btnData="btnData" />
+		<!-- 删除提示 -->
+		<modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除该分类吗?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
 	</div>
 </template>
 
@@ -68,54 +76,216 @@
 import ModalModule from '@/components/plugin/modal'
 import AppUploader from '@/components/app-uploader'
 import OperateModule from '@/pages/admin/components/module/operate'
+import AppWrapperEmpty from '@/components/app-wrapper-empty'
+import { list } from '@/mixins'
+// api
+import { categoryListB, categoryStatusB, categoryAddB, categoryUpdateB, categoryDelB } from '@/api/goods'
 export default {
 	name: 'category-manage',
 	components: {
 		ModalModule,
 		AppUploader,
-		OperateModule
+		OperateModule,
+		AppWrapperEmpty
 	},
+	mixins: [list],
 	data() {
 		return {
 			modifyModal: false,
+			modifyTitle: '添加',
+			modifyForm: {
+				categoryName: '',
+				img: '',
+				inTurn: 0,
+				status: 1
+			},
+			// 删除弹窗
+			delModal: false,
 			imgList: [],
-			btnData: [
+			// operate
+			operateShow: false,
+			operateData: {},
+			operateIndex: null,
+			operateTop: 0
+		}
+	},
+	computed: {
+		btnData() {
+			return [
 				{
 					text: '编辑',
 					icon: 'iconbianji',
 					click: () => {
-						this.operateDelFn()
+						// this.operateShow = false
+						this.modifyModal = true
+						this.modifyTitle = '编辑'
+
+						this.modifyForm = {
+							categoryName: this.operateData.categoryName,
+							img: this.operateData.img,
+							inTurn: this.operateData.inTurn,
+							status: this.operateData.status
+						}
 					}
 				},
 				{
-					text: '启用',
-					icon: true ? 'iconqiyong' : 'iconjinyong',
+					text: this.operateData.status == 1 ? '禁用' : '启用',
+					icon: this.operateData.status == 1 ? 'iconjinyong' : 'iconqiyong',
 					click: () => {
-						this.operateDelFn()
+						this.changeStatusFn()
 					}
 				},
 				{
-					text: '编辑',
+					text: '删除',
 					icon: 'iconshanchu1',
 					click: () => {
-						this.operateDelFn()
-					}
-				},
-				{
-					text: '分享',
-					icon: 'iconfenxiang1',
-					click: () => {
-						this.operateDelFn()
+						this.operateCancle()
+						this.delModal = true
 					}
 				}
+				// {
+				// 	text: '分享',
+				// 	icon: 'iconfenxiang1',
+				// 	click: () => {
+				// 		this.$msg('功能开发中...')
+				// 	}
+				// }
 			]
 		}
 	},
+	onPullDownRefresh() {
+		this.resetList()
+		this._list().then(res => {
+			uni.stopPullDownRefresh()
+		})
+	},
+	onReachBottom() {
+		if (this.list.data.length < this.list.total) {
+			this._list().then(res => {
+				uni.stopPullDownRefresh()
+			})
+		} else {
+			uni.stopPullDownRefresh()
+		}
+	},
+	onLoad() {
+		this.init()
+	},
 	methods: {
+		async init() {
+			this._list()
+		},
+		_list() {
+			return categoryListB().then(res => {
+				let data = {
+					code: res.code,
+					msg: res.msg,
+					data: {
+						list: res.data
+					}
+				}
+				this.completes(data)
+			})
+		},
+		_categoryAddB() {
+			categoryAddB({
+				...this.modifyForm
+			}).then(res => {
+				this.$msg('新增成功!')
+				this.modalCancel()
+				this.operateCancle()
+				setTimeout(() => {
+					this.resetList()
+					this._list()
+				}, 1000)
+			})
+		},
+		_categoryUpdateB() {
+			categoryUpdateB({
+				categoryId: this.operateData.id,
+				...this.modifyForm
+			}).then(res => {
+				this.$msg('修改成功!')
+				this.modalCancel()
+				this.operateCancle()
+				setTimeout(() => {
+					this.resetList()
+					this._list()
+				}, 1000)
+			})
+		},
+		// 操作
+		addCategoryFn() {
+			this.resetForm()
+			this.modifyModal = true
+			this.modifyTitle = '新增'
+		},
+		resetForm() {
+			this.modifyForm = {
+				categoryName: '',
+				img: '',
+				inTurn: 0,
+				status: 1
+			}
+		},
+		modifyModalClick(e) {
+			if (e.index === 0) {
+				this.modalCancel()
+			} else {
+				if (this.modifyTitle == '编辑') {
+					this._categoryUpdateB()
+				} else {
+					this._categoryAddB()
+				}
+			}
+		},
 		modalCancel() {
+			this.delModal = false
 			this.modifyModal = false
 		},
-		switchChangeFn() {}
+		switchChangeFn(e) {
+			this.modifyForm.status = e.detail.value ? 1 : 0
+		},
+		delModalClick(e) {
+			if (e.index === 0) {
+				this.modalCancel()
+			} else {
+				categoryDelB({ categoryId: this.operateData.id }).then(res => {
+					this.modalCancel()
+					this.operateCancle()
+					this.$msg('删除成功!')
+					this.resetList()
+					this._list()
+				})
+			}
+		},
+		// operate
+		operateFn(item, index) {
+			if (this.operateIndex == index) {
+				this.operateCancle()
+			} else {
+				this.operateData = item
+				this.operateIndex = index
+				this.operateShow = true
+				this.operateTop = (index + 1) * 191
+			}
+		},
+		operateCancle() {
+			this.operateData = {}
+			this.operateIndex = null
+			this.operateShow = false
+		},
+		changeStatusFn() {
+			let status = this.operateData.status == 1 ? 0 : 1
+			categoryStatusB({
+				categoryId: this.operateData.id,
+				status: status
+			}).then(res => {
+				this.list.data[this.operateIndex].status = status
+				this.operateCancle()
+				this.$msg('操作成功!')
+			})
+		}
 	}
 }
 </script>
@@ -127,8 +297,10 @@ export default {
 	}
 	// list
 	.list-wrap {
+		position: relative;
 		background-color: #fff;
 		.list {
+			height: 130px;
 			@include disFlex(center, flex-start);
 			padding: 30px 0;
 			margin: 0 30px;

+ 72 - 19
mobile-code/src/pages/goodsManage/img-store.vue

@@ -12,9 +12,7 @@
 				<template v-slot:dropdownbox>
 					<div class="sel-list-wrap">
 						<scroll-view scroll-y class="tui-dropdown-scroll">
-							<div class="sel-list">花束</div>
-							<div class="sel-list">花盒</div>
-							<div class="sel-list">开业花篮</div>
+							<div class="sel-list" v-for="(item, index) in categoryData" :key="index">{{ item.categoryName }}</div>
 						</scroll-view>
 					</div>
 				</template>
@@ -26,27 +24,32 @@
 		</div>
 		<!-- list -->
 		<div class="list-wrap">
-			<div class="list" v-for="(item, index) in 10" :key="index">
-				<div class="list-img">
-					<img src="../../static/images/extension.png" alt="" mode="widthFix" >
-				</div>
-				<div class="list-det">
-					<div class="app-size-28">天使没人</div>
-					<div class="flex-center-between">
-						<div v-if="index == 4" class="app-price">¥8551</div>
-						<div v-else class="app-color-3">暂无</div>
-						<div class="operate-icon-wrap">
-							<div class="operate-icon">
-								<i class="iconfont" :class="[ operateIndex == index ? 'iconcaozuojihuo' : 'iconcaozuo']"></i>
+			<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" />
+					</div>
+					<div class="list-det">
+						<div class="app-size-28">{{ item.name }}</div>
+						<div class="flex-center-between">
+							<div v-if="index == 4" class="app-price">¥{{ item.price }}</div>
+							<div v-else class="app-color-3">暂无</div>
+							<div class="operate-icon-wrap" @click="operateFn(item, index)">
+								<div class="operate-icon">
+									<i class="iconfont" :class="[ operateIndex == index ? 'iconcaozuojihuo' : 'iconcaozuo']"></i>
+								</div>
 							</div>
 						</div>
 					</div>
 				</div>
-			</div>
+			</block>
+			<block v-else>
+				<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
+			</block>
 		</div>
 		<!-- button -->
 		<div class="app-footer">
-			<button class="admin-button-com middle default">查看分类</button>
+			<button class="admin-button-com middle default" @click="$util.pageTo('/pages/goodsManage/category')">查看分类</button>
 			<button class="admin-button-com middle blue">新增</button>
 		</div>
 		<!-- 图片上传成功弹窗! -->
@@ -93,14 +96,22 @@
 </template>
 
 <script>
+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 { list } from '@/mixins'
+// api
+import { getCategory } from '@/utils/config'
+import { getListB } from '@/api/img-store'
 export default {
 	name: 'image-store',
 	components: {
 		ModalModule,
-		DropdownList
+		DropdownList,
+		AppWrapperEmpty
 	},
+	mixins: [list],
 	data() {
 		return {
 			dropdownShow: false,
@@ -128,12 +139,51 @@ export default {
 				{
 					name: '其它'
 				}
-			]
+			],
+			// operate
+			operateIndex: null,
+			operateShow: false,
+			operateData: {},
+			operateTop: 0
 		}
 	},
+	computed: {
+		...mapGetters({ categoryData: 'getCategory' })
+	},
+	onLoad() {
+		this.init()
+	},
 	methods: {
+		async init() {
+			getCategory()
+			this._list()
+		},
+		_list() {
+			return getListB({
+				categoryId: -1,
+				page: this.list.page
+			}).then(res => {
+				this.completes(res)
+			})
+		},
 		modalCancel() {
 			this.settingModal = false
+		},
+		// operate
+		operateFn(item, index) {
+			if (this.operateIndex == index) {
+				this.operateCancle()
+			} else {
+				this.operateData = item
+				this.operateIndex = index
+				this.operateShow = true
+				this.operateTop = (index + 1) * 191
+			}
+		},
+		operateCancle() {
+			this.operateData = {}
+			this.operateIndex = null
+			this.operateShow = false
 		}
 	}
 }
@@ -181,6 +231,9 @@ export default {
 				// border-top: 1px solid $borderColor;
 			}
 		}
+		.tui-dropdown-scroll {
+			height: 400px;
+		}
 	}
 	// list
 	.list-wrap {

+ 4 - 4
mobile-code/src/pages/goodsManage/list.vue

@@ -30,19 +30,19 @@ export default {
 			operateShow: true,
 			btnData: [
 				{
-					text: '图库管理',
+					name: '图库管理',
 					click: () => this.$util.pageTo('/pages/goodsManage/img-store')
 				},
 				{
-					text: '运费设置',
+					name: '运费设置',
 					click: () => this.$util.pageTo('/pages/goodsManage/freight')
 				},
 				{
-					text: '通用简介',
+					name: '通用简介',
 					click: () => alert('请在电脑端进行设置!')
 				},
 				{
-					text: '自动涨价',
+					name: '自动涨价',
 					click: () => this.$util.pageTo('/pages/goodsManage/price-increase')
 				}
 			]

+ 4 - 0
mobile-code/src/pages/member/add.vue

@@ -44,6 +44,7 @@ import { mapGetters } from 'vuex'
 import TuiListCell from '@/components/plugin/list-cell'
 const form = require('@/utils/formValidation.js')
 // api
+import { getLevel } from '@/utils/config'
 import { add } from '@/api/member'
 export default {
 	name: 'member-add',
@@ -66,6 +67,9 @@ export default {
 	computed: {
 		...mapGetters({ levelData: 'getLevel' })
 	},
+	onLoad() {
+		getLevel()
+	},
 	methods: {
 		confirmFn() {
 			add(this.form).then(res => {

+ 2 - 0
mobile-code/src/pages/member/detail.vue

@@ -140,6 +140,7 @@ import AppVipModule from '@/components/module/app-vip'
 import AppAvatarModule from '@/components/module/app-avatar'
 import ModalModule from '@/components/plugin/modal'
 // api
+import { getLevel } from '@/utils/config'
 import { getUserDet, remarkAdd, remarkDel, upgrade, rechargeB, resetPassword } from '@/api/member'
 // img
 import tabIcon1 from '@/static/images/member/tab-icon-1.png'
@@ -279,6 +280,7 @@ export default {
 	methods: {
 		init() {
 			this._getUserDet()
+			getLevel()
 		},
 		// api
 		_getUserDet() {

+ 37 - 25
mobile-code/src/store/modules/config.js

@@ -1,53 +1,65 @@
+import store from '@/store'
 import UTIL from '@/utils/util'
-import { getLevel } from '@/utils/config'
+import { getLevel, getCategory } from '@/utils/config'
+import {
+	getList as getLevelList
+} from '@/api/level'
 /** 字典配置 */
 const state = {
-	level: {}
+	level: {},
+	category: {}
 }
 
 const getters = {
-	// 基本用户信息
+	// 等级数据
 	getLevel: (state) => {
-		if (!UTIL.isEmpty(state.level)) return state.level
-		let data = {}
-		getLevel().then(res => {
-			data = res
-		})
-		return data
+		return state.level || {}
+	},
+	// 分类数据
+	getCategory: (state) => {
+		return state.category || {}
 	}
 }
 
 const actions = {
 	// 等级信息
 	setLevel({
-		commit,
-		dispatch,
-		getters,
-		rootGetters,
-		rootState,
-		state
+		commit
+	}, data) {
+		commit('SET_LEVEL', data)
+	},
+	delLevel({
+		commit
+	}) {
+		commit('DEL_LEVEL')
+	},
+	// 分类数据
+	setCategory({
+		commit
 	}, data) {
-		commit('SET_BASIC_USER', data)
+		commit('SET_CATEGORY', data)
 	},
 	delLevel({
-		commit,
-		dispatch,
-		getters,
-		rootGetters,
-		rootState,
-		state
+		commit
 	}) {
-		commit('DEL_BASIC_USER')
+		commit('DEL_CATEGORY')
 	}
 }
 
 const mutations = {
 	// 等级信息
-	SET_BASIC_USER(state, data = {}) {
+	SET_LEVEL(state, data = {}) {
 		state.level = data
 	},
-	DEL_BASIC_USER(state) {
+	DEL_LEVEL(state) {
 		state.level = ''
+	},
+	// 分类信息
+	SET_CATEGORY(state, data = {}) {
+		state.category = data
+	},
+	DEL_CATEGORY(state) {
+		state.category = ''
 	}
 }
 

+ 23 - 1
mobile-code/src/utils/config.js

@@ -5,13 +5,16 @@ import UTIL from '@/utils/util'
 import {
 	getList as getLevelList
 } from '@/api/level'
+import {
+	categoryListB as getCategoryList
+} from '@/api/goods'
 
 /**
  * 获取等级列表
  * @parmas update为true时会重新触发请求,重置vuex的数据
  */
 export async function getLevel(update) {
-	let data = store.getters.getSelfUser
+	let data = store.getters.getLevel
 	if (!UTIL.isEmpty(data) && !update) {
 		return data
 	}
@@ -24,3 +27,22 @@ export async function getLevel(update) {
 
 	return data
 }
+
+/**
+ * 获取分类列表
+ * @parmas update为true时会重新触发请求,重置vuex的数据
+ */
+export async function getCategory(update) {
+	let data = store.getters.getCategory
+	if (!UTIL.isEmpty(data) && !update) {
+		return data
+	}
+	await getCategoryList().then(res => {
+		data = res.data
+		store.dispatch('setCategory', data)
+	}).catch(() => {
+		return false
+	})
+
+	return data
+}