filecache
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<view class="page_container">
|
||||
<view class="login">
|
||||
<view class="logo">
|
||||
<img src="static/images/about_logo.png" alt="" />
|
||||
<img :src="cdn(config.app_logo)" alt="" />
|
||||
<view class="title">欢迎使用{{ config.name }}</view>
|
||||
</view>
|
||||
<u-tabs v-if="1 == 2" :list="list" :current="active" @click="click"></u-tabs>
|
||||
@@ -67,6 +67,7 @@ import AreaPicker from "@/components/AreaPicker";
|
||||
import { checkLoginError } from "@/util/common";
|
||||
import { SmsUserFor } from "@/constant";
|
||||
import IMSDK from "openim-uniapp-polyfill";
|
||||
import util from "@/util/index.js"
|
||||
|
||||
let timer;
|
||||
|
||||
@@ -119,6 +120,7 @@ export default {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
...util,
|
||||
click({ index }) {
|
||||
this.active = index;
|
||||
},
|
||||
@@ -148,7 +150,7 @@ export default {
|
||||
this.eying = !this.eying;
|
||||
},
|
||||
toRegisterOrForget(isRegister) {
|
||||
uni.$u.route("/pages/login/common/index", {
|
||||
uni.$u.route("/pages/common/login/index", {
|
||||
isRegister,
|
||||
});
|
||||
},
|
||||
@@ -279,7 +281,7 @@ export default {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
width: 160rpx;
|
||||
|
||||
@@ -23,13 +23,16 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<canvas canvas-id="qrcode_canvas" id="qrcode_canvas" style="width: 600rpx; height: 600rpx"></canvas>
|
||||
<view id="qrcode_canvas_container" style="width: 600rpx; height: 600rpx">
|
||||
<canvas canvas-id="qrcode_canvas" id="qrcode_canvas" style="width: 600rpx; height: 600rpx"></canvas>
|
||||
</view>
|
||||
<u-gap></u-gap>
|
||||
<view style="color: #b4b4b4;">扫一扫上面的二维码图案,加我为朋友</view>
|
||||
</view>
|
||||
<view style="width: 80%;display: flex;align-items: center;justify-content: center;height: 20%;">
|
||||
<u-button type="default" plain :hairline="false" iconColor="#9aa2b2" @click="scan">扫一扫</u-button>
|
||||
<u-button type="default" plain :hairline="false" iconColor="#9aa2b2">换个样式</u-button>
|
||||
<u-button @click="save" type="default" plain :hairline="false" iconColor="#9aa2b2">保存图片</u-button>
|
||||
<u-button @click="scan" type="default" plain :hairline="false" color="#506388" iconColor="#9aa2b2">扫一扫</u-button>
|
||||
<u-button @click="createQrcode" type="default" plain :hairline="false" color="#506388" iconColor="#9aa2b2">换个样式</u-button>
|
||||
<u-button @click="save" type="default" plain :hairline="false" color="#506388" iconColor="#9aa2b2">保存图片</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -40,7 +43,6 @@
|
||||
import UserBase from '@/components/User.vue';
|
||||
import util from "@/util";
|
||||
import { mapGetters } from "vuex";
|
||||
import md5 from "md5";
|
||||
export default {
|
||||
mixins:[UserBase],
|
||||
components: {
|
||||
@@ -55,12 +57,21 @@
|
||||
showName:"",
|
||||
faceURL:"",
|
||||
code:"",
|
||||
}
|
||||
},
|
||||
qrcodeSize:"360",
|
||||
qrcodeStyle:[]
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(["storeFriendList","storeGroupList","config"]),
|
||||
},
|
||||
watch:{
|
||||
qrcodeSize(nv,ov){
|
||||
if(nv && this.qrcodeUrl){
|
||||
this.createQrcode();
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(opt) {
|
||||
if(opt.sourceInfo){
|
||||
this.source = JSON.parse(opt.sourceInfo);
|
||||
@@ -72,14 +83,36 @@
|
||||
code:"",
|
||||
};
|
||||
}
|
||||
console.log(this.config);
|
||||
if(this.source.type == "user"){
|
||||
this.qrcodeUrl = `${this.config.website}/u/${this.source.code}`;
|
||||
}else{
|
||||
this.qrcodeUrl = `${this.config.website}/g/${this.source.code}`;
|
||||
}
|
||||
console.log(this.qrcodeUrl);
|
||||
this.createQrcode();
|
||||
this.qrcodeStyle.push({
|
||||
background: "#fff", // 背景色
|
||||
foreground: '#000000', // 前景色
|
||||
pdground: '#000000', // 定位角点颜色
|
||||
correctLevel: 3, // 容错级别
|
||||
image: this.config.app_logo, // 二维码图标
|
||||
imageSize: 40, // 二维码图标大小
|
||||
});
|
||||
this.qrcodeStyle.push({
|
||||
background: "#fff", // 背景色
|
||||
foreground: '#000000', // 前景色
|
||||
pdground: '#000000', // 定位角点颜色
|
||||
correctLevel: 3, // 容错级别
|
||||
image: this.source.faceURL, // 二维码图标
|
||||
imageSize: 40, // 二维码图标大小
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
const _this = this;
|
||||
uni.createSelectorQuery().in(this).select("#qrcode_canvas_container")
|
||||
.boundingClientRect((data) => {
|
||||
_this.qrcodeSize = data.width
|
||||
|
||||
})
|
||||
.exec();
|
||||
},
|
||||
methods: {
|
||||
...util,
|
||||
@@ -98,26 +131,47 @@
|
||||
},
|
||||
createQrcode() {
|
||||
const _this = this;
|
||||
const style = this.qrcodeStyle[Math.floor(Math.random() * this.qrcodeStyle.length)];
|
||||
style.imageSize = parseInt(this.qrcodeSize * 0.2);
|
||||
return new Promise((resolve, reject) => {
|
||||
new QRCode({
|
||||
context: _this, // 上下文环境
|
||||
canvasId: 'qrcode_canvas', // canvas-id
|
||||
usingComponents: true, // 是否是自定义组件
|
||||
showLoading: false, // 是否显示loading
|
||||
loadingText: "", // loading文字
|
||||
text: `${this.qrcodeUrl}`, // 生成内容
|
||||
size: 320, // 二维码大小
|
||||
background: "#fff", // 背景色
|
||||
foreground: '#000000', // 前景色
|
||||
pdground: '#000000', // 定位角点颜色
|
||||
correctLevel: 3, // 容错级别
|
||||
image: "", // 二维码图标
|
||||
imageSize: 40, // 二维码图标大小
|
||||
cbResult: function(res) { // 生成二维码的回调
|
||||
_this.qrcode_src = (res)
|
||||
//resolve(res);
|
||||
},
|
||||
});
|
||||
var createFn = (icon)=>{
|
||||
console.log(icon)
|
||||
new QRCode({
|
||||
context: _this, // 上下文环境
|
||||
canvasId: 'qrcode_canvas', // canvas-id
|
||||
usingComponents: true, // 是否是自定义组件
|
||||
showLoading: false, // 是否显示loading
|
||||
loadingText: "", // loading文字
|
||||
text: `${_this.qrcodeUrl}`, // 生成内容
|
||||
size: _this.qrcodeSize, // 二维码大小
|
||||
background: style.background, // 背景色
|
||||
foreground: style.foreground, // 前景色
|
||||
pdground: style.pdground, // 定位角点颜色
|
||||
correctLevel: 3, // 容错级别
|
||||
image: icon || "", // 二维码图标
|
||||
imageSize: style.imageSize || 40, // 二维码图标大小
|
||||
cbResult: function(res) { // 生成二维码的回调
|
||||
_this.qrcode_src = (res)
|
||||
//resolve(res);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if(!style.image){
|
||||
createFn();
|
||||
return ;
|
||||
}
|
||||
if(style.image.startsWith("/static/images")){
|
||||
createFn(style.image);
|
||||
return ;
|
||||
}
|
||||
if(!style.image.startsWith("http")){
|
||||
style.image = util.cdn(style.image);
|
||||
}
|
||||
util.cacheFile(style.image,'avatar').then(fn=>{
|
||||
createFn(fn);
|
||||
});
|
||||
return ;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
onReady() {},
|
||||
methods: {
|
||||
back() {
|
||||
uni.$u.route("/pages/login/common/index", {
|
||||
uni.$u.route("/pages/common/login/index", {
|
||||
isRegister: this.isRegister,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
});
|
||||
})
|
||||
.catch(({data,errCode,errMsg}) => {
|
||||
console.log(errCode,errMsg);
|
||||
console.log(errCode,errMsg,data);
|
||||
uni.$u.toast(errMsg);
|
||||
this.updateOneMessage({
|
||||
message: data,
|
||||
|
||||
@@ -31,11 +31,7 @@
|
||||
return {
|
||||
loadingWidth: "120px",
|
||||
maxHeight:'120px',
|
||||
src:"",
|
||||
coverCachePath:"",
|
||||
coverDownloading:false,
|
||||
coverExists:false,
|
||||
coverDownloadProgress:"",
|
||||
src:""
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -52,40 +48,11 @@
|
||||
methods: {
|
||||
async init(){
|
||||
const self = this;
|
||||
let url = "";
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.message.FaceElem.data;
|
||||
const key = md5(snapshotUrl || '');
|
||||
this.coverCachePath = `_doc/${this.conversationID}/face_${key}.jpg`;
|
||||
if (typeof plus === 'undefined' || !this.coverCachePath) return;
|
||||
try {
|
||||
// 检查封面是否存在
|
||||
const coverExists = await util.fileExsit(self.coverCachePath);
|
||||
this.coverExists = !!coverExists;
|
||||
if (this.coverExists) {
|
||||
this.src = this.coverCachePath;
|
||||
return;
|
||||
}
|
||||
if (!snapshotUrl) {
|
||||
this.src="/static/images/sync_error.png";
|
||||
return;
|
||||
}
|
||||
this.coverDownloading = true;
|
||||
await new Promise((resolve, reject) => {
|
||||
util.downloadFile(snapshotUrl, self.coverCachePath, function(localPath) {
|
||||
self.coverDownloading = false;
|
||||
self.coverExists = true;
|
||||
resolve(localPath);
|
||||
}, function(err) {
|
||||
self.coverDownloading = false;
|
||||
reject(err);
|
||||
}, function(progress) {
|
||||
self.coverDownloadProgress = progress;
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
this.coverDownloading = false;
|
||||
}
|
||||
// 检查封面是否存在
|
||||
util.cacheFile(snapshotUrl,'face').then((fn)=>{
|
||||
self.src = fn;
|
||||
});
|
||||
},
|
||||
onLoaded() {
|
||||
this.loadingWidth = "auto";
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
<script>
|
||||
import util from "@/util"
|
||||
import md5 from "md5";
|
||||
export default {
|
||||
name: "LocationMessageRender",
|
||||
components: {},
|
||||
@@ -78,23 +77,14 @@
|
||||
},
|
||||
async init(){
|
||||
const self = this;
|
||||
let url = "";
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.apisrc ;
|
||||
const key = md5(snapshotUrl || '');
|
||||
const dir_name = `${this.conversationID}`;
|
||||
const save_file_name = `loc_${key}.png`;
|
||||
const coverCachePath = `${dir_name}/${save_file_name}`;
|
||||
if (typeof plus === 'undefined' || !coverCachePath) return;
|
||||
self.coverDownloading = true;
|
||||
util.cacheFile(snapshotUrl,coverCachePath,(fn)=>{
|
||||
util.cacheFile(snapshotUrl,dir_name).then((fn)=>{
|
||||
self.coverDownloading = false;
|
||||
self.getImageInfo(fn);
|
||||
//console.log(fn);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
clickMediaItem() {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
//console.log(this.message);
|
||||
console.log(this.message);
|
||||
return {
|
||||
loadingWidth: "120px",
|
||||
src:"",
|
||||
@@ -60,23 +60,18 @@
|
||||
let url = "";
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = (this.message.pictureElem.snapshotPicture?.url ?? this.message.pictureElem.sourcePath );
|
||||
const key = md5(snapshotUrl || '');
|
||||
this.coverCachePath = `${this.conversationID}/img_${key}.jpg`;
|
||||
util.cacheFile(snapshotUrl,this.coverCachePath,(e)=>{
|
||||
//console.log(snapshotUrl);
|
||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||
self.coverDownloading = false;
|
||||
self.src = coverCachePath;
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
self.src = fn;
|
||||
console.log(fn);
|
||||
});
|
||||
},
|
||||
clickMediaItem() {
|
||||
uni.previewImage({
|
||||
current: 0,
|
||||
//urls: [this.message.pictureElem.sourcePicture.url],
|
||||
urls: ["_doc/"+this.coverCachePath],
|
||||
urls: [this.src],
|
||||
indicator: "none",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -116,21 +116,12 @@
|
||||
},
|
||||
methods: {
|
||||
async init(){
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
||||
const key = md5(this.message?.videoElem?.videoUrl || '');
|
||||
const coverCachePath = `${this.conversationID}/cover_${key}.jpg`;
|
||||
this.videoCachePath = `${this.conversationID}/${key}.mp4`;
|
||||
this.videoExists = await util.fileExists(this.videoCachePath);
|
||||
self.coverDownloading = true;
|
||||
util.cacheFile(snapshotUrl,coverCachePath,(e)=>{
|
||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||
self.coverDownloading = false;
|
||||
self.src = coverCachePath;
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
self.src = fn;
|
||||
console.log(fn);
|
||||
});
|
||||
},
|
||||
clickMediaItem() {
|
||||
@@ -145,10 +136,6 @@
|
||||
},
|
||||
onOverlayClick() {
|
||||
// 点击覆盖层:如果视频已缓存则直接播放,否则开始下载
|
||||
if (this.videoExists) {
|
||||
this.playVideo("_doc/"+this.videoCachePath);
|
||||
return;
|
||||
}
|
||||
const url = this.message?.videoElem?.videoUrl || this.message?.videoElem?.videoPath;
|
||||
if (!url) {
|
||||
uni.showToast({ title: '无可下载的视频' });
|
||||
@@ -156,15 +143,12 @@
|
||||
}
|
||||
this.videoDownloading = true;
|
||||
this.videoDownloadProgress = 0;
|
||||
util.downloadFile(url, this.videoCachePath, (localPath) => {
|
||||
util.downloadFile(url, `${this.conversationID}`, (prog) => {
|
||||
//this.videoDownloadProgress = prog;
|
||||
}).then((fn) => {
|
||||
this.videoDownloading = false;
|
||||
this.videoExists = true;
|
||||
this.playVideo("_doc/"+localPath);
|
||||
}, (err) => {
|
||||
this.videoDownloading = false;
|
||||
uni.showToast({ title: '下载失败' });
|
||||
}, (prog) => {
|
||||
this.videoDownloadProgress = prog;
|
||||
this.playVideo(fn);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -47,20 +47,10 @@
|
||||
//console.log(this.message);
|
||||
const self = this;
|
||||
let audio = this.message.soundElem;
|
||||
//soundPath
|
||||
// 如果有远程 snapshotUrl,则下载到 cachePath
|
||||
const snapshotUrl = audio.sourceUrl;
|
||||
const key = md5(snapshotUrl || '');
|
||||
const save_file_name = `audio_${key}.${audio.soundType}`;
|
||||
const cachePath = `${this.conversationID}/${save_file_name}`;
|
||||
if (typeof plus === 'undefined' || !cachePath) return;
|
||||
util.cacheFile(snapshotUrl,cachePath,(fn)=>{
|
||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||
self.src = fn;
|
||||
//console.log(fn);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
handleAudio(){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="page_container">
|
||||
<custom-nav-bar title="关于我们" />
|
||||
<view class="logo_area">
|
||||
<image src="@/static/images/about_logo.png" mode=""></image>
|
||||
<image :src="cdn(config.app_logo)" mode=""></image>
|
||||
<view>{{ appversion }}</view>
|
||||
|
||||
<info-item @click="checkUpdate" class="check" title="检测更新" />
|
||||
@@ -31,6 +31,7 @@
|
||||
import InfoItem from "../selfInfo/InfoItem.vue";
|
||||
import {checkUpgrade} from "@/api/login.js"
|
||||
import { mapGetters } from "vuex";
|
||||
import util from "@/util/index.js"
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
@@ -57,6 +58,7 @@
|
||||
IMSDK.unsubscribe('uploadLogsProgress', this.uploadHandler);
|
||||
},
|
||||
methods: {
|
||||
...util,
|
||||
uploadLog() {
|
||||
this.show = false
|
||||
IMSDK.asyncApi('uploadLogs',IMSDK.uuid(), {
|
||||
|
||||
Reference in New Issue
Block a user