身份证,通话

This commit is contained in:
小李 2026-03-16 17:32:36 +08:00
parent 21c79178fd
commit b5685a0d6f
19 changed files with 2017 additions and 797 deletions

View File

@ -11,18 +11,18 @@
<image v-if="type=='ios'" src="/static/image/call/iosSearchRight.png" mode=""></image> <image v-if="type=='ios'" src="/static/image/call/iosSearchRight.png" mode=""></image>
</view> </view>
<view class="selectType" v-if="type=='huawei'"> <view class="selectType" v-if="type=='huawei'">
<view class="btn active"> <view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部来电 全部来电
</view> </view>
<view class="btn"> <view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接来电 未接来电
</view> </view>
</view> </view>
<view class="selectTypeVivo" v-if="type=='vivo'"> <view class="selectTypeVivo" v-if="type=='vivo'">
<view class="btn active"> <view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部 全部
</view> </view>
<view class="btn"> <view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接 未接
</view> </view>
</view> </view>
@ -53,6 +53,7 @@
}) })
const data = reactive({ const data = reactive({
active:true,
statusBarHeight: 0, statusBarHeight: 0,
showTipLayer: true, showTipLayer: true,
title:'最近通话', title:'最近通话',
@ -67,6 +68,7 @@
}) })
let { let {
active,
searchTitle, searchTitle,
title, title,
list, list,
@ -77,7 +79,7 @@
if(props.type=='xiaomi'){ if(props.type=='xiaomi'){
searchTitle.value="搜索联系人" searchTitle.value="搜索联系人"
title.value="通话" title.value="通话"
console.log('aaaaaaaaaaa') // console.log('aaaaaaaaaaa')
}else if(props.type=='oppo'){ }else if(props.type=='oppo'){
title.value="通话" title.value="通话"
}else if(props.type=='huawei'){ }else if(props.type=='huawei'){
@ -85,6 +87,11 @@
} }
}) })
function setActive(status){
active.value=status
uni.$emit('setActive',status)
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<template> <template>
<uni-nav-bar :backgroundColor="navBgColor" class="nav-bar" :border="false" :title="title" fixed="true"> <uni-nav-bar :backgroundColor="navBgColor" class="nav-bar" :border="false" :title="title" fixed="true" statusBar="true">
<template v-slot:left> <template v-slot:left>
<slot name="left"> <slot name="left">
<view :class="[type+'LeftTitle']" :style="{opacity:(type!='huawei'&&type!='oppo'?1: navOpacity)}"> <view :class="[type+'LeftTitle']" :style="{opacity:(type!='huawei'&&type!='oppo'?1: navOpacity)}">
@ -11,18 +11,18 @@
<view class="nav-bar-title " :class="['nav-bar-title-'+type]"> <view class="nav-bar-title " :class="['nav-bar-title-'+type]">
<slot> <slot>
<view class="iosBox" v-if="type=='ios'"> <view class="iosBox" v-if="type=='ios'">
<view class="btn active"> <view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部来电 全部来电
</view> </view>
<view class="btn"> <view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接来电 未接来电
</view> </view>
</view> </view>
<view class="oppoBox" v-if="type=='oppo'" :style="{opacity: navOpacity?1-navOpacity:1}"> <view class="oppoBox" v-if="type=='oppo'" :style="{opacity: navOpacity?1-navOpacity:1}">
<view class="btn active"> <view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部 全部
</view> </view>
<view class="btn"> <view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接 未接
</view> </view>
</view> </view>
@ -80,6 +80,7 @@
}) })
const data = reactive({ const data = reactive({
active:true,
statusBarHeight: 0, statusBarHeight: 0,
LeftTitle:'', LeftTitle:'',
showTipLayer: true, showTipLayer: true,
@ -88,6 +89,7 @@
}) })
let { let {
active,
LeftTitle, LeftTitle,
showTipLayer, showTipLayer,
navOpacity, navOpacity,
@ -96,7 +98,7 @@
// scrollTop // scrollTop
watch(() => props.scrollTop, (newValue, oldValue) => { watch(() => props.scrollTop, (newValue, oldValue) => {
console.log('scrollTop changed:', newValue); // console.log('scrollTop changed:', newValue);
// scrollTop // scrollTop
if (newValue > 0) { if (newValue > 0) {
// scrollTop 0 // scrollTop 0
@ -123,11 +125,15 @@
LeftTitle.value='' LeftTitle.value=''
} }
}) })
function setActive(status){
active.value=status
uni.$emit('setActive',status)
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
::v-deep .uni-navbar__header-btns { ::v-deep .uni-navbar__header-btns {
width: 25vw !important; width: 27vw !important;
} }
.iosLeftTitle { .iosLeftTitle {
@ -246,6 +252,7 @@
background: #FFFFFF; background: #FFFFFF;
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.1);
border-radius: 6px 6px 6px 6px; border-radius: 6px 6px 6px 6px;
margin: 0 2px;
} }
} }
} }

