Browse Source

更改登录流程并接营业概况

fuwei 5 years ago
parent
commit
77938c2794

+ 53 - 41
ghs/src/App.vue

@@ -7,7 +7,6 @@
 		// 有坑 分包里的页面访问不到
 		globalData: {},
 		onLaunch() {
-			// this.getAllOptions()
 			// 删除缓存
 			if (process.env.NODE_ENV == 'production') {
 				uni.removeStorageSync('shopUser')
@@ -16,56 +15,69 @@
 			// wxLoginFn()
 			// uni.clearStorage()
 			const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
-
 			uni.setStorageSync('account', extConfig.account)
 			// #endif
-			// 开发
-			// if (process.env.NODE_ENV == 'development') {
-			// 	if (this.$constant.source == 'business') {
-			// 		uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNyJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLmIuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5iLmh1YW1sLmNvbSIsImp0aSI6IjBfNyIsImlhdCI6MTU4MjAyOTY2MywibmJmIjoxNTgyMDI5NjYzLCJleHAiOjE1OTA2Njk2NjMsInVuaXF1ZUlkIjoiNyIsInNvdXJjZUlkIjowfQ.v04WwuiNYArwrCzERY--uB3mWx4r2Za2R0chdjdTZF4')
-			// 		uni.setStorageSync('account', '12362')
-			// 	} else {
-			// 		uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM3NDUifQ.eyJpc3MiOiJodHRwOlwvXC9hcGkubS5odWFtbC5jb20iLCJhdWQiOiJodHRwOlwvXC9hcGkubS5odWFtbC5jb20iLCJqdGkiOiIwXzEyNTQzNzQ1IiwiaWF0IjoxNTgyNDY5NDIzLCJuYmYiOjE1ODI0Njk0MjMsImV4cCI6MTU5MTEwOTQyMywidW5pcXVlSWQiOiIxMjU0Mzc0NSIsInNvdXJjZUlkIjowfQ.ebTPvzLj4aI8F4iLHy_UdsVlAI-KyzErGQbJhPL1YRY')
-			// 		uni.setStorageSync('account', '12362')
-			// 	}
-			// }
+			var pages = getCurrentPages();
+			console.log(pages)
+			wxLoginFn()
+				.then(res => {
+					//花店员工和未知身份可以访问的地址
+					var urlArr = ['admin/shopAdmin/bind', 'pagesClient/official'];
+					var redirectPage = res.redirectPage;
+					var needRedirect = true;
+					urlArr.forEach((item, index, array) => {
+						if (redirectPage.indexOf(item) != -1) {
+							needRedirect = false;
+						}
+					})
+					if (needRedirect === true) {
+						//供货商员工
+						if (res.data.admin.identity == '2') {
+							// this.$util.pageTo({
+							// 	url: "/admin/home/workbench",
+							// 	type: 4
+							// });
+						//花店员工
+						} else if(res.data.admin.identity == '1'){
+							this.$util.pageTo({
+								url: "/pagesClient/official/latest-shop",
+								type: 2,
+								query:{
+									...this.option	
+								}
+							});
+						//未知身份
+						}else{
+							if(this.option.style != 1){
+								this.$util.pageTo({
+									url: "/pagesClient/official/index",
+									type: 2,
+									query: {
+										...this.option	
+									}
+								});
+							}	
+						}
+					}
+					getUser(true)
+					//获取门店信息
+					this.setUserShopAll()
+				})
+		},
+		onLoad(){
+			const pages = getCurrentPages();
+			const currentPage = pages[pages.length - 1];
+			const url = `/${currentPage.route}`;
+			console.log(1111,url)
 		},
 		onShow() {
-			// this.isLogin()
 		},
 		onHide() {},
 		onError(err) {
 			console.error(err, '错误捕获')
 		},
 		methods: {
-			isLogin() {
-				let token = uni.getStorageSync('token')
-				if (!token) {
-					uni.reLaunch({
-						url: '/pages/page/login/index'
-					})
-				}
-			}
-			// ...mapMutations(['setLoginInfo'])
-			// #ifdef MP-WEIXIN
-			// wxLogin() {
-			// 	uni.login({
-			// 		provider: 'weixin',
-			// 		success: res => {
-			// 			uni.setStorageSync('code', res.code)
-			// 			console.log(res.code, 'res.code')
-			// 			postWxCode({ code: res.code }).then(subRes => {
-			// 				const { openid, session_key, unionid } = subRes.data
-			// 				this.setLoginInfo({
-			// 					openid,
-			// 					session_key,
-			// 					unionid
-			// 				})
-			// 			})
-			// 		}
-			// 	})
-			// }
-			// #endif
+			...mapActions(['setUserShopAll'])
 		}
 	}
 </script>

