27
This commit is contained in:
+26
-4
@@ -129,17 +129,39 @@ export const upload = (files,data,onProgress) =>{
|
|||||||
onProgress = data;
|
onProgress = data;
|
||||||
data = {};
|
data = {};
|
||||||
}
|
}
|
||||||
|
data.data = data.data ? data.data : {};
|
||||||
|
let headers = {};
|
||||||
|
if(data.token){
|
||||||
|
headers = data.headers;
|
||||||
|
delete data.headers;
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
...headers,
|
||||||
|
client:uni.getSystemInfoSync().osName,
|
||||||
|
token:uni.getStorageSync("BusinessToken"),
|
||||||
|
operationID: (Math.random() * 36).toString(36).slice(2) + new Date().getTime().toString(),
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
ClientVersion:plus.runtime.versionCode,
|
||||||
|
// #endif
|
||||||
|
// #ifndef APP-PLUS
|
||||||
|
ClientVersion:350,
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
console.log(typeof files);
|
console.log(typeof files);
|
||||||
|
let url = "/user/upload";
|
||||||
|
if(data.url){
|
||||||
|
url = data.url;
|
||||||
|
delete data.url;
|
||||||
|
}
|
||||||
|
url= config.getRegisterUrl()+url;
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
var u = uni.uploadFile({
|
var u = uni.uploadFile({
|
||||||
url: config.getRegisterUrl()+(data?.url || "/user/upload"),
|
url: url,
|
||||||
filePath: files,
|
filePath: files,
|
||||||
//files:files.length > 1 ? files : files[0],
|
//files:files.length > 1 ? files : files[0],
|
||||||
name: "file",
|
name: "file",
|
||||||
formData:data,
|
formData:data,
|
||||||
header:{
|
header:headers,
|
||||||
token:uni.getStorageSync("BusinessToken"),
|
|
||||||
},
|
|
||||||
success({data,errMsg}){
|
success({data,errMsg}){
|
||||||
console.log(data);
|
console.log(data);
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
|||||||
@@ -0,0 +1,678 @@
|
|||||||
|
<template>
|
||||||
|
<div class="cut-avatar-page" v-if="tempFilePath">
|
||||||
|
<div class="main-content" v-if="1==2">
|
||||||
|
<div class="preview-section">
|
||||||
|
<div v-if="resultPath" class="result-box">
|
||||||
|
<image :src="resultPath" mode="widthFix" class="result-image" @click="previewResult"></image>
|
||||||
|
<div class="action-row">
|
||||||
|
<button class="btn btn-outline" @click="reSelect">重新选择</button>
|
||||||
|
<button class="btn btn-primary" @click="uploadImage">确认上传</button>
|
||||||
|
</div>
|
||||||
|
<text class="tip-text">点击图片可预览大图</text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="upload-box" @click="onSelect">
|
||||||
|
<div class="placeholder-icon">+</div>
|
||||||
|
<text class="upload-text">点击上传图片</text>
|
||||||
|
<text class="upload-sub-text">支持 JPG/PNG,自动裁剪 1:1</text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="isShowEditor" class="editor-modal" :class="{ 'dark-mode': isDarkMode }">
|
||||||
|
<div class="cropper-wrapper">
|
||||||
|
<movable-area class="crop-area" :style="{ height: screenHeight + 'px' }">
|
||||||
|
<movable-view
|
||||||
|
class="crop-view"
|
||||||
|
direction="all"
|
||||||
|
:out-of-bounds="true"
|
||||||
|
:x="imgX"
|
||||||
|
:y="imgY"
|
||||||
|
:scale="scale+''"
|
||||||
|
:scale-min="0.5"
|
||||||
|
:scale-max="4"
|
||||||
|
:animation="false"
|
||||||
|
@change="onMoveChange"
|
||||||
|
@scale="onScaleChange"
|
||||||
|
:style="{ width: imgDisplayWidth + 'px', height: imgDisplayHeight + 'px' }"
|
||||||
|
>
|
||||||
|
<image :src="tempFilePath" class="target-image" :style="{ transform: 'rotate(' + rotation + 'deg)' }"></image>
|
||||||
|
</movable-view>
|
||||||
|
</movable-area>
|
||||||
|
|
||||||
|
<div class="mask-layer" :style="{ height: screenHeight + 'px' }">
|
||||||
|
<div class="mask-top" :style="{ height: (screenHeight - cropSize) / 2 + 'px' }"></div>
|
||||||
|
<div class="mask-middle" :style="{ height: cropSize + 'px' }">
|
||||||
|
<div class="mask-left" :style="{ width: (screenWidth - cropSize) / 2 + 'px' }"></div>
|
||||||
|
<div class="crop-box" :style="{ width: cropSize + 'px', height: cropSize + 'px' }">
|
||||||
|
<div class="corner c-tl"></div>
|
||||||
|
<div class="corner c-tr"></div>
|
||||||
|
<div class="corner c-bl"></div>
|
||||||
|
<div class="corner c-br"></div>
|
||||||
|
</div>
|
||||||
|
<div class="mask-right" :style="{ width: (screenWidth - cropSize) / 2 + 'px' }"></div>
|
||||||
|
</div>
|
||||||
|
<div class="mask-bottom" :style="{ height: (screenHeight - cropSize) / 2 + 'px' }"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="editor-toolbar">
|
||||||
|
<div class="tool-btn" @click="onCancel">取消</div>
|
||||||
|
<div class="tool-btn" @click="onReset"> <text class="icon-reset">↻</text> 重置 </div>
|
||||||
|
<div class="tool-btn" @click="onRotate"> <text class="icon-rotate">↻</text> 旋转 </div>
|
||||||
|
<div class="tool-btn btn-confirm" @click="onConfirm">确定</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<canvas canvas-id="cropCanvas" class="crop-canvas" :style="{ width: cropSize + 'px', height: cropSize + 'px' }"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* 核心逻辑说明:
|
||||||
|
* 1. 使用 movable-view 实现用户手势交互(拖拽、缩放)。
|
||||||
|
* 2. 使用 image 的 css transform 实现视觉上的旋转。
|
||||||
|
* 3. 最终生成时,通过计算偏移量,使用 CanvasContext 绘制图像。
|
||||||
|
* 4. 旋转后的 Canvas 绘图坐标系需要特殊处理 (translate + rotate)。
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// --- 系统/环境参数 ---
|
||||||
|
screenWidth: 375,
|
||||||
|
screenHeight: 600,
|
||||||
|
isDarkMode: false,
|
||||||
|
|
||||||
|
// --- 业务数据 ---
|
||||||
|
resultPath: '', // 最终生成的图片路径
|
||||||
|
|
||||||
|
// --- 编辑器状态 ---
|
||||||
|
isShowEditor: false,
|
||||||
|
tempFilePath: '', // 选中的原始图片路径
|
||||||
|
|
||||||
|
// --- 图片原始信息 ---
|
||||||
|
realImgWidth: 0,
|
||||||
|
realImgHeight: 0,
|
||||||
|
|
||||||
|
// --- 交互状态数据 ---
|
||||||
|
cropSize: 280, // 裁剪框大小 (正方形)
|
||||||
|
imgDisplayWidth: 0, // 图片在屏幕上的初始显示宽度
|
||||||
|
imgDisplayHeight: 0, // 图片在屏幕上的初始显示高度
|
||||||
|
|
||||||
|
// movable-view 的属性
|
||||||
|
imgX: 0,
|
||||||
|
imgY: 0,
|
||||||
|
scale: 1,
|
||||||
|
rotation: 0, // 0, 90, 180, 270
|
||||||
|
|
||||||
|
// 记录移动过程中的临时数据 (用于计算)
|
||||||
|
currentX: 0,
|
||||||
|
currentY: 0,
|
||||||
|
currentScale: 1,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initSystemInfo();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// 初始化与系统适配
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
initSystemInfo() {
|
||||||
|
const sys = uni.getSystemInfoSync();
|
||||||
|
this.screenWidth = sys.windowWidth;
|
||||||
|
this.screenHeight = sys.windowHeight;
|
||||||
|
|
||||||
|
// 适配暗黑模式
|
||||||
|
if (sys.theme === 'dark') {
|
||||||
|
this.isDarkMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 动态计算裁剪框大小 (屏幕宽度的 80%,最大 400px 用于适配 Pad)
|
||||||
|
let size = this.screenWidth * 0.8;
|
||||||
|
if (size > 400) size = 400;
|
||||||
|
this.cropSize = Math.floor(size);
|
||||||
|
},
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// 交互逻辑
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
onSelect() {
|
||||||
|
console.log('[Debug] 点击选择图片');
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['original', 'compressed'],
|
||||||
|
sourceType: ['album', 'camera'],
|
||||||
|
success: (res) => {
|
||||||
|
const src = res.tempFilePaths[0];
|
||||||
|
this.enterEditor(src);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('[Error] 选择图片失败', err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
reSelect() {
|
||||||
|
this.onSelect();
|
||||||
|
},
|
||||||
|
|
||||||
|
previewResult() {
|
||||||
|
if (this.resultPath) {
|
||||||
|
uni.previewImage({
|
||||||
|
urls: [this.resultPath],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadImage() {
|
||||||
|
console.log('[Debug] 触发上传逻辑, 路径:', this.resultPath);
|
||||||
|
// 这里预留上传 API 调用
|
||||||
|
uni.showLoading({ title: '正在上传...' });
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '模拟上传成功', icon: 'success' });
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// 编辑器逻辑
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
|
// 进入编辑模式,初始化图片位置
|
||||||
|
enterEditor(src) {
|
||||||
|
uni.showLoading({ title: '加载中...' });
|
||||||
|
|
||||||
|
uni.getImageInfo({
|
||||||
|
src: src,
|
||||||
|
success: (res) => {
|
||||||
|
this.tempFilePath = src;
|
||||||
|
this.realImgWidth = res.width;
|
||||||
|
this.realImgHeight = res.height;
|
||||||
|
|
||||||
|
// 重置状态
|
||||||
|
this.rotation = 0;
|
||||||
|
this.scale = 1;
|
||||||
|
this.currentScale = 1;
|
||||||
|
|
||||||
|
// 计算图片初始显示尺寸(使其适应屏幕宽度,类似 width: 100%)
|
||||||
|
// 这里我们让图片的短边至少填满裁剪框,方便用户操作
|
||||||
|
const ratio = this.realImgWidth / this.realImgHeight;
|
||||||
|
|
||||||
|
if (ratio > 1) {
|
||||||
|
// 横图:高度定为裁剪框大小 + 一点冗余,宽度自适应
|
||||||
|
this.imgDisplayHeight = this.cropSize;
|
||||||
|
this.imgDisplayWidth = this.imgDisplayHeight * ratio;
|
||||||
|
} else {
|
||||||
|
// 竖图
|
||||||
|
this.imgDisplayWidth = this.cropSize;
|
||||||
|
this.imgDisplayHeight = this.imgDisplayWidth / ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 居中计算
|
||||||
|
// 屏幕中心
|
||||||
|
const centerX = this.screenWidth / 2;
|
||||||
|
const centerY = this.screenHeight / 2;
|
||||||
|
|
||||||
|
// 计算 movable-view 的初始 x, y 使其居中
|
||||||
|
// movable-view 的 x,y 是相对于 movable-area (全屏) 的左上角
|
||||||
|
this.imgX = centerX - this.imgDisplayWidth / 2;
|
||||||
|
this.imgY = centerY - this.imgDisplayHeight / 2;
|
||||||
|
|
||||||
|
// 同步 current 值
|
||||||
|
this.currentX = this.imgX;
|
||||||
|
this.currentY = this.imgY;
|
||||||
|
|
||||||
|
this.isShowEditor = true;
|
||||||
|
uni.hideLoading();
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '图片加载失败', icon: 'none' });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onMoveChange(e) {
|
||||||
|
// 记录移动位置,用于最终裁剪计算
|
||||||
|
// detail: {x, y, source}
|
||||||
|
this.currentX = e.detail.x;
|
||||||
|
this.currentY = e.detail.y;
|
||||||
|
},
|
||||||
|
onReset(){
|
||||||
|
this.rotation = 0;
|
||||||
|
this.currentScale = 1;
|
||||||
|
},
|
||||||
|
onScaleChange(e) {
|
||||||
|
// detail: {scale}
|
||||||
|
this.currentScale = e.detail.scale;
|
||||||
|
},
|
||||||
|
|
||||||
|
onRotate() {
|
||||||
|
console.log('[Debug] 点击旋转');
|
||||||
|
// 顺时针旋转 90 度
|
||||||
|
this.rotation = (this.rotation + 90) % 360;
|
||||||
|
// 旋转后,可能需要重置一下缩放或位置逻辑?
|
||||||
|
// 本方案中,为了简化体验,仅做视觉旋转,
|
||||||
|
// 最终 Canvas 裁剪时根据 rotation 参数处理坐标系。
|
||||||
|
},
|
||||||
|
|
||||||
|
onCancel() {
|
||||||
|
this.isShowEditor = false;
|
||||||
|
this.tempFilePath = '';
|
||||||
|
},
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// 核心裁剪生成逻辑 (Canvas)
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
onConfirm() {
|
||||||
|
console.log('[Debug] 开始生成图片');
|
||||||
|
uni.showLoading({ title: '处理中...' });
|
||||||
|
|
||||||
|
const ctx = uni.createCanvasContext('cropCanvas', this);
|
||||||
|
|
||||||
|
// 1. 基础参数
|
||||||
|
const destSize = this.cropSize; // 画布大小 (正方形)
|
||||||
|
const halfDest = destSize / 2;
|
||||||
|
|
||||||
|
// 清空画布
|
||||||
|
ctx.setFillStyle('#FFFFFF');
|
||||||
|
ctx.fillRect(0, 0, destSize, destSize);
|
||||||
|
|
||||||
|
// 2. 计算【屏幕坐标系】下的中心点偏移
|
||||||
|
// 这里的逻辑是:找出"图片中心"相对于"裁剪框中心"在屏幕上的距离
|
||||||
|
|
||||||
|
// A. 裁剪框中心在屏幕上的坐标
|
||||||
|
const cropCenterX = (this.screenWidth - this.cropSize) / 2 + this.cropSize / 2;
|
||||||
|
const cropCenterY = (this.screenHeight - this.cropSize) / 2 + this.cropSize / 2;
|
||||||
|
|
||||||
|
// B. 图片中心在屏幕上的坐标
|
||||||
|
// 注意:movable-view 的 x,y 是左上角坐标,且 movable-view 的缩放是以中心为原点的
|
||||||
|
// 实际上 uni-app 的 movable-view 在缩放/移动后,x/y 会自动更新为当前的左上角位置
|
||||||
|
// 所以图片中心 = 当前x + (显示宽度 * 缩放 / 2)
|
||||||
|
const currentRealWidth = this.imgDisplayWidth * this.currentScale;
|
||||||
|
const currentRealHeight = this.imgDisplayHeight * this.currentScale;
|
||||||
|
|
||||||
|
const imgCenterX = this.currentX + currentRealWidth / 2;
|
||||||
|
const imgCenterY = this.currentY + currentRealHeight / 2;
|
||||||
|
|
||||||
|
// C. 算出屏幕偏移向量 (Screen Diff)
|
||||||
|
// 含义:图片中心在裁剪框中心的 右侧 diffX 像素,下方 diffY 像素
|
||||||
|
const diffX = imgCenterX - cropCenterX;
|
||||||
|
const diffY = imgCenterY - cropCenterY;
|
||||||
|
|
||||||
|
// 3. 将屏幕偏移向量【映射】到旋转后的 Canvas 坐标系
|
||||||
|
// 我们需要算出:在旋转后的坐标系里,图片中心应该在哪里 (drawX, drawY)
|
||||||
|
let drawX = 0;
|
||||||
|
let drawY = 0;
|
||||||
|
|
||||||
|
// 规范化旋转角度 (0, 90, 180, 270)
|
||||||
|
const angle = this.rotation % 360;
|
||||||
|
|
||||||
|
// 坐标系映射逻辑:
|
||||||
|
// 屏幕 X+ (向右),屏幕 Y+ (向下)
|
||||||
|
// 假设 Canvas 原点已移至中心并旋转:
|
||||||
|
switch (angle) {
|
||||||
|
case 0:
|
||||||
|
// 0度:坐标系一致
|
||||||
|
drawX = diffX;
|
||||||
|
drawY = diffY;
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
// 90度 (顺时针):Canvas X轴指向屏幕下,Canvas Y轴指向屏幕左
|
||||||
|
// 屏幕的 X+ (向右) 对应 Canvas 的 Y- (向左的相反) -> drawY = -diffX
|
||||||
|
// 屏幕的 Y+ (向下) 对应 Canvas 的 X+ (向下) -> drawX = diffY
|
||||||
|
drawX = diffY;
|
||||||
|
drawY = -diffX;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
// 180度:Canvas X轴向左,Canvas Y轴向上 (完全相反)
|
||||||
|
drawX = -diffX;
|
||||||
|
drawY = -diffY;
|
||||||
|
break;
|
||||||
|
case 270: // 相当于 -90度
|
||||||
|
// 270度:Canvas X轴向上,Canvas Y轴向右
|
||||||
|
// 屏幕 X+ (向右) 对应 Canvas Y+ -> drawY = diffX
|
||||||
|
// 屏幕 Y+ (向下) 对应 Canvas X- -> drawX = -diffY
|
||||||
|
drawX = -diffY;
|
||||||
|
drawY = diffX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 执行绘制
|
||||||
|
ctx.save();
|
||||||
|
|
||||||
|
// a. 将原点移到画布中心
|
||||||
|
ctx.translate(halfDest, halfDest);
|
||||||
|
// b. 旋转坐标系
|
||||||
|
ctx.rotate((angle * Math.PI) / 180);
|
||||||
|
|
||||||
|
// c. 绘制图片
|
||||||
|
// drawImage 的 x,y 是图片的左上角坐标
|
||||||
|
// 我们算出的 drawX, drawY 是图片中心相对于画布中心的坐标
|
||||||
|
// 所以要减去宽高的一半
|
||||||
|
ctx.drawImage(this.tempFilePath, drawX - currentRealWidth / 2, drawY - currentRealHeight / 2, currentRealWidth, currentRealHeight);
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 5. 导出图片
|
||||||
|
ctx.draw(false, () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.canvasToTempFilePath(
|
||||||
|
{
|
||||||
|
canvasId: 'cropCanvas',
|
||||||
|
width: destSize,
|
||||||
|
height: destSize,
|
||||||
|
fileType: 'jpg',
|
||||||
|
quality: 1,
|
||||||
|
success: (res) => {
|
||||||
|
this.resultPath = res.tempFilePath;
|
||||||
|
this.tempFilePath = "";
|
||||||
|
this.isShowEditor = false;
|
||||||
|
uni.hideLoading();
|
||||||
|
this.$emit('save', {path:this.resultPath});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '生成失败', icon: 'none' });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* ========================
|
||||||
|
CSS 变量定义
|
||||||
|
======================== */
|
||||||
|
.cut-avatar-page {
|
||||||
|
--primary-color: #ef3912;
|
||||||
|
--bg-color: #f8f9fa;
|
||||||
|
--text-color: #333333;
|
||||||
|
--modal-bg: #000000;
|
||||||
|
|
||||||
|
min-height: 100vh;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 适配暗黑模式 */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.page-container {
|
||||||
|
--bg-color: #1a1a1a;
|
||||||
|
--text-color: #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========================
|
||||||
|
主界面样式
|
||||||
|
======================== */
|
||||||
|
.nav-bar {
|
||||||
|
height: 44px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
/* 简单的顶部阴影 */
|
||||||
|
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-section {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px; /* Pad 适配限制 */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 上传占位框 */
|
||||||
|
.upload-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 200px;
|
||||||
|
border: 2px dashed #cccccc;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: rgba(0, 0, 0, 0.02);
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-box:active {
|
||||||
|
background-color: rgba(239, 57, 18, 0.05);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder-icon {
|
||||||
|
font-size: 40px;
|
||||||
|
color: #999;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-text {
|
||||||
|
font-size: 16px;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-sub-text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 结果展示区 */
|
||||||
|
.result-box {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-image {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
background-color: #eee;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 15px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 8px 24px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-outline {
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tip-text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========================
|
||||||
|
编辑器弹窗样式 (全屏)
|
||||||
|
======================== */
|
||||||
|
.editor-modal {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 999;
|
||||||
|
background-color: #000;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cropper-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.crop-area {
|
||||||
|
width: 100%;
|
||||||
|
/* height 由 JS 动态控制 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.crop-view {
|
||||||
|
/* 初始不可见,加载图片后显示 */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
/* 优化图片渲染 */
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 遮罩层布局 */
|
||||||
|
.mask-layer {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
pointer-events: none; /* 让事件穿透到底下的 movable-area */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mask-top,
|
||||||
|
.mask-bottom,
|
||||||
|
.mask-left,
|
||||||
|
.mask-right {
|
||||||
|
background-color: rgba(0, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mask-middle {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 裁剪框样式 */
|
||||||
|
.crop-box {
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 四个角的装饰 */
|
||||||
|
.corner {
|
||||||
|
position: absolute;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
border: 3px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.c-tl {
|
||||||
|
top: -2px;
|
||||||
|
left: -2px;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.c-tr {
|
||||||
|
top: -2px;
|
||||||
|
right: -2px;
|
||||||
|
border-left: none;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.c-bl {
|
||||||
|
bottom: -2px;
|
||||||
|
left: -2px;
|
||||||
|
border-right: none;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
.c-br {
|
||||||
|
bottom: -2px;
|
||||||
|
right: -2px;
|
||||||
|
border-left: none;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 底部工具栏 */
|
||||||
|
.editor-toolbar {
|
||||||
|
height: 80px; /* 留足安全距离 */
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 30px;
|
||||||
|
padding-bottom: constant(safe-area-inset-bottom);
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-btn {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-confirm {
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-rotate {
|
||||||
|
font-size: 18px;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Canvas 隐藏处理 */
|
||||||
|
.crop-canvas {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
top: -9999px;
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden; /* 这里用 hidden, 有些环境 display:none 会导致不渲染 */
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -128,14 +128,14 @@
|
|||||||
uni.request({
|
uni.request({
|
||||||
url:url,
|
url:url,
|
||||||
success(res){
|
success(res){
|
||||||
//console.log(res.data);
|
console.log(res.data);
|
||||||
const result = res.data.result;
|
const result = res.data.result;
|
||||||
_this.address = result.formatted_address;
|
_this.address = result.formatted_address;
|
||||||
console.log( {
|
// console.log( {
|
||||||
lng: result.location.lon,
|
// lng: result.location.lon,
|
||||||
lat: result.location.lat,
|
// lat: result.location.lat,
|
||||||
address: result.formatted_address
|
// address: result.formatted_address
|
||||||
});
|
// });
|
||||||
//return 1;
|
//return 1;
|
||||||
// 通过事件通道返回数据给父页面
|
// 通过事件通道返回数据给父页面
|
||||||
const eventChannel = _this.getOpenerEventChannel();
|
const eventChannel = _this.getOpenerEventChannel();
|
||||||
@@ -143,7 +143,9 @@
|
|||||||
eventChannel.emit('onConfirm', {
|
eventChannel.emit('onConfirm', {
|
||||||
lng: result.location.lon,
|
lng: result.location.lon,
|
||||||
lat: result.location.lat,
|
lat: result.location.lat,
|
||||||
address: result.formatted_address
|
name: result.addressComponent.town,
|
||||||
|
address: result.formatted_address,
|
||||||
|
addressComponent:result.addressComponent
|
||||||
});
|
});
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
to="/pages/contact/applicationList/index?applicationType=NewGroup"
|
to="/pages/contact/applicationList/index?applicationType=NewGroup"
|
||||||
thumb="/static/images/contact_new_group.png"></uni-list-item>
|
thumb="/static/images/contact_new_group.png"></uni-list-item>
|
||||||
<uni-list-item
|
<uni-list-item
|
||||||
|
v-if="1==2"
|
||||||
title="群聊"
|
title="群聊"
|
||||||
thumbSize="lg"
|
thumbSize="lg"
|
||||||
to="/pages/contact/groupList/index"
|
to="/pages/contact/groupList/index"
|
||||||
|
|||||||
@@ -67,7 +67,9 @@
|
|||||||
import SimpleEditor from "./SimpleEditor";
|
import SimpleEditor from "./SimpleEditor";
|
||||||
import ChatingActionBar from "./ChatingActionBar";
|
import ChatingActionBar from "./ChatingActionBar";
|
||||||
import Recoder from "./Recoder";
|
import Recoder from "./Recoder";
|
||||||
|
import {upload} from "@/api/login.js"
|
||||||
|
import IM from "@/util/im.js";
|
||||||
|
import permision from "@/js_sdk/wa-permission/permission.js"
|
||||||
const needClearTypes = [MessageType.TextMessage];
|
const needClearTypes = [MessageType.TextMessage];
|
||||||
|
|
||||||
const rtcChoose = [
|
const rtcChoose = [
|
||||||
@@ -177,8 +179,12 @@
|
|||||||
if (needClearTypes.includes(message.contentType)) {
|
if (needClearTypes.includes(message.contentType)) {
|
||||||
this.$refs.customEditor.clear();
|
this.$refs.customEditor.clear();
|
||||||
}
|
}
|
||||||
|
let method = IMMethods.SendMessage;
|
||||||
|
if([MessageType.PictureMessage,MessageType.VoiceMessage,MessageType.VideoMessage,MessageType.FileMessage].includes(message.contentType)){
|
||||||
|
method = IMMethods.SendMessageNotOss;
|
||||||
|
}
|
||||||
this.$emit("scrollToBottom");
|
this.$emit("scrollToBottom");
|
||||||
IMSDK.asyncApi(IMMethods.SendMessage, IMSDK.uuid(), {
|
IMSDK.asyncApi(method, IMSDK.uuid(), {
|
||||||
recvID: user_id,
|
recvID: user_id,
|
||||||
groupID: group_id,
|
groupID: group_id,
|
||||||
message,
|
message,
|
||||||
@@ -211,7 +217,6 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
recordAudioMsg(){
|
recordAudioMsg(){
|
||||||
|
|
||||||
if (uni.getSystemInfoSync().platform == "android") {
|
if (uni.getSystemInfoSync().platform == "android") {
|
||||||
permission.requestAndroid("android.permission.RECORD_AUDIO"); //Android请求录音权限
|
permission.requestAndroid("android.permission.RECORD_AUDIO"); //Android请求录音权限
|
||||||
} else {
|
} else {
|
||||||
@@ -281,36 +286,15 @@
|
|||||||
sendMediaMesage(paths) {
|
sendMediaMesage(paths) {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
paths.forEach(async (item) => {
|
paths.forEach(async (item) => {
|
||||||
|
console.log(item);
|
||||||
try {
|
try {
|
||||||
let message = null;
|
let message = null;
|
||||||
if(item.search('.mp4')>0){
|
if(item.search('.mp4')>0){
|
||||||
const realVideoPath = await getPurePath(item);
|
message = await IM.createVideoMessage(item);
|
||||||
console.log('处理后的可用路径', realVideoPath);
|
|
||||||
const info = await getVideoInfo(realVideoPath);
|
|
||||||
//const cover = await getVideoCover(item);
|
|
||||||
const res1 = await IMSDK.getVideoCover(item);
|
|
||||||
//console.log(res1.path);
|
|
||||||
const videoParams = {
|
|
||||||
videoPath: realVideoPath,
|
|
||||||
videoType: "mp4",
|
|
||||||
duration: info.duration,
|
|
||||||
snapshotPath: getPurePath(res1.path),
|
|
||||||
//snapshotPath: getPurePath(cover),
|
|
||||||
};
|
|
||||||
console.log('videoParams', videoParams);
|
|
||||||
message = await IMSDK.asyncApi(
|
|
||||||
IMMethods.CreateVideoMessageFromFullPath,
|
|
||||||
IMSDK.uuid(),
|
|
||||||
videoParams
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
message = await IMSDK.asyncApi(
|
message = await IM.createImageMessage(item);
|
||||||
IMMethods.CreateImageMessageFromFullPath,
|
|
||||||
IMSDK.uuid(),
|
|
||||||
getPurePath(item)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
//console.log(message);
|
console.log(message);
|
||||||
if(message){
|
if(message){
|
||||||
_this.sendMessage(message,_this.storeCurrentConversation.userID,_this.storeCurrentConversation.groupID);
|
_this.sendMessage(message,_this.storeCurrentConversation.userID,_this.storeCurrentConversation.groupID);
|
||||||
}
|
}
|
||||||
@@ -401,6 +385,31 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
pickMedia(){
|
||||||
|
const _this = this;
|
||||||
|
plus.gallery.pick(({files})=>{
|
||||||
|
console.log(files);
|
||||||
|
_this.sendMediaMesage(files);
|
||||||
|
}, (error )=>{
|
||||||
|
console.log(error);
|
||||||
|
}, {
|
||||||
|
animation:true,
|
||||||
|
confirmText:"确定",
|
||||||
|
//crop:null,
|
||||||
|
editable:true,
|
||||||
|
filename:"_doc/",
|
||||||
|
//filter:"none",//image,none,video
|
||||||
|
filter:"image",
|
||||||
|
maximum:9,
|
||||||
|
multiple:true,
|
||||||
|
permissionAlert:true,
|
||||||
|
//popover:{},
|
||||||
|
//selected:[""],
|
||||||
|
onmaxed(){
|
||||||
|
console.log("超出最大选择数");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
onUserEvent(e){
|
onUserEvent(e){
|
||||||
const _this = this;
|
const _this = this;
|
||||||
switch(e.type){
|
switch(e.type){
|
||||||
@@ -455,32 +464,7 @@
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if(e.source == "album"){
|
if(e.source == "album"){
|
||||||
// IMSDK.pickFile().then(res=>{
|
_this.pickMedia();
|
||||||
// console.log(res);
|
|
||||||
// }).catch(e=>{
|
|
||||||
// console.log(e);
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
plus.gallery.pick(({files})=>{
|
|
||||||
_this.sendMediaMesage(files);
|
|
||||||
}, (error )=>{
|
|
||||||
console.log(error);
|
|
||||||
}, {
|
|
||||||
animation:true,
|
|
||||||
confirmText:"确定",
|
|
||||||
//crop:null,
|
|
||||||
editable:true,
|
|
||||||
filename:"_doc/",
|
|
||||||
filter:"none",
|
|
||||||
maximum:9,
|
|
||||||
multiple:true,
|
|
||||||
permissionAlert:true,
|
|
||||||
//popover:{},
|
|
||||||
//selected:[""],
|
|
||||||
onmaxed(){
|
|
||||||
console.log("超出最大选择数");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "prepend_call_message":
|
case "prepend_call_message":
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<view class="video_message_container" @click="clickMediaItem">
|
<view class="video_message_container">
|
||||||
<u--image
|
<u--image
|
||||||
:showLoading="true"
|
:showLoading="true"
|
||||||
:src="src"
|
:src="src"
|
||||||
:width="imgWidth"
|
:width="imgWidth"
|
||||||
:height="maxHeight"
|
:height="maxHeight"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@load="onLoaded"
|
@load="onLoaded" >
|
||||||
@click="clickMediaItem">
|
|
||||||
<template v-slot:loading>
|
<template v-slot:loading>
|
||||||
<u-loading-icon color="red"></u-loading-icon>
|
<u-loading-icon color="red"></u-loading-icon>
|
||||||
</template>
|
</template>
|
||||||
@@ -21,8 +20,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<text class="progress-text">{{ videoDownloadProgress }}%</text>
|
<text class="progress-text">{{ videoDownloadProgress }}%</text>
|
||||||
</view>
|
</view>
|
||||||
<u-icon v-else-if="videoExists" class="play_icon" name="play-circle" size="48" color="#fff"></u-icon>
|
<u-icon v-else-if="videoExists" class="play_icon" name="play-circle" size="48" color="#ccc"></u-icon>
|
||||||
<uni-icons v-else class="play_icon" type="cloud-download" size="48" color="#fff"></uni-icons>
|
<uni-icons v-else class="play_icon" type="cloud-download" size="48" color="#ccc"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 视频播放器组件 -->
|
<!-- 视频播放器组件 -->
|
||||||
@@ -116,23 +115,17 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async init(){
|
async init(){
|
||||||
const self = this;
|
const _this = this;
|
||||||
console.log(this.message?.videoElem,this.conversationID);
|
console.log(this.message?.videoElem,this.conversationID);
|
||||||
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
||||||
self.coverDownloading = true;
|
_this.coverDownloading = true;
|
||||||
//console.log(snapshotUrl);
|
//console.log(snapshotUrl);
|
||||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||||
self.coverDownloading = false;
|
_this.coverDownloading = false;
|
||||||
self.src = fn;
|
_this.src = fn;
|
||||||
//console.log(fn);
|
//console.log(fn);
|
||||||
});
|
});
|
||||||
},
|
_this.videoExists = util.fileExsit(util.getCachePath(_this.message?.videoElem?.videoUrl,`${_this.conversationID}`));
|
||||||
clickMediaItem() {
|
|
||||||
uni.previewImage({
|
|
||||||
current: 0,
|
|
||||||
urls: [this.message.videoElem?.snapshotUrl],
|
|
||||||
indicator: "none",
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
async onLoaded() {
|
async onLoaded() {
|
||||||
this.loadingWidth = "auto";
|
this.loadingWidth = "auto";
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view v-if="isNoticeMessage" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
|
<view v-if="isNoticeMessage" class="notice_message_container" :id="`auchor${source.clientMsgID}`">
|
||||||
<text>{{ getNoticeContent }}</text>
|
<text>{{ getNoticeContent }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-else-if="source.contentType == 1519" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
|
<view v-else-if="source.contentType == 1519" class="notice_message_container" :id="`auchor${source.clientMsgID}`">
|
||||||
<text @click="toAnnouncement">{{ announcementElem.opUser.nickname }}更新了群公告</text>
|
<text @click="toAnnouncement">{{ announcementElem.opUser.nickname }}更新了群公告</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="message_wrapper">
|
<view v-else class="message_wrapper">
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
margin-bottom: 6rpx;
|
margin-bottom: 6rpx;
|
||||||
}
|
}
|
||||||
.message_content_wrap_shadow {
|
.message_content_wrap_shadow {
|
||||||
box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
|
box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
.message_content_wrap {
|
.message_content_wrap {
|
||||||
@include vCenterBox();
|
@include vCenterBox();
|
||||||
@@ -345,7 +345,7 @@
|
|||||||
// text-align: end;
|
// text-align: end;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
.message_content_wrap_shadow {
|
.message_content_wrap_shadow {
|
||||||
box-shadow: 0px 0px 2px #95e261;
|
box-shadow: 0px 0px 0px #95e261;
|
||||||
}
|
}
|
||||||
.message_content_wrap {
|
.message_content_wrap {
|
||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
@@ -375,10 +375,14 @@
|
|||||||
.notice_message_container {
|
.notice_message_container {
|
||||||
@include ellipsisWithLine(2);
|
@include ellipsisWithLine(2);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 24rpx 48rpx;
|
padding: 24rpx 48rpx;
|
||||||
|
word-break: break-word;
|
||||||
// font-size: 24rpx;
|
// font-size: 24rpx;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
|
text-align: center;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
:autoBack="true"
|
:autoBack="true"
|
||||||
>
|
>
|
||||||
<view class="u-nav-slot" slot="right" v-if="isOwner || isAdmin">
|
<view class="u-nav-slot" slot="right" v-if="isOwner || isAdmin">
|
||||||
<u-button type="primary" size="mini" @click="save">保存</u-button>
|
<u-button type="primary" @click="save">保存</u-button>
|
||||||
</view>
|
</view>
|
||||||
</u-navbar>
|
</u-navbar>
|
||||||
<u-parse v-if="!isOwner && !isAdmin" :content="announcement"></u-parse>
|
<u-parse v-if="!isOwner && !isAdmin" :content="announcement"></u-parse>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
focus
|
focus
|
||||||
autoHeight
|
autoHeight
|
||||||
height="500"
|
height="500"
|
||||||
maxlength="-1"
|
maxlength="1500"
|
||||||
border="none"
|
border="none"
|
||||||
:adjustPosition="false"
|
:adjustPosition="false"
|
||||||
class="textarea"
|
class="textarea"
|
||||||
@@ -77,4 +77,9 @@
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.textarea{
|
.textarea{
|
||||||
}
|
}
|
||||||
|
.u-nav-slot{
|
||||||
|
.u-button{
|
||||||
|
height: 60rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<u-toast ref="uToast"></u-toast>
|
<u-toast ref="uToast"></u-toast>
|
||||||
|
<c-cut-avatar ref="cutAvatar" @save="saveAvatar" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
import GroupMemberRow from "./components/GroupMemberRow.vue";
|
import GroupMemberRow from "./components/GroupMemberRow.vue";
|
||||||
import {getPurePath} from "@/util/common";
|
import {getPurePath} from "@/util/common";
|
||||||
import util from "@/util/index.js"
|
import util from "@/util/index.js"
|
||||||
|
import {upload} from "@/api/login.js";
|
||||||
|
|
||||||
const ConfirmTypes = {
|
const ConfirmTypes = {
|
||||||
Dismiss: "Dismiss",
|
Dismiss: "Dismiss",
|
||||||
@@ -273,6 +275,22 @@
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
saveAvatar(e){
|
||||||
|
if (!this.isAdmin && !this.isOwner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.tempFilePath = e.path;
|
||||||
|
upload(e.path,{
|
||||||
|
'url':"/group/avatar",
|
||||||
|
savePath: "groupavatar",
|
||||||
|
groupID: this.storeCurrentConversation.groupID,
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("上传成功",res);
|
||||||
|
//userStore.selfInfo.faceURL = res.data.faceURL;
|
||||||
|
}).catch((res1) => {
|
||||||
|
console.log("上传失败",res1);
|
||||||
|
});
|
||||||
|
},
|
||||||
updateGroupAvatar() {
|
updateGroupAvatar() {
|
||||||
if (!this.isAdmin && !this.isOwner) {
|
if (!this.isAdmin && !this.isOwner) {
|
||||||
return;
|
return;
|
||||||
@@ -285,6 +303,8 @@
|
|||||||
tempFilePaths
|
tempFilePaths
|
||||||
}) => {
|
}) => {
|
||||||
const path = tempFilePaths[0];
|
const path = tempFilePaths[0];
|
||||||
|
this.$refs.cutAvatar.enterEditor(path);
|
||||||
|
return ;
|
||||||
const nameIdx = path.lastIndexOf("/") + 1;
|
const nameIdx = path.lastIndexOf("/") + 1;
|
||||||
const typeIdx = path.lastIndexOf(".") + 1;
|
const typeIdx = path.lastIndexOf(".") + 1;
|
||||||
const fileName = path.slice(nameIdx);
|
const fileName = path.slice(nameIdx);
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<u-navbar title="选择背景图" :background="{ background: '#ffffff'}"
|
<uni-nav-bar
|
||||||
:border-bottom="false">
|
left-icon="back"
|
||||||
<view class="slot-wrap" slot="right">
|
@clickLeft="uni.$u.route({type:'back'})"
|
||||||
|
statusBar
|
||||||
|
backgroundColor="#ffffff"
|
||||||
|
:border="false"
|
||||||
|
title="选择背景图">
|
||||||
|
<template v-slot:footer>
|
||||||
<u-button :custom-style="customBtnStyle" size="mini" :disabled="submitFlag"
|
<u-button :custom-style="customBtnStyle" size="mini" :disabled="submitFlag"
|
||||||
:type="submitFlag?'info ':'success'" @click="handleLink()">设置</u-button>
|
:type="submitFlag?'info ':'success'" @click="handleLink()">设置</u-button>
|
||||||
</view>
|
</template>
|
||||||
</u-navbar>
|
</uni-nav-bar>
|
||||||
<u-grid @click="clickGrid">
|
<u-grid @click="clickGrid">
|
||||||
<u-grid-item v-for="(item, index) in bgList" :key="index" :index="index" :custom-style="item.isCheck?girdItemCustomStyle:{}">
|
<u-grid-item v-for="(item, index) in bgList" :key="index" :index="index" :custom-style="item.isCheck?girdItemCustomStyle:{}">
|
||||||
<u-image :src="item.src" width="200rpx" height="200rpx" mode="aspectFill"></u-image>
|
<u-image :src="item.src" width="200rpx" height="200rpx" mode="aspectFill"></u-image>
|
||||||
@@ -46,7 +51,10 @@ export default {
|
|||||||
handleLink(){
|
handleLink(){
|
||||||
const item = this.bgList.find(it=>it.isCheck);
|
const item = this.bgList.find(it=>it.isCheck);
|
||||||
if(item){
|
if(item){
|
||||||
this.$u.vuex('circleBgImg', item.src);
|
this.$store.commit('circle/SET_SETTINGS',{
|
||||||
|
...this.$store.storeCircleSettings,
|
||||||
|
bg:item.src
|
||||||
|
});
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta:2
|
delta:2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<u-cell-group>
|
<uni-nav-bar
|
||||||
<u-cell-item title="选择内置背景图" :title-style="titleStyle"
|
left-icon="back"
|
||||||
:border-bottom="false" :border-top="false"
|
@clickLeft="uni.$u.route({type:'back'})"
|
||||||
@click="linkToBuiltinBgImg"></u-cell-item>
|
statusBar
|
||||||
</u-cell-group>
|
backgroundColor="#ffffff"
|
||||||
<u-gap :height="16" bg-color="#f4f4f5"></u-gap>
|
title="选择背景图">
|
||||||
<u-cell-group>
|
</uni-nav-bar>
|
||||||
<u-cell-item title="通过手机选择" :title-style="titleStyle"
|
<uni-list>
|
||||||
:border-bottom="false" :border-top="false"
|
<uni-list-item disabled="true" title="选择内置背景图" @click="linkToBuiltinBgImg" clickable showArrow></uni-list-item>
|
||||||
@click="chooseImg"></u-cell-item>
|
<uni-list-item title="通过手机选择" @click="chooseImg" clickable showArrow></uni-list-item>
|
||||||
</u-cell-group>
|
</uni-list>
|
||||||
|
|
||||||
<u-toast ref="uToast" />
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {upload} from "@/api/login"
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -46,26 +45,21 @@ export default {
|
|||||||
|
|
||||||
//上传返回图片
|
//上传返回图片
|
||||||
myUpload(filePath) {
|
myUpload(filePath) {
|
||||||
let that=this;
|
let _this=this;
|
||||||
let obj = {
|
let obj = {
|
||||||
filePath:filePath,
|
filePath:filePath,
|
||||||
savePath: "friendCircle" //文件存放目录
|
'url':"/friendcircle/upload_bg",
|
||||||
|
savePath: "circle" //文件存放目录
|
||||||
}
|
}
|
||||||
console.log("通过手机选择",obj);
|
console.log("通过手机选择",obj);
|
||||||
this.globalUtil.globalUpload(that,{
|
upload(filePath,obj).then((res1) => {
|
||||||
param:obj,
|
_this.$store.commit('circle/SET_SETTINGS',{
|
||||||
success: (res1) => {
|
..._this.$store.storeCircleSettings,
|
||||||
console.log("上传成功",res1);
|
bg:res1.data.url
|
||||||
let avatar= res1.result.url;
|
});
|
||||||
that.$u.vuex('circleBgImg',avatar);
|
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
},
|
}).catch((res1) => {
|
||||||
fail:(res1) => {
|
|
||||||
console.log("上传失败",res1);
|
console.log("上传失败",res1);
|
||||||
},
|
|
||||||
complete: (res1) => {
|
|
||||||
console.log("上传完成",res1);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,7 @@
|
|||||||
<!-- 视频 -->
|
<!-- 视频 -->
|
||||||
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
|
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
|
||||||
v-if="item.files.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
|
v-if="item.files.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
|
||||||
<view v-if="vuex_OSPlat=='ios'">
|
<view class="u-flex u-row-center u-col-center"
|
||||||
<u-image width="280rpx" :src="getVideoPoster(item.files[0])" mode="widthFix">
|
|
||||||
<u-loading-icon slot="loading"></u-loading-icon>
|
|
||||||
</u-image>
|
|
||||||
</view>
|
|
||||||
<view v-else class="u-flex u-row-center u-col-center"
|
|
||||||
style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
|
style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
|
||||||
<u-icon name="play-circle" size="48" color="#36648b"
|
<u-icon name="play-circle" size="48" color="#36648b"
|
||||||
label="点击查看视频" label-pos="bottom"></u-icon>
|
label="点击查看视频" label-pos="bottom"></u-icon>
|
||||||
@@ -55,9 +50,9 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 地点 -->
|
<!-- 地点 -->
|
||||||
<view v-if="(item.address&&item.address.chooseFlag)==true" class="u-line-2 u-m-t-10 u-m-b-10" style="font-size: 30rpx;color: #36648b;">
|
<view v-if="(item.address&&item.address.chooseFlag)==true" @click="gotomap(item)" class="content-address">
|
||||||
<u-icon name="map" color="#36648b" size="30" :custom-style="{marginLeft:'-4rpx'}"></u-icon>
|
<u-icon name="map" color="#36648b"></u-icon>
|
||||||
<text> {{ item.address.name}}</text>
|
<u-text class="name" :lines="1" :text="item.address.name"></u-text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 相对时间 点赞按钮等 -->
|
<!-- 相对时间 点赞按钮等 -->
|
||||||
@@ -182,6 +177,12 @@
|
|||||||
return "http://192.168.31.125:9090/we-chat/images/friendCircle/1715421601709.mp4";
|
return "http://192.168.31.125:9090/we-chat/images/friendCircle/1715421601709.mp4";
|
||||||
//return videoSrc;
|
//return videoSrc;
|
||||||
},
|
},
|
||||||
|
gotomap(item){
|
||||||
|
const addr = item.address;
|
||||||
|
uni.navigateTo({
|
||||||
|
url:`/pages/common/map?type=viewlocation&lng=${addr.longitude}&lat=${addr.latitude}&address=${addr.address}`
|
||||||
|
})
|
||||||
|
},
|
||||||
cdn:util.cdn
|
cdn:util.cdn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,7 +255,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&-address{
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #36648b;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
.u-icon{
|
||||||
|
|
||||||
|
}
|
||||||
|
.name{
|
||||||
|
}
|
||||||
|
}
|
||||||
.msg-box {
|
.msg-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</u-navbar>
|
</u-navbar>
|
||||||
<!-- 我的朋友圈基本信息 -->
|
<!-- 我的朋友圈基本信息 -->
|
||||||
<view class="content-imgbox" :class="{top:scrollTop>bannarHeight}">
|
<view class="content-imgbox" :class="{top:scrollTop>bannarHeight}">
|
||||||
<image class="bgimg" v-if="storeCircleSettings.bg" :src="storeCircleSettings.bg" mode="scaleToFill" @tap="showSheet"></image>
|
<image class="bgimg" v-if="storeCircleSettings.bg" :src="cdn(storeCircleSettings.bg)" mode="scaleToFill" @tap="showSheet"></image>
|
||||||
<view class="bgimg" v-else @tap="showSheet"></view>
|
<view class="bgimg" v-else @tap="showSheet"></view>
|
||||||
|
|
||||||
<MyAvatar class="headimg" :src="storeSelfInfo.faceURL" :desc="storeSelfInfo.nickname || storeSelfInfo.remark"
|
<MyAvatar class="headimg" :src="storeSelfInfo.faceURL" :desc="storeSelfInfo.nickname || storeSelfInfo.remark"
|
||||||
@@ -90,9 +90,9 @@
|
|||||||
import {getFriendCircle} from "@/api/login.js"
|
import {getFriendCircle} from "@/api/login.js"
|
||||||
import UserBase from "@/components/User.vue"
|
import UserBase from "@/components/User.vue"
|
||||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||||
import util from "@/util/index.js";
|
|
||||||
import CircleItem from "./components/circleItem.vue"
|
import CircleItem from "./components/circleItem.vue"
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
import util from "@/util";
|
||||||
export default {
|
export default {
|
||||||
name: 'firendCircle',
|
name: 'firendCircle',
|
||||||
mixins:[UserBase],
|
mixins:[UserBase],
|
||||||
@@ -185,6 +185,7 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
goto:util.goto,
|
goto:util.goto,
|
||||||
|
cdn:util.cdn,
|
||||||
clearUnReadCount(){
|
clearUnReadCount(){
|
||||||
this.$store.dispatch('circle/updateUnreadCount',0-this.unreadCount);
|
this.$store.dispatch('circle/updateUnreadCount',0-this.unreadCount);
|
||||||
},
|
},
|
||||||
@@ -244,11 +245,13 @@
|
|||||||
showTypeSheet() {
|
showTypeSheet() {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
itemList:['选择照片','选择视频'],
|
itemList:['文字','照片'/*,'视频'*/],
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
//toChooseRelease
|
//toChooseRelease
|
||||||
if(res.tapIndex<2){
|
if([1,2].includes(res.tapIndex)){
|
||||||
_this.toChooseRelease(res.tapIndex);
|
_this.toChooseRelease(res.tapIndex);
|
||||||
|
}else{
|
||||||
|
_this.linkToRelease({releaseType:0})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: function (res) {
|
fail: function (res) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
:adjust-position="true" :auto-blur="true" @linechange="inputLineChange" @input="inputing"
|
:adjust-position="true" :auto-blur="true" @linechange="inputLineChange" @input="inputing"
|
||||||
:confirm-hold="true" :show-confirm-bar="false"
|
:confirm-hold="true" :show-confirm-bar="false"
|
||||||
:focus="inputFocusFlag" :disable-default-padding="true"
|
:focus="inputFocusFlag" :disable-default-padding="true"
|
||||||
v-model="content" :cursor="content.length" :maxlength="-1" />
|
v-model="content" :cursor="content.length" :maxlength="1500" />
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<!-- 文件选择区 -->
|
<!-- 文件选择区 -->
|
||||||
<view v-if="releaseType!=0" class="uploadBox">
|
<view v-if="releaseType!=0" class="uploadBox">
|
||||||
@@ -49,29 +49,33 @@
|
|||||||
</view>
|
</view>
|
||||||
<!-- 选项 -->
|
<!-- 选项 -->
|
||||||
<view class="tips">
|
<view class="tips">
|
||||||
<u-cell-group>
|
<uni-list>
|
||||||
<!-- :value="address.name" :value-style="customValueStyle" :label="address.address" -->
|
<uni-list-item
|
||||||
<u-cell bg-color="#ffffff"
|
title="所在位置"
|
||||||
:title="address.chooseFlag?(address.name):'所在位置'" :title-style="customTitleStyle"
|
:rightText="address.chooseFlag?(address.name):'请选择'"
|
||||||
:value="address.chooseFlag?(address.address):'请选择'" isLink
|
:show-extra-icon="true"
|
||||||
@click="toChooseLocation()">
|
:extra-icon="{color: '#666',size: '22',type: 'location-filled'}"
|
||||||
<view slot="icon" class="u-flex u-row-center u-col-center">
|
clickable
|
||||||
<u-icon name="map" size="32" :color="address.chooseFlag?'#19be6b':'#606266'"></u-icon>
|
showArrow
|
||||||
</view>
|
@click="toChooseLocation">
|
||||||
</u-cell>
|
</uni-list-item>
|
||||||
<u-cell bg-color="#ffffff" title="提醒谁看" :title-style="customTitleStyle" @click="toRemind">
|
<uni-list-item v-if="1==2"
|
||||||
<view slot="icon" class="u-flex u-row-center u-col-center">
|
title="提醒谁看"
|
||||||
<u-icon name="/static/images/friendCircle/at.png" width="24" height="24" color="#606266"></u-icon>
|
:rightText="address.chooseFlag?(address.address):'请选择'"
|
||||||
</view>
|
clickable
|
||||||
</u-cell>
|
showArrow
|
||||||
<u-cell bg-color="#ffffff" @click="toSetPromission()"
|
@click="toRemind">
|
||||||
title="谁可以看" :title-style="customTitleStyle"
|
</uni-list-item>
|
||||||
:value="'公开'" :value-style="customValueStyle">
|
<uni-list-item
|
||||||
<view slot="icon" class="u-flex u-row-center u-col-center">
|
title="谁可以看"
|
||||||
<u-icon name="account" size="32" color="#606266"></u-icon>
|
rightText="公开"
|
||||||
</view>
|
:show-extra-icon="true"
|
||||||
</u-cell>
|
:extra-icon="{color: '#666',size: '22',type: 'notification-filled'}"
|
||||||
</u-cell-group>
|
clickable
|
||||||
|
showArrow
|
||||||
|
@click="toSetPromission">
|
||||||
|
</uni-list-item>
|
||||||
|
</uni-list>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -273,21 +277,23 @@
|
|||||||
//去选择所在位置
|
//去选择所在位置
|
||||||
toChooseLocation:function(){
|
toChooseLocation:function(){
|
||||||
let that=this;
|
let that=this;
|
||||||
uni.chooseLocation({
|
uni.navigateTo({
|
||||||
success: function (res) {
|
url:"/pages/common/map",
|
||||||
// console.log('位置名称:' + res.name);
|
events:{
|
||||||
// console.log('详细地址:' + res.address);
|
onConfirm(res) {
|
||||||
// console.log('纬度:' + res.latitude);
|
//_this.sendLocationMessage(res);
|
||||||
//console.log('经度:' + res.longitude);
|
that.address={
|
||||||
that.address=res;
|
address:res.address,
|
||||||
|
name:`${res.addressComponent.city}•${res.addressComponent.town}`,
|
||||||
|
latitude:res.lat,
|
||||||
|
longitude:res.lng,
|
||||||
|
};
|
||||||
that.address.chooseFlag=true;
|
that.address.chooseFlag=true;
|
||||||
//console.log("that.address",that.address);
|
console.log(res);
|
||||||
},
|
|
||||||
fail:function(){
|
|
||||||
that.address={};
|
|
||||||
that.address.chooseFlag=false;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
return ;
|
||||||
},
|
},
|
||||||
//设置发布朋友圈的查看权限
|
//设置发布朋友圈的查看权限
|
||||||
toSetPromission:function(){
|
toSetPromission:function(){
|
||||||
@@ -422,28 +428,16 @@
|
|||||||
let that=this;
|
let that=this;
|
||||||
console.error('submitPublish');
|
console.error('submitPublish');
|
||||||
uni.$u.http.post('/friendcircle/create',param).then(res => {
|
uni.$u.http.post('/friendcircle/create',param).then(res => {
|
||||||
let newCircle=res;
|
console.log("发布成功",res);
|
||||||
if(newCircle.address!=null&&newCircle.address.length>0){
|
let newCircle=res.data;
|
||||||
newCircle.address=JSON.parse(newCircle.address);
|
newCircle['user'] = {
|
||||||
}else{
|
"id": this.$store.getters.storeSelfInfo.userID,
|
||||||
newCircle.address={"chooseFlag":false};
|
"nickname": this.$store.getters.storeSelfInfo.nickname,
|
||||||
}
|
"avatar": this.$store.getters.storeSelfInfo.faceURL,
|
||||||
if(newCircle.fileList!=null&&newCircle.fileList.length>0){
|
};
|
||||||
newCircle.fileList=JSON.parse(newCircle.fileList);
|
newCircle['likes'] = [];
|
||||||
}else{
|
newCircle['comments'] = [];
|
||||||
newCircle.fileList=[];
|
newCircle['is_liked'] = false;
|
||||||
}
|
|
||||||
if(newCircle.praise!=null){
|
|
||||||
newCircle.praise=JSON.parse(newCircle.praise);
|
|
||||||
}else{
|
|
||||||
newCircle.praise=[];
|
|
||||||
}
|
|
||||||
if(newCircle.comment!=null){
|
|
||||||
newCircle.comment=JSON.parse(newCircle.comment);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
newCircle.comment=[];
|
|
||||||
}
|
|
||||||
let circleDataList=[...this.circleData];
|
let circleDataList=[...this.circleData];
|
||||||
circleDataList.unshift(newCircle);
|
circleDataList.unshift(newCircle);
|
||||||
that.$store.commit('circle/SET_LIST',circleDataList);
|
that.$store.commit('circle/SET_LIST',circleDataList);
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
<u-datetime-picker :minDate="0" :maxDate="nowDate" :show="showDatePicker" @confirm="confirmDate"
|
<u-datetime-picker :minDate="0" :maxDate="nowDate" :show="showDatePicker" @confirm="confirmDate"
|
||||||
@cancel="() => (showDatePicker = false)" v-model="selfInfo.birth" mode="date" />
|
@cancel="() => (showDatePicker = false)" v-model="selfInfo.birth" mode="date" />
|
||||||
|
|
||||||
|
<c-cut-avatar ref="cutAvatar" @save="saveAvatar" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {businessInfoUpdate,upload} from "@/api/login";
|
||||||
businessInfoUpdate
|
|
||||||
} from "@/api/login";
|
|
||||||
import IMSDK from "openim-uniapp-polyfill";
|
import IMSDK from "openim-uniapp-polyfill";
|
||||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||||
@@ -87,14 +87,31 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
saveAvatar(e){
|
||||||
|
this.tempFilePath = e.path;
|
||||||
|
upload(e.path,{
|
||||||
|
'url':"/user/avatar",
|
||||||
|
savePath: "avatar"
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("上传成功",res);
|
||||||
|
this.$store.commit("user/SET_SELF_INFO",{
|
||||||
|
...this.$store.getters.storeSelfInfo,
|
||||||
|
faceURL: res.data.avatar,
|
||||||
|
});
|
||||||
|
}).catch((res1) => {
|
||||||
|
console.log("上传失败",res1);
|
||||||
|
});
|
||||||
|
},
|
||||||
updateAvatar() {
|
updateAvatar() {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
sizeType: ["compressed"],
|
sizeType: ["original"],
|
||||||
success: async ({
|
success: async ({
|
||||||
tempFilePaths
|
tempFilePaths
|
||||||
}) => {
|
}) => {
|
||||||
const path = tempFilePaths[0];
|
const path = tempFilePaths[0];
|
||||||
|
this.$refs.cutAvatar.enterEditor(path);
|
||||||
|
return ;
|
||||||
const nameIdx = path.lastIndexOf("/") + 1;
|
const nameIdx = path.lastIndexOf("/") + 1;
|
||||||
const typeIdx = path.lastIndexOf(".") + 1;
|
const typeIdx = path.lastIndexOf(".") + 1;
|
||||||
const fileName = path.slice(nameIdx);
|
const fileName = path.slice(nameIdx);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const actions = {
|
|||||||
},
|
},
|
||||||
async getFriendCircleInfo({ commit, state}) {
|
async getFriendCircleInfo({ commit, state}) {
|
||||||
uni.$u.http.get('/friendcircle/info').then(data=>{
|
uni.$u.http.get('/friendcircle/info').then(data=>{
|
||||||
|
console.log("获取朋友圈信息",data);
|
||||||
commit("SET_UNREAD_COUNT", data.unread_count);
|
commit("SET_UNREAD_COUNT", data.unread_count);
|
||||||
commit("SET_TOP_UNREAD_ITEMS", data.top_unread_items);
|
commit("SET_TOP_UNREAD_ITEMS", data.top_unread_items);
|
||||||
commit("SET_SETTINGS", data.settings);
|
commit("SET_SETTINGS", data.settings);
|
||||||
|
|||||||
+30
-4
@@ -3,6 +3,9 @@ import IMSDK,{IMMethods} from "openim-uniapp-polyfill";
|
|||||||
import {offlinePushInfo} from "@/util/imCommon";
|
import {offlinePushInfo} from "@/util/imCommon";
|
||||||
import {upload} from "@/api/login.js";
|
import {upload} from "@/api/login.js";
|
||||||
import {getVideoInfo} from "@/util/common";
|
import {getVideoInfo} from "@/util/common";
|
||||||
|
// #ifdef APP
|
||||||
|
import {downloadFile} from "@/uni_modules/network-manage";
|
||||||
|
// #endif
|
||||||
export const imapi = (method,data)=>{
|
export const imapi = (method,data)=>{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
IMSDK.asyncApi(method,IMSDK.uuid(),data)
|
IMSDK.asyncApi(method,IMSDK.uuid(),data)
|
||||||
@@ -19,10 +22,30 @@ export const copyFileToTempPath = (src) => {
|
|||||||
console.log('src', src);
|
console.log('src', src);
|
||||||
console.log('src', src.includes(plus.io.PRIVATE_DOC));
|
console.log('src', src.includes(plus.io.PRIVATE_DOC));
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
plus.io.resolveLocalFileSystemURL(src, (entry) => {
|
||||||
|
const cacheFilePath = '_doc/uniapp_temp/'+entry.name;
|
||||||
|
console.log('cacheFilePath', cacheFilePath);
|
||||||
|
const task = downloadFile({
|
||||||
|
url:src,
|
||||||
|
timeout: 30000,
|
||||||
|
filePath:cacheFilePath,
|
||||||
|
success(res) {
|
||||||
|
console.log('res',res);
|
||||||
|
},
|
||||||
|
fail(e){
|
||||||
|
console.log('e',e);
|
||||||
|
},
|
||||||
|
complate(){
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return ;
|
||||||
|
|
||||||
plus.io.resolveLocalFileSystemURL(src, (entry) => {
|
plus.io.resolveLocalFileSystemURL(src, (entry) => {
|
||||||
console.log('entry name', entry.name);
|
console.log('entry name', entry.name);
|
||||||
console.log('dir', '_doc/uniapp_temp/');
|
console.log('dir', '_doc/uniapp_temp/');
|
||||||
entry.copyTo('_doc/uniapp_temp/', entry.name, (newEntry) => {
|
entry.copyTo(plus.io.PUBLIC_DOCUMENTS, '/uniapp_temp/'+entry.name, (newEntry) => {
|
||||||
console.log('newEntry', newEntry.fullPath);
|
console.log('newEntry', newEntry.fullPath);
|
||||||
resolve(newEntry.toLocalURL());
|
resolve(newEntry.toLocalURL());
|
||||||
}, reject);
|
}, reject);
|
||||||
@@ -61,9 +84,9 @@ export const getVideoCover = async (path)=>{
|
|||||||
export const createVideoMessage = (path)=>{
|
export const createVideoMessage = (path)=>{
|
||||||
return new Promise(async(resolve, reject) => {
|
return new Promise(async(resolve, reject) => {
|
||||||
console.log('处理前的可用路径', path);
|
console.log('处理前的可用路径', path);
|
||||||
const realVideoPath = await copyFileToTempPath(path);
|
//const realVideoPath = await copyFileToTempPath(path);
|
||||||
//const realVideoPath = await getPurePath(path);
|
const realVideoPath = await getPurePath(path);
|
||||||
console.log('处理后的可用路径', realVideoPath);
|
//console.log('处理后的可用路径', realVideoPath);
|
||||||
const info = await getVideoInfo(realVideoPath);
|
const info = await getVideoInfo(realVideoPath);
|
||||||
console.log('info', info);
|
console.log('info', info);
|
||||||
const cover = await getVideoCover(realVideoPath);
|
const cover = await getVideoCover(realVideoPath);
|
||||||
@@ -80,6 +103,9 @@ export const createVideoMessage = (path)=>{
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
console.log('videoresult', videoresult);
|
console.log('videoresult', videoresult);
|
||||||
|
const video_url = "";
|
||||||
|
//封面
|
||||||
|
const cover_url = `${video_url}?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast`;
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
if(videoresult.code !=0){
|
if(videoresult.code !=0){
|
||||||
|
|||||||
@@ -245,6 +245,23 @@ const get_absolute_path = (fn)=>{
|
|||||||
return plus.io.convertLocalFileSystemURL(fn);
|
return plus.io.convertLocalFileSystemURL(fn);
|
||||||
}
|
}
|
||||||
const pendingDownloads = new Map();
|
const pendingDownloads = new Map();
|
||||||
|
const getCachePath = (url,saveDir)=>{
|
||||||
|
if(!url || !url.startsWith('http')){
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
const key = md5(url);
|
||||||
|
var ext = "png"
|
||||||
|
if(url.toLowerCase().indexOf('.mp4')!==-1){
|
||||||
|
ext = "mp4";
|
||||||
|
}
|
||||||
|
let cacheDir = plus.io.convertLocalFileSystemURL(`_doc/{{dir}}/{{key}}.{{ext}}`);
|
||||||
|
if(uni.getSystemInfoSync().osName == 'android'){
|
||||||
|
cacheDir = cacheDir.replace('apps/'+plus.runtime.appid+'/doc','cache');
|
||||||
|
}
|
||||||
|
return cacheDir.replace('{{dir}}',saveDir)
|
||||||
|
.replace('{{key}}',key)
|
||||||
|
.replace('{{ext}}',ext);
|
||||||
|
}
|
||||||
const cacheFile = (url, saveDir,progressCallback) => {
|
const cacheFile = (url, saveDir,progressCallback) => {
|
||||||
//console.log(url);
|
//console.log(url);
|
||||||
// #ifndef APP
|
// #ifndef APP
|
||||||
@@ -462,6 +479,7 @@ export default{
|
|||||||
toMapAPP,
|
toMapAPP,
|
||||||
cacheFile,
|
cacheFile,
|
||||||
fileExsit,
|
fileExsit,
|
||||||
|
getCachePath,
|
||||||
get_absolute_path,
|
get_absolute_path,
|
||||||
// #ifdef APP
|
// #ifdef APP
|
||||||
downloadFile,
|
downloadFile,
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ module.exports = (vm) => {
|
|||||||
...config.header,
|
...config.header,
|
||||||
token:uni.getStorageSync("BusinessToken"),
|
token:uni.getStorageSync("BusinessToken"),
|
||||||
operationID: uuidV4(),
|
operationID: uuidV4(),
|
||||||
|
client:uni.getSystemInfoSync().osName,
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
ClientVersion:plus.runtime.versionCode,
|
||||||
|
// #endif
|
||||||
|
// #ifndef APP-PLUS
|
||||||
|
ClientVersion:350,
|
||||||
|
// #endif
|
||||||
};
|
};
|
||||||
if(typeof config.data === 'object'){
|
if(typeof config.data === 'object'){
|
||||||
config.data = JSON.stringify(config.data);
|
config.data = JSON.stringify(config.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user