提交 46a95b0c 作者: wk

项目详情未选择项目情况下 默认第一个

父级 ecfce872
......@@ -473,7 +473,7 @@
}
.rq-image {
width: 22rpx;
width: 24rpx;
height: 16px;
margin: 0 10rpx 0 30rpx;
}
......
......@@ -8,7 +8,7 @@
<view class="item-value"></view>
</view>
<view class="line"></view>
<view class="item">
<view class="item" @click="showQrcode">
<view class="item-name">项目二维码:</view>
<view class="item-value-blue">二维码下载</view>
</view>
......@@ -25,7 +25,8 @@
<view class="line"></view>
<view class="item">
<view class="item-name">项目地址:</view>
<view class="item-value">{{project.province}}{{project.city}}{{project.area}}</view>
<view class="item-value" style="width: 488rpx;">{{project.province}}{{project.city}}{{project.area}}
</view>
</view>
<view class="line"></view>
<view class="item">
......@@ -44,17 +45,33 @@
<view class="item-value"></view>
</view>
</view>
<view class="model-view" :style="showModal?'':'display:none;'">
<view class="model-out-box">
<view class="text-black-normal">{{curTitle}}</view>
<view class="model-content">
<canvas canvas-id="qrcode" style="margin: 40rpx;"></canvas>
</view>
<view style="display: flex;flex-direction: row;width: 100%;">
<view class="btn-dialog-grey" @click="cancel">取消</view>
<view class="btn-dialog-blue" @click="saveQrcode">保存图片</view>
</view>
</view>
</view>
</view>
</template>
<script>
import uQRCode from "../../../common/Sansnn-uQRCode/uqrcode.js"
import Api from "../../../api/api.js"
export default {
data() {
return {
longitude: "122",
latitude: "36",
project: {}
project: {},
showModal: false,
qrcodeSrc: "",
curTitle: ""
}
},
onLoad() {
......@@ -62,18 +79,109 @@
},
methods: {
getProjectInfo() {
Api.getProjectInfo({
let projectId = uni.getStorageSync("project_id")
if (projectId) {
Api.getProjectInfo({
data: {
project_id: uni.getStorageSync("project_id")
}
}).then((result) => {
console.log("项目信息", result);
if (result.code == 0) {
this.project = result.data
} else {
this.$toast.showToast(result.msg)
}
})
} else {
this.loadProject()
}
},
loadProject() {
let orgNo = uni.getStorageSync("org_no")
if (orgNo == '001') {
orgNo = ""
}
Api.getProjectList({
data: {
project_id: uni.getStorageSync("project_id")
is_all: 1,
org_no: orgNo
}
}).then((result) => {
console.log("项目信息", result);
if (result.code == 0) {
this.project = result.data
console.log("项目列表:", result);
if (result.code === 0) {
this.projectList = result.data.list
this.project = this.projectList[0]
} else {
this.$toast.showToast(result.msg)
}
})
},
showQrcode() {
this.curTitle = this.project.project_name
this.showModal = true
this.$nextTick(function() {
this.cancvsQrcode(this.project.project_id)
})
},
cancvsQrcode(text) {
uQRCode.make({
canvasId: 'qrcode',
componentInstance: this,
text: text,
size: 160,
margin: 10,
backgroundColor: '#ffffff',
foregroundColor: '#000000',
fileType: 'jpg',
correctLevel: uQRCode.errorCorrectLevel.H,
success: res => {
console.log(res)
this.qrcodeSrc = res
},
fail: error => {
console.log(error)
}
})
},
cancel() {
this.curTitle = ""
this.showModal = false
},
saveQrcode() {
// #ifndef H5
this.save(this.qrcodeSrc)
// #endif
// #ifdef H5
let _t = this;
uni.downloadFile({
url: this.qrcodeSrc,
success: (res) => {
if (res.statusCode === 200) {
let file = res.tempFilePath;
_t.save(file)
}
}
});
// #endif
},
save(url) {
let _this = this;
uni.saveImageToPhotosAlbum({
filePath: url,
success: () => {
uni.hideLoading();
uni.showToast({
title: "图片已保存到相册"
});
},
fail: () => {
uni.hideLoading();
uni.showToast({
title: "图片保存失败"
});
}
});
}
}
}
......@@ -168,5 +276,63 @@
}
}
}
.model-view {
position: fixed;
top: 0;
z-index: 1;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
}
.model-out-box {
width: 600rpx;
height: 600rpx;
background-color: #FFFFFF;
border-radius: 20rpx;
margin-top: 45%;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 32rpx 0 0 0;
align-items: center;
}
.model-content {
width: 400rpx;
height: 400rpx;
border-radius: 10rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
}
.btn-dialog-grey {
display: flex;
flex: 1;
height: 100rpx;
font-size: 32rpx;
color: #333333;
align-items: center;
border-top: 2rpx solid rgba(0, 0, 0, 0.1);
border-right: 2rpx solid rgba(0, 0, 0, 0.1);
justify-content: center;
}
.btn-dialog-blue {
display: flex;
flex: 1;
height: 100rpx;
font-size: 32rpx;
color: #3B73FE;
border-top: 2rpx solid rgba(0, 0, 0, 0.1);
align-items: center;
justify-content: center;
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment