tool.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. export const getPhotograph = () => {
  2. uni.chooseImage({
  3. count: 6, //默认9
  4. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  5. sourceType: ['camera ', 'album'], //从相册选择
  6. success: function(res) {
  7. console.log(JSON.stringify(res.tempFilePaths));
  8. }
  9. });
  10. // // #ifdef APP-PLUS
  11. // var appid = plus.runtime.appid;
  12. // console.log('应用的 appid 为:' + appid);
  13. // // #endif
  14. // // #ifdef APP
  15. // var cmr = plus.camera.getCamera();
  16. // // 属性:
  17. // // supportedImageResolutions: 字符串数组,摄像头支持的拍照分辨率
  18. // // supportedVideoResolutions: 字符串数组,摄像头支持的摄像分辨率
  19. // // supportedImageFormats: 字符串数组,摄像头支持的拍照文件格式
  20. // // supportedVideoFormats: 字符串数组,摄像头支持的摄像文件格式
  21. // // 方法:
  22. // // captureImage: 进行拍照操作
  23. // // startVideoCapture: 调用摄像头进行摄像操作
  24. // // stopVideoCapture: 结束摄像操作
  25. // // 拍照 captureImage
  26. // var res = cmr.supportedImageResolutions[0];
  27. // var fmt = cmr.supportedImageFormats[0];
  28. // console.log("Resolution: " + res + ", Format: " + fmt);
  29. // cmr.captureImage(function(path) {
  30. // console.log("Capture image success: " + path);
  31. // },
  32. // function(error) {
  33. // console.log("Capture image failed: " + error.message);
  34. // }, {
  35. // resolution: res,
  36. // format: fmt
  37. // }
  38. // )
  39. // // 摄像
  40. // // function videoCapture(){
  41. // // }
  42. // // var cmr = plus.camera.getCamera();
  43. // // var res = cmr.supportedVideoResolutions[0];
  44. // // var fmt = cmr.supportedVideoFormats[0];
  45. // // console.log("Resolution: " + res + ", Format: " + fmt);
  46. // // cmr.startVideoCapture(function(path) {
  47. // // console.log("Capture video success: " + path);
  48. // // },
  49. // // function(error) {
  50. // // console.log("Capture video failed: " + error.message);
  51. // // }, {
  52. // // resolution: res,
  53. // // format: fmt
  54. // // }
  55. // // );
  56. // // #endif
  57. }
  58. export const distanceCalculate = (num) => {
  59. if (num < 1000) {
  60. return `${num}米`
  61. } else {
  62. const n = (num / 1000).toFixed(1);
  63. return `${n}公里`
  64. };
  65. }