+ 3 - 1
ghs/src/api/common/index.js

@@ -33,4 +33,6 @@ export const sendSms = param => https.get('/inform-user/send-sms', param)
 export const suggestion = param => https.get('/map/suggestion', param)
 
 // 微信分享 m b
-export const wxShare = data => https.post('/wx-share/get-params', data)
+export const wxShare = data => https.post('/wx-share/get-params', data)
+
+export const shopAll = data => https.get('/shop/all', data)

+ 5 - 0
ghs/src/api/statistics/index.js

@@ -6,3 +6,8 @@ import https from '@/plugins/luch-request_0.0.7/request'
 export const getStatList = data => {
 	return https.get('/stat/list', data)
 }
+// 经营概况
+export const getMainProfile = data => {
+	return https.get('/main/profile', data)
+}
+

+ 0 - 85
ghs/src/mixins/allOptions.js

@@ -1,85 +0,0 @@
-import { mapGetters, mapActions } from 'vuex'
-export default {
-	data() {
-		return {
-			selectData: {}
-		}
-	},
-	computed: {
-		...mapGetters(['allOptions']),
-		sysBookingStatus() {
-			return this.$util.isEmpty(this.$store.getters.allOptions) ? [] : this.$store.getters.allOptions.sysBookingStatus.option
-		},
-		sysRenovationStatus() {
-			return this.$util.isEmpty(this.$store.getters.allOptions) ? [] : this.$store.getters.allOptions.sysRenovationStatus.option
-		},
-		sysBudgetStatus() {
-			return this.$util.isEmpty(this.$store.getters.allOptions) ? [] : this.$store.getters.allOptions.sysBudgetStatus.option
-		},
-		sysBookingChannel() {
-			return this.$util.isEmpty(this.$store.getters.allOptions) ? [] : this.$store.getters.allOptions.sysBookingChannel.option
-		}
-	},
-	created() {
-		// uni.setStorageSync('allOptions', {})
-	},
-	mounted() {
-		console.log(this.allOptions)
-	},
-	methods: {
-		...mapActions(['getAllOptions']),
-		formatOptions(data) {
-			return Object.keys(data).map(i => ({
-				name: data[i],
-				status: false,
-				id: i
-			}))
-		}, /** fliterMask 列表 */
-		filterMaskBtn(item, status, pIndex, index) {
-			if (this.filterMaskData[pIndex].type !== 2) {
-				for (let i in item) {
-					// eslint-disable-next-line no-param-reassign
-					item[i].status = false
-				}
-			}
-			// eslint-disable-next-line no-param-reassign
-			item[index].status = !status
-		}, // 初始化
-		initSelectStatus(data) {
-			Object.keys(this.selectData).forEach(i => {
-				this.selectData[i] = data[i]
-				this.filterMaskData.forEach(j => {
-					if (i === j.key) {
-						let arr = []
-						if (data[i] !== 0) {
-							arr = data[i].toString().split()
-						}
-						if (!this.$util.isEmpty(arr)) {
-							arr.forEach(s => {
-								// eslint-disable-next-line no-param-reassign
-								let idx = j.list.findIndex(i => i.id == s)
-								j.list[idx].status = true
-							})
-						}
-					}
-				})
-			})
-		}, /** 格式化上传数据 */
-		formatFilterMaskData() {
-			Object.keys(this.selectData).forEach(s => {
-				this.filterMaskData.forEach((i) => {
-					if (s === i.key) {
-						let current = []
-						i.list.forEach((j, idx) => {
-							if (j.status) {
-								current.push((j.id))
-							}
-						})
-						this.selectData[s] = current.join(',')
-					}
-				})
-			})
-			return this.selectData
-		}
-	}
-}

