Commit ef82a71b by 胡悦

Merge branch 'v1.0.1' of http://192.168.3.233:8090/glsx/gl_tape into v1.0.1

2 parents d4763275 c68080c6
import http from '../request/http' import http from "../request/http";
module.exports = { module.exports = {
search(data) { search(data) {
return http.post({ return http.post({
method: 'scrm.api.carlife.weapp.homeSearch.search', method: "scrm.api.carlife.weapp.homeSearch.search",
pageSize: 10, pageSize: 10,
...data, ...data,
}) });
}, },
findSoureList(data) { findSoureList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.recepiton.soure.findSoureList', method: 'dj.api.smartcarlife.recepiton.soure.findSoureList',
...data, ...data,
}) })
}
}
\ No newline at end of file \ No newline at end of file
},
getToken(data) {
return http.post({
method: "dj.api.mindworkplate.badge.getToken",
projectName: "mindworkplate",
sessionId: "2ae39c60-60c9-4096-901a-68da57068cd9",
});
},
};
import http from '../request/http' import http from '../request/http'
module.exports = { module.exports = {
getSmsCode (data) { /**获取短信 */
getSmsCode (data = {}) {
data.projectName = 'boutique' data.projectName = 'boutique'
return http.fetch('dj.api.smartcarlife.sms.get.code', data) return http.fetch('dj.api.smartcarlife.sms.get.code', data)
}, },
/**手机验证码登录 */
smsLogin (data = {}) {
data.projectName = 'boutique'
data.source = 'MINIAPP'
data.productCode = 'PC00c2'
return http.fetch('dj.api.smartcarlife.sms.login', data)
},
/**获取当前登录账号能查看的园区店列表 */
getYQList () {
return http.fetch('dj.api.smartcarlife.serviceMerchant.curYqList')
},
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<image <image
:src="imagePath" :src="imagePath"
:mode="mode" :mode="mode"
:webp="webp||isWebp"
lazy-load
/> />
</template> </template>
...@@ -22,7 +20,6 @@ export default { ...@@ -22,7 +20,6 @@ export default {
type: null, type: null,
default: '' default: ''
}, },
webp: Boolean
}, },
name: 'GlsxImage', name: 'GlsxImage',
data () { data () {
...@@ -53,4 +50,9 @@ export default { ...@@ -53,4 +50,9 @@ export default {
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
image{
width: 100%;
height: 100%;
vertical-align: top;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
import Vue from 'vue' // import Vue from 'vue'
const componentsFiles = require.context(`./`, true, /.vue$/) // const componentsFiles = require.context(`./`, true, /.vue$/)
componentsFiles.keys().forEach(path => { // componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default // const component = componentsFiles(path).default
Vue.component(component.name, component) // // Vue.component(component.name, component)
}) // })
\ No newline at end of file \ No newline at end of file
module.exports = { module.exports = {
// 请求域名 格式:https://xxx.xxx.com // 请求域名 格式:https://xxx.xxx.com
HTTP_REQUEST_URL: 'http://127.0.0.1:8000/api', HTTP_REQUEST_URL: "http://127.0.0.1:8000/api",
// 阿里云oss域名 格式:https://xxx.oss-cn-xxx.aliyuncs.com // 阿里云oss域名 格式:https://xxx.oss-cn-xxx.aliyuncs.com
OSS_DOMAIN: '', OSS_DOMAIN: "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com",
// 文件直传到阿里云oss时需用到
ACCESSKEYID: '',
ACCESSKEYSECRET: '',
// 与后端约定的token字段名 // 文件直传到阿里云oss时需用到
TOKEN_NAME: 'Authorization' ACCESSKEYID: "LTAI5tCRcCUgd7bt1J7JY596",
} ACCESSKEYSECRET: "kJos9mgylkR5ztosnDt8Asrc3ulgqy",
BUKET_NAME: "glsk-oss",
FOLDER: "quality/",
// 与后端约定的token字段名
TOKEN_NAME: "glsk-oss",
};
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease'] const target = ["ip", "dev", "uat", "prod", "preRelease"];
const index = 2 const index = 2;
/** /**
* *
0本地 0本地
...@@ -12,109 +12,109 @@ const secretKey = { ...@@ -12,109 +12,109 @@ const secretKey = {
ip: {}, ip: {},
dev: { dev: {
sso: { sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89', appKey: "8b31ae1009ccb0f96130ca4bd90e3d89",
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b' secret: "02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b",
} },
}, },
uat: { uat: {
sso: { sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89', appKey: "8b31ae1009ccb0f96130ca4bd90e3d89",
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b' secret: "02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b",
} },
}, },
prod: { prod: {
sso: { sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89', appKey: "8b31ae1009ccb0f96130ca4bd90e3d89",
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b' secret: "02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b",
} },
}, },
preRelease: { preRelease: {
sso: { sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89', appKey: "8b31ae1009ccb0f96130ca4bd90e3d89",
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b' secret: "02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b",
} },
} },
}[target[index]] }[target[index]];
const domain = { const domain = {
// ip: 'http://192.168.2.94:8558', // ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.3:8315', // ip: 'http://192.168.2.3:8315',
ip: 'http://192.168.1.170:8315', ip: "http://192.168.1.170:8315",
/**登录: 192.168.2.3:8315 /**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */ 商城: 192.168.2.3:8558 */
dev: 'https://scrm.dev.glsx.com.cn', dev: "https://scrm.dev.glsx.com.cn",
uat: 'https://scrm.test.glsx.com.cn', uat: "https://scrm.test.glsx.com.cn",
preRelease: 'https://scrm.beta.glsx.com.cn', preRelease: "https://scrm.beta.glsx.com.cn",
prod: 'https://scrm.glsx.com.cn' prod: "https://scrm.glsx.com.cn",
}[target[index]] }[target[index]];
const djDomain = { const djDomain = {
ip: 'http://192.168.2.59:8292', ip: "http://192.168.2.59:8292",
// ip: 'http://192.168.2.80:8558', // ip: 'http://192.168.2.80:8558',
dev: 'https://dj.dev.glsx.com.cn', dev: "https://dj.dev.glsx.com.cn",
beta: 'https://dj.beta.glsx.com.cn', //预发布 appid: wx9f91c1ec493eb425 beta: "https://dj.beta.glsx.com.cn", //预发布 appid: wx9f91c1ec493eb425
uat: 'https://dj.test.glsx.com.cn', //测试 appid: wxe10067a63c1856ac uat: "https://dj.test.glsx.com.cn", //测试 appid: wxe10067a63c1856ac
prod: 'https://dj.glsx.com.cn', prod: "https://dj.glsx.com.cn",
pet: 'https://cdptest.glsx.com.cn' //压测 appid: wx7ce755e425603084 pet: "https://cdptest.glsx.com.cn", //压测 appid: wx7ce755e425603084
}[target[index]] }[target[index]];
const merchantDomain = { const merchantDomain = {
ip: 'http://rop-merchant.dev.glsx.com.cn', ip: "http://rop-merchant.dev.glsx.com.cn",
dev: 'http://rop-merchant.dev.glsx.com.cn', dev: "http://rop-merchant.dev.glsx.com.cn",
beta: 'https://rop-merchant.beta.glsx.com.cn', beta: "https://rop-merchant.beta.glsx.com.cn",
uat: 'https://rop-merchant.test.glsx.com.cn', uat: "https://rop-merchant.test.glsx.com.cn",
prod: 'https://commodity.glsx.com.cn', prod: "https://commodity.glsx.com.cn",
pet: '' pet: "",
}[target[index]] }[target[index]];
const djSecretKey = { const djSecretKey = {
ip: { ip: {},
},
dev: { dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b', secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
uat: { uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b', secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
beta: { beta: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022', appKey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353', secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
}, },
prod: { prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022', appKey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353' secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
}, },
pet: { pet: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022', appKey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353' secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
} },
}[target[index]] }[target[index]];
const pathEnum = { const pathEnum = {
sso: '/rop-scrm-sso/', sso: "/rop-scrm-sso/",
shopmall: '/rop-scrm-shopmall/', shopmall: "/rop-scrm-shopmall/",
coupon: '/rop-scrm-coupon/', coupon: "/rop-scrm-coupon/",
carlife: '/rop-scrm-carlife/', carlife: "/rop-scrm-carlife/",
live: '/rop-scrm-live/', live: "/rop-scrm-live/",
equity: '/rop-scrm-equity/', equity: "/rop-scrm-equity/",
entmicro: '/rop-scrm-entmicro/', entmicro: "/rop-scrm-entmicro/",
wechat: '/rop-scrm-wechat/', wechat: "/rop-scrm-wechat/",
boutiquecoupon: '/rop-scrm-boutiquecoupon/', boutiquecoupon: "/rop-scrm-boutiquecoupon/",
material: '/rop-scrm-marketing/', //素材 material: "/rop-scrm-marketing/", //素材
sop: '/rop-scrm-sop/', sop: "/rop-scrm-sop/",
customercollect: '/rop-scrm-bigdatautil/', customercollect: "/rop-scrm-bigdatautil/",
drac: '/rop-scrm-entmicro/', mindworkplate: "/rop-dj-smartcarlife/",
busassistant: '/rop-scrm-busassistant/', drac: "/rop-scrm-entmicro/",
boutique: '/rop-dj-car-boutique/' busassistant: "/rop-scrm-busassistant/",
} boutique: "/rop-dj-car-boutique/",
};
const CONFIG_ENV_MAP = { const CONFIG_ENV_MAP = {
1: 'develop', 1: "develop",
2: 'test', 2: "test",
3: 'production', 3: "production",
4: 'beta' 4: "beta",
} };
module.exports = { module.exports = {
index, index,
domain, domain,
...@@ -123,5 +123,5 @@ module.exports = { ...@@ -123,5 +123,5 @@ module.exports = {
env: CONFIG_ENV_MAP[index], env: CONFIG_ENV_MAP[index],
djDomain, djDomain,
merchantDomain, merchantDomain,
djSecretKey djSecretKey,
} };
...@@ -4,7 +4,8 @@ import config from '@/config.js' ...@@ -4,7 +4,8 @@ import config from '@/config.js'
import store from '@/store'; import store from '@/store';
import api from './api/index' import api from './api/index'
import { Storage } from './utils/cache/index' import { Storage } from './utils/cache/index'
import 'components' import GlsxImage from './components/GlsxImage'
Vue.component('GlsxImage', GlsxImage)
uni.$api = api uni.$api = api
uni.$storage = new Storage() uni.$storage = new Storage()
Vue.config.productionTip = false Vue.config.productionTip = false
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-08 13:47:00
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const recorderManager = uni.getRecorderManager();
export default {
data() {
return {
timer: null,
times: 0,
timeout: 10 * 60,
reaction: 10,
};
},
onShow() {
window.addEventListener("devicemotion", this.handleDeviceMotion);
},
onHide() {
window.removeEventListener("devicemotion", this.handleDeviceMotion);
},
created() {
recorderManager.start();
this.initTime();
document.addEventListener("visibilitychange", this.handleVisibilityChange);
},
methods: {
handleDeviceMotion(event) {
let acceleration = event.accelerationIncludingGravity;
let brightness =
Math.abs(acceleration.x) +
Math.abs(acceleration.y) +
Math.abs(acceleration.z);
if (brightness < 10) {
// 假设<10的值代表屏幕可能变暗了
console.log("屏幕可能熄灭了");
// 在这里执行你需要的操作
}
},
//监听点击事件
initTime() {
this.timer = setInterval(() => {
this.times++;
console.log(this.times);
if (this.times >= this.timeout) {
this.showToast();
}
if (this.times >= this.reaction + this.timeout) {
this.handleEnd();
}
}, 1000);
},
handleTouchStart() {
this.times = 0;
},
},
handleVisibilityChange() {
if (document.visibilityState === "hidden") {
// 屏幕被关闭
console.log("Screen closed");
}
},
beforeCreate() {
clearInterval(this.timer);
this.timer = null;
},
};
...@@ -12,7 +12,17 @@ ...@@ -12,7 +12,17 @@
maxlength="11" maxlength="11"
/> />
<template v-if="mobile"> <template v-if="mobile">
<text class="icon" @click="mobile = ''">X</text> <view
class="icon"
@click="mobile = ''"
>
<icon
type="clear"
size="16"
color="#000"
>
</icon>
</view>
</template> </template>
</view> </view>
<view class="input"> <view class="input">
...@@ -23,15 +33,31 @@ ...@@ -23,15 +33,31 @@
maxlength="4" maxlength="4"
/> />
<template v-if="code"> <template v-if="code">
<text class="icon" @click="code = ''">X</text> <view
class="icon"
@click="code = ''"
>
<icon
type="clear"
size="16"
color="#000"
>
</icon>
</view>
</template> </template>
<!-- :class="['code-btn', { 'code-disabled': count }]" -->
<view <view
:class="['code-btn', { 'code-disabled': count }]"
@click="getSmsCode" @click="getSmsCode"
>{{ count ? `重新发送(${count}s)` : '获取验证码' }}</view >{{ count ? `重新发送(${count}s)` : '获取验证码' }}</view>
>
</view> </view>
<button class="btn" :disabled="!mobile || !code">登录</button> <button
class="btn"
:disabled="!mobile || !code"
@click="login"
>
登录
</button>
</view> </view>
</view> </view>
</template> </template>
...@@ -39,28 +65,27 @@ ...@@ -39,28 +65,27 @@
<script> <script>
const phoneRex = /^[1]([3-9])[0-9]{9}$/; const phoneRex = /^[1]([3-9])[0-9]{9}$/;
export default { export default {
data() { data () {
return { return {
mobile: '', mobile: '15626599738',
code: '', code: '8888',
count: '', count: '',
}; };
}, },
onLoad(options) { onLoad (options) {
uni.hideLoading();
}, },
methods: { methods: {
/**获取验证码 */ /**获取验证码 */
async getSmsCode() { async getSmsCode () {
const { mobile, count } = this; const { mobile, count } = this;
try { try {
if (!mobile) throw '请输入手机号'; if (!mobile) throw '请输入手机号';
if (!phoneRex.test(mobile)) throw '请输入正确的手机号'; if (!phoneRex.test(mobile)) throw '请输入正确的手机号';
if (count) throw '验证码发送过于频繁,请稍后在试'; if (count) throw '验证码发送过于频繁,请稍后在试';
this.countDown(60); this.countDown(60);
uni.showLoading() uni.showLoading();
const { code, message } = await uni.$api.userApi.getSmsCode({mobile}); const { code, message } = await uni.$api.userApi.getSmsCode({ mobile });
uni.hideLoading() uni.hideLoading();
if (code == '0') { if (code == '0') {
uni.showToast({ uni.showToast({
title: '验证码已发送', title: '验证码已发送',
...@@ -69,15 +94,15 @@ export default { ...@@ -69,15 +94,15 @@ export default {
this.countDown(60); this.countDown(60);
} else throw message || '发送验证码失败'; } else throw message || '发送验证码失败';
} catch (error) { } catch (error) {
uni.hideLoading() uni.hideLoading();
uni.showToast({ uni.showToast({
title: error, title: error,
icon: 'none', icon: 'none',
}) });
} }
}, },
/**验证码倒计时 */ /**验证码倒计时 */
countDown(countDown) { countDown (countDown) {
if (countDown) this.count = countDown; if (countDown) this.count = countDown;
setTimeout(() => { setTimeout(() => {
let { count } = this; let { count } = this;
...@@ -86,18 +111,117 @@ export default { ...@@ -86,18 +111,117 @@ export default {
else this.count = null; else this.count = null;
}, 1e3); }, 1e3);
}, },
async login () {
const { mobile, code: smsCode } = this;
try {
uni.showLoading();
const { code, data, message } = await uni.$api.userApi.smsLogin({
mobile,
code: smsCode,
noSignIn: false,
});
console.log(code, data, message);
uni.hideLoading();
if (code == 0) {
let {
loginUserInfoList,
sessionId,
noSignInUuid,
needSelectAccount,
} = data;
if (loginUserInfoList.length) {
const loginUserObj =
loginUserInfoList.filter(
(val) =>
val.subLoginUser && Object.keys(val.subLoginUser)?.length
)[0] || {};
uni.$storage.set('sessionId', sessionId);
console.log(loginUserObj)
// getYQList();
// noSignInUuid ? setNoSignInUuid(noSignInUuid) : rmNoSignInUuid();
// 记录登录信息 已选园区店、4s店和场景
if (!needSelectAccount && Object.keys(loginUserObj)?.length && loginUserObj?.shopMerchantId && !((loginUserObj?.sceneType ?? '') === '')) {
this.getYqMerchantSceneConfig(loginUserObj, 0);
} else if (!needSelectAccount && Object.keys(loginUserObj)?.length && loginUserObj?.shopMerchantId && (loginUserObj?.sceneType ?? '') === '') {
// 已选园区店、4s店
this.getYqMerchantSceneConfig(loginUserObj, 1);
} else if (!needSelectAccount) {
// 仅选择园区店
this.getYqMerchantSceneConfig(loginUserObj, 2);
} else {
// 未记录到登录信息
this.getAccountLoginList(loginUserInfoList);
}
} else wx.$router.reLaunch('pages.nothing');
} else
uni.showModal({
title: '温馨提示',
content: message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#347BFF',
});
} catch (error) {
uni.hideLoading();
uni.showToast({
title: error,
icon: 'none',
});
}
},
async getYqMerchantSceneConfig (loginUserObj, num) {
// let checkAgreeClient = await this.checkAgreeClient(loginUserObj)
// if (!checkAgreeClient) return wx.$router.go('pages.accountItems')
// num 0已选园区店、4s店和场景 1已选园区店、4s店 2仅选择园区店
let pageUrl = ['pages.loading', 'pages.sceneIndex', 'pages.merchantList']
let { shopMerchantId, shopMerchantName } = loginUserObj
wx.$util.setUserInfo(loginUserObj)
if (num == 2) {
this.get4SStoreList(loginUserObj, pageUrl[num])
} else {
// 兼容除精品升级外场景 已选门店数据
wx.$util.setUserInfo({
...wx.$util.getUserInfo(),
default4SStoreInfo: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
},
default4SStoreInfo_crowdFunding: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
},
default4SStoreInfo_newCarConversion: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
}
})
if (num == 0) wx.$router.reLaunch(pageUrl[num])
else wx.$router.go(pageUrl[num])
this.setData({ jumpPageFlag: false })
}
},
// 获取登录账号下园区店列表
getAccountLoginList (loginUserInfoList) {
if (loginUserInfoList?.length == 1) this.getYqMerchantSceneConfig(loginUserInfoList[0], 2)
else wx.$router.go('pages.accountItems')
},
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.a{
width: 500px;
height: 200px;
}
.bg { .bg {
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
left: 0; left: 0;
top: 0; top: 0;
background-image: url('https://img02.glsx.com.cn/weapp/resource/app-tape/login/bg.png'); background-image: url("https://img02.glsx.com.cn/weapp/resource/app-tape/login/bg.png");
background-size: 100% 100%; background-size: 100% 100%;
} }
.login { .login {
...@@ -124,7 +248,7 @@ export default { ...@@ -124,7 +248,7 @@ export default {
border-radius: 56rpx; border-radius: 56rpx;
margin-bottom: 40rpx; margin-bottom: 40rpx;
box-sizing: border-box; box-sizing: border-box;
padding: 0 40rpx; padding-left: 40rpx;
display: flex; display: flex;
align-items: center; align-items: center;
input { input {
...@@ -135,6 +259,10 @@ export default { ...@@ -135,6 +259,10 @@ export default {
.icon { .icon {
margin-left: auto; margin-left: auto;
flex-shrink: 0; flex-shrink: 0;
display: flex;
align-items: center;
padding: 0 40rpx;
height: 100%;
} }
.code-btn { .code-btn {
font-weight: 500; font-weight: 500;
...@@ -142,6 +270,7 @@ export default { ...@@ -142,6 +270,7 @@ export default {
color: #2c66f7; color: #2c66f7;
flex-shrink: 0; flex-shrink: 0;
border: none; border: none;
margin-right: 40rpx;
} }
.code-disabled { .code-disabled {
color: #9b9b9e; color: #9b9b9e;
...@@ -160,7 +289,7 @@ export default { ...@@ -160,7 +289,7 @@ export default {
color: #ffffff; color: #ffffff;
} }
.btn[disabled]:not([type]), .btn[disabled]:not([type]),
.btn[disabled][type='default'] { .btn[disabled][type="default"] {
background: #c9c9c9 !important; background: #c9c9c9 !important;
} }
} }
......
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; //
var base64DecodeChars = new Array( // THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND!
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ;
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, (function (global, factory) {
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, typeof exports === 'object' && typeof module !== 'undefined'
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ? module.exports = factory()
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, : typeof define === 'function' && define.amd
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, ? define(factory) :
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); // cf. https://github.com/dankogai/js-base64/issues/119
(function () {
function encode(str) { // existing version for noConflict()
var out, i, len; var _Base64 = global.Base64;
var c1, c2, c3; var gBase64 = factory();
len = str.length; gBase64.noConflict = function () {
i = 0; global.Base64 = _Base64;
out = ""; return gBase64;
while (i < len) { };
c1 = str.charCodeAt(i++) & 0xff; if (global.Meteor) { // Meteor.js
if (i == len) { Base64 = gBase64;
out += base64EncodeChars.charAt(c1 >> 2); }
out += base64EncodeChars.charAt((c1 & 0x3) << 4); global.Base64 = gBase64;
out += "=="; })();
break; }((typeof self !== 'undefined' ? self
} : typeof window !== 'undefined' ? window
c2 = str.charCodeAt(i++); : typeof global !== 'undefined' ? global
if (i == len) { : this), function () {
out += base64EncodeChars.charAt(c1 >> 2); 'use strict';
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); /**
out += base64EncodeChars.charAt((c2 & 0xF) << 2); * base64.ts
out += "="; *
break; * Licensed under the BSD 3-Clause License.
} * http://opensource.org/licenses/BSD-3-Clause
c3 = str.charCodeAt(i++); *
out += base64EncodeChars.charAt(c1 >> 2); * References:
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); * http://en.wikipedia.org/wiki/Base64
out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); *
out += base64EncodeChars.charAt(c3 & 0x3F); * @author Dan Kogai (https://github.com/dankogai)
} */
return out; var version = '3.7.5';
} /**
* @deprecated use lowercase `version`.
function decode(str) { */
var c1, c2, c3, c4; var VERSION = version;
var i, len, out; var _hasatob = typeof atob === 'function';
len = str.length; var _hasbtoa = typeof btoa === 'function';
i = 0; var _hasBuffer = typeof Buffer === 'function';
out = ""; var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
while (i < len) { var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
/* c1 */ var b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
do { var b64chs = Array.prototype.slice.call(b64ch);
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; var b64tab = (function (a) {
} while (i < len && c1 == -1); var tab = {};
if (c1 == -1) a.forEach(function (c, i) { return tab[c] = i; });
break; return tab;
/* c2 */ })(b64chs);
do { var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; var _fromCC = String.fromCharCode.bind(String);
} while (i < len && c2 == -1); var _U8Afrom = typeof Uint8Array.from === 'function'
if (c2 == -1) ? Uint8Array.from.bind(Uint8Array)
break; : function (it) { return new Uint8Array(Array.prototype.slice.call(it, 0)); };
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4)); var _mkUriSafe = function (src) { return src
/* c3 */ .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
do { var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
c3 = str.charCodeAt(i++) & 0xff; /**
if (c3 == 61) * polyfill version of `btoa`
return out; */
c3 = base64DecodeChars[c3]; var btoaPolyfill = function (bin) {
} while (i < len && c3 == -1); // console.log('polyfilled');
if (c3 == -1) var u32, c0, c1, c2, asc = '';
break; var pad = bin.length % 3;
out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2)); for (var i = 0; i < bin.length;) {
/* c4 */ if ((c0 = bin.charCodeAt(i++)) > 255 ||
do { (c1 = bin.charCodeAt(i++)) > 255 ||
c4 = str.charCodeAt(i++) & 0xff; (c2 = bin.charCodeAt(i++)) > 255)
if (c4 == 61) throw new TypeError('invalid character found');
return out; u32 = (c0 << 16) | (c1 << 8) | c2;
c4 = base64DecodeChars[c4]; asc += b64chs[u32 >> 18 & 63]
} while (i < len && c4 == -1); + b64chs[u32 >> 12 & 63]
if (c4 == -1) + b64chs[u32 >> 6 & 63]
break; + b64chs[u32 & 63];
out += String.fromCharCode(((c3 & 0x03) << 6) | c4); }
} return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
return out; };
} /**
* does what `window.btoa` of web browsers do.
* @param {String} bin binary string
function utf16to8(str) { * @returns {string} Base64-encoded string
var out, i, len, c; */
out = ""; var _btoa = _hasbtoa ? function (bin) { return btoa(bin); }
len = str.length; : _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); }
for (i = 0; i < len; i++) { : btoaPolyfill;
c = str.charCodeAt(i); var _fromUint8Array = _hasBuffer
if ((c >= 0x0001) && (c <= 0x007F)) { ? function (u8a) { return Buffer.from(u8a).toString('base64'); }
out += str.charAt(i); : function (u8a) {
} else if (c > 0x07FF) { // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); var maxargs = 0x1000;
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); var strs = [];
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); for (var i = 0, l = u8a.length; i < l; i += maxargs) {
} else { strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); }
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); return _btoa(strs.join(''));
} };
} /**
return out; * converts a Uint8Array to a Base64 string.
} * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
* @returns {string} Base64 string
function utf8to16(str) { */
var out, i, len, c; var fromUint8Array = function (u8a, urlsafe) {
var char2, char3; if (urlsafe === void 0) { urlsafe = false; }
out = ""; return urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
len = str.length; };
i = 0; // This trick is found broken https://github.com/dankogai/js-base64/issues/130
while (i < len) { // const utob = (src: string) => unescape(encodeURIComponent(src));
c = str.charCodeAt(i++); // reverting good old fationed regexp
switch (c >> 4) { var cb_utob = function (c) {
case 0: if (c.length < 2) {
case 1: var cc = c.charCodeAt(0);
case 2: return cc < 0x80 ? c
case 3: : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
case 4: + _fromCC(0x80 | (cc & 0x3f)))
case 5: : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
case 6: + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
case 7: + _fromCC(0x80 | (cc & 0x3f)));
// 0xxxxxxx }
out += str.charAt(i - 1); else {
break; var cc = 0x10000
case 12: + (c.charCodeAt(0) - 0xD800) * 0x400
case 13: + (c.charCodeAt(1) - 0xDC00);
// 110x xxxx 10xx xxxx return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
char2 = str.charCodeAt(i++); + _fromCC(0x80 | ((cc >>> 12) & 0x3f))
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
break; + _fromCC(0x80 | (cc & 0x3f)));
case 14: }
// 1110 xxxx 10xx xxxx 10xx xxxx };
char2 = str.charCodeAt(i++); var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
char3 = str.charCodeAt(i++); /**
out += String.fromCharCode(((c & 0x0F) << 12) | * @deprecated should have been internal use only.
((char2 & 0x3F) << 6) | * @param {string} src UTF-8 string
((char3 & 0x3F) << 0)); * @returns {string} UTF-16 string
break; */
} var utob = function (u) { return u.replace(re_utob, cb_utob); };
} //
return out; var _encode = _hasBuffer
} ? function (s) { return Buffer.from(s, 'utf8').toString('base64'); }
: _TE
? function (s) { return _fromUint8Array(_TE.encode(s)); }
module.exports = { : function (s) { return _btoa(utob(s)); };
encode: encode, /**
decode: decode, * converts a UTF-8-encoded string to a Base64 string.
utf16to8: utf16to8, * @param {boolean} [urlsafe] if `true` make the result URL-safe
utf8to16: utf8to16 * @returns {string} Base64 string
} */
var encode = function (src, urlsafe) {
if (urlsafe === void 0) { urlsafe = false; }
return urlsafe
? _mkUriSafe(_encode(src))
: _encode(src);
};
/**
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
* @returns {string} Base64 string
*/
var encodeURI = function (src) { return encode(src, true); };
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
// const btou = (src: string) => decodeURIComponent(escape(src));
// reverting good old fationed regexp
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
var cb_btou = function (cccc) {
switch (cccc.length) {
case 4:
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
| ((0x3f & cccc.charCodeAt(1)) << 12)
| ((0x3f & cccc.charCodeAt(2)) << 6)
| (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
return (_fromCC((offset >>> 10) + 0xD800)
+ _fromCC((offset & 0x3FF) + 0xDC00));
case 3:
return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
| ((0x3f & cccc.charCodeAt(1)) << 6)
| (0x3f & cccc.charCodeAt(2)));
default:
return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
| (0x3f & cccc.charCodeAt(1)));
}
};
/**
* @deprecated should have been internal use only.
* @param {string} src UTF-16 string
* @returns {string} UTF-8 string
*/
var btou = function (b) { return b.replace(re_btou, cb_btou); };
/**
* polyfill version of `atob`
*/
var atobPolyfill = function (asc) {
// console.log('polyfilled');
asc = asc.replace(/\s+/g, '');
if (!b64re.test(asc))
throw new TypeError('malformed base64.');
asc += '=='.slice(2 - (asc.length & 3));
var u24, bin = '', r1, r2;
for (var i = 0; i < asc.length;) {
u24 = b64tab[asc.charAt(i++)] << 18
| b64tab[asc.charAt(i++)] << 12
| (r1 = b64tab[asc.charAt(i++)]) << 6
| (r2 = b64tab[asc.charAt(i++)]);
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
: r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
: _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
}
return bin;
};
/**
* does what `window.atob` of web browsers do.
* @param {String} asc Base64-encoded string
* @returns {string} binary string
*/
var _atob = _hasatob ? function (asc) { return atob(_tidyB64(asc)); }
: _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
: atobPolyfill;
//
var _toUint8Array = _hasBuffer
? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
: function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); };
/**
* converts a Base64 string to a Uint8Array.
*/
var toUint8Array = function (a) { return _toUint8Array(_unURI(a)); };
//
var _decode = _hasBuffer
? function (a) { return Buffer.from(a, 'base64').toString('utf8'); }
: _TD
? function (a) { return _TD.decode(_toUint8Array(a)); }
: function (a) { return btou(_atob(a)); };
var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); };
/**
* converts a Base64 string to a UTF-8 string.
* @param {String} src Base64 string. Both normal and URL-safe are supported
* @returns {string} UTF-8 string
*/
var decode = function (src) { return _decode(_unURI(src)); };
/**
* check if a value is a valid Base64 string
* @param {String} src a value to check
*/
var isValid = function (src) {
if (typeof src !== 'string')
return false;
var s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
};
//
var _noEnum = function (v) {
return {
value: v, enumerable: false, writable: true, configurable: true
};
};
/**
* extend String.prototype with relevant methods
*/
var extendString = function () {
var _add = function (name, body) { return Object.defineProperty(String.prototype, name, _noEnum(body)); };
_add('fromBase64', function () { return decode(this); });
_add('toBase64', function (urlsafe) { return encode(this, urlsafe); });
_add('toBase64URI', function () { return encode(this, true); });
_add('toBase64URL', function () { return encode(this, true); });
_add('toUint8Array', function () { return toUint8Array(this); });
};
/**
* extend Uint8Array.prototype with relevant methods
*/
var extendUint8Array = function () {
var _add = function (name, body) { return Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); };
_add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });
_add('toBase64URI', function () { return fromUint8Array(this, true); });
_add('toBase64URL', function () { return fromUint8Array(this, true); });
};
/**
* extend Builtin prototypes with relevant methods
*/
var extendBuiltins = function () {
extendString();
extendUint8Array();
};
var gBase64 = {
version: version,
VERSION: VERSION,
atob: _atob,
atobPolyfill: atobPolyfill,
btoa: _btoa,
btoaPolyfill: btoaPolyfill,
fromBase64: decode,
toBase64: encode,
encode: encode,
encodeURI: encodeURI,
encodeURL: encodeURI,
utob: utob,
btou: btou,
decode: decode,
isValid: isValid,
fromUint8Array: fromUint8Array,
toUint8Array: toUint8Array,
extendString: extendString,
extendUint8Array: extendUint8Array,
extendBuiltins: extendBuiltins
};
//
// export Base64 to the namespace
//
// ES5 is yet to have Object.assign() that may make transpilers unhappy.
// gBase64.Base64 = Object.assign({}, gBase64);
gBase64.Base64 = {};
Object.keys(gBase64).forEach(function (k) { return gBase64.Base64[k] = gBase64[k]; });
return gBase64;
}));
...@@ -2,7 +2,9 @@ import config from '@/config.js' ...@@ -2,7 +2,9 @@ import config from '@/config.js'
// 在h5端上传涉及到跨域,需在阿里云上配置跨域规则才能正常使用 // 在h5端上传涉及到跨域,需在阿里云上配置跨域规则才能正常使用
module.exports = { module.exports = {
uploadImageUrl: config.OSS_DOMAIN + '/', // 默认存在根目录后面要跟个'/' (在你当前小程序的后台的uploadFile 合法域名也要配上这个域名) bucketName: config.BUKET_NAME,
folder: config.FOLDER,
uploadUrl: config.OSS_DOMAIN + '/', // 默认存在根目录后面要跟个'/' (在你当前小程序的后台的uploadFile 合法域名也要配上这个域名)
AccessKeySecret: config.ACCESSKEYSECRET, // AccessKeySecret 去你的阿里云上控制台上找 AccessKeySecret: config.ACCESSKEYSECRET, // AccessKeySecret 去你的阿里云上控制台上找
OSSAccessKeyId: config.ACCESSKEYID, // AccessKeyId 去你的阿里云上控制台上找 OSSAccessKeyId: config.ACCESSKEYID, // AccessKeyId 去你的阿里云上控制台上找
timeout: 87600 // 这个是上传文件时Policy的失效时间 timeout: 87600 // 这个是上传文件时Policy的失效时间
......
This diff could not be displayed because it is too large.
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:51
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-08 10:53:29
* @FilePath: \gl_tape\utils\ossUploadFile\uploadFile.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// base64,Hmac,Sha1,Crypto 相关算法 // base64,Hmac,Sha1,Crypto 相关算法
import config from './config.js'; import config from "./config.js";
import base64 from './base64.js'; import base64 from "./base64.js";
import Hmac from './hmac.js'; import Hmac from "./hmac.js";
import Sha1 from './sha1.js'; import Sha1 from "./sha1.js";
import Crypto from './crypto.js'; import Crypto from "./crypto.js";
/** /**
* 上传文件到阿里云oss * 上传文件到阿里云oss
* @param {string} filePath 图片的本地资源路径 * @param {string} filePath 图片的本地资源路径
* @param {string} dir 表示要传到哪个目录下 * @param {string} dir 表示要传到哪个目录下
* @return 完整的图片地址 * @return 完整的图片地址
*/ */
const uploadFile = function(filePath, dir) { const uploadFile = function (filePath) {
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
if (!filePath || filePath.length < 9) { if (!filePath || filePath.length < 9) {
uni.showModal({ uni.showModal({
title: '图片错误', title: "文件错误",
content: '请重试', content: "请重试",
showCancel: false, showCancel: false,
}) });
reject('图片错误'); reject("文件错误");
} }
// 获取上传的文件类型
console.log('上传图片中...'); let fileTypeIndex = filePath.lastIndexOf("/");
let fileType = filePath.substring(fileTypeIndex + 1);
// #ifdef H5 let aliyunFileKey = config.folder + fileType;
// 图片名字 可以自行定义 const aliyunServerURL = config.uploadUrl; // OSS地址
let aliyunFileKey = dir + '.png'; const accessid = config.OSSAccessKeyId;
// #endif const policyBase64 = getPolicyBase64();
const { signature, securityToken, lsaccessKeyId } = await getSignature(
// #ifndef H5 policyBase64
// 获取上传的文件类型 ); // 获取签名
let fileTypeIndex = filePath.lastIndexOf('.');
let fileType = filePath.substring(fileTypeIndex);
let aliyunFileKey = dir + fileType;
// #endif
const aliyunServerURL = config.uploadImageUrl; // OSS地址,需要https
const accessid = config.OSSAccessKeyId;
const policyBase64 = getPolicyBase64();
const signature = getSignature(policyBase64); // 获取签名
uni.uploadFile({ uni.uploadFile({
url: aliyunServerURL, // 开发者服务器url url: aliyunServerURL, // 开发者服务器url
filePath: filePath, // 要上传文件资源的路径 filePath: filePath, // 要上传文件资源的路径
name: 'file', // 必须填file name: "file", // 必须填file
formData: { formData: {
'key': aliyunFileKey, key: aliyunFileKey,
'policy': policyBase64, policy: policyBase64,
'OSSAccessKeyId': accessid, OSSAccessKeyId: lsaccessKeyId,
'success_action_status': '200', // 让服务端返回200, 不然默认会返回204 success_action_status: "200", // 让服务端返回200, 不然默认会返回204
'signature': signature, signature: signature,
}, "x-oss-security-token": securityToken, // 使用STS签名时必传。
success: function(res) { },
if (res.statusCode != 200) { success: function (res) {
reject(new Error('上传错误:' + JSON.stringify(res))); console.log(res, 444);
} if (res.statusCode != 200) {
resolve(aliyunServerURL + aliyunFileKey); reject(new Error("上传错误:" + JSON.stringify(res)));
}, }
fail: function(err) { resolve(aliyunServerURL + aliyunFileKey);
err.domainName = aliyunServerURL; },
reject(err); fail: function (err) {
}, err.domainName = aliyunServerURL;
}) reject(err);
}); },
} });
});
};
const getPolicyBase64 = function() { const getPolicyBase64 = function () {
let date = new Date(); let date = new Date();
date.setHours(date.getHours() + config.timeout); date.setHours(date.getHours() + config.timeout);
let srcT = date.toISOString(); let srcT = date.toISOString();
const policyText = { const policyText = {
"expiration": '2099-01-01T12:00:00.000Z', //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了 expiration: srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
"conditions": [ conditions: [
["content-length-range", 0, 5242880] // 设置上传文件的大小限制(5m) ["content-length-range", 0, 1024 * 1024 * 1024], // 设置上传文件的大小限制(5m)
] ],
}; };
const policyBase64 = base64.encode(JSON.stringify(policyText)); const policyBase64 = base64.encode(JSON.stringify(policyText));
return policyBase64; return policyBase64;
} };
// 生成签名 // 生成签名
const getSignature = function(policyBase64) { const getSignature = function (policyBase64) {
const accesskey = config.AccessKeySecret; return new Promise(async (reslove) => {
const bytes = Crypto.HMAC(Crypto.SHA1, policyBase64, accesskey, { const result = uni.$api.commonApi.getToken({}).then((res) => {
asBytes: true const { lsaccessKeySecret, securityToken, lsaccessKeyId } = res;
}); const bytes = Crypto.HmacSHA1(policyBase64, lsaccessKeySecret);
const signature = Crypto.util.bytesToBase64(bytes); const signature = Crypto.enc.Base64.stringify(bytes);
return signature; reslove({
} signature,
securityToken,
lsaccessKeyId,
});
});
// const result = await uni.request({
// url: 'https://dj.test.glsx.com.cn/rop-dj-smartcarlife/router',
// data: {
// method: 'dj.api.mindworkplate.badge.getToken',
// appKey: '48e5e13229b82c1b4e6e8c96151f0637',
// timestamp: '1712487472621',
// v: '1.0.0',
// format: 'json',
// locale: 'zh_CN',
// sessionId: '98152bee-7533-41ed-bc94-60310f2df6f0',
// sign: '238CE46892F88BBAD035BAEA73E27AC7C080F340'
// },
// success(res) {
// const {
// lsaccessKeySecret,
// securityToken,
// lsaccessKeyId
// } = res.data.data;
// const bytes = Crypto.HmacSHA1(policyBase64, lsaccessKeySecret);
// const signature = Crypto.enc.Base64.stringify(bytes);
// reslove({
// signature,
// securityToken,
// lsaccessKeyId
// })
// }
// })
});
};
module.exports = uploadFile; module.exports = uploadFile;
import defaultStorage from './storage';
export default defaultStorage;
\ No newline at end of file \ No newline at end of file
export default {
// 设置永久缓存
set(key, value) {
uni.setStorageSync(key, value);
},
// 获取永久缓存
get(key) {
return uni.getStorageSync(key);
},
// 移除永久缓存
remove(key) {
uni.removeStorageSync(key);
},
// 移除全部永久缓存
clear() {
uni.clearStorageSync();
},
};
\ No newline at end of file \ No newline at end of file
export const setToken = (data) => {
uni.setStorageSync('token', data);
};
export const getToken = () => uni.getStorageSync('token');
export const removeToken = () => {
uni.removeStorageSync('token');
};
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!