Browse Source

store: 更新登录跳转页-分享 及图片接口请求

fuwei 6 years ago
parent
commit
fdfe787ef5

+ 1 - 0
store/src/App.vue

@@ -7,6 +7,7 @@
 		// 有坑 分包里的页面访问不到
 		globalData: {},
 		onLaunch() {
+			console.log(789)
 			// this.getAllOptions()
 			// 删除缓存
 			if (process.env.NODE_ENV == 'production') {

+ 1 - 0
store/src/admin/official/apply.vue

@@ -143,6 +143,7 @@ export default {
   },
   methods: {
     init() {
+   
       this.$util.getCheckLogin().then(res => {
         if (res) {
           let id = uni.getStorageSync("introMerchantId");

+ 7 - 3
store/src/admin/official/index.vue

@@ -72,12 +72,14 @@ import AppSwiper from "@/components/app-swiper";
 import AppImg from "@/components/app-img";
 // api
 import { applyStatus } from "@/api/official";
+import { share } from '@/mixins'
 export default {
   name: "index",
   components: {
     AppSwiper,
     AppImg
   },
+  mixins:[share],
   data() {
     return {
       constant: this.$constant,
@@ -138,7 +140,11 @@ export default {
     };
   },
   onLoad() {
-    // this.init()
+    this.jweixinFn({
+      title:'申请试用',
+      pagePath:'/pages/admin/official/index',
+      imageUrl:''
+    })
   },
   methods: {
     init() {
@@ -163,8 +169,6 @@ export default {
         typeof this.option.introMerchantId == "undefined"
           ? 0
           : this.option.introMerchantId;
-      console.log("数据分析。。。。。。。");
-      console.log(introMerchantId);
       uni.setStorageSync("introMerchantId", introMerchantId);
 
       // let token = uni.getStorageSync('token')

+ 5 - 5
store/src/components/app-uploader.vue

@@ -80,10 +80,10 @@ export default {
 			type: String,
 			default: 'scaleToFill'
 		},
-		uploadPicApi: {
-			type: Function,
-			default: uploadPic
-		},
+		// uploadPic: {
+		// 	type: Function,
+		// 	default: uploadPic
+		// },
 		// 是否显示主图切换
 		isMain: {
 			type: Boolean,
@@ -144,7 +144,7 @@ export default {
 				})
 			}
 			return new Promise((resolve, reject) => {
-				this.uploadPicApi({
+				uploadPic({
 					...params
 				}).then(res => {
 					if (res.code === 1) {

+ 16 - 5
store/src/mixins/globalMixins.js

@@ -19,7 +19,7 @@ export default {
 	// 	...mapGetters({ userInfo: 'getUser' })
 	// },
 	// 页面生命周期才触发
-	onLoad: function (option) {
+	onLoad:	function (option) {
 		this.option = option || null
 		if (option.token) {
 			uni.setStorageSync('token', option.token)
@@ -30,10 +30,21 @@ export default {
 
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
 		if (isLogin() == false) {
-
-			wxLoginFn().then(res => {
-				getUser()
-			})
+			wxLoginFn()
+				.then(res => {
+					if(+res.data.shopId > 0) {
+						this.$util.pageTo({
+							url: "/admin/home/workbench",
+							type: 3
+							});
+					}else{
+						this.$util.pageTo({
+							url: "/admin/official/index",
+							type: 2
+							});
+					}
+					getUser()
+				})
 		}
 
 		if (this.init) {

+ 2 - 1
store/src/mixins/share.js

@@ -18,7 +18,8 @@ export default {
 	methods: {
 		async jweixinFn(data) {
 			let that = this
-			function success() {
+			function success(e) {
+				console.log(e)
 				// that.shareStatiscFN(data.linkurl, data.owner_user_id, data.puser_id)
 			}
 			// #ifdef H5

+ 13 - 17
store/src/utils/auth.js

@@ -4,7 +4,7 @@ import store from '@/store'
 // #endif
 // import { share } from '@/mixins'
 import CONSTANT from '@/constant'
-import UTIL from '@/utils/util'
+// import util from '@/utils/util'
 
 import {
 	getStaffApi,
@@ -21,7 +21,7 @@ import util from './util'
  */
 export async function getShopUser(update) {
 	let userInfo = store.getters.getShopUser
-	if (!UTIL.isEmpty(userInfo) && !update) {
+	if (!util.isEmpty(userInfo) && !update) {
 	  return userInfo
 	}
 	await getShopUserApi().then((res) => {
@@ -40,7 +40,7 @@ export async function getShopUser(update) {
  */
 export async function getUser(update) {
 	let userInfo = store.getters.getUser
-	if (!UTIL.isEmpty(userInfo) && !update) {
+	if (!util.isEmpty(userInfo) && !update) {
 	  return userInfo
 	}
 	await getUserApi().then((res) => {
@@ -82,27 +82,23 @@ export async function wxLoginFn(update) {
 	if (!util.isEmpty(loginInfo) && !update) {
 		return loginInfo
 	}
-
-	let getObj = await new Promise(resolve => {
+	return new Promise(resolve => {
 		uni.login({
 			provider: 'weixin',
 			success: res => {
 				uni.setStorageSync('code', res.code)
-				resolve(res)
+				postWxCode({ code: res.code }).then(subRes => {
+					if (util.isEmpty(subRes)){
+						return false
+					} 
+					resolve(subRes)
+					uni.setStorageSync('token', subRes.data.token)
+					uni.setStorageSync('shopId', subRes.data.shopId)
+					store.commit('setLoginInfo', subRes.data.user)
+				})
 			}
 		})
 	})
-
-	await postWxCode({ code: getObj.code }).then(subRes => {
-		if (UTIL.isEmpty(subRes)){
-			return false
-		} 
-		uni.setStorageSync('token', subRes.data.token)
-		uni.setStorageSync('shopId', subRes.data.shopId)
-		store.commit('setLoginInfo', subRes.data.user)
-	})
-
-	return dataInfo
 }
 
 // export default {