+ 0 - 46
ghs/src/mixins/globalMixins.js

@@ -28,52 +28,6 @@ export default {
 			uni.setStorageSync('account', option.account)
 		}
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
-		
-		if (isLogin() == false || this.$util.isEmpty(this.loginInfo)) {
-			wxLoginFn()
-				.then(res => {
-					//花店员工和未知身份可以访问的地址
-					var urlArr = ['admin/shopAdmin/bind', 'pagesClient/official'];
-					var redirectPage = res.redirectPage;
-					var needRedirect = true;
-					urlArr.forEach((item, index, array) => {
-						if (redirectPage.indexOf(item) != -1) {
-							needRedirect = false;
-						}
-					})
-					if (needRedirect == true) {
-						//供货商员工
-						if (res.data.admin.identity == '2') {
-							this.$util.pageTo({
-								url: "/admin/home/workbench",
-								type: 4
-							});
-						//花店员工
-						} else if(res.data.admin.identity == '1'){
-							this.$util.pageTo({
-								url: "/pagesClient/official/latest-shop",
-								type: 2,
-								query:{
-									...this.option	
-								}
-							});
-						//未知身份
-						}else{
-							if(this.option.style != 1){
-								this.$util.pageTo({
-									url: "/pagesClient/official/index",
-									type: 2,
-									query: {
-										...this.option	
-									}
-								});
-							}	
-						}
-					}
-					getUser()
-				})
-		}
-
 		if (this.init) {
 			this.init()
 		}

+ 1 - 1
ghs/src/mixins/index.js

@@ -1,5 +1,5 @@
 export { default as list } from './list'
 // export { default as allOptions } from './allOptions'
 export { default as share } from './share'
-export { default as orderBtn } from './orderBtn'
+// export { default as orderBtn } from './orderBtn'
 // export { default as area } from './area'

+ 0 - 30
ghs/src/mixins/orderBtn.js

@@ -1,30 +0,0 @@
-import freeShipping from '@/api/order'
-export default {
-    methods: {
-        openBt(val){
-            // //花材
-            // if(val.type == 'item') {
-
-            //     // 自取
-            // }else if(val.type === 'selfGet') {
-
-            //     //发货
-            // }else if(val.type === 'send') {
-            //     this.pageTo({
-            //         url: '/admin/order/ship',
-            //         query: {
-            //           id: val.id,
-            //           pageStatus: 0
-            //         }
-            //       })
-            // }
-            this.pageTo({
-                url: '/pagesOrder/ship',
-                query: {
-                  id: 25,
-                  pageStatus: 0
-                }
-              })
-        },
-    }
-}

+ 0 - 3
ghs/src/pagesOrder/detail.vue

@@ -158,15 +158,12 @@
     import stepStatus from './components/stepStatus'
     import TuiListCell from '@/components/plugin/list-cell'
     import { getDetail,freeShipping } from '@/api/order/index'
