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

+ 7 - 2
mobile-code/src/App.vue

@@ -1,7 +1,7 @@
 <script>
 import { mapMutations, mapActions, mapGetters } from 'vuex'
 import { setTimeout } from 'timers'
-import { wxLoginFn } from '@/utils/auth'
+import { getCheckLogin, getUser } from '@/utils/auth'
 export default {
 	// 全端,数据共享,还可以解决页面初始化模板访问不到值得问题
 	// 有坑 分包里的页面访问不到
@@ -9,13 +9,18 @@ export default {
 	},
 	onLaunch() {
 		// this.getAllOptions()
-		wxLoginFn()
 		// #ifdef MP-WEIXIN
 		// wxLoginFn()
 		// #endif
 		// 开发
 		uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjFfMTI1MzY2MzAifQ.eyJpc3MiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJhdWQiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJqdGkiOiIxXzEyNTM2NjMwIiwiaWF0IjoxNTc0NDIzMDc4LCJuYmYiOjE1NzQ0MjMwNzgsImV4cCI6MTU3NDQyNjY3OCwidXNlcklkIjoxMjUzNjYzMH0.v_T9NuFRpzuI7GtwuuuNlVg6EylImaCUwqo2A6NRTE4')
 		uni.setStorageSync('account', '12358')
+		// 登录
+		getCheckLogin().then(res => {
+			if (res) {
+				getUser()
+			}
+		})
 	},
 	onShow() {
 		// this.isLogin()

+ 3 - 0
mobile-code/src/api/common/index.js

@@ -5,3 +5,6 @@ export const uploadPic = data => {
 }
 
 export const getOptions = param => https.get('/apihkds/api/option/getOptions', param)
+
+// 用户信息
+export const getUserApi = param => https.get('/merchant/detail', param)

+ 8 - 0
mobile-code/src/api/invite/index.js

@@ -0,0 +1,8 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+/** *
+ * 列表 b
+ */
+export const getList = data => {
+	return https.get('/invite/list', data)
+}

+ 8 - 0
mobile-code/src/api/workbench/index.js

@@ -0,0 +1,8 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+/** *
+ * 控制台首页 b
+ */
+export const consoleIndex = data => {
+	return https.get('/console/profile', data)
+}

+ 1 - 1
mobile-code/src/components/module/app-avatar.vue

@@ -13,7 +13,7 @@ export default {
 			type: Number,
 			default: 100
 		},
-		img: {
+		src: {
 			type: String,
 			default: ''
 		},

+ 4 - 0
mobile-code/src/mixins/globalMixins.js

@@ -1,3 +1,4 @@
+import { mapGetters } from 'vuex'
 export default {
 	data() {
 		return {
@@ -7,6 +8,9 @@ export default {
 			constant: this.$constant
 		}
 	},
+	computed: {
+		...mapGetters({ userInfo: 'getUser' })
+	},
 	// 页面生命周期才触发
 	onLoad: function(option) {
 		this.option = option || null

+ 0 - 6
mobile-code/src/pages.json

@@ -1,11 +1,5 @@
 {
 	"pages": [
-		{
-			"path": "pages/login/index",
-			"style": {
-				"navigationBarTitleText": "登录"
-			}
-		},
 		{
 			"path": "pages/admin/workbench",
 			"style": {

+ 62 - 19
mobile-code/src/pages/admin/workbench.vue

@@ -5,25 +5,25 @@
 			<div class="user-top">
 				<div class="app-size-28">今日概况</div>
 				<div @click="$util.pageTo('/pages/setting/password')">
-					<app-avatar-module :width="80" />
+					<app-avatar-module :src="avatarImg" :width="80" />
 				</div>
 			</div>
 			<div class="income-amount">
 				<div>收入金额</div>
-				<div class="price">3279.5</div>
+				<div class="price">{{ data.todayData.income }}</div>
 			</div>
 			<div class="user-bottom">
 				<div class="info-list">
 					<div class="info-list-name">浏览量</div>
-					<div class="info-list-value">127</div>
+					<div class="info-list-value">{{ data.todayData.visit || 0 }}</div>
 				</div>
 				<div class="info-list">
 					<div class="info-list-name">新粉丝</div>
-					<div class="info-list-value">82</div>
+					<div class="info-list-value">{{ data.todayData.fans || 0 }}</div>
 				</div>
 				<div class="info-list">
 					<div class="info-list-name">新客户</div>
-					<div class="info-list-value">32</div>
+					<div class="info-list-value">{{ data.todayData.user || 0 }}</div>
 				</div>
 			</div>
 		</div>
@@ -38,10 +38,10 @@
 		</div>
 		<!-- 消息 -->
 		<div class="module-com news-wrap">
-			<div class="news-list" v-for="(item, index) in 3" :key="index">
+			<div class="news-list" v-for="(item, index) in data.notice" :key="index" @click="pageToFn(item)">
 				<div class="news-left">
 					<i class="iconfont iconxiaoxi2"></i>
-					<span>您还没有绑定公众号</span>
+					<span>{{ item.title }}</span>
 				</div>
 				<div class="news-right">
 					<span>立即授权绑定</span>
@@ -75,6 +75,8 @@
 <script>
 import FabModule from '@/components/plugin/fab'
 import AppAvatarModule from '@/components/module/app-avatar'
+// api
+import { consoleIndex } from '@/api/workbench'
 // img
 import tabIcon1 from '@/static/images/admin/tab-icon-1.png'
 import tabIcon2 from '@/static/images/admin/tab-icon-2.png'
@@ -92,31 +94,37 @@ export default {
 	},
 	data() {
 		return {
+			data: {
+				admin: {},
+				asset: {},
+				notice: {},
+				todayData: {}
+			},
 			// 订单总览
 			orderData: [
 				{
 					name: '待付款',
-					value: 127
+					value: 0
 				},
 				{
 					name: '待配送',
-					value: 42
+					value: 0
 				},
 				{
 					name: '配送中',
-					value: 20
+					value: 0
 				},
 				{
 					name: '待通知',
-					value: 89
+					value: 0
 				},
 				{
 					name: '已完结',
-					value: 489
+					value: 0
 				},
 				{
 					name: '待退款',
-					value: 22
+					value: 0
 				}
 			],
 			// tab按钮
@@ -168,32 +176,67 @@ export default {
 			totalData: [
 				{
 					name: '客户数',
-					value: 127
+					value: 0
 				},
 				{
 					name: '粉丝数',
-					value: 42
+					value: 0
 				},
 				{
 					name: '会员数',
-					value: 20
+					value: 0
 				},
 				{
 					name: '总收入(元)',
-					value: 8589
+					value: 0
 				},
 				{
 					name: '总访问量',
-					value: 489
+					value: 0
 				},
 				{
 					name: '剩余短信',
-					value: 22
+					value: 0
 				}
 			]
 		}
 	},
+	computed: {
+		avatarImg() {
+			return this.userInfo.logoUrl
+		}
+	},
 	onLoad(option) {
+		// if (this.$util.getCheckLogin()) return
+		this.init()
+	},
+	methods: {
+		init() {
+			consoleIndex().then(res => {
+				this.data = res.data
+				const { asset } = res.data
+				if (!this.$util.isEmpty(asset)) {
+					// 订单总览
+					this.orderData[0].value = asset.unPayOrder
+					this.orderData[1].value = asset.unSendOrder
+					this.orderData[2].value = asset.sendingOrder
+					this.orderData[3].value = asset.unNoticeOrder
+					this.orderData[4].value = asset.finishOrder
+					this.orderData[5].value = asset.cancelOrder
+					// 总览数据
+					this.totalData[0].value = asset.totalMember
+					this.totalData[1].value = asset.totalFans
+					this.totalData[2].value = asset.totalUser
+					this.totalData[3].value = asset.totalIncome
+					this.totalData[4].value = asset.totalVisit
+					this.totalData[5].value = asset.remainSmsNum
+				}
+			})
+		},
+		// 跳转
+		pageToFn(item) {
+			location.href = item.url
+		}
 	}
 }
 </script>

+ 5 - 0
mobile-code/src/pages/interest/admin/invite.vue

@@ -70,6 +70,8 @@ import AppTabs from '@/components/plugin/tabs'
 import AppSearchModule from '@/components/module/app-search'
 import AppAvatarModule from '@/components/module/app-avatar'
 import ModalModule from '@/components/plugin/modal'
+// api
+import { getList } from '@/api/invite'
 export default {
 	name: 'admin-invite',
 	components: {
@@ -99,6 +101,9 @@ export default {
 		}
 	},
 	methods: {
+		_getList() {
+			getList().then(res => {})
+		},
 		change(e) {
 			this.tabIndex = e.index
 		},

+ 1 - 9
mobile-code/src/pages/pay/index.vue

@@ -75,15 +75,7 @@ export default {
 	},
 	methods: {
 		init() {
-			getCheckLogin().then(res => {
-				if (!res) {
-					// let params = {
-					// 	suffixUrl: getMiniAppUrl(this.option, true)
-					// }
-					// oauth(params).then(res => {})
-					location.href = `${this.constant.hostUrl}/auth/prepare?url=${encodeURIComponent(getMiniAppUrl(this.option, true))}`
-				}
-			})
+			getCheckLogin()
 		},
 		_pay() {
 			if (!this.amount) {

+ 1 - 1
mobile-code/src/store/modules/basicUser.js

@@ -12,7 +12,7 @@ const getters = {
 	 getState(state, 'basicUser', 'basicUser')
 		return state.basicUser
 	},
-	// 后台管理用户信息
+	// 用户信息
 	getUser: (state) => {
 		getState(state, 'user', 'userInfo')
 		return state.user

+ 79 - 78
mobile-code/src/utils/auth.js

@@ -1,16 +1,16 @@
-// import store from '@/store'
+import store from '@/store'
 // #ifdef H5
 import jweixin from 'jweixin-module'
 // #endif
-import { share } from '@/mixins'
-import Util from '@/utils/util'
-
-// import {
-// 	getBasicUserApi,
-// 	getUserApi,
-// 	checkLogin,
-// 	getRoleRealApi
-// } from '@/api/system'
+// import { share } from '@/mixins'
+import CONSTANT from '@/constant'
+import UTIL from '@/utils/util'
+
+import {
+	getUserApi
+	// checkLogin,
+	// getRoleRealApi
+} from '@/api/common'
 // import { postWxCode } from '@/api/login'
 
 // import util from './util'
@@ -43,26 +43,25 @@ import Util from '@/utils/util'
 // 	return userInfo
 // }
 
-// /**
-//  * 获取后台用户信息
-//  * @parmas update为true时会重新触发请求,重置vuex的数据
-//  */
-// export async function getUser(update) {
-// 	let userInfo = store.getters.getUser
-// 	if (!util.isEmpty(userInfo) && !update) {
-// 	  return userInfo
-// 	}
-// 	await getUserApi().then((res) => {
-// 		userInfo = res.data
-// 		store.dispatch('setUser', userInfo)
-// 		uni.setStorageSync('user_id', res.data.user_id)
-// 	}).catch(() => {
-// 		uni.removeStorageSync('token')
-// 		uni.removeStorageSync('user_id')
-// 	})
+/**
+ * 获取后台用户信息
+ * @parmas update为true时会重新触发请求,重置vuex的数据
+ */
+export async function getUser(update) {
+	let userInfo = store.getters.getUser
+	if (!UTIL.isEmpty(userInfo) && !update) {
+	  return userInfo
+	}
+	console.log(getUserApi)
+	await getUserApi().then((res) => {
+		userInfo = res.data
+		store.dispatch('setUser', userInfo)
+	}).catch(() => {
+		uni.removeStorageSync('token')
+	})
 
-// 	return userInfo
-// }
+	return userInfo
+}
 // /**
 //  * 清除vuex的用户信息,目前包含(basicUser, user)
 //  * @parmas 暂无,可扩展
@@ -98,56 +97,56 @@ import Util from '@/utils/util'
  */
 // let wxLoginFrist = true
 export async function wxLoginFn(update) {
-	// let params = {
-	// 	appid: 'wxad348eb41eda2363',
-	// 	redirect_uri: encodeURI('https://www.meijiabang.com'),
-	// 	response_type: 'code',
-	// 	scope: 'snsapi_base'
-	// }
-	// let oauthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize${Util.parse(params)}#wechat_redirect`
-	// console.log(oauthUrl)
-	// window.location.href = oauthUrl
-	// uni.redirectTo({
-	// 	url: `https://open.weixin.qq.com/connect/oauth2/authorize${Util.parse(params)}#wechat_redirect`
-	// })
-	// share.methods.getWeiXinOptin()
-	return false
-	let dataInfo = null
-	let loginInfo = store.state.login.loginInfo
-	if (!util.isEmpty(loginInfo) && !update) {
-		return loginInfo
-	}
-
-	// #ifdef H5
-	jweixin.ready(function() {
-
-	})
-	// #endif
-	// // #ifdef MP-WEIXIN
-	// wxLoginFrist = false
-	let getObj = await new Promise(resolve => {
-		uni.login({
-			provider: 'weixin',
-			success: res => {
-				uni.setStorageSync('code', res.code)
-				console.log(res.code, 'res.code')
-				resolve(res)
-			}
-		})
-	})
-	// // #endif
-
-	await postWxCode({ code: getObj.code }).then(subRes => {
-		const { openid, session_key, unionid } = subRes.data
-		dataInfo = subRes.data
-		store.commit('setLoginInfo', {
-			openid,
-			session_key,
-			unionid
-		  })
-	})
+// 	// let params = {
+// 	// 	appid: 'wxad348eb41eda2363',
+// 	// 	redirect_uri: encodeURI('https://www.meijiabang.com'),
+// 	// 	response_type: 'code',
+// 	// 	scope: 'snsapi_base'
+// 	// }
+// 	// let oauthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize${Util.parse(params)}#wechat_redirect`
+// 	// console.log(oauthUrl)
+// 	// window.location.href = oauthUrl
+// 	// uni.redirectTo({
+// 	// 	url: `https://open.weixin.qq.com/connect/oauth2/authorize${Util.parse(params)}#wechat_redirect`
+// 	// })
+// 	// share.methods.getWeiXinOptin()
+// 	return false
+// 	let dataInfo = null
+// 	let loginInfo = store.state.login.loginInfo
+// 	if (!util.isEmpty(loginInfo) && !update) {
+// 		return loginInfo
+// 	}
 
-	return dataInfo
+	// 	// #ifdef H5
+	// 	jweixin.ready(function() {
+
+	// 	})
+	// 	// #endif
+	// 	// // #ifdef MP-WEIXIN
+	// 	// wxLoginFrist = false
+	// 	let getObj = await new Promise(resolve => {
+	// 		uni.login({
+	// 			provider: 'weixin',
+	// 			success: res => {
+	// 				uni.setStorageSync('code', res.code)
+	// 				console.log(res.code, 'res.code')
+	// 				resolve(res)
+	// 			}
+	// 		})
+	// 	})
+	// 	// // #endif
+
+	// 	await postWxCode({ code: getObj.code }).then(subRes => {
+	// 		const { openid, session_key, unionid } = subRes.data
+	// 		dataInfo = subRes.data
+	// 		store.commit('setLoginInfo', {
+	// 			openid,
+	// 			session_key,
+	// 			unionid
+	// 		  })
+	// 	})
+
+// 	return dataInfo
 }
 
 /**
@@ -158,6 +157,8 @@ export async function getCheckLogin() {
 	let token = uni.getStorageSync('token')
 	if (token) {
 		status = true
+	} else {
+		location.href = `${CONSTANT.hostUrl}/auth/prepare?url=${encodeURIComponent(getMiniAppUrl(this.option, true))}`
 	}
 	// await checkLogin().then((res) => {
 	//   if (res.status === 'success') {

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

@@ -1,3 +1,4 @@
+import CONSTANT from '@/constant'
 import { mobileReg } from '@/utils/tools/validate'
 // 是否为空
 const isEmpty = (val) => {
@@ -42,6 +43,22 @@ const isFunction = (obj) => {
 	return (typeof obj == 'object') && obj.constructor == Function
 }
 
+/** *
+ * 检查登录
+ * @parmas query 拼接得参数对象
+ * @parmas isFrist 为true时开头为&
+ */
+export const getCheckLogin = () => {
+	let status = false
+	let token = uni.getStorageSync('token')
+	if (token) {
+		status = true
+	} else {
+		location.href = `${CONSTANT.hostUrl}/auth/prepare?url=${encodeURIComponent(getMiniAppUrl(this.option, true))}`
+	}
+	return status
+}
+
 /** *
  * 对象参数转为url参数
  * @parmas query 拼接得参数对象
@@ -167,5 +184,6 @@ export default {
 	$checkName,
 	$formatDate,
 	pageTo,
-	isLogin
+	isLogin,
+	getCheckLogin
 }