informationEntry.vue 6.88 KB
<!--
 * @Description: 
 * @Author: huyue
 * @Date: 2024-04-07 14:54:28
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2024-04-18 11:24:22
-->
<template>
  <view class="information-entry">
    <view class="information-tips"
      >建议同步采集凭证,若接待工作繁忙可在提单环节再进行补充。</view
    >
    <view class="information-box">
      <view
        class="information-item"
        v-for="(item, index) in infoList"
        :key="item.title"
      >
        <view class="upload-img" v-if="item.imgUrl">
          <image
            class="img"
            :src="item.imgUrl"
            mode="aspectFill"
            @click="preview(index)"
          />
          <view class="upload-close" @click="close(index)"
            ><glsx-image src="detail/icon-close.png" mode="scaleToFill"
          /></view>
          <!-- <uni-icons
            class="upload-close"
            type="clear"
            :size="20"
            @click="close(index)"
          ></uni-icons> -->
        </view>
        <view v-else class="icon" @tap="choose(index)">
          <view class="icon-upload sprite-icon icon-icon-upload"></view>
        </view>
        <view class="information-title">{{ item.title }} </view>
      </view>
    </view>
    <view class="information-done" @click="done()">完成接待</view>
    <!-- <uni-popup ref="preview" type="center" border-radius="10px 10px 0 0">
      <image class="preview-img" :src="previewImg" mode="aspectFit" />
    </uni-popup> -->
    <MessageBox
      ref="tipBox"
      @cancel="tipCancel"
      @confirm="tipConfirm"
      content="系统检测到您在当前页面停留较久,是否仍在客户接待中?"
      cancelBtnText="否"
      confirmBtnText="是"
    ></MessageBox>
    <finish-step ref="stepRef" @submit="submit" />
    <update-box />
  </view>
</template>
<script>
import upload from "@/utils/ossUploadFile/uploadFile.js";
import utils from "@/utils/utils";
const INFO_LIST = [
  {
    id: 1,
    title: "客户付款凭证",
  },
  {
    id: 2,

    title: "客户购车发票",
  },
  {
    id: 3,
    title: "客户延保合同",
  },
];
import myClick from "@/mixin/click";
import { mapMutations } from "vuex";
import FinishStep from "@/components/FinishStep.vue";
export default {
  components: { FinishStep },
  mixins: [myClick],
  data() {
    return {
      infoList: INFO_LIST,
      previewImg: "",
      isPreview: false,
    };
  },
  onLoad(options) {
    const text = options.text;
    uni.setNavigationBarTitle({
      title: text,
    });
  },
  onBackPress() {
    this.infoList = this.infoList.map((item) => {
      if (item.imgUrl) {
        delete item.imgUrl;
      }
      return item;
    });
  },
  methods: {
    ...mapMutations("audio", ["setBooks"]),
    // 上传图
    async choose(index) {
      const result = await this.$permision.requestAndroidPermission(
        "android.permission.CAMERA"
      );
      if (result !== 1) {
        uni.showToast({
          title: "为了访问您的相机和图库,请打开相机权限",
          icon: "none",
        });
        return;
      }
      uni.chooseImage({
        count: 1,
        success: async (res) => {
          // await upload(res.tempFilePath)
          this.$set(
            this.infoList[index],
            "imgUrl",
            await upload(res.tempFilePaths[0])
          );
        },
        fail: (err) => {
          console.log(err);
        },
      });
    },
    // 删除图
    close(index) {
      this.$set(this.infoList[index], "imgUrl");
    },
    // 完成接待按钮
    done() {
      this.$refs.stepRef.open();
    },
    submit() {
      this.$refs.stepRef.close();
      this.setBooks(utils.deepClone(this.infoList));
      this.stopAudio();
      this.infoList = INFO_LIST.map((item) => delete item.imgUrl);
      setTimeout(() => {
        uni.reLaunch({
          url: "/pages/home/home",
        });
      }, 1500);
    },
    // 预览图片
    preview(index) {
      this.isPreview = true;
      this.previewImg = this.infoList[index].imgUrl;
      uni.previewImage({
        urls: [this.infoList[index].imgUrl],
        longPressActions: {
          // itemList: ['发送给朋友', '保存图片', '收藏'],
          success: function (data) {
            console.log(
              "选中了第" +
                (data.tapIndex + 1) +
                "个按钮,第" +
                (data.index + 1) +
                "张图片"
            );
          },
          fail: function (err) {
            console.log(err.errMsg);
          },
        },
      });
      // this.$refs.preview.open("center");
    },
  },
};
</script>
<style lang="scss" scoped>
.information-entry {
  position: relative;
  background-color: #fff;
  height: 100vh;
  .information-tips {
    background: rgba(44, 102, 247, 0.1);
    color: #2c66f7;
    padding: 32rpx 0 24rpx 80rpx;
    font-size: 28rpx;
  }
  .information-box {
    display: flex;
    padding: 40rpx 80rpx;
    .information-item {
      display: flex;
      flex-direction: column;
      width: 264rpx;
      margin-right: 48rpx;
      .icon {
        background-color: #f4f5f7;
        border: 2rpx solid #eff0f2;
        border-radius: 16rpx;
        .icon-upload {
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
          width: 128rpx;
          height: 128rpx;
        }
      }
      .icon,
      .upload-img {
        position: relative;
        width: 264rpx;
        height: 264rpx;
      }
      .upload-img {
        .img {
          border-radius: 16rpx;
          width: 100%;
          height: 100%;
        }
        .upload-close {
          position: absolute;
          right: 0;
          top: 0;
          width: 40rpx;
          height: 40rpx;
          // transform: translate(50%, -50%);
          // text-align: center;
          // font-size: 36rpx;
          // line-height: 40rpx;
          // display: flex;
          // align-items: center;
          // justify-content: center;
          // background-color: #fff;
          // border-radius: 50%;
          // padding: 0;
        }
      }
      .information-title {
        margin-top: 24rpx;
        font-weight: 500;
        font-size: 28rpx;
        color: #222222;
        letter-spacing: 0;
        line-height: 48rpx;
        text-align: center;
      }
    }
  }
}
.information-done {
  position: absolute;
  bottom: 30rpx;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 240rpx);
  height: 80rpx;
  font-weight: 500;
  font-size: 32rpx;
  color: #ffffff;
  text-align: center;
  line-height: 80rpx;
  background-color: #2c66f7;
  border-radius: 40rpx;
}

.preview-img {
  height: 1300rpx;
}
</style>