-    // import {orderBtn} from '@/mixins'
-    // import { copyText } from '@/utils/common'
     export default {
         name:'orderDetail',
         components:{
             stepStatus,
             TuiListCell
         },
-        // mixins:[orderBtn],
         data(){
             return {
                 stepActive: 0,

+ 172 - 121
ghs/src/pagesStatistics/business.vue

@@ -1,157 +1,193 @@
 <template>
 	<scroll-view scroll-y class="business-page">
-		<view class="business-info">
-			<view class="amount-view">
-				<text class="amount-label">账户余额</text>
-				<text class="amount-btn">
-					瑞景店
-					<text class="iconfont iconsanjiao_xia"></text>
-				</text>
-			</view>
-			<view class="price-view">
-				<text class="unit">¥</text>
-				<text class="price">{{ "278,209.20" || "--" }}</text>
-			</view>
-
-			<view class="down-view">
-				<view class="down-item">
-					<text class="label">应收客户款</text>
-					<text class="value"
-						><text class="unit">¥</text>{{ "278,209.20" || "--" }}</text
-					>
-				</view>
-				<view class="down-item">
-					<text class="label">应付供应商款</text>
-					<text class="value"
-						><text class="unit">¥</text>{{ "278,209.20" || "--" }}</text
-					>
-				</view>
-			</view>
-		</view>
-		<view class="space-view space-layout">
-			<view class="space-left">
-				<view class="title-bar">
-					<image
-						class="title-icon"
-						src="../../../static/images/common/business-stock.png"
-					>
-					</image>
-					<text class="title">
-						库存成本 ¥ 30,922.46
+		<template v-if="!$util.isEmpty(baseInfo)">
+			<view class="business-info">
+				<view class="amount-view">
+					<text class="amount-label">账户余额</text>
+					<text class="amount-btn">
+						瑞景店
+						<text class="iconfont iconsanjiao_xia"></text>
 					</text>
 				</view>
-			</view>
-			<view class="space-right"> </view>
-		</view>
-		<view class="space-view space-remark">
-			<view class="space-left">
-				<view class="show-item">
-					<view class="show-name">库存总数</view>
-					<view class="show-value">123</view>
+				<view class="price-view">
+					<text class="unit">¥</text>
+					<text class="price">{{ baseInfo.balance || "--" }}</text>
 				</view>
-			</view>
-			<view class="space-right">
-				<view class="show-item">
-					<view class="show-name"
-						>库存预警数
-						<text class="iconfont iconchangjianwentixiangguanwenti2"></text
-					></view>
-					<view class="show-value red">123</view>
+
+				<view class="down-view">
+					<view class="down-item">
+						<text class="label">应收客户款</text>
+						<text class="value"
+							><text class="unit">¥</text>{{ baseInfo.mayGathering || "--" }}</text
+						>
+					</view>
+					<view class="down-item">
+						<text class="label">应付供应商款</text>
+						<text class="value"
+							><text class="unit">¥</text>{{ baseInfo.mayPay || "--" }}</text
+						>
+					</view>
 				</view>
 			</view>
-		</view>
-		<view class="space-view space-layout">
-			<view class="space-left">
-				<view class="title-bar">
-					<image
-						class="title-icon"
-						src="../../../static/images/common/business-sale.png"
-					>
-					</image>
-					<text class="title">
-						今日销售 ¥ 30,922.46
-					</text>
+			<view class="space-view space-layout">
+				<view class="space-left">
+					<view class="title-bar">
+						<image
+							class="title-icon"
+							src="../../../static/images/common/business-stock.png"
+						>
+						</image>
+						<text class="title">
+							库存成本 ¥ {{baseInfo.stockCost}}
+						</text>
+					</view>
 				</view>
+				<view class="space-right"> </view>
 			</view>
-			<view class="space-right">
-				<view class="show-tag down">
-					<view class="tag ">
-						同期
-						<image class="arrow" src="../../../static/images/common/arrow.png" />
+			<view class="space-view space-remark">
+				<view class="space-left">
+					<view class="show-item">
+						<view class="show-name">库存总数</view>
+						<view class="show-value">{{baseInfo.stockNum}}</view>
 					</view>
-					<text>-27.00</text>
 				</view>
-			</view>
-		</view>
-		<view class="space-view space-remark">
-			<view class="space-left">
-				<view class="show-item">
-					<view class="show-name">近7天销售</view>
-					<view class="show-value"><text class="unit">¥</text>123</view>
-
-					<view class="show-tag up">
-						<view class="tag ">
-							同期
-							<image class="arrow" src="../../../static/images/common/arrow.png" />
-						</view>
-						<text>+27.00</text>
+				<view class="space-right">
+					<view class="show-item">
+						<view class="show-name"
+							>库存预警数
+							<text class="iconfont iconchangjianwentixiangguanwenti2"></text
+						></view>
+						<view class="show-value red">{{baseInfo.stockWarning}}</view>
 					</view>
 				</view>
 			</view>
-			<view class="space-right">
-				<view class="show-item">
-					<view class="show-name">
-						近30天销售
+			<view class="space-view space-layout">
+				<view class="space-left">
+					<view class="title-bar">
+						<image
+							class="title-icon"
+							src="../../../static/images/common/business-sale.png"
+						>
+						</image>
+						<text class="title">
+							今日销售 ¥ {{baseInfo.today}}
+						</text>
 					</view>
-					<view class="show-value red"><text class="unit">¥</text>123</view>
-					<view class="show-tag up">
-						<view class="tag ">
+				</view>
+				<view class="space-right">
+					<view :class="['show-tag',baseInfo.todayCompareYesterday>0?'up':'down']">
+						<view class="tag">
 							同期
 							<image class="arrow" src="../../../static/images/common/arrow.png" />
 						</view>
-						<text>+27.00</text>
+						<text>{{baseInfo.todayCompareYesterday}}</text>
 					</view>
 				</view>
 			</view>
-		</view>
+			<view class="space-view space-remark">
+				<view class="space-left">
+					<view class="show-item">
+						<view class="show-name">近7天销售</view>
+						<view class="show-value"><text class="unit">¥</text>{{baseInfo.latestSeven}}</view>
 
-		<view class="space-view space-layout business-list">
-			<view class="list-tab">
-				<view
-					:class="['tab-item', { active: curTabIndex == index }]"
-					v-for="(item, index) in tabList"
-					:key="index"
-				>
-					{{ item.label }}
-				</view>
-			</view>
-			<view class="list-main">
-				<view class="list-item" v-for="(item, index) in bussinessList" :key="index">
-					<view class="item-left">
-						<view class="content-row">
-							<text class="content-label"> 收入</text>
-							<text class="content-value"> <text class="unit">¥</text> 36,950.00</text>
+						<view :class="['show-tag',baseInfo.latestSevenSameTerm>0?'up':'down']">
+							<view class="tag">
+								同期
+								<image class="arrow" src="../../../static/images/common/arrow.png" />
+							</view>
+							<text>{{baseInfo.latestSevenSameTerm}}</text>
 						</view>
-						<view class="content-row">
-							<text class="content-label"> 支出</text>
-							<text class="content-value"> <text class="unit">¥</text> 36,950.00</text>
+					</view>
+				</view>
+				<view class="space-right">
+					<view class="show-item">
+						<view class="show-name">
+							近30天销售
 						</view>
-						<view class="content-row">
-							<text class="content-label"> 收入</text>
-							<text class="content-value"> <text class="unit">¥</text> 36,950.00</text>
+						<view class="show-value red"><text class="unit">¥</text>{{baseInfo.latestThirty}}</view>
+						<view :class="['show-tag',baseInfo.latestThirtySameTerm>0?'up':'down']">
+							<view class="tag ">
+								同期
+								<image class="arrow" src="../../../static/images/common/arrow.png" />
+							</view>
+							<text>{{baseInfo.latestThirtySameTerm}}</text>
 						</view>
 					</view>
-					<view class="item-right">
-						<text class="iconfont iconxiangyou"> </text>
+				</view>
+			</view>
+
+			<view class="space-view space-layout business-list">
+				<view class="list-tab">
+					<view
+						@click="changeDate(index)"
+						:class="['tab-item', { active: curTabIndex == index }]"
+						v-for="(item, index) in tabList"
+						:key="index"
+					>
+						{{ item.label }}
 					</view>
 				</view>
+				<view class="list-main">
+					<view v-for="(item, index) in bussinessList" :key="index">
+						<template v-if="index == curTabIndex">
+							<view class="list-item" >
+								<view class="item-left">
+									<view class="content-row">
+										<text class="content-label"> 收入</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.income}}</text>
+									</view>
+									<view class="content-row">
+										<text class="content-label"> 支出</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.expend}}</text>
+									</view>
+								</view>
+								<view class="item-right">
+									<text class="iconfont iconxiangyou"> </text>
+								</view>
+							</view>
+							<view class="list-item" >
+								<view class="item-left">
+									<view class="content-row">
+										<text class="content-label"> 销售数量</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.saleNum}}</text>
+									</view>
+									<view class="content-row">
+										<text class="content-label"> 销售金额</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.saleAmount}}</text>
+									</view>
+								</view>
+								<view class="item-right">
+									<text class="iconfont iconxiangyou"> </text>
+								</view>
+							</view>	
+							<view class="list-item" >
+								<view class="item-left">
+									<view class="content-row">
+										<text class="content-label"> 采购数量</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.purchaseNum}}</text>
+									</view>
+									<view class="content-row">
+										<text class="content-label"> 采购金额</text>
+										<text class="content-value"> <text class="unit">¥</text> {{item.purchaseAmount}}</text>
+									</view>
+								</view>
+								<view class="item-right">
+									<!-- <text class="iconfont iconxiangyou"> </text> -->
+								</view>
+							</view>	
+						</template>
+					</view>
+					
+				</view>
 			</view>
