1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import $store from '../store'
- import request from '@/utils/request.js'
- const isUserId = function() {
- var userId=uni.getStorageSync("wxOpenData").loginInfo.uid;
-
- if(!userId){
- uni.navigateTo({
- url:'../login/login'
- })
- }
- }
- const automaticlogin = function() {
-
- var that=this;
- const extConfig = uni.getExtConfigSync();
-
-
- return new Promise((resolve, reject) => {
- if($store.state.userInfo){
- resolve()
- }else{
- uni.login({
- provider: 'weixin',
- success: function (loginRes) {
-
- request.http('miniApp2/sys/getWxOpenID', {
- code:loginRes.code,
- unionId:extConfig.unionId
- },'GET').then(res => {
- $store.commit('mutationswxOpenData', res.data);
- if(res.data.loginInfo){
- $store.commit('mutationsuserInfo', res.data.loginInfo.openUser)
- }
- resolve()
- })
- }
- });
- }
-
- })
-
-
- }
- function noMultipleClicks(methods, info) {
-
- let that = this;
- if (that.noClick) {
-
- that.noClick= false;
- if((info && info !== '') || info ==0) {
-
- methods(info);
- } else {
- methods();
- }
- setTimeout(()=> {
- that.noClick= true;
- }, 3000)
- } else {
-
- }
- }
- function getExtStoreId(type){
- try{
- const extConfig = uni.getExtConfigSync ? uni.getExtConfigSync() : {shopId:'默认的门店id'}
- console.log(extConfig,'extJson对象');
-
- return extConfig
- }catch(err){
- console.log(err,'getExtStoreId__error')
- }
- }
- export default {
- commonData:{
- companyType:1,
- },
- automaticlogin,
- isUserId,
- getExtStoreId,
- noMultipleClicks,
- }
|