View File

@ -27,7 +27,7 @@ export function createApp() {
const systemInfo = uni.getStorageSync('systemInfo') || {} const systemInfo = uni.getStorageSync('systemInfo') || {}
app.config.globalProperties.$system = systemInfo.platform == 'ios' ? 'iOS' : 'Android' app.config.globalProperties.$system = systemInfo.platform == 'ios' ? 'iOS' : 'Android'
app.config.globalProperties.$systemInfo = systemInfo app.config.globalProperties.$systemInfo = systemInfo
uni.setStorageSync('version', '1.0.3.sp1') uni.setStorageSync('version', '1.0.3.sp2')
app.config.globalProperties.$version = uni.getStorageSync('version') app.config.globalProperties.$version = uni.getStorageSync('version')
app.use(globalMethods); app.use(globalMethods);

View File

@ -193,6 +193,14 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "qf-image/qf-image",
"style": {
"navigationBarTitleText": "图片裁剪",
"navigationStyle": "custom"
}
},
{ {
"path": "train-tickets/ctrip-train-tickets/ctrip-train-tickets", "path": "train-tickets/ctrip-train-tickets/ctrip-train-tickets",
"style": { "style": {

View File

@ -1,10 +1,11 @@
<template> <template>
<view class="container"> <view class="container">
<!-- 自定义头部导航栏 --> <!-- 自定义头部导航栏 -->
<ZdyNavbar :type="data.type" :scrollTop="data.scrollTop"/> <ZdyNavbar :type="data.type" :scrollTop="data.scrollTop" @click="open"/>
<ZdyHeader :type="data.type" /> <ZdyHeader :type="data.type" />
<callList :type="data.type"></callList> <callList :type="data.type" ref="callLogList"></callList>
<tabbar :type="data.type" /> <tabbar :type="data.type" />
<image v-if="data.type!='ios'" :src="`/static/image/call/${data.type}BtnImg.png`" mode="" class="btnImg" :class="['btnImg_'+data.type]"></image>
</view> </view>
</template> </template>
@ -13,7 +14,7 @@
import ZdyHeader from "@/components/call-log/header/header.vue" import ZdyHeader from "@/components/call-log/header/header.vue"
import callList from "@/components/call-log/list/list.vue" import callList from "@/components/call-log/list/list.vue"
import tabbar from "@/components/call-log/tabbar/tabbar.vue" import tabbar from "@/components/call-log/tabbar/tabbar.vue"
import {util} from"@/utils/common.js"
import { ref, reactive, watch, nextTick, getCurrentInstance } from "vue"; import { ref, reactive, watch, nextTick, getCurrentInstance } from "vue";
import { onLoad, onShow, onReady, onPageScroll, onReachBottom } from "@dcloudio/uni-app"; import { onLoad, onShow, onReady, onPageScroll, onReachBottom } from "@dcloudio/uni-app";
@ -22,24 +23,75 @@
type: 'vivo', type: 'vivo',
scrollTop:0 scrollTop:0
}) })
let callLogList = ref();
onLoad((option) => { onLoad((option) => {
data.type=option.type
}) })
onReady(() => { onReady(() => {
}) })
onShow(() => {}) onShow(() => {
try {
if (plus.os.name === 'Android') {
let colorTabbar="#FAFAFA"
if(data.type=='xiaomi'||data.type=='oppo'){
colorTabbar="#FFF"
}
util.setAndroidSystemBarColor(colorTabbar)
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500)
}
} catch (error) {
console.log("修改导航条颜色失败", error);
}
})
onPageScroll((e) => { onPageScroll((e) => {
console.log(e) // console.log(e)
data.scrollTop=e.scrollTop data.scrollTop=e.scrollTop
}) })
onReachBottom(() => { onReachBottom(() => {
}) })
function open(){
console.log(callLogList.value)
callLogList.value.openAddModal()
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" >
page{
background-color: #fff;
}
.btnImg{
position: fixed;
}
.btnImg_vivo{
width: 80px;
height: 96px;
left: 40px;
bottom: 130px;
}
.btnImg_huawei{
width: 54px;
height: 54px;
left: calc(50% - 27px);
bottom: 65px;
}
.btnImg_oppo{
width: 58px;
height: 58px;
right: 20px;
bottom: 100px;
}
.btnImg_xiaomi{
width: 55px;
height: 55px;
right: 34px;
bottom: 100px;
}
</style> </style>

View File

@ -39,7 +39,7 @@ const source = ref([{
}, },
icon: 'iphone', icon: 'iphone',
messageUrl: "/pages/message/list-index?phone=iphone", messageUrl: "/pages/message/list-index?phone=iphone",
callUrl: "" callUrl: "/pages/call-log/call?type=ios"
}, },
{ {
name: '华为', name: '华为',
@ -50,7 +50,7 @@ const source = ref([{
}, },
icon: 'huawei', icon: 'huawei',
messageUrl: "/pages/message/list-index?phone=huawei", messageUrl: "/pages/message/list-index?phone=huawei",
callUrl: "" callUrl: "/pages/call-log/call?type=huawei"
}, },
{ {
name: '小米', name: '小米',
@ -61,7 +61,7 @@ const source = ref([{
}, },
icon: 'mi', icon: 'mi',
messageUrl: "/pages/message/list-index?phone=mi", messageUrl: "/pages/message/list-index?phone=mi",
callUrl: "" callUrl: "/pages/call-log/call?type=xiaomi"
}, },
{ {
name: 'oppo', name: 'oppo',
@ -72,7 +72,7 @@ const source = ref([{
}, },
icon: 'oppo', icon: 'oppo',
messageUrl: "/pages/message/list-index?phone=oppo", messageUrl: "/pages/message/list-index?phone=oppo",
callUrl: "" callUrl: "/pages/call-log/call?type=oppo"
}, { }, {
name: 'vivo', name: 'vivo',
color: { color: {
@ -82,7 +82,7 @@ const source = ref([{
}, },
icon: 'vivo', icon: 'vivo',
messageUrl: "/pages/message/list-index?phone=vivo", messageUrl: "/pages/message/list-index?phone=vivo",
callUrl: "" callUrl: "/pages/call-log/call?type=vivo"
}, },
]) ])

View File

@ -256,10 +256,15 @@ const otherList = [{
path: "/pages/other/card/card" path: "/pages/other/card/card"
}, },
{ {
icon: "/static/image/index/qita/card.png", icon: "/static/image/index/qita/message.png",
name: "短信", name: "短信",
path: "/pages/common/call-and-message-entry/call-and-message-entry?type=message" path: "/pages/common/call-and-message-entry/call-and-message-entry?type=message"
}, },
{
icon: "/static/image/index/qita/call.png",
name: "通话",
path: "/pages/common/call-and-message-entry/call-and-message-entry?type=call"
},
] ]
const data = reactive({ const data = reactive({

View File

@ -11,33 +11,36 @@
<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" hidden <l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" hidden
:css="`width:${data.width}px;height:${data.height }px;background-color:#fff;`"> :css="`width:${data.width}px;height:${data.height }px;background-color:#fff;`">
<l-painter-view <l-painter-view
:css="`margin-top:116px;margin-left:75px;position: relative;width:650px;height:360px;background-image: url('/static/image/other/card/cardBGImg.png');background-size:650px 360px;`"> :css="`margin-top:109px;margin-left:75px;position: relative;width:666px;height:406px;background-image: url('/static/image/other/card/cardBGImg.png');background-size:6660px 406px;`">
<!-- 头部年月 --> <!-- 头部年月 -->
<l-painter-view :css="`position: absolute;left:122px;top:28px;`"> <l-painter-view :css="`position: absolute;left:122px;top:50px;`">
<l-painter-text :css="data.textCss+data.textCssLeft" :text="data.form.name" /> <l-painter-text :css="data.textCss+data.textCssLeft" :text="data.form.name" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:122px;top:78px;`"> <l-painter-view :css="`position: absolute;left:122px;top:100px;`">
<l-painter-text :css="data.textCss2+data.textCssLeft" :text="data.form.gender" /> <l-painter-text :css="data.textCss2+data.textCssLeft" :text="data.form.gender" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:254px;top:78px;`"> <l-painter-view :css="`position: absolute;left:260px;top:100px;`">
<l-painter-text :css="data.textCss2+data.textCssLeft" :text="data.form.nation" /> <l-painter-text :css="data.textCss2+data.textCssLeft" :text="data.form.nation" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:122px;top:126px;`"> <l-painter-view :css="`position: absolute;left:122px;top:148px;`">
<l-painter-text v-for="(item,index) in data.form.year.toString()" :css="data.textCss3+data.textCssLeft" :text="item" :key="index" /> <l-painter-text v-for="(item,index) in data.form.year.toString()" :css="data.textCss3+data.textCssLeft"
:text="item" :key="index" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:184px;top:126px;`"> <l-painter-view :css="`position: absolute;left:190px;top:148px;`">
<l-painter-text :css="data.textCss2+data.textCssCenter" :text="data.form.month.toString()" /> <l-painter-text :css="data.textCss2+data.textCssCenter" :text="data.form.month.toString()" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:244px;top:126px;`"> <l-painter-view :css="`position: absolute;left:250px;top:148px;`">
<l-painter-text :css="data.textCss2+data.textCssCenter" :text="data.form.day.toString()" /> <l-painter-text :css="data.textCss2+data.textCssCenter" :text="data.form.day.toString()" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:122px;top:177px;width:274px;`"> <l-painter-view :css="`position: absolute;left:122px;top:196px;width:274px;`">
<l-painter-text v-for="(item,index) in data.form.address" :css="data.textCss3+data.textCssLeft" :text="item" :key="index"/> <l-painter-text v-for="(item,index) in data.form.address" :css="data.textCss3+data.textCssLeft" :text="item"
:key="index" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;left:223px;top:300px;`"> <l-painter-view :css="`position: absolute;left:223px;top:320px;`">
<l-painter-text v-for="(item,index) in data.form.idNumber" :css="data.textCss4+data.textCssLeft" :text="item" :key="index"/> <l-painter-text v-for="(item,index) in data.form.idNumber" :css="data.textCss4+data.textCssLeft" :text="item"
:key="index" />
</l-painter-view> </l-painter-view>
<l-painter-view :css="`position: absolute;right:48px;top:55px;`"> <l-painter-view :css="`position: absolute;right:48px;top:62px;`">
<l-painter-image v-if="data.form.photo" :src="data.form.photo" css="width: 196px; height: 230px;" /> <l-painter-image v-if="data.form.photo" :src="data.form.photo" css="width: 196px; height: 230px;" />
<l-painter-view v-else css="width: 196px; height: 230px;background-color:#fff;"> <l-painter-view v-else css="width: 196px; height: 230px;background-color:#fff;">
</l-painter-view> </l-painter-view>
@ -158,18 +161,23 @@ const showEditPopup = ref(false);
const editForm = ref({}); const editForm = ref({});
// //
function successImage(e) { function successImage(e) {
console.log(e)
data.code = e data.code = e
} }
function progress(e) { function progress(e) {
console.log(e)
if (e < 0.03) { if (e < 0.03) {
uni.showLoading({ uni.showLoading({
title: "生成中" title: "生成中"
}) })
} }
if (e == 1) { if (e == 1) {
setTimeout(() => {
uni.hideLoading() uni.hideLoading()
}, 1000)
} }
console.log(e)
} }
// //
function edit() { function edit() {
@ -189,6 +197,7 @@ function closeEditPopup() {
function saveEditForm() { function saveEditForm() {
// //
data.form = JSON.parse(JSON.stringify(editForm.value)); data.form = JSON.parse(JSON.stringify(editForm.value));
uni.setStorageSync("cardForm",data.form)
// //
showEditPopup.value = false; showEditPopup.value = false;
} }
@ -199,8 +208,33 @@ function chooseImage() {
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
crop:{
width:'196px',
height:"230px"
},
success: (res) => { success: (res) => {
editForm.value.photo = res.tempFilePaths[0]; uni.showLoading({
title:"抠图中"
})
convertLocalImageToFile(res.tempFilePaths[0]).then(file => {
proxy.$imageUpload(file.split(',', 2)[1]).then(resimage=>{
console.log(resimage);
console.log(resimage.data);
editForm.value.photo = decodeURI(resimage.data);
uni.hideLoading()
}).catch(err=>{
uni.hideLoading()
console.log(err.data.message)
uni.showToast({
icon:"none",
title:err.data.message
})
})
}).catch(err=>{
uni.hideLoading()
})
}, },
fail: (err) => { fail: (err) => {
console.log('选择图片失败', err); console.log('选择图片失败', err);
@ -208,6 +242,34 @@ function chooseImage() {
}); });
} }
/**
* 将本地图片路径通过 Canvas 转换为 File 对象
* @param {string} localPath - 本地图片路径如从 uni.chooseImage 获取的 tempFilePath
* @param {Object} options - 可选参数
* @param {string} options.format - 输出格式 'image/png' 'image/jpeg'默认 'image/png'
* @param {number} options.quality - 图片质量 jpeg 有效0~1默认 0.92
* @param {number} options.maxWidth - 最大宽度等比缩放不填则使用原图尺寸
* @param {number} options.maxHeight - 最大高度等比缩放不填则使用原图尺寸
* @returns {Promise<File>} 返回一个 Promiseresolve File 对象
*/
function convertLocalImageToFile(localPath) {
return new Promise((resolve, reject) => {
// 1. Base64 Image
plus.io.resolveLocalFileSystemURL(localPath, (entry) => {
entry.file((file) => {
const reader = new plus.io.FileReader();
reader.onload = (e) => {
const base64Data = e.target.result; // data:image/jpeg;base64,/9j/...
resolve(e.target.result)
};
reader.onerror = (err) => reject(err);
reader.readAsDataURL(file); // DataURL
}, reject);
}, reject);
});
}
// //
function previewImage() { function previewImage() {
if (data.code) { if (data.code) {
@ -365,6 +427,10 @@ onLoad((option) => {
prefix: '.uni.other.', prefix: '.uni.other.',
value: "身份证" value: "身份证"
}) })
let formdata=uni.getStorageSync("cardForm")
if(formdata){
data.form=formdata
}
}) })
onReady(() => { onReady(() => {
@ -550,7 +616,7 @@ onReachBottom(() => {
} }
.btn-save { .btn-save {
background-color: #ff6b35; background-color: #187AFF;
color: #fff; color: #fff;
border: none; border: none;
} }

View File

@ -0,0 +1,20 @@
<template>
<view>
<qf-image-cropper :width="196" :height="230" :radius="0" @crop="handleCrop" :reverseRotatable="true"></qf-image-cropper>
</view>
</template>
<script>
export default {
methods: {
handleCrop(e) {
uni.saveFile({
tempFilePath: e.tempFilePath,
success: function(res) {
res.avatar = res.savedFilePath
}
});
}
}
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

176
test.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,9 @@ import {
postJson postJson
} from "@/utils/requests.js" } from "@/utils/requests.js"
import pageData from "@/static/json/page.json" import pageData from "@/static/json/page.json"
import {
jsonString
} from "../uni_modules/uv-ui-tools/libs/function/test";
export default { export default {
install(app, options) { install(app, options) {
@ -148,7 +151,7 @@ export default {
temp += "&" + CryptoJS.MD5(key).toString(); temp += "&" + CryptoJS.MD5(key).toString();
config.data.signature = CryptoJS.MD5(temp).toString(); config.data.signature = CryptoJS.MD5(temp).toString();
} }
// console.log("config:", config) console.log("config:", config)
return config return config
}; };
@ -169,11 +172,14 @@ export default {
const sortedKeys = Object.keys(data.data).sort(); const sortedKeys = Object.keys(data.data).sort();
let str = '' let str = ''
for (const key of sortedKeys) { for (const key of sortedKeys) {
if(!(data.url=='api/image/segment/base64'&&key=='file')){
str += '&' + key + '=' + encodeURIComponent(data.data[key]); str += '&' + key + '=' + encodeURIComponent(data.data[key]);
} }
}
str = str.replace('&', '?') str = str.replace('&', '?')
// 拼接URL
host=host+str host=host+str
console.log(host)
console.log(data)
const response = await new Promise((resolve, reject) => { const response = await new Promise((resolve, reject) => {
uni.request({ uni.request({
url: host, url: host,
@ -181,15 +187,17 @@ export default {
data: data.data, data: data.data,
header, header,
success: res => { success: res => {
console.log(res)
try { try {
if (isCode) { if (isCode) {
res.data = deCode(res.data.data) res.data = deCode(res.data.data)
console.log(res.data)
} else { } else {
res.data = res.data.data res.data = res.data.data
} }
} catch (err) { } catch (err) {
console.log(err);
} }
resolve(res.data); resolve(res.data);
}, },
@ -201,8 +209,6 @@ export default {
return response; return response;
}; };
app.config.globalProperties.$getUserInfo = async () => { app.config.globalProperties.$getUserInfo = async () => {
try { try {
let user = await app.config.globalProperties.$requestPromise({ let user = await app.config.globalProperties.$requestPromise({
@ -214,22 +220,69 @@ export default {
if (user.code == 0) { if (user.code == 0) {
uni.setStorageSync('AppUser', user.data) uni.setStorageSync('AppUser', user.data)
uni.setStorageSync('userInfo', user.data) uni.setStorageSync('userInfo', user.data)
// uni.showModal({
// title: '提示',
// content: JSON.stringify(user.data),
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击确定');
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// });
} }
} catch (error) { } catch (error) {
//TODO handle the exception //TODO handle the exception
} }
} }
// 上传图片
app.config.globalProperties.$uploadImage = async (filePath) => {
//头部header
let header = uni.getStorageSync('header')
//请求地址
let host = uni.getStorageSync('host') + 'api/image/segment'
header['content-type'] = "multipart/form-data"
// // 排序
let data={
method:'POST',
data:{},
url:'api/image/segment'
}
data = sign(data)
const sortedKeys = Object.keys(data.data).sort();
let str = ''
for (const key of sortedKeys) {
str += '&' + key + '=' + encodeURIComponent(data.data[key]);
}
str = str.replace('&', '?')
// 拼接URL
host = host + str
console.log(host);
console.log(data);
uni.uploadFile({
url: host, // 完整URL
filePath: filePath,
name: 'file',
method:"POST",
header: header,
formData:{
...data.data
},
success: (res) => {
console.log('1.上传成功:',JSON.stringify(res));
},
fail: (err) => {
console.error('2. 错误详情:', JSON.stringify(err));
},
complete: (res) => {
console.log('3. 上传完成');
}
});
};
app.config.globalProperties.$imageUpload = async (imagePath) => {
return new Promise((resolve, reject) => {
postJson('a', 'api/image/segment/base64', {
file:imagePath
}).then(res=>{
resolve(res)
}).catch(err=>{
reject(err)
})
})
};
} }
}; };

View File

@ -185,6 +185,7 @@ const request = (method = 'GET', serverUrl, domainUrl, params, dataType = "json"
console.log("传参详情", data) console.log("传参详情", data)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request(data).then(res => { uni.request(data).then(res => {
console.log(deCode(res.data.data))
if (res.statusCode == 200) { if (res.statusCode == 200) {
if (res.data.encrypt) { if (res.data.encrypt) {
if (q != 'test') { if (q != 'test') {