| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 | import $store from '../store'import request from '@/utils/request.js'const isUserId = function() {	var userId=uni.getStorageSync("wxOpenData").loginInfo.uid;	//console.log("userId---"+userId)	if(!userId){		   uni.navigateTo({			  url:'../login/login'		   })	 }}const automaticlogin = function() {	//console.log($store.state.userInfo)	var that=this;	var extConfig = uni.getExtConfigSync();	 /* extConfig={		"shopId": "23173848-292E-4AEA-B590-73AC9A763F1D",		"url":"https://store-api.qdbtl.cn/",		"unionId":"C3748B46-B778-40AA-8C60-A9B0F2FA23A7",		"appId":"wxc023ff04deb28f2d"	} */	console.log("automaticlogin")	console.log(extConfig)		 return new Promise((resolve, reject) => {		 if($store.state.userInfo){			 resolve()		 }else{			uni.login({			  provider: 'weixin',			  success: function (loginRes) {			    //console.log(loginRes);				uni.showLoading({					title: '加载中'				});				request.http('miniApp2/sys/getWxOpenID', {				   code:loginRes.code,				   unionId:extConfig.unionId				  },'GET').then(res => {					  uni.hideLoading();					  $store.commit('mutationswxOpenData', res.data);					  var themeColor= res.data.themeColor					   uni.setStorageSync('themeColor',themeColor);					  if(res.data.loginInfo){					  	$store.commit('mutationsuserInfo', res.data.loginInfo.openUser)					  }					 resolve()				  })							  }			}); 		 }			 })	 //return Promise.resolve()	 }/* const uid =function() {	var userId=uni.getStorageSync("logodata").uid;	return} */// 防止处理多次点击function noMultipleClicks(methods, info) {    // methods是点击后需要执行的函数, info是函数需要传的参数    let that = this;    if (that.noClick) {        // 第一次点击        that.noClick= false;        if((info && info !== '') || info ==0) {            // info是执行函数需要传的参数            methods(info);        } else {            methods();        }        setTimeout(()=> {            that.noClick= true;        }, 3000)    } else {        //  这里是重复点击的判断    }}function getExtStoreId(type){	try{	 var extConfig = uni.getExtConfigSync ? uni.getExtConfigSync() : {shopId:'默认的门店id'};		  /* extConfig={			  "shopId": "E37BB296-5A08-4534-859D-B351BA611AF9",			  "url":"https://apidms.66km.com",			  "unionId":"EF7981B9-2D1D-4006-9C0A-66CE7177134D",			  "appId":"wx2c6f04c0dcd15984"			 } */		  /* extConfig={				 "shopId": "23173848-292E-4AEA-B590-73AC9A763F1D",				 "url":"https://store-api.qdbtl.cn/",				 "unionId":"C3748B46-B778-40AA-8C60-A9B0F2FA23A7",				 "appId":"wxc023ff04deb28f2d"		  } */	 /* extConfig={			 "shopId": "4490D0C9-176B-4C34-BE50-111CA3FA4DC1",			 "url":"https://apidms.jcatt.cn/",			 "unionId":"9DE2D6D6-D59A-401B-8275-F5DACC99AC22",			 "appId":"wx575a8b1339951f27"		  } */		 /* extConfig={		  			 "shopId": "F8035D21-99FB-48C6-A364-5A3298DBB65C",		  			 "url":"https://dmsapi.chipaioil.com/",		  			 "unionId":"903F3E3F-E2A5-4D1B-92D7-8D3560013F01",		  			 "appId":"wx2b59a5281464a89e"		  		  } */		 /* extConfig={		  			  "shopId": "471944C8-B664-4B7B-B6D4-F552E66BE554",		  			  "url":"https://apidms.66km.com",		  			  "unionId":"07206389-E726-48EC-A063-ED040A5E15AE",		  			  "appId":"wx5f2274fc8fb1c1e3"		  			 } */		  		console.log(extConfig,'extJson对象');		//return extConfig[type];		return extConfig	}catch(err){		console.log(err,'getExtStoreId__error')	}}function formateTimeStamp (timeStamp) {  var hour;  var min;  var seconds;  let today = new Date() // 当前时间if (Number(new Date(timeStamp).getTime()) < Number(new Date().getTime())) {	const zTime = {	  hour: 0,	  min: 0,	  seconds: 0	}	return zTime	return false  }  let startTime = new Date(timeStamp.replace(/-/g, '/')) // 结束时间  let shenyu = startTime.getTime() - today.getTime() // 倒计时毫秒数 let shengyuD = parseInt(shenyu / (60 * 60 * 24 * 1000)) // 转换为天  //console.log(shengyuD+'shengyuD')  //hour = parseInt(shenyu / (60 * 60)) // 计算整数小时数  hour = parseInt(shenyu / (60 * 60 * 1000))  var afterHour = shenyu - hour * 60 * 60 * 1000 // 取得算出小时数后剩余的秒数  min = parseInt(afterHour / (60 * 1000)) // 计算整数分  //seconds = parseInt(shenyu - hour * 60 * 60 - min * 60) // 取得算出分后剩余的秒数  seconds= parseInt((shenyu - shengyuD * 60 * 60 * 24 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000) / 1000)  if (hour < 10) {    hour = '0' + hour  }  //console.log(hour)  if (min < 10) {    min = '0' + min;  }//console.log(min)  if (seconds < 10) {    seconds = '0' + seconds;  }//console.log(seconds)  const restTime = {    hour: hour,    min: min,    seconds: seconds  }  //console.log(restTime)  /// setTimeout(formateTimeStamp(timeStamp), 1000)  return restTime}function countdown (timeStamp) {  var hour;  var min;  var seconds;  let today = new Date() // 当前时间  let startTime = new Date(timeStamp.replace(/-/g, '/')) // 结束时间  let shenyu = startTime.getTime() - today.getTime() // 倒计时毫秒数 let shengyuD = parseInt(shenyu / (60 * 60 * 24 * 1000)) // 转换为天  //console.log(shengyuD+'shengyuD')  //hour = parseInt(shenyu / (60 * 60)) // 计算整数小时数  hour = parseInt(shenyu / (60 * 60 * 1000))  var afterHour = shenyu - hour * 60 * 60 * 1000 // 取得算出小时数后剩余的秒数  min = parseInt(afterHour / (60 * 1000)) // 计算整数分  //seconds = parseInt(shenyu - hour * 60 * 60 - min * 60) // 取得算出分后剩余的秒数seconds= parseInt((shenyu - shengyuD * 60 * 60 * 24 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000) / 1000)  if (hour < 10) {    hour = '0' + hour  }  console.log(hour)  if (min < 10) {    min = '0' + min;  }//console.log(min)  if (seconds < 10) {    seconds = '0' + seconds;  }  const restTime = {    hour: hour,    min: min,    seconds: seconds  }   var txt = hour+':'+min+':'+seconds;  console.log(txt)  return txt}export default {    commonData:{        companyType:1,    },	automaticlogin,    isUserId,	getExtStoreId,	noMultipleClicks,      // 禁止多次点击	formateTimeStamp,	countdown}
 |