liuyg
2021-11-04 f40d357b292c24c6091e79e98d40e224baf26d03
pages/issue/issue.vue
@@ -10,32 +10,32 @@
               :auto-upload="false" max-count="1" width="150" height="150" @on-choose-complete="afterRead">
            </u-upload>
         </u-form-item>
         <u-form-item label="来源">
         <!--    <u-form-item label="来源">
            <u-input v-model="form.b" />
         </u-form-item>
         </u-form-item> -->
         <u-form-item label="类型">
            <u-input v-model="form.c" type="select" @click="cshow = true" />
            <u-action-sheet :list="actionSheetList" v-model="cshow" @click="actionSheetCallback"></u-action-sheet>
         </u-form-item>
         <u-form-item label="时间">
         <!--    <u-form-item label="时间">
            <u-input v-model="form.d" />
         </u-form-item>
         <u-form-item label="状态">
            <u-input v-model="form.e" />
         </u-form-item>
         </u-form-item> -->
         <!--    <u-form-item label="评论">
            <u-input v-model="form.f" />
         </u-form-item> -->
         <u-form-item label="内容" v-show="isWenzi">
            <u-input v-model="form.g" type="textarea" />
         </u-form-item>
         <u-form-item label="标题" v-show="isshipin">
         <u-form-item label="简介" v-show="isshipin">
            <u-input v-model="form.h" />
         </u-form-item>
         <u-form-item label="视频" v-show="isshipin" class="shipMp4">
            <!-- <u-input v-model="form.i" /> -->
         </u-form-item>
         <img v-show="isshipin" class="shipMp4img" :src="videoSrc" mode="" @click="getVideo"></img>
         <img v-show="isshipin" class="shipMp4img" :videos="videos" :src="videoSrc" mode="" @click="getVideo"></img>
      </u-form>
      <view class="but">
         <u-button class="custom-style" type="primary" @click="inits"> 我发布</u-button>
@@ -62,6 +62,7 @@
            },
            fileList: [], // 图片文件
            multipleImgs: [], // 多张图片
            videos: "",
            action: '你的地址',
            sizeType: ['compressed'],
            cshow: false,
@@ -79,10 +80,36 @@
      },
      methods: {
         inits() {
            for (let k in this.form) {
               console.log(this.form[k])
            var datas = this.form;
            var that = this;
            var content = "";
            var videoUrl = "";
            if(datas.c == "文字类"){
               datas.c = "kxw"
               content = datas.g;
            }else{
               datas.c = "ksp"
               videoUrl = that.videos
            }
            console.log(this.fileList)
            uni.request({
               url: this.$store.state.piAPI + '/article/article/submit',
               method: 'POST',
               data: {
                  title: datas.a,
                  articleType: datas.c,
                  publish: 0,
                  url:that.fileList[0].url,
                  videoUrl:videoUrl,
                  sourceName:"群众",
                  content:content
               },
               success: (res) => {
                  if (res.data.code == 200) {
                  }
               }
            });
         },
         // 读取文件 -- 单个
         afterRead() {
@@ -110,23 +137,22 @@
         uploadDo(event, type) {
            let that = this;
            uni.uploadFile({
               url: "请求地址",
               url: that.$store.state.piAPI + '/depl/put-depl',
               filePath: event.file.path,
               name: 'uploadFile',
               name: 'file',
               formData: {
                  user: 'test'
               },
               success(res) {
                  console.log(res)
                  // let resp = JSON.parse(res.data)
                  // if (resp && resp.state === 200) {
                  //    let obj = {};
                  //    obj.url = that.requestUrl.api.fileUrl + resp.data.path
                  //    obj.name = '图' + that.avatar.length + 1
                  //    that.fileList = []
                  //    that.fileList.push(obj)
                  //    that.$refs.uUpload.clear()
                  // }
                  let resp = JSON.parse(res.data)
                  console.log(resp + "2323232")
                  if (resp && resp.code === 200) {
                     let obj = {};
                     obj.url = resp.data
                     that.fileList = []
                     that.fileList.push(obj)
                     that.$refs.uUpload.clear()
                  }
               }
            });
         },
@@ -143,45 +169,53 @@
            }
         },
         getVideo() {
            // console.log("get")
            // 上传视频
            var that = this;
            uni.chooseVideo({
               sourceType: ['album', 'camera'],
               maxDuration: 60,
               count: 1,
               // camera: this.cameraList[this.cameraIndex].value,
               sourceType: ['album'],
               success: res => {
                  console.log(res);
                  this.videoSrc = res.tempFilePath;
                  // console.log(this.res_url2)
               camera: 'back',
               success(res) {
                  var tempFilePath = res.tempFilePath;
                  // try {
                  uni.showLoading({
                     title: "上传中...",
                     mask: true
                  })
                  uni.uploadFile({
                     // url: 'https://web.byisf.com/api/depl/put-depl', //仅为示例,非真实的接口地址
                     url: that.$store.state.piAPI + '/depl/put-depl',
                     filePath: tempFilePath,
                     name: 'file',
                     formData: {
                        'user': 'test' // 上传附带参数
                     },
                     success: (data) => {
                        uni.showToast({
                           title: '上传视频成功!',
                           duration: 1000
                        });
                        //       // 根据接口具体返回格式   赋值具体对应url
                        // that.videos.push({
                        //    id: that.videos.length,
                        //    src: JSON.parse(data.data).data
                        // })
                        that.videos = JSON.parse(data.data).data;
                        // console.log(JSON.parse(data.data).data)
                     }
                  });
                  // var that2 = this;
                  // uni.uploadFile({
                  //    // 需要上传的地址
                  //    url:  '需要上传的地址',
                  //    // filePath  需要上传的文件
                  //    filePath: that2.res_url2,
                  //    name: 'file',
                  //    success(res1) {
                  //       console.log(res1)
                  //       // 显示上传信息
                  //       console.log(JSON.parse(res1.data))
                  //       let a = JSON.parse(res1.data);
                  //       if (res1.errMsg == 'uploadFile:ok') {
                  //          uni.showToast({
                  //             title: '视频上传成功'
                  //          })
                  //       }
                  //       console.log(a.data.url);
                  //       that2.url2 = a.data.url;
                  //       console.log(that2.url2);
                  //    },
                  //    fail(res) {
                  //       console.log(res)
                  //    }
                  // } catch (e) {
                  // console.log(e);
                  // wx.showToast({
                  //    title: '上传视频失败!',
                  //    duration: 2000
                  // });
                  // } finally {
                  // wx.hideLoading();
                  // }
               }
            });
            })
         }
      },
      created() {
@@ -208,12 +242,13 @@
      .custom-style {
         background-image: linear-gradient(to right, #08EFF6, #0693FD);
         border-radius: 20px;
         margin-top: 2rem;
      }
   }
   .shipMp4img {
      position: absolute;
      top: 27.6rem;
      top: 17.4rem;
      left: 3.2rem;
      width: 7rem;
      height: 7rem;