123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <template>
- <view class="content">
- <view class="inner">
- <view class="align-center justify-between wrap">
- <view class="add-img" @tap="chooseImage">
- <image src="/static/images/user/add_picture_icon24.png" class="w40 h40"></image>
-
- </view>
- <!-- <view class="img" v-for="(item,index) in imgList" :key="index" @tap="viewImage" :data-url="imgList[index]">
- <image :src="item"></image>
- <image class="close-img" src="@/static/images/close32.png" mode="" @tap.stop="delImg" :data-index="index"></image>
- <view class="text">
- <view class="title">体检报告</view>
- <view class="time">2021-04-21</view>
- </view>
- </view> -->
- <view class="img" v-for="(item,index) in dataList" :key="index" @tap="viewImage" :data-url="dataList[index]">
- <image :src="item.url" @longpress="cancel(item)"></image>
- <!-- <image class="close-img" src="@/static/images/close32.png" mode="" @tap.stop="delImg" :data-index="index"></image> -->
- <view class="text">
- <view class="title">体检报告</view>
- <view class="time">{{utils.timeFormat(item.createTime,'yyyy-mm-dd')}}</view>
- </view>
- </view>
- <view class="img"></view>
- </view>
- </view>
- </view>
- </template>
- <script>
-
- import {
- addAttachment,
- getAttachment,deleteAttachment
- } from '@/api/companyUser.js'
- export default {
-
- data() {
- return {
- curDate: '',
- markDays: [],
- type: null,
- patientId: null,
- famaleurl: "/static/images/health/female_profile.png",
- maleurl: "/static/images/health/my_heads.png",
- checked: 1,
- dataList:[],
- imgList:[],
- photos:[]
- };
- },
- onLoad(option) {
- console.log(option)
- if(option.id){
- this.parentId=option.id
- uni.setNavigationBarTitle({
- title: option.title
- });
- this.getAttachment()
- }
-
- },
- methods: {
- //日历
- onDayClick(data) {
- this.curDate = data.date;
- },
- navgetTo() {
- uni.navigateTo({
- url: '/pages_user/user/addIndicator'
- })
- },
- getAttachment() {
- let data = {
- parentId:this.parentId,
- pageNum: 1,
- pageSize: 100
- }
- getAttachment(data).then(
- res => {
- if (res.code == 200) {
- this.dataList = res.data.list
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- cancel(item){
- var that=this
- uni.showModal({
- title: '提示',
- content: '确定删除文件吗',
- success: function (res) {
- if (res.confirm) {
- deleteAttachment(item.attachmentId).then(res => {
- if(res.code==200){
- uni.showToast({
- icon:'success',
- title: '删除成功!',
- });
- uni.$emit('refreshMyFolder');
- this.getAttachment()
-
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- });
- }
- else if (res.cancel) {
-
- }
- }
- });
- },
- // 选择上传的图片
- chooseImage() {
- console.log('图片')
- var that = this;
- uni.showActionSheet({
- itemList: ['相册', '拍照'],
- success: function(res) {
- if (res.tapIndex == 0) {
- //从相册选择
- that.chooseImageFunction('album')
- } else if (res.tapIndex == 1) {
- //拍照
- that.chooseImageFunction('camera')
- }
- },
- fail: function(res) {
-
- }
- });
- },
- chooseImageFunction: function(type) {
- var that = this;
- uni.chooseImage({
- count:1, // 默认9
- sourceType: [type],
- success: (res) => {
- console.log(res,'res')
- uni.uploadFile({
- url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
- filePath: res.tempFilePaths[0],
- name: 'file',
- formData: {
- 'user': 'test' // 上传附带参数
- },
- success: (uploadFileRes) => {
- // 根据接口具体返回格式 赋值具体对应url
- this.url=JSON.parse(uploadFileRes.data).url
- this.addAttachment()
- // if (this.imgList.length != 0) {
- // this.imgList = this.imgList.concat(res.tempFilePaths)
- // } else {
- // this.imgList = res.tempFilePaths
- // }
- // this.photos = this.photos.concat(JSON.parse(uploadFileRes.data).url)
-
- }
- });
-
- }
- });
- },
- addAttachment(){
- var data={
- type:1,
- url:this.url,
- parentId:this.parentId
- }
- addAttachment(data).then(
- res => {
- if (res.code == 200) {
- uni.showToast({
- icon: 'success',
- title: "操作成功",
- });
- uni.$emit('refreshMyFolder');
- that.getAttachment()
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
-
- // 查看图片
- viewImage(e) {
- uni.previewImage({
- urls: this.imgList,
- current: e.currentTarget.dataset.url
- });
- },
- // 删除上传的图片
- delImg(e) {
- var that = this;
- uni.showModal({
- title: '提示',
- content: '确定要删除照片吗?',
- cancelText: '取消',
- confirmText: '确定',
- success: res => {
- if (res.confirm) {
- that.imgList.splice(e.currentTarget.dataset.index, 1)
- this.photos.splice(e.currentTarget.dataset.index, 1);
- }
- },
- })
- },
- // 出生日期选择
- bindDateChange: function(e) {
- this.form.birthday = e.target.value
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- height: 100%;
- background: #fff;
- }
- .content {
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .top-fixed {
- position: absolute;
- top: 0;
- background: #FFFFFF;
- padding: 20rpx;
- width: 100%;
- box-sizing: border-box;
- }
- .inner {
- // height: calc(100% - 120upx);
- padding:20upx;
- // padding-top: 110rpx;
- .add-img{
- width: 226rpx;
- height: 264rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: #F5F7FA;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- margin-bottom:20rpx ;
- }
- .img{
- width: 226rpx;
- height: 264rpx;
- border-radius:16rpx;
- overflow: hidden;
- position: relative;
- margin-bottom:20rpx ;
- image{
- width: 100%;
- height: 100%;
- }
- .close-img{
- width: 32upx;
- height: 32upx;
- position: absolute;
- top:2upx;
- right: 2upx;
- }
- .text{
- position: absolute;
- bottom: 0;
- z-index: 9;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- width: 100%;
- padding: 20rpx;
- box-sizing: border-box;
- .title{
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 28rpx;
- color: #FFFFFF;
- text-align: left;
- }
- .time{
- font-weight: 400;
- font-size: 22rpx;
- color: #FFFFFF;
- text-align: left;
- }
- }
- }
-
- }
- }
- </style>
|