lalala 6 years ago
parent
commit
a4a3118de7

+ 192 - 174
mobile-code/src/admin/ad/add.vue

@@ -9,7 +9,7 @@
 				</tui-list-cell>
 				<tui-list-cell class="line-cell" :arrow="true">
 					<div class="tui-title required">开始时间</div>
-					<picker mode="date" :value="form.startTime" @change="startTimeFn"  class="tui-input">
+					<picker mode="date" :value="form.startTime" @change="startTimeFn" class="tui-input">
 						<input v-model="form.startTime" name="startTime" type="text" hidden />
 						<div v-if="form.startTime">{{ form.startTime }}</div>
 						<div class="tui-placeholder" v-else>请选择</div>
@@ -89,191 +89,209 @@
 </template>
 
 <script>
-import TuiListCell from '@/components/plugin/list-cell'
-import AppUploader from '@/components/app-uploader'
-import AppDatePicker from '@/components/app-date-picker'
-const form = require('@/utils/formValidation.js')
-// api
-import { getDet, add, update } from '@/api/ad'
-import { getDetailB as getGoodsDet } from '@/api/goods'
-export default {
-	name: 'ad-add',
-	components: {
-		TuiListCell,
-		AppUploader,
-		AppDatePicker
-	},
-	data() {
-		return {
-			form: {
-				adName: '',
-				adImg: [],
-				status: 0,
-				inTurn: '1',
-				type: 0,
-				style: 0,
-				url: '',
-				goodsId: '',
-				startTime: 0,
-				endTime: 0
-			},
-			// imgList: [],
-			goodsData: {}
-		}
-	},
-	computed: {
-		adImgStr() {
-			// let img = JSON
-			return this.form.adImg.join()
-		}
-	},
-	onLoad(option) {
-		this.setPageTitle()
-		// this.init()
-	},
-	methods: {
-		init() {
-			this.type = this.option.type
-
-			let data = uni.getStorageSync('addAdData')
-			if (data) {
-				uni.removeStorageSync('addAdData')
-				setTimeout(() => {
-					this.form = data.form
-					// this.imgList = data.imgList
-				})
-				this.goodsData = data.goodsData
-			}
-			let goodsData = uni.getStorageSync('adSelGoods')
-			if (goodsData) {
-				uni.removeStorageSync('adSelGoods')
-				this.goodsData = goodsData
-				this.goodsId = goodsData.id
+	import TuiListCell from '@/components/plugin/list-cell'
+	import AppUploader from '@/components/app-uploader'
+	import AppDatePicker from '@/components/app-date-picker'
+	const form = require('@/utils/formValidation.js')
+	// api
+	import { getDet, add, update } from '@/api/ad'
+	import { getDetailB as getGoodsDet } from '@/api/goods'
+	export default {
+		name: 'ad-add',
+		components: {
+			TuiListCell,
+			AppUploader,
+			AppDatePicker
+		},
+		data() {
+			return {
+				form: {
+					adName: '',
+					adImg: [],
+					status: 0,
+					inTurn: '1',
+					type: 0,
+					style: 0,
+					url: '',
+					goodsId: '',
+					startTime: 0,
+					endTime: 0
+				},
+				// imgList: [],
+				goodsData: {}
 			}
-
-			if (this.option.id && !data) {
-				this._getDet()
+		},
+		computed: {
+			adImgStr() {
+				// let img = JSON
+				if (this.$util.isArray(this.form.adImg)) {
+					return this.form.adImg.join()
+				} else {
+					return this.form.adImg
+				}
 			}
 		},
-		setPageTitle() {
-			if (this.option.id) {
-				uni.setNavigationBarTitle({
-      				title: this.option.type == 0 ? '修改门店轮播图' : '修改商城首页轮播图'
+		onLoad(option) {
+			this.setPageTitle()
+			// this.init()
+		},
+		methods: {
+			init() {
+				this.type = this.option.type
+
+				let data = uni.getStorageSync('addAdData')
+				if (data) {
+					uni.removeStorageSync('addAdData')
+					setTimeout(() => {
+						this.form = data.form
+						// this.imgList = data.imgList
+					})
+					this.goodsData = data.goodsData
+					this.getFormAdImg(data.goodsData)
+				}
+				let goodsData = uni.getStorageSync('adSelGoods')
+				if (goodsData) {
+					uni.removeStorageSync('adSelGoods')
+					this.goodsData = goodsData
+					this.goodsId = goodsData.id
+					this.getFormAdImg(data.goodsData)
+				}
+
+				if (this.option.id && !data) {
+					this._getDet()
+				}
+			},
+			setPageTitle() {
+				if (this.option.id) {
+					uni.setNavigationBarTitle({
+						title: this.option.type == 0 ? '修改门店轮播图' : '修改商城首页轮播图'
+					})
+				} else {
+					uni.setNavigationBarTitle({
+						title: this.option.type == 0 ? '添加门店轮播图' : '添加商城首页轮播图'
+					})
+				}
+			},
+			getFormAdImg(data) {
+				if (this.$util.isArray(data.adImg)) {
+					this.form.adImg = data.adImg
+				} else {
+					this.form.adImg = [data.adImg]
+				}
+			},
+			// api
+			_getDet() {
+				getDet({ id: this.option.id }).then(res => {
+					if (this.$util.isEmpty(res.data)) return
+					Object.keys(this.form).forEach((i, index) => {
+						if (i == 'adImg') {
+							this.form.adImg = [res.data.adImgUrl]
+						} else {
+							this.form[i] = res.data[i]
+						}
+					})
+
+					this.form.startTime = this.$util.$formatDate(this.form.startTime, 'YYYY-MM-DD')
+					this.form.endTime = this.$util.$formatDate(this.form.endTime, 'YYYY-MM-DD')
+
+					if (this.form.style && this.form.style != '0') {
+						this._getGoodsDet()
+					}
 				})
-			} else {
-				uni.setNavigationBarTitle({
-      				title: this.option.type == 0 ? '添加门店轮播图' : '添加商城首页轮播图'
+			},
+			// 获取商品详情
+			_getGoodsDet() {
+				getGoodsDet({ id: this.form.goodsId }).then(res => {
+					if (this.$util.isEmpty(res.data)) return
+					this.goodsData = res.data
 				})
-			}
-		},
-		// api
-		_getDet() {
-			getDet({ id: this.option.id }).then(res => {
-				if (this.$util.isEmpty(res.data)) return
-				Object.keys(this.form).forEach((i, index) => {
-					this.form[i] = res.data[i]
+			},
+			// 操作
+			// 选择商品
+			selGoodsFn() {
+				let data = {
+					form: this.form,
+					// imgList: this.imgList,
+					goodsData: this.goodsData
+				}
+				uni.setStorageSync('addAdData', data)
+				this.$util.pageTo({
+					url: '/admin/ad/sel-goods',
+					query: {
+						...this.option
+					}
 				})
-				this.form.startTime = this.$util.$formatDate(this.form.startTime, 'YYYY-MM-DD')
-				this.form.endTime = this.$util.$formatDate(this.form.endTime, 'YYYY-MM-DD')
-
-				if (this.form.style) {
-					this._getGoodsDet()
+			},
+			startTimeFn(e) {
+				console.log(e)
+				this.form.startTime = e.detail.value
+			},
+			endTimeFn(e) {
+				this.form.endTime = e.detail.value
+			},
+			switchChangeFn(e) {
+				this.form.status = e.target.value ? 1 : 0
+			},
+			radioChange(e) {
+				this.form.style = e.detail.value
+			},
+			confirmFn() {
+				let hostFn = this.option.id ? update : add
+				let form = JSON.parse(JSON.stringify(this.form))
+				console.log(form)
+				form.adImg = this.$util.imgSubstr(form.adImg)
+				form.adImg = form.adImg.join()
+				if (this.option.id) {
+					form.id = this.option.id
 				}
-			})
-		},
-		// 获取商品详情
-		_getGoodsDet() {
-			getGoodsDet({ id: this.form.goodsId }).then(res => {
-				if (this.$util.isEmpty(res.data)) return
-				this.goodsData = res.data
-			})
-		},
-		// 操作
-		// 选择商品
-		selGoodsFn() {
-			let data = {
-				form: this.form,
-				// imgList: this.imgList,
-				goodsData: this.goodsData
-			}
-			uni.setStorageSync('addAdData', data)
-			this.$util.pageTo({
-				url: '/admin/ad/sel-goods',
-				query: {
-					...this.option
+				if (form.style == 0) {
+					delete form.goodsId
+				} else {
+					// form.url = ''
+					delete form.url
 				}
-			})
-		},
-		startTimeFn(e) {
-			console.log(e)
-			this.form.startTime = e.detail.value
-		},
-		endTimeFn(e) {
-			this.form.endTime = e.detail.value
-		},
-		switchChangeFn(e) {
-			this.form.status = e.target.value ? 1 : 0
-		},
-		radioChange(e) {
-			this.form.style = e.detail.value
-		},
-		confirmFn() {
-			let hostFn = this.option.id ? update : add
-			let form = JSON.parse(JSON.stringify(this.form))
-			console.log(form)
-			form.adImg = this.$util.imgSubstr(form.adImg)
-			form.adImg = form.adImg.join()
-			if (this.option.id) {
-				form.id = this.option.id
-			}
-			if (form.style == 0) {
-				delete form.goodsId
-			} else {
-				// form.url = ''
-				delete form.url
-			}
-			hostFn(form).then(res => {
-				let promptText = this.option.id ? '修改成功!' : '添加成功!'
-				this.$msg(promptText)
-			})
-		},
-		// 表单验证
-		formSubmit(e) {
-			// 表单规则
-			let rules = [
-				{
-					name: 'adName',
-					rule: ['required'],
-					msg: ['请输入名称']
-				},
-				{
-					name: 'startTime',
-					rule: ['required'],
-					msg: ['请选择开始时间']
-				},
-				{
-					name: 'endTime',
-					rule: ['required'],
-					msg: ['请选择结束时间']
-				},
-				{
-					name: 'adImgStr',
-					rule: ['required'],
-					msg: ['请先上传图片']
+				hostFn(form).then(res => {
+					let promptText = this.option.id ? '修改成功!' : '添加成功!'
+					this.$msg(promptText)
+				})
+			},
+			// 表单验证
+			formSubmit(e) {
+				// 表单规则
+				let rules = [
+					{
+						name: 'adName',
+						rule: ['required'],
+						msg: ['请输入名称']
+					},
+					{
+						name: 'startTime',
+						rule: ['required'],
+						msg: ['请选择开始时间']
+					},
+					{
+						name: 'endTime',
+						rule: ['required'],
+						msg: ['请选择结束时间']
+					},
+					{
+						name: 'adImgStr',
+						rule: ['required'],
+						msg: ['请先上传图片']
+					}
+				]
+				// 进行表单检查
+				let formData = e.detail.value
+				let checkRes = form.validation(formData, rules)
+				// 验证通过!
+				if (!checkRes) {
+					this.confirmFn()
+				} else {
+					this.$msg(checkRes)
 				}
-			]
-			// 进行表单检查
-			let formData = e.detail.value
-			let checkRes = form.validation(formData, rules)
-			// 验证通过!
-			if (!checkRes) {
-				this.confirmFn()
-			} else {
-				this.$msg(checkRes)
 			}
 		}
 	}
-}
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
mobile-code/src/admin/interest/my-invite.vue

@@ -97,7 +97,7 @@ export default {
 				{
 					name: '账号余额(¥)',
 					value: 0,
-					btn: '提现'
+					// btn: '提现'
 				},
 				{
 					name: '邀请花店',

+ 5 - 5
mobile-code/src/admin/member/detail.vue

@@ -8,7 +8,7 @@
 					<div>
 						<div class="flex-center">
 							<span class="app-size-32">{{ data.userName }}</span>
-							<app-vip-module class="level-img" v-if="data.isMember == 1" :text="`VIP${data.userAsset.memberLevel}`" />
+							<app-vip-module class="level-img" v-if="data.member && data.member != 0" :text="`VIP${data.member}`" />
 						</div>
 						<div class="app-color-3">{{ data.id }}</div>
 					</div>
@@ -104,8 +104,8 @@
 					<div class="inp-list-line">
 						<div class="line-label">请选择等级</div>
 						<div class="line-input">
-							<picker mode="selector" :value="upgradeForm.memberLevel" :range="levelData.list" range-key="level" @change="changeLevelFn" class="inp-select">
-								<div v-if="upgradeForm.memberLevel">{{ levelSelData.level }}</div>
+							<picker mode="selector" :value="upgradeForm.member" :range="levelData.list" range-key="level" @change="changeLevelFn" class="inp-select">
+								<div v-if="upgradeForm.member">{{ levelSelData.level }}</div>
 								<div class="tui-placeholder" v-else>请选择</div>
 							</picker>
 						</div>
@@ -248,7 +248,7 @@ export default {
 			// 升级
 			levelSelData: {},
 			upgradeForm: {
-				memberLevel: '',
+				member: '',
 				confirmPassword: ''
 			},
 			// 备注
@@ -341,7 +341,7 @@ export default {
 		// 弹窗按钮
 		changeLevelFn(e) {
 			this.levelSelData = this.levelData.list[e.detail.value]
-			this.upgradeForm.memberLevel = this.levelSelData.level
+			this.upgradeForm.member = this.levelSelData.level
 		},
 		passwordModalClick(e) {
 			if (e.index === 0) {

+ 161 - 151
mobile-code/src/admin/staff/add.vue

@@ -75,170 +75,180 @@
 </template>
 
 <script>
-import TuiListCell from '@/components/plugin/list-cell'
-import AppAvatarModule from '@/components/module/app-avatar'
-const form = require('@/utils/formValidation.js')
-// api
-import { getRoleList, getStaffDet as getDet, addStaff as add, updateStaff as update } from '@/api/staff'
-import { getDet as getMemberDet } from '@/api/member'
-export default {
-	name: 'staff-add',
-	components: {
-		TuiListCell,
-		AppAvatarModule
-	},
-	data() {
-		return {
-			form: {
-				adminName: '',
-				mobile: '',
-				roleId: '',
-				remind: 0,
-				password: '',
-				userId: '',
-				status: 0,
-				remark: ''
-			},
-			roleList: [],
-			roleSelData: {},
-			memberData: {}
-		}
-	},
-	onLoad() {
-		// this.init()
-	},
-	methods: {
-		init() {
-			let data = uni.getStorageSync('addStaffData')
-			if (data) {
-				uni.removeStorageSync('addStaffData')
-				this.form = data.form
-				this.roleList = data.roleList
-				this.roleSelData = data.roleSelData
-			}
-			let memberData = uni.getStorageSync('addSelMember')
-			if (memberData) {
-				uni.removeStorageSync('addSelMember')
-				this.memberData = memberData
-				this.form.userId = memberData.id
+	import TuiListCell from '@/components/plugin/list-cell'
+	import AppAvatarModule from '@/components/module/app-avatar'
+	const form = require('@/utils/formValidation.js')
+	// api
+	import { getRoleList, getStaffDet as getDet, addStaff as add, updateStaff as update } from '@/api/staff'
+	import { getDet as getMemberDet } from '@/api/member'
+	export default {
+		name: 'staff-add',
+		components: {
+			TuiListCell,
+			AppAvatarModule
+		},
+		data() {
+			return {
+				form: {
+					adminName: '',
+					mobile: '',
+					roleId: '',
+					remind: 0,
+					password: '',
+					userId: '',
+					status: 0,
+					remark: ''
+				},
+				roleList: [],
+				roleSelData: {},
+				memberData: {}
 			}
+		},
+		onLoad() {
+			// this.init()
+		},
+		methods: {
+			init() {
+				let data = uni.getStorageSync('addStaffData')
+				if (data) {
+					uni.removeStorageSync('addStaffData')
+					this.form = data.form
+					this.roleList = data.roleList
+					this.roleSelData = data.roleSelData
+				}
+				let memberData = uni.getStorageSync('addSelMember')
+				if (memberData) {
+					uni.removeStorageSync('addSelMember')
+					this.memberData = memberData
+					this.form.userId = memberData.id
+				}
 
-			if (data) return false
-
-			this._getRoleList().then(res => {
 				if (this.option.id) {
-					this._getDet()
+					uni.setNavigationBarTitle({
+						title: `修改员工`
+					})
+				} else {
+					uni.setNavigationBarTitle({
+						title: `添加员工`
+					})
 				}
-			})
-		},
-		// api
-		async _getRoleList() {
-			await getRoleList().then(res => {
-				if (this.$util.isEmpty(res.data)) return false
-				this.roleList = res.data.list
-			})
-		},
-		_getDet() {
-			getDet({ id: this.option.id }).then(res => {
-				if (this.$util.isEmpty(res.data)) return
-				Object.keys(this.form).forEach((i, index) => {
-					if (i != 'password') {
-						this.form[i] = res.data[i]
+
+				if (data) return false
+
+				this._getRoleList().then(res => {
+					if (this.option.id) {
+						this._getDet()
 					}
 				})
-				this.roleSelData = this.roleList.filter(e => this.form.roleId == e.id)[0]
+			},
+			// api
+			async _getRoleList() {
+				await getRoleList().then(res => {
+					if (this.$util.isEmpty(res.data)) return false
+					this.roleList = res.data.list
+				})
+			},
+			_getDet() {
+				getDet({ id: this.option.id }).then(res => {
+					if (this.$util.isEmpty(res.data)) return
+					Object.keys(this.form).forEach((i, index) => {
+						if (i != 'password') {
+							this.form[i] = res.data[i]
+						}
+					})
+					this.roleSelData = this.roleList.filter(e => this.form.roleId == e.id)[0]
 
-				if (this.form.userId) {
-					this._getMemberDet()
+					if (this.form.userId) {
+						this._getMemberDet()
+					}
+				})
+			},
+			// 获取客户详情
+			_getMemberDet() {
+				getMemberDet({ userId: this.form.userId }).then(res => {
+					if (this.$util.isEmpty(res.data)) return
+					this.memberData = res.data
+				})
+			},
+			// option
+			// 关联微信
+			selMemberFn() {
+				let data = {
+					form: this.form,
+					roleList: this.roleList,
+					roleSelData: this.roleSelData
 				}
-			})
-		},
-		// 获取客户详情
-		_getMemberDet() {
-			getMemberDet({ userId: this.form.userId }).then(res => {
-				if (this.$util.isEmpty(res.data)) return
-				this.memberData = res.data
-			})
-		},
-		// option
-		// 关联微信
-		selMemberFn() {
-			let data = {
-				form: this.form,
-				roleList: this.roleList,
-				roleSelData: this.roleSelData
-			}
-			uni.setStorageSync('addStaffData', data)
-			this.$util.pageTo({
-				url: '/admin/staff/sel-member',
-				query: {
-					...this.option
+				uni.setStorageSync('addStaffData', data)
+				this.$util.pageTo({
+					url: '/admin/staff/sel-member',
+					query: {
+						...this.option
+					}
+				})
+			},
+			changeRoleFn(e) {
+				this.roleSelData = this.roleList[e.detail.value]
+				this.form.roleId = this.roleSelData.id
+			},
+			remindChangeFn(e) {
+				this.form.remind = e.detail.value ? 1 : 0
+			},
+			statusChangeFn(e) {
+				this.form.status = e.detail.value ? 1 : 0
+			},
+			confirmFn() {
+				let hostFn = this.option.id ? update : add
+				if (this.option.id) {
+					this.form.id = this.option.id
 				}
-			})
-		},
-		changeRoleFn(e) {
-			this.roleSelData = this.roleList[e.detail.value]
-			this.form.roleId = this.roleSelData.id
-		},
-		remindChangeFn(e) {
-			this.form.remind = e.detail.value ? 1 : 0
-		},
-		statusChangeFn(e) {
-			this.form.status = e.detail.value ? 1 : 0
-		},
-		confirmFn() {
-			let hostFn = this.option.id ? update : add
-			if (this.option.id) {
-				this.form.id = this.option.id
-			}
-			hostFn(this.form).then(res => {
-				let promptText = this.option.id ? '修改成功!' : '添加成功!'
-				this.$msg(promptText)
-				this.$util.pageTo('/admin/staff/list')
-			})
-		},
-		// 表单验证
-		formSubmit(e) {
-			// 表单规则
-			let rules = [
-				{
-					name: 'adminName',
-					rule: ['required'],
-					msg: ['请输入姓名']
-				},
-				{
-					name: 'mobile',
-					rule: ['required'],
-					msg: ['请输入手机号']
-				},
-				{
-					name: 'roleId',
-					rule: ['required'],
-					msg: ['请选择角色']
-				},
-				{
-					name: 'userId',
-					rule: ['required'],
-					msg: ['请选择关联微信']
-				},
-				{
-					name: 'password',
-					rule: ['required'],
-					msg: ['请输入密码']
+				hostFn(this.form).then(res => {
+					let promptText = this.option.id ? '修改成功!' : '添加成功!'
+					this.$msg(promptText)
+					this.$util.pageTo('/admin/staff/list')
+				})
+			},
+			// 表单验证
+			formSubmit(e) {
+				// 表单规则
+				let rules = [
+					{
+						name: 'adminName',
+						rule: ['required'],
+						msg: ['请输入姓名']
+					},
+					{
+						name: 'mobile',
+						rule: ['required'],
+						msg: ['请输入手机号']
+					},
+					{
+						name: 'roleId',
+						rule: ['required'],
+						msg: ['请选择角色']
+					},
+					{
+						name: 'userId',
+						rule: ['required'],
+						msg: ['请选择关联微信']
+					},
+					{
+						name: 'password',
+						rule: ['required'],
+						msg: ['请输入密码']
+					}
+				]
+				// 进行表单检查
+				let formData = e.detail.value
+				let checkRes = form.validation(formData, rules)
+				// 验证通过!
+				if (!checkRes) {
+					this.confirmFn()
+				} else {
+					this.$msg(checkRes)
 				}
-			]
-			// 进行表单检查
-			let formData = e.detail.value
-			let checkRes = form.validation(formData, rules)
-			// 验证通过!
-			if (!checkRes) {
-				this.confirmFn()
-			} else {
-				this.$msg(checkRes)
 			}
 		}
 	}
-}
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
mobile-code/src/pages.json

@@ -142,7 +142,7 @@
 				{
 					"path": "add",
 					"style": {
-						"navigationBarTitleText": "添加员工"
+						"navigationBarTitleText": ""
 					}
 				},
 				{

+ 1 - 0
mobile-code/src/utils/util.js

@@ -227,6 +227,7 @@ export const isLogin = () => {
 export default {
 	isEmpty,
 	imgSubstr,
+	isArray,
 	parse,
 	checkMobile,
 	checkName,