URL跳转传值
/**
* 编辑客户内容
*/
handleEdit(){
uni.navigateTo({
url:"../../pagesA/customer/reportAdd?id="+this.cusId
})
},
跳转的界面利用onload接收
onLoad(e) {
console.log("reportAdd", e.id);
if (e.id) {
this.selectCompany = false;
this.typeTitle = "客户编辑"
var data = {
id: e.id
}
customer.customerDetail(data).then(res => {
this.company = res[1].data.data
console.log("detial:", this.company);
})
} else {
this.selectCompany = true;
this.typeTitle = "录客报备"
}
},
佐证附件上传
<view class="list-certer">
<view class="imgs-list" v-if="image.length>0" v-for="(item,index) in image">
<image :src="item" mode=""></image>
<view class="xxlsitd" @click="scpire(index)">删除</view>
</view>
<view class="imgs-list" @click="upIMG()">
<image src="https://lgzf.oss-cn-chengdu.aliyuncs.com/appImgs/static/images/asdff.png" mode="">
</image>
</view>
</view>
.list-certer {
width: 100%;
display: flex;
flex-wrap: wrap;
padding-left: 24rpx;
padding-bottom: 20rpx;
.imgs-list {
width: 110rpx;
height: 122rpx;
margin-right: 18rpx;
margin-bottom: 18rpx;
position: relative;
image {
width: 100%;
height: 100%;
}
.xxlsitd {
width: 100%;
height: 62rpx;
position: absolute;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .4);
color: #fff;
text-align: center;
line-height: 62rpx;
font-size: 24rpx;
}
}
}
//删除图片
scpire(index) {
this.image.splice(index, 1);
uni.showToast({
title: "删除成功",
icon: 'none',
duration: 2000,
mask: true
});
},
upIMG() {
let that = this
const token = cache.get("Token");
if (that.image.length < 10) {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
that.showIMG = true
console.log('res.tempFilePaths', res.tempFilePaths);
var QYimg1 = res.tempFilePaths[0];
var header = {
'Authorization': 'Bearer ' + token
};
console.log("header", header)
console.log("QYimg1", QYimg1)
uni.uploadFile({
// 需要上传的地址
header: header,
url: config.baseUrl + '/common/ossUpload',
// filePath 需要上传的文件
filePath: QYimg1,
name: 'file',
success(res1) {
console.log(1234, res1)
// 显示上传信息
var str = res1.data;
var jsonStr = str.replace(" ", "");
if (typeof jsonStr != 'object') {
jsonStr = jsonStr.replace(/\ufeff/g, ""); //重点
var JJ = JSON.parse(jsonStr);
var QYimg = JJ.url;
// that.QYimg = QYimg;
that.image.push(QYimg)
console.log(123, JJ.url)
}
}
});
}
});
} else {
uni.showToast({
title: "只能上传十张照片",
icon: 'none',
duration: 2000,
mask: true
})
}
},
自定义导航栏
<view class="top-back claslis"
:style="{'height':navHeight * 2 +'rpx','padding-top':statusBarHeight * 2 +'rpx'}">
<view class="top-back-frame">
<image src="https://rundianmedia.oss-cn-hangzhou.aliyuncs.com/img/file202205312101193611.png"
class="top-back-arrow" @click="returnArrow" />
</image>
<view class="top-back-word">{{typeTitle}}</view>
</view>
</view>
.top-back {
width: 750rpx;
height: 88rpx;
display: flex;
background-color: #FFFFFF;
.top-back-frame {
width: 100%;
height: 100%;
/* padding-top: 40upx; */
box-sizing: border-box;
color: #000000;
font-size: 32upx;
font-weight: 700;
display: flex;
justify-content: center;
align-items: center;
position: relative;
.top-back-arrow {
position: absolute;
/* top: 74upx; */
left: 22upx;
width: 48upx;
height: 44upx;
}
}
}
.claslis {
position: fixed;
top: 0;
left: 0;
z-index: 99;
}
data() {
return {
navHeight: '', //整体顶部导航栏的高度
statusBarHeight: '', //状态栏高度
}
},
onShow() {
//获取手机系统的信息(在这主要是获取状态栏和胶囊的高度)
let {
statusBarHeight,
system
} = uni.getSystemInfoSync()
this.statusBarHeight = statusBarHeight
this.navHeight = statusBarHeight + (system.indexOf('iOS') > -1 ? 44 : 48)
},
页面通讯
onUnload() {
this.chooseBrand();
},
/// 被监听者
chooseBrand() {
uni.$emit("handClick", {
data: [this.userCode, this.nickName]
});
},
/// 监听者
onShow() {
uni.$on("handClick", res => {
console.log("选择客户11", res.data);
this.sponsorCode = res.data[0]
this.sponsorName = res.data[1]
console.log("this.userCode", this.sponsorCode)
console.log("this.nickName", this.sponsorName)
// 清除监听
uni.$off('handClick');
})
// 获取从搜索媒体界面返回的媒体选择
this.chooseMedia = cache.get('chooseMedia');
console.log("chooseMedia",this.chooseMedia);
},
本文来自博客园,作者:depressiom,转载请注明原文链接:https://www.cnblogs.com/depressiom/p/16358439.html