-		</view>
+		</template>
 	</scroll-view>
 </template>
 
 <script>
+import {getMainProfile} from '@/api/statistics'
 export default {
+	name:'Business',
 	data() {
 		return {
 			curTabIndex: 0,
@@ -173,8 +209,23 @@ export default {
 					value: "04"
 				}
 			],
-			bussinessList: [{}, {}]
+			bussinessList: [{}, {}],
+			baseInfo:{}
 		};
+	},
+	methods:{
+		async init(){
+				try {
+					let {data:{base,more}} = await getMainProfile({})
+					this.baseInfo = base
+					this.bussinessList = [more.today,more.yesterday,more.latestSeven,more.latestThirty]
+				} finally {
+
+				}
+		},
+		changeDate(idx){
+			this.curTabIndex = idx;
+		}
 	}
 };
 </script>

+ 1 - 26
ghs/src/store/index.js

@@ -8,38 +8,13 @@ Vue.use(Vuex)
 const store = new Vuex.Store({
   modules,
   state: {
-    allOptions: '',
   },
   getters: {
-    allOptions: (state) =>
-      state.allOptions ||
-      (util.isEmpty(uni.getStorageSync('allOptions'))
-        ? {}
-        : JSON.parse(uni.getStorageSync('allOptions'))),
   },
   mutations: {
-    // 全局选项
-    setAllOptions(state, data = {}) {
-      state.allOptions = data
-      uni.setStorageSync('allOptions', JSON.stringify(data))
-    },
+    
   },
   actions: {
-    getAllOptions({ commit }) {
-      // sysBudgetStatus 预算   sysRenovationStatus 装修类型  sysBookingStatus 派单状态
-      return getOptions({
-        type: '',
-      }).then((res) => {
-        if (res.status === 'success') {
-          commit('setAllOptions', res.data)
-        } else {
-          uni.showToast({
-            title: res.errors.message,
-            icon: 'none',
-          })
-        }
-      })
-    },
   },
 })
 

