1、分享的图片二维码:上传时的错路径判断
2、发布的静态页面 3、分类的底部导航栏取消 4、积分的任务跳转页面 5、积分商城:数据接口对接
This commit is contained in:
parent
3564721d23
commit
c621ff0ff4
@ -6,70 +6,77 @@
|
||||
<view class="conTop">
|
||||
<view class="textLine">
|
||||
<view class="fs30 bold c3" style="line-height: 26rpx;">当前积分</view>
|
||||
<view class="fs60 bold c3" style="margin-top: 30rpx;line-height: 60rpx;">6963</view>
|
||||
<view class="fs60 bold c3" style="margin-top: 30rpx;line-height: 60rpx;">{{score}}</view>
|
||||
<view class="scoreDetail" @click="toPage('/pages/user/wallet/score')">
|
||||
<view class="fs28 c9">积分明细</view>
|
||||
<image style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"
|
||||
src="https://jiangxiaoxian.0rui.cn/rightMore.png"></image>
|
||||
src="https://jiangxiaoxian.0rui.cn/rightMore.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- tabs页签 -->
|
||||
<view class="tabs-box">
|
||||
<su-tabs
|
||||
:list="tabMaps"
|
||||
@change="onChange"
|
||||
:scrollable="false"
|
||||
:current="currentTab"
|
||||
></su-tabs>
|
||||
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="currentTab"></su-tabs>
|
||||
</view>
|
||||
|
||||
<!-- 可兑换券列表 -->
|
||||
<view class="exChangeBox">
|
||||
<view class="exChangeBox" v-if="currentTab == 0">
|
||||
<view class="couponsList">
|
||||
<view class="list-item">
|
||||
<image style="width: 330rpx;height: 200rpx;" src="https://jiangxiaoxian.0rui.cn/fullCoupon.png"></image>
|
||||
<view class="list-item" v-for="(item, index) in couponList" :key="index" @click="openCouponPro(item)">
|
||||
<image style="width: 330rpx;height: 200rpx;" src="https://jiangxiaoxian.0rui.cn/fullCoupon.png">
|
||||
</image>
|
||||
<view class="item-text">
|
||||
<view class="fs30 c3" style="margin: 0 auto;">优惠券满100减50</view>
|
||||
<view class="fs30 c3" style="margin: 0 auto;text-align: center;">{{item.name}}</view>
|
||||
<view class="exchangeBtn">
|
||||
100积分兑换
|
||||
{{item.score}}积分兑换
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<image style="width: 330rpx;height: 200rpx;" src="https://jiangxiaoxian.0rui.cn/fullCoupon.png"></image>
|
||||
<view class="item-text">
|
||||
<view class="fs30 c3" style="margin: 0 auto;">优惠券满100减50</view>
|
||||
<view class="exchangeBtn">
|
||||
100积分兑换
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<image style="width: 330rpx;height: 200rpx;" src="https://jiangxiaoxian.0rui.cn/fullCoupon.png"></image>
|
||||
</view>
|
||||
<!-- 次数券 -->
|
||||
<view class="exChangeBox" v-if="currentTab == 1">
|
||||
<view class="couponsList">
|
||||
<view class="list-item" v-for="(item, index) in couponList" :key="index" @click="openCouponPro(item)">
|
||||
<image style="width: 330rpx;height: 200rpx;"
|
||||
src="https://jiangxiaoxian.0rui.cn/scoreNumCoupon.png"></image>
|
||||
<view class="item-text">
|
||||
<view class="fs30 c3" style="margin: 0 auto;">优惠券满100减50</view>
|
||||
<view class="fs30 c3" style="margin: 0 auto;text-align: center;">{{ item.name }}</view>
|
||||
<view class="exchangeBtn">
|
||||
100积分兑换
|
||||
{{item.score}}积分兑换
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<!-- 无数据展示
|
||||
|
||||
|
||||
<!-- 无数据展示 -->
|
||||
<view class="flex flex-column flex-start align-items"
|
||||
v-if="feetHisList.length == 0" style="margin-top: 300rpx;">
|
||||
v-if="couponList.length == 0" style="margin-top: 300rpx;">
|
||||
<image src="https://jiangxiaoxian.0rui.cn/noneList.png" mode="" style="width: 180rpx;height: 180rpx;">
|
||||
</image>
|
||||
<view style="margin-top: 30rpx;font-size: 28rpx;color: #323232;">暂无数据信息</view>
|
||||
</view>-->
|
||||
</view>
|
||||
|
||||
|
||||
<su-popup :show="showCouponPro == true" type="center" round="10" :isMaskClick="false">
|
||||
<view class="popupContacted">
|
||||
<view class="contactedBox">
|
||||
<image style="width: 198rpx;height: 122rpx;position: relative;left: 12rpx;" src="https://jiangxiaoxian.0rui.cn/couponSuccess.png"></image>
|
||||
<view style="font-size: 36rpx;line-height: 50rpx;font-weight: 900;color: #3d3d3d;text-align: center;">是否兑换</view>
|
||||
<view style="font-size: 30rpx;line-height: 44rpx;font-weight: 400;color: #3d3d3d;text-align: center;">{{couponName}}</view>
|
||||
</view>
|
||||
<view class="contactBtn">
|
||||
<view class="tactBtnBox" style="color: #999999;" @click="showCouponPro = false">取消</view>
|
||||
<view class="tactBtnBox2" style="color: #333333;" @click="handleCouponSure">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</su-popup>
|
||||
|
||||
</view>
|
||||
|
||||
</s-layout>
|
||||
@ -88,23 +95,30 @@
|
||||
} from 'vue';
|
||||
import _ from 'lodash';
|
||||
|
||||
const tabMaps = [
|
||||
{
|
||||
name: '优惠券',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
name: '次数券',
|
||||
value: '1',
|
||||
},
|
||||
const listQuery = ref({
|
||||
page: 1,
|
||||
limit: 10,
|
||||
list_rows: 10,
|
||||
status: 1,
|
||||
})
|
||||
const tabMaps = [{
|
||||
name: '优惠券',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
name: '次数券',
|
||||
value: '2',
|
||||
},
|
||||
];
|
||||
const currentTab = ref(0)
|
||||
const score = ref(0)
|
||||
//切换tabs
|
||||
function onChange(e) {
|
||||
console.log('onChange',e);
|
||||
currentTab.value = e.index
|
||||
console.log('切换tabs',currentTab.value);
|
||||
// getLogList();
|
||||
console.log('onChange', e);
|
||||
currentTab.value = e.index
|
||||
console.log('切换tabs', currentTab.value);
|
||||
listQuery.value.status = e.value
|
||||
getCouponList();
|
||||
}
|
||||
|
||||
//页面跳转
|
||||
@ -115,12 +129,61 @@
|
||||
|
||||
}
|
||||
|
||||
//满减券
|
||||
const couponList = ref([])
|
||||
const couponCount = ref(0)
|
||||
async function getCouponList() {
|
||||
const res = await sheep.$api.app.scoreShop.fullList({
|
||||
page: listQuery.value.page,
|
||||
limit: listQuery.value.limit,
|
||||
status: listQuery.value.status,
|
||||
order: 'normal'
|
||||
});
|
||||
if (res.code === 1) {
|
||||
couponList.value = res.data.list;
|
||||
couponCount.value = res.data.count;
|
||||
score.value = res.data.score
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const showCouponPro = ref(false)
|
||||
const couponName = ref('')
|
||||
const couponSelectId = ref('')
|
||||
function openCouponPro(item) {
|
||||
showCouponPro.value = true;
|
||||
couponName.value = item.name;
|
||||
couponSelectId.value = item.id
|
||||
}
|
||||
async function handleCouponSure() {
|
||||
const res = await sheep.$api.app.scoreShop.exCoupon({
|
||||
id: couponSelectId.value
|
||||
});
|
||||
if (res.code === 1) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success'
|
||||
})
|
||||
showCouponPro.value = false;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
showCouponPro.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 上拉加载更多
|
||||
onReachBottom(() => {
|
||||
// loadmore();
|
||||
});
|
||||
onLoad(() => {
|
||||
// getData();
|
||||
getCouponList();
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -151,6 +214,7 @@
|
||||
|
||||
.container {
|
||||
background-color: #ffffff;
|
||||
height: 100vh;
|
||||
|
||||
.conTop {
|
||||
width: 100%;
|
||||
@ -176,12 +240,14 @@
|
||||
.exChangeBox {
|
||||
background-color: #ffffff;
|
||||
width: 690rpx;
|
||||
margin-top: 30rpx;
|
||||
|
||||
.couponsList {
|
||||
width: 100%;
|
||||
padding: 0 30rpx;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
;
|
||||
grid-gap: 20px;
|
||||
// display: flex;
|
||||
// justify-content: center;
|
||||
@ -200,6 +266,7 @@
|
||||
background-color: #fcc74e;
|
||||
height: 70rpx;
|
||||
width: 270rpx;
|
||||
margin-top: 30rpx;
|
||||
border-radius: 223rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@ -215,5 +282,51 @@
|
||||
|
||||
}
|
||||
|
||||
.popupContacted {
|
||||
width: 660rpx;
|
||||
height: 477rpx;
|
||||
background-color: #fff;
|
||||
display: grid;
|
||||
border-radius: 18rpx;
|
||||
|
||||
.contactedBox {
|
||||
width: 660rpx;
|
||||
height: 325rpx;
|
||||
padding: 30rpx 0;
|
||||
// margin-top: 40rpx;
|
||||
display: grid;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.contactBtn {
|
||||
width: 660rpx;
|
||||
height: 92rpx;
|
||||
border-top: 1rpx solid #eeeeee;
|
||||
display: flex;
|
||||
border-radius: 0 0 18rpx 18rpx;
|
||||
// margin-top: 40rpx;
|
||||
|
||||
.tactBtnBox {
|
||||
width: 330rpx;
|
||||
height: 92rpx;
|
||||
border-right: 1rpx solid #eeeeee;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tactBtnBox2 {
|
||||
width: 330rpx;
|
||||
height: 92rpx;
|
||||
// border-right: 1rpx solid #eeeeee;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
@ -84,7 +84,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="signBtn">
|
||||
<view class="signBtn" @click="toTabb('/pages/index/fabu')">
|
||||
去发布
|
||||
</view>
|
||||
</view>
|
||||
@ -125,7 +125,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="signBtn">
|
||||
<view class="signBtn" @click="toPage('/pages/index/category')">
|
||||
去消费
|
||||
</view>
|
||||
</view>
|
||||
@ -143,7 +143,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="signBtn">
|
||||
<view class="signBtn" @click="showShare">
|
||||
去分享
|
||||
</view>
|
||||
</view>
|
||||
@ -218,6 +218,7 @@
|
||||
computed,
|
||||
reactive
|
||||
} from 'vue';
|
||||
import { showShareModal } from '@/sheep/hooks/useModal';
|
||||
|
||||
const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/app/sign.png');
|
||||
|
||||
@ -381,6 +382,30 @@
|
||||
url: e
|
||||
})
|
||||
}
|
||||
|
||||
//跳转tabbars
|
||||
const toTabb = (e) => {
|
||||
uni.switchTab({
|
||||
url: e
|
||||
})
|
||||
}
|
||||
|
||||
//分享功能
|
||||
function showShare() {
|
||||
// 确保使用有效的图片URL
|
||||
const shareInfo = {
|
||||
title: '每日签到领积分',
|
||||
desc: '快来签到领取积分奖励吧',
|
||||
image: 'https://jiangxiaoxian.0rui.cn/valid-image.png', // 替换为有效的图片URL
|
||||
params: {
|
||||
page: 'sign'
|
||||
}
|
||||
};
|
||||
|
||||
// 调用分享方法
|
||||
showShareModal(shareInfo);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<s-layout title="分类" tabbar="/pages/index/category" :bgStyle="{ color: '#fff' }">
|
||||
<!-- tabbar="/pages/index/category" -->
|
||||
<s-layout title="分类" :bgStyle="{ color: '#fff' }">
|
||||
<view class="s-category">
|
||||
<view class="three-level-wrap ss-flex ss-col-top">
|
||||
<view class="side-menu-wrap" :style="[{ top: Number(statusBarHeight + 88) + 'rpx' }]">
|
||||
|
1266
pages/index/fabu.vue
1266
pages/index/fabu.vue
File diff suppressed because it is too large
Load Diff
278
sheep/api/app.js
278
sheep/api/app.js
@ -1,137 +1,151 @@
|
||||
import request from '@/sheep/request';
|
||||
import { baseUrl } from '@/sheep/config';
|
||||
import {
|
||||
baseUrl
|
||||
} from '@/sheep/config';
|
||||
|
||||
export default {
|
||||
// 系统初始化
|
||||
init: (templateId) =>
|
||||
request({
|
||||
url: 'index/init',
|
||||
params: {
|
||||
templateId,
|
||||
},
|
||||
custom: {
|
||||
showError: false,
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
// 同步客户端页面到后端
|
||||
pageSync: (pages) =>
|
||||
request({
|
||||
url: 'index/pageSync',
|
||||
method: 'POST',
|
||||
data: {
|
||||
pages,
|
||||
},
|
||||
custom: {
|
||||
showError: false,
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
// 发送短信
|
||||
sendSms: (data) =>
|
||||
request({
|
||||
url: 'index/send',
|
||||
method: 'POST',
|
||||
data,
|
||||
custom: {
|
||||
showSuccess: true,
|
||||
loadingMsg: '发送中',
|
||||
},
|
||||
}),
|
||||
//意见反馈
|
||||
feedback: (data) =>
|
||||
request({
|
||||
url: 'index/feedback',
|
||||
method: 'POST',
|
||||
data,
|
||||
}),
|
||||
// 自定义页面
|
||||
page: (id) =>
|
||||
request({
|
||||
url: 'index/page',
|
||||
method: 'GET',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
}),
|
||||
//积分商城
|
||||
scoreShop: {
|
||||
list: (params) =>
|
||||
request({
|
||||
url: 'app.score_shop',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
ids: (params = {}) =>
|
||||
request({
|
||||
url: 'app.score_shop/ids',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
detail: (id) =>
|
||||
request({
|
||||
url: 'app.score_shop/detail',
|
||||
method: 'GET',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
}),
|
||||
},
|
||||
//小程序直播
|
||||
mplive: {
|
||||
getMpLink: () =>
|
||||
request({
|
||||
url: 'app.mplive/getMpLink',
|
||||
method: 'GET',
|
||||
}),
|
||||
getRoomList: (ids) =>
|
||||
request({
|
||||
url: 'app.mplive/getRoomList',
|
||||
method: 'GET',
|
||||
params: {
|
||||
ids: ids.join(','),
|
||||
}
|
||||
}),
|
||||
},
|
||||
// 系统初始化
|
||||
init: (templateId) =>
|
||||
request({
|
||||
url: 'index/init',
|
||||
params: {
|
||||
templateId,
|
||||
},
|
||||
custom: {
|
||||
showError: false,
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
// 同步客户端页面到后端
|
||||
pageSync: (pages) =>
|
||||
request({
|
||||
url: 'index/pageSync',
|
||||
method: 'POST',
|
||||
data: {
|
||||
pages,
|
||||
},
|
||||
custom: {
|
||||
showError: false,
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
// 发送短信
|
||||
sendSms: (data) =>
|
||||
request({
|
||||
url: 'index/send',
|
||||
method: 'POST',
|
||||
data,
|
||||
custom: {
|
||||
showSuccess: true,
|
||||
loadingMsg: '发送中',
|
||||
},
|
||||
}),
|
||||
//意见反馈
|
||||
feedback: (data) =>
|
||||
request({
|
||||
url: 'index/feedback',
|
||||
method: 'POST',
|
||||
data,
|
||||
}),
|
||||
// 自定义页面
|
||||
page: (id) =>
|
||||
request({
|
||||
url: 'index/page',
|
||||
method: 'GET',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
}),
|
||||
//积分商城
|
||||
scoreShop: {
|
||||
fullList: (params) =>
|
||||
request({
|
||||
url: 'meal.score/product_list',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
exCoupon: (data) =>
|
||||
request({
|
||||
url: 'meal.score/exchange',
|
||||
method: 'POST',
|
||||
data,
|
||||
}),
|
||||
list: (params) =>
|
||||
request({
|
||||
url: 'app.score_shop',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
ids: (params = {}) =>
|
||||
request({
|
||||
url: 'app.score_shop/ids',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
detail: (id) =>
|
||||
request({
|
||||
url: 'app.score_shop/detail',
|
||||
method: 'GET',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
}),
|
||||
},
|
||||
//小程序直播
|
||||
mplive: {
|
||||
getMpLink: () =>
|
||||
request({
|
||||
url: 'app.mplive/getMpLink',
|
||||
method: 'GET',
|
||||
}),
|
||||
getRoomList: (ids) =>
|
||||
request({
|
||||
url: 'app.mplive/getRoomList',
|
||||
method: 'GET',
|
||||
params: {
|
||||
ids: ids.join(','),
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
//上传
|
||||
upload: (file, group = 'ugc', callback) => {
|
||||
const token = uni.getStorageSync('token');
|
||||
uni.showLoading({
|
||||
title: '上传中',
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/api/common/upload',
|
||||
filePath: file,
|
||||
name: 'file',
|
||||
formData: {
|
||||
group,
|
||||
},
|
||||
header: {
|
||||
Accept: 'text/json',
|
||||
// Authorization: token,
|
||||
token: token
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
let result = JSON.parse(uploadFileRes.data);
|
||||
if (result.code === 0) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: result.msg,
|
||||
});
|
||||
} else {
|
||||
return resolve(result.data);
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log('上传失败:', error);
|
||||
return resolve(false);
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading();
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
//上传
|
||||
upload: (file, group = 'ugc', callback) => {
|
||||
const token = uni.getStorageSync('token');
|
||||
uni.showLoading({
|
||||
title: '上传中',
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/api/common/upload',
|
||||
filePath: file,
|
||||
name: 'file',
|
||||
formData: {
|
||||
group,
|
||||
},
|
||||
header: {
|
||||
Accept: 'text/json',
|
||||
// Authorization: token,
|
||||
token: token
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
let result = JSON.parse(uploadFileRes.data);
|
||||
if (result.code === 0) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: result.msg,
|
||||
});
|
||||
} else {
|
||||
return resolve(result.data);
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log('上传失败:', error);
|
||||
return resolve(false);
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading();
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
@ -3,12 +3,12 @@
|
||||
* @param {String} name
|
||||
*/
|
||||
export const get_file_ext = (name) => {
|
||||
const last_len = name.lastIndexOf('.');
|
||||
const len = name.length;
|
||||
return {
|
||||
name: name.substring(0, last_len),
|
||||
ext: name.substring(last_len + 1, len),
|
||||
};
|
||||
const last_len = name.lastIndexOf('.');
|
||||
const len = name.length;
|
||||
return {
|
||||
name: name.substring(0, last_len),
|
||||
ext: name.substring(last_len + 1, len),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -16,49 +16,49 @@ export const get_file_ext = (name) => {
|
||||
* @param {Array} fileExtname
|
||||
*/
|
||||
export const get_extname = (fileExtname) => {
|
||||
if (!Array.isArray(fileExtname)) {
|
||||
let extname = fileExtname.replace(/(\[|\])/g, '');
|
||||
return extname.split(',');
|
||||
} else {
|
||||
return fileExtname;
|
||||
}
|
||||
return [];
|
||||
if (!Array.isArray(fileExtname)) {
|
||||
let extname = fileExtname.replace(/(\[|\])/g, '');
|
||||
return extname.split(',');
|
||||
} else {
|
||||
return fileExtname;
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取文件和检测是否可选
|
||||
*/
|
||||
export const get_files_and_is_max = (res, _extname) => {
|
||||
let filePaths = [];
|
||||
let files = [];
|
||||
if (!_extname || _extname.length === 0) {
|
||||
return {
|
||||
filePaths,
|
||||
files,
|
||||
};
|
||||
}
|
||||
res.tempFiles.forEach((v) => {
|
||||
let fileFullName = get_file_ext(v.name);
|
||||
const extname = fileFullName.ext.toLowerCase();
|
||||
if (_extname.indexOf(extname) !== -1) {
|
||||
files.push(v);
|
||||
filePaths.push(v.path);
|
||||
}
|
||||
});
|
||||
if (files.length !== res.tempFiles.length) {
|
||||
uni.showToast({
|
||||
title: `当前选择了${res.tempFiles.length}个文件 ,${
|
||||
let filePaths = [];
|
||||
let files = [];
|
||||
if (!_extname || _extname.length === 0) {
|
||||
return {
|
||||
filePaths,
|
||||
files,
|
||||
};
|
||||
}
|
||||
res.tempFiles.forEach((v) => {
|
||||
let fileFullName = get_file_ext(v.name);
|
||||
const extname = fileFullName.ext.toLowerCase();
|
||||
if (_extname.indexOf(extname) !== -1) {
|
||||
files.push(v);
|
||||
filePaths.push(v.path);
|
||||
}
|
||||
});
|
||||
if (files.length !== res.tempFiles.length) {
|
||||
uni.showToast({
|
||||
title: `当前选择了${res.tempFiles.length}个文件 ,${
|
||||
res.tempFiles.length - files.length
|
||||
} 个文件格式不正确`,
|
||||
icon: 'none',
|
||||
duration: 5000,
|
||||
});
|
||||
}
|
||||
icon: 'none',
|
||||
duration: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
filePaths,
|
||||
files,
|
||||
};
|
||||
return {
|
||||
filePaths,
|
||||
files,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -66,45 +66,59 @@ export const get_files_and_is_max = (res, _extname) => {
|
||||
* @param {Object} filepath
|
||||
*/
|
||||
export const get_file_info = (filepath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getImageInfo({
|
||||
src: filepath,
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!filepath) {
|
||||
reject(new Error('Invalid file path'));
|
||||
return;
|
||||
}
|
||||
|
||||
uni.getImageInfo({
|
||||
src: filepath,
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(err) {
|
||||
console.error('Failed to get image info:', err);
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 获取封装数据
|
||||
*/
|
||||
export const get_file_data = async (files, type = 'image') => {
|
||||
// 最终需要上传数据库的数据
|
||||
let fileFullName = get_file_ext(files.name);
|
||||
const extname = fileFullName.ext.toLowerCase();
|
||||
let filedata = {
|
||||
name: files.name,
|
||||
uuid: files.uuid,
|
||||
extname: extname || '',
|
||||
cloudPath: files.cloudPath,
|
||||
fileType: files.fileType,
|
||||
url: files.path || files.path,
|
||||
size: files.size, //单位是字节
|
||||
image: {},
|
||||
path: files.path,
|
||||
video: {},
|
||||
};
|
||||
if (type === 'image') {
|
||||
const imageinfo = await get_file_info(files.path);
|
||||
delete filedata.video;
|
||||
filedata.image.width = imageinfo.width;
|
||||
filedata.image.height = imageinfo.height;
|
||||
filedata.image.location = imageinfo.path;
|
||||
} else {
|
||||
delete filedata.image;
|
||||
}
|
||||
return filedata;
|
||||
// 最终需要上传数据库的数据
|
||||
let fileFullName = get_file_ext(files.name);
|
||||
const extname = fileFullName.ext.toLowerCase();
|
||||
let filedata = {
|
||||
name: files.name,
|
||||
uuid: files.uuid,
|
||||
extname: extname || '',
|
||||
cloudPath: files.cloudPath,
|
||||
fileType: files.fileType,
|
||||
url: files.path || files.path,
|
||||
size: files.size, //单位是字节
|
||||
image: {},
|
||||
path: files.path,
|
||||
video: {},
|
||||
};
|
||||
|
||||
try {
|
||||
if (type === 'image') {
|
||||
const imageinfo = await get_file_info(files.path);
|
||||
delete filedata.video;
|
||||
filedata.image.width = imageinfo.width;
|
||||
filedata.image.height = imageinfo.height;
|
||||
filedata.image.location = imageinfo.path;
|
||||
} else {
|
||||
delete filedata.image;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error processing file data:', error);
|
||||
// 返回基本文件数据,即使图片信息获取失败
|
||||
delete filedata.image;
|
||||
delete filedata.video;
|
||||
}
|
||||
return filedata;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user