123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <view>
- <view style="height: 5px;"></view>
- <view class="uni-navigate-item-my" @click="InspctOperate">
- <text class="uni-navigate-text-my">质检操作</text>
- <text class="uni-navigate-icon-my uni-icon"></text>
- </view>
- <view style="height: 5px;"></view>
- <view class="uni-navigate-item-my" @click="InspectRecordQuery">
- <text class="uni-navigate-text-my">质检记录查询</text>
- <text class="uni-navigate-icon-my uni-icon"></text>
- </view>
- <view style="height: 5px;"></view>
- <view class="uni-navigate-item-my" @click="PrintLabelFun">
- <text class="uni-navigate-text-my">交验单标签打印</text>
- <text class="uni-navigate-icon-my uni-icon"></text>
- </view>
- <view style="height: 5px;"></view>
- <view class="uni-navigate-item-my" @click="InspectOneClickOutStore">
- <text class="uni-navigate-text-my">质检结果-快速出库</text>
- <text class="uni-navigate-icon-my uni-icon"></text>
- </view>
- <!-- <view class="uni-navigate-item-my" @click="TestTmp">
- <text class="uni-navigate-text-my">测试使用</text>
- <text class="uni-navigate-icon-my uni-icon"></text>
- </view> -->
- <!-- 以下代码用于测试选择相册图片和拍照图片。 建议不要删除。保留好。 -->
- <!-- <view class="demo">
- <block v-if="imageSrc">
- <image :src="imageSrc" class="image" mode="widthFix" @click="previewImage11(1)"></image>
- </block>
- <block v-else>
- <view class="uni-hello-addfile" @click="chooseImage">+ 选择图片</view>
- </block>
- </view>
- <view class="uni-flex uni-row">
- <button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;" @click="deletePic">删除</button>
- </view>
- <view class="demo">
- <block v-if="imageSrc1">
- <image :src="imageSrc1" class="image" mode="widthFix" @click="previewImage11(2)"></image>
- </block>
- </view>
- <view class="uni-flex uni-row">
- <button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;" @click="downloadPic">下载图片</button>
- </view> -->
- </view>
- </template>
- <script>
- // TODO 修复Android v3 加载过慢问题
- // #ifdef APP-PLUS
- var domModule = weex.requireModule('dom');
- domModule.addRule('fontFace', {
- 'fontFamily': "uniicons",
- 'src': "url('/static/uni.ttf')"
- });
- // #endif
- export default {
- data() {
- return {
- imageSrc: '',
- imageSrc1: '',
- previewImagePath: '',
- previewImagePath1: '',
- }
- },
- onUnload() {
- this.imageSrc = '';
- },
- methods: {
- InspctOperate() {
- uni.navigateTo({
- url:"/pages/Inspect/inspect01",
- })
- },
- InspectRecordQuery() {
- // 以下代码用于测试选择相册图片和拍照图片。 建议不要删除。保留好。
- // uni.chooseImage({
- // count: 6, //默认9
- // sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
- // sourceType: ['camera'], //从相册选择
- // success: function (res) {
- // console.log(JSON.stringify(res.tempFilePaths));
- // }
- // });
- uni.navigateTo({
- url:"/pages/Inspect/inspectRecordQuery",
- })
- },
- PrintLabelFun() {
- uni.navigateTo({
- url:"/pages/Inspect/PrintLabel",
- })
- },
- InspectOneClickOutStore() {
- uni.navigateTo({
- url:"/pages/Inspect/FastOutStoreInspect01",
- })
- },
- chooseImage: function() {
- let userMsg = uni.getStorageSync('userInfo')
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['camera'],
- success: (res) => {
- // console.log(res.tempFilePaths)
- // console.log('chooseImage success, temp path is', res.tempFilePaths[0])
- var imageSrc = res.tempFilePaths[0]
- this.previewImagePath = res.tempFilePaths
- this.imageSrc = imageSrc
- uni.uploadFile({
- url: getApp().globalData.baseUrl + '/Common/UploadFile',
- filePath: imageSrc,
- fileType: 'image',
- header: { //自定义请求头信息
- Authorization: 'Bearer ' + userMsg.tokenStr + ''
- },
- formData: {
- 'FileName': 'test',
- 'FileDir': '1111',
- 'FileNameType': '1',
- 'File' : res.tempFiles[0]
- },
- name: 'data',
- success: (res) => {
- // console.log('uploadImage success, res is:', res)
- uni.showToast({
- title: '上传成功',
- icon: 'success',
- duration: 1000
- })
- },
- fail: (err) => {
- // console.log('uploadImage fail', err);
- uni.showModal({
- content: err.errMsg,
- showCancel: false
- });
- }
- });
- },
- fail: (err) => {
- // console.log('chooseImage fail', err)
- // #ifdef MP
- uni.getSetting({
- success: (res) => {
- let authStatus = res.authSetting['scope.album'];
- if (!authStatus) {
- uni.showModal({
- title: '授权失败',
- content: 'Hello uni-app需要从您的相册获取图片,请在设置界面打开相关权限',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting()
- }
- }
- })
- }
- }
- })
- // #endif
- }
- })
- },
- deletePic() {
- this.imageSrc = ''
- this.imageSrc1 = ''
- },
- downloadPic() {
- let userMsg = uni.getStorageSync('userInfo')
- let that = this
- uni.downloadFile({
- url: getApp().globalData.baseUrl + '/business/Testimage/GetQrCode', //GetTestimage?Id=4
- method: 'GET',
- header: { //自定义请求头信息
- Authorization: 'Bearer ' + userMsg.tokenStr + ''
- },
- success: res => {
- // console.log(res)
-
- // const arrayBuffer = new Uint8Array(res.data)
- // this.imageSrc1 = 'data:image/png;base64,' + uni.arrayBufferToBase64(arrayBuffer);
- // this.previewImagePath1 = this.imageSrc1
-
- this.imageSrc1 = res.tempFilePath
- uni.saveFile({
- tempFilePath: res.tempFilePath,
- success: function (res) {
- var savedFilePath = res.savedFilePath;
- that.previewImagePath1 = res.savedFilePath
- }
- });
- },
- fail: (err) => {
- // console.log(err)
- }
- });
- },
- previewImage11(res) {
- // ToDo: 暂未实现 从后端获取图片并预览大图 孙亚龙
- // 预览图片
- uni.previewImage({
- urls: res == 1 ? this.previewImagePath : this.previewImagePath1
- });
- },
- TestTmp() {
- uni.navigateTo({
- url:"/pages/Inspect/TestPage001",
- })
- }
- }
- }
- </script>
- <style lang="scss">
- @import '../../../common/uni-nvue.css';
- .image {
- width: 100%;
- }
-
- .demo {
- background: #FFF;
- padding: 50rpx;
- }
- </style>
|