+ 12 - 2
ghs/src/store/modules/user.js

@@ -1,11 +1,12 @@
 import { getState, setState } from '@/store/modules/vuexStorange'
 import { getSelfInfo } from '@/utils/auth'
-
+import { shopAll } from '@/api/common'
 /** 员工用户信息 */
 const state = {
 	selfInfo: null,
 	user: null,
-	shopUser: null
+	shopUser: null,
+	userShopAll: {}  //用户所有店铺
 }
 
 const getters = {
@@ -95,6 +96,12 @@ const actions = {
 		state
 	}) {
 		commit('DEL_SHOP_USER')
+	},
+	setUserShopAll({commit,state},info={}){
+		return shopAll(info).then(res=>{
+			console.log(res)
+			commit('SET_USER_SHOP_ALL',res.data)
+		})
 	}
 }
 
@@ -119,6 +126,9 @@ const mutations = {
 	},
 	DEL_USER(state) {
 		state.shopUser = ''
+	},
+	SET_USER_SHOP_ALL(state,info={}) {
+		state.userShopAll = info
 	}
 }
 

+ 0 - 1
ghs/src/utils/auth.js

@@ -94,7 +94,6 @@ export async function wxLoginFn(update) {
 
 					var pages = getCurrentPages();
 					var page = (pages[pages.length - 1]).route;
-
 					resolve({ redirectPage: page, ...subRes })
 
 					uni.setStorageSync('token', subRes.data.token)