|
|
|
@ -47,6 +47,9 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup name="Home"> |
|
|
|
import Vconsolefrom from 'vconsole'; |
|
|
|
import * as w6s from 'szient-js-sdk'; |
|
|
|
import sha1 from 'crypto-js/sha1'; |
|
|
|
import {getEnterpriseMerchantAuthorization,getSiqLoginAuth} from '../api/Home'; |
|
|
|
const { useCommon } = $globalStore; |
|
|
|
const router = useRouter(); |
|
|
|
@ -120,20 +123,80 @@ const onLoad = () => { |
|
|
|
// recommendGoods(true); |
|
|
|
}; |
|
|
|
|
|
|
|
const generateRandomNumber =() =>{ |
|
|
|
const min = 100000; |
|
|
|
const max = 999999; |
|
|
|
const randomNum = Math.floor(Math.random() * (max - min + 1)) + min; |
|
|
|
return randomNum.toString().padStart(6, '0'); |
|
|
|
} |
|
|
|
onMounted(() => { |
|
|
|
// console.log(useCommon.phonenumber) |
|
|
|
// useCommon.SET_USER_PHONENUMBER(success.data.phonenumber); |
|
|
|
getSiqLoginAuth({userId:"1608434855568265217",userName:"汤家荣"},success =>{ |
|
|
|
new Vconsolefrom(); |
|
|
|
|
|
|
|
const access_key = '6374106c5eb449a4ad6c2430f30796e6'; |
|
|
|
const access_secret = '434fec85aa5846e88bbeb8fac6cf6d7f'; |
|
|
|
const nonce = generateRandomNumber(); |
|
|
|
const timestamp = `${Date.now()}`; |
|
|
|
console.log(nonce); |
|
|
|
console.log(timestamp); |
|
|
|
|
|
|
|
const str = [access_secret, nonce, timestamp] |
|
|
|
.sort() |
|
|
|
.reduce((str, item) => str += item, ''); |
|
|
|
console.log(str); |
|
|
|
|
|
|
|
// 最终还需要转成全小写 |
|
|
|
const signature = sha1(str).toString().toLowerCase(); |
|
|
|
console.log(signature); |
|
|
|
//深i企鉴权 |
|
|
|
w6s.config({ |
|
|
|
access_key: access_key, |
|
|
|
nonce: nonce, |
|
|
|
timestamp: timestamp, |
|
|
|
signature: signature, |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
// 成功 |
|
|
|
console.log("鉴权",res); |
|
|
|
|
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
// 失败 |
|
|
|
// console.log(err) |
|
|
|
console.log("鉴权",err); |
|
|
|
}); |
|
|
|
|
|
|
|
w6s.ready(() => { |
|
|
|
w6s.szient.getAuthCode({ |
|
|
|
success: function(res) { |
|
|
|
console.log(res) |
|
|
|
console.log("认证",res); |
|
|
|
console.log(res.result.result.code) |
|
|
|
getSiqLoginAuth({code: res.result.result.code},success =>{ |
|
|
|
console.log(success.data) |
|
|
|
},error =>{ |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
fail: function(err) { |
|
|
|
console.log(err) |
|
|
|
console.log("认证",err); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
getSiqLoginAuth({code:""},success =>{ |
|
|
|
console.log(success.data) |
|
|
|
},error =>{ |
|
|
|
|
|
|
|
}) |
|
|
|
getEnterpriseMerchantAuthorization({merchantTel: useCommon.phonenumber},success =>{ |
|
|
|
if(!(success.data == null && success.data.length == 0)){ |
|
|
|
useCommon.SET_USER_ENTERPRISE_NUMBER(success.data[0].enterpriseNumber); |
|
|
|
} |
|
|
|
},error =>{ |
|
|
|
}) |
|
|
|
// getEnterpriseMerchantAuthorization({merchantTel: useCommon.phonenumber},success =>{ |
|
|
|
// if(!(success.data == null && success.data.length == 0)){ |
|
|
|
// useCommon.SET_USER_ENTERPRISE_NUMBER(success.data[0].enterpriseNumber); |
|
|
|
// } |
|
|
|
// },error =>{ |
|
|
|
// }) |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
|