@@ -1,28 +1,38 @@ | |||
import { conforms } from 'lodash'; | |||
import wx from './weixin-js-sdk.js'; | |||
export default { | |||
scanCodeFun() { | |||
const promise = new Promise((resolve, reject) => { | |||
// #ifdef APP-PLUS || MP-WEIXIN | |||
uni.scanCode({ | |||
success: function(res) { | |||
// console.log(res) | |||
// console.log('条码类型:' + res.scanType); | |||
// console.log('条码内容:' + res.result); | |||
resolve(res) | |||
}, | |||
fail: function(res) { | |||
this.HTTP_GET("weixinapi/getweixinwebaccess_token?url=" + encodeURIComponent(window.location.href)).then((success)=>{ | |||
if(!success){ | |||
resolve(false) | |||
return | |||
} | |||
}); | |||
// #endif | |||
// #ifndef APP-PLUS || MP-WEIXIN | |||
resolve(false) | |||
uni.showToast({ | |||
title: '请下载app或者到微信浏览器打开网页', | |||
icon: 'none', | |||
mask: false | |||
wx.config({ | |||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | |||
appId: success.appid, // 必填,公众号的唯一标识 | |||
timestamp: success.timestamp, // 必填,生成签名的时间戳 | |||
nonceStr: success.noncestr, // 必填,生成签名的随机串 | |||
signature: success.certificate, // 必填,签名 | |||
jsApiList: ["scanQRCode"] // 必填,需要使用的JS接口列表 | |||
}); | |||
wx.ready(() => { | |||
wx.scanQRCode({ | |||
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, | |||
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有 | |||
success: function (res) { | |||
var result = res.resultStr; // 当 needResult 为 1 时,扫码返回的结果 | |||
var resultArr = result.split(','); // 扫描结果以逗号分割数组 | |||
var codeContent = resultArr[resultArr.length - 1]; // 获取数组最后一个元素,也就是最终的内容 | |||
resolve(result) | |||
}, | |||
fail: error => { | |||
this.TOAST("调用扫码失败") | |||
resolve(false) | |||
} | |||
}); | |||
}) | |||
}) | |||
// #endif | |||
}) | |||
return promise | |||
} | |||
@@ -86,8 +86,6 @@ | |||
}, | |||
async chooseChangeback(tempFilePaths, tempFiles) { | |||
// let {tempFilePaths,tempFiles} = res | |||
// if(!this.validate(tempFiles))return | |||
let uploadImageRes = await this.uploadImage(tempFilePaths[0], tempFiles[0] ? tempFiles[0].name : "") | |||
let newList = this.imgList || [] | |||
if (uploadImageRes) { | |||
@@ -131,72 +129,6 @@ | |||
}) | |||
}, | |||
ceshi() { | |||
function apiFn(params) { | |||
return new Promise((resolve, reject) => { | |||
this.LOADING('正在上传…'); | |||
this.HTTP_UPLOAD2('StuInfoFresh/upload', params.url, { | |||
folderId: this.folderId | |||
}).then((data) => { | |||
this.HIDE_LOADING(); | |||
if (data) { | |||
// this.HTTP_GET('StuInfoFresh/upload', {fileId:data}) | |||
this.imgList[params.index] = [{ | |||
id: data.F_Id, | |||
name: data.F_FileName, | |||
url: data.F_FilePath, | |||
type: data.F_FileType | |||
}] | |||
reslove(this.imgList[params.index]) | |||
} else { | |||
reject('上传失败!') | |||
} | |||
}) | |||
}) | |||
} | |||
let array = this.imgList.map(item => { | |||
if (item.id) { | |||
return "" | |||
} else { | |||
return { | |||
url: "learun/adms/annexes/upload" | |||
} | |||
} | |||
}) | |||
this.promiseAllLimit(2, [1, 2, 3, 4, 5, 6, 7, 8, 9], a).then(res => { | |||
console.log(res) | |||
}) | |||
}, | |||
/** | |||
* @description 控制promise.all并发数量 | |||
* @param limit 并发数 | |||
* @param array 参数列表 | |||
* @param apiFn 执行函数 | |||
* @returns {Promise<Awaited<unknown>[]>} | |||
*/ | |||
async promiseAllLimit(limit, array, apiFn) { | |||
const ret = [] // 用于存放所有的promise实例 | |||
const executing = [] // 用于存放目前正在执行的promise | |||
for (const item of array) { | |||
const p = apiFn(item) | |||
ret.push(p) | |||
if (limit <= array.length) { | |||
// then回调中,当这个promise状态变为fulfilled后,将其从正在执行的promise列表executing中删除 | |||
const e = p.then(() => executing.splice(executing.indexOf(e), 1)) | |||
executing.push(e) | |||
if (executing.length >= limit) { | |||
// 一旦正在执行的promise列表数量等于限制数,就使用Promise.race等待某一个promise状态发生变更, | |||
// 状态变更后,就会执行上面then的回调,将该promise从executing中删除, | |||
// 然后再进入到下一次for循环,生成新的promise进行补充 | |||
await Promise.race(executing) | |||
} | |||
} | |||
} | |||
return Promise.all(ret) | |||
}, | |||
validate(array) { | |||
// let type = array.every(item=>{ | |||
// return item.type && item.type.substring(0,6) == "image/" | |||
@@ -233,33 +165,6 @@ | |||
}); | |||
} | |||
}, | |||
// previewFile() { | |||
// var file = document.querySelector('input[type=file]').files[0]; | |||
// var reader = new FileReader(); | |||
// // fileReader.readAsDataURL(blob); | |||
// // fileReader.onerror = () => { | |||
// // reject(new Error('blobToBase64 error')); | |||
// // }; | |||
// // var encodedData = window.btoa("Hello, world"); | |||
// reader.onloadend = function () { | |||
// //$('#PhotoImg').attr('src', reader.result); | |||
// var postData = { | |||
// Base64Url: reader.result | |||
// } | |||
// this.HTTP_POST(config.webapi + "StuInfoFresh/savePhoto", postData, (data) => { | |||
// if (data) { | |||
// $('#Photo').val(data.AnnexesFileId); | |||
// $('#PhotoImg').attr('src', config.web + data.Url); | |||
// } else { | |||
// learun.layer.toast('采集照片信息失败!'); | |||
// } | |||
// }); | |||
// } | |||
// if (file) { | |||
// reader.readAsDataURL(file); | |||
// } | |||
// }, | |||
}, | |||
created() { | |||
console.log(this.value) | |||
@@ -70,7 +70,7 @@ | |||
</view> | |||
</scroll-view> | |||
<l-customlist-add v-if="!sideOpen" @click="action('add')" /> | |||
<!-- <l-customlist-add v-if="!sideOpen" @click="action('add')" /> --> | |||
</view> | |||
</template> | |||
@@ -45,8 +45,8 @@ | |||
<u-parse v-if="ready" :imageProp="{ domain: apiRoot }" :content="getValue('SYS_ReceiveMessage.CONTENTS')" noData="暂无内容"></u-parse> | |||
</view> | |||
</view> | |||
<view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;"> | |||
<!-- <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block> | |||
<!-- <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;"> | |||
<l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block> | |||
提交保存 | |||
</l-button> | |||
<l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block> | |||
@@ -57,8 +57,8 @@ | |||
</l-button> | |||
<l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block> | |||
删除 | |||
</l-button> --> | |||
</view> | |||
</l-button> | |||
</view> --> | |||
</view> | |||
</template> | |||
@@ -60,8 +60,8 @@ | |||
<u-parse v-if="ready" :imageProp="{ domain: apiRoot }" :content="getValue('Sys_ReceiveFile.Contents')" noData="暂无内容"></u-parse> | |||
</view> | |||
</view> | |||
<view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;"> | |||
<!-- <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block> | |||
<!-- <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;"> | |||
<l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block> | |||
提交保存 | |||
</l-button> | |||
<l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block> | |||
@@ -72,8 +72,8 @@ | |||
</l-button> | |||
<l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block> | |||
删除 | |||
</l-button> --> | |||
</view> | |||
</l-button> | |||
</view> --> | |||
</view | |||
> | |||
</template> | |||
@@ -1,4 +1,4 @@ | |||
<template> | |||
<template> | |||
<view class="page"> | |||
<!-- 主列表页 --> | |||
<view | |||
@@ -13,17 +13,22 @@ export default { | |||
methods: { | |||
init() { | |||
let _this = this; | |||
scanCodeFun.scanCodeFun().then((res) => { | |||
scanCodeFun.scanCodeFun.call(_this).then((res) => { | |||
if (!res) return; | |||
var userInfo = this.GET_GLOBAL("loginUser"); | |||
var result = this.HTTP_GET( | |||
"learun/adms/PersonnelManagement/MeetingSignInRecord/scan", | |||
{ | |||
userid: userInfo.userId, | |||
meetid: res.result, | |||
meetid: res, | |||
}, | |||
"签到时出错" | |||
).then(res1=>{this.TOAST(res1.result )}) | |||
).then(res1=>{ | |||
this.TOAST(res1.result) | |||
setTimeout(()=>{ | |||
this.NAV_BACK() | |||
},1000) | |||
}) | |||
}); | |||
}, | |||
tapScan() { | |||