index.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. var common_vendor = require("../../../common/vendor.js");
  3. const Layout = () => "./Layout.js";
  4. const _sfc_main = {
  5. components: {
  6. Layout
  7. },
  8. data() {
  9. return {
  10. baseUrl: common_vendor.index.getStorageSync("requestPath"),
  11. statusBarHeight: common_vendor.index.getSystemInfoSync().statusBarHeight + "px",
  12. device: "back",
  13. cameraContext: null,
  14. shutterShow: false,
  15. coverImage: null,
  16. menuLeft: "100%"
  17. };
  18. },
  19. mounted() {
  20. common_vendor.index.getSystemInfo({
  21. success: (result) => {
  22. const menuButtonInfo = common_vendor.index.getMenuButtonBoundingClientRect();
  23. this.menuLeft = menuButtonInfo.left + "px";
  24. },
  25. fail: (error) => {
  26. console.log(error);
  27. }
  28. });
  29. this.cameraContext = common_vendor.index.createCameraContext();
  30. },
  31. methods: {
  32. switchCamera() {
  33. this.device = this.device === "back" ? "front" : "back";
  34. },
  35. back() {
  36. common_vendor.index.navigateBack();
  37. },
  38. error(err) {
  39. console.log(err);
  40. },
  41. takePhoto() {
  42. this.$emit("takePhoto");
  43. },
  44. handleInstruct(instruct) {
  45. switch (instruct) {
  46. case "back":
  47. this.$emit("back");
  48. break;
  49. case "shutter":
  50. this.cameraContext.takePhoto({
  51. quality: "high",
  52. success: (res) => {
  53. this.$emit("getImage", res.tempImagePath);
  54. }
  55. });
  56. break;
  57. case "reversal":
  58. this.device = this.device === "back" ? "front" : "back";
  59. break;
  60. case "album":
  61. common_vendor.index.chooseImage({
  62. count: 1,
  63. sizeType: ["original", "compressed"],
  64. sourceType: ["album"],
  65. success: (res) => {
  66. common_vendor.index.setStorageSync("tongueUrl", res.tempFilePaths[0]);
  67. this.$emit("getImage");
  68. }
  69. });
  70. break;
  71. }
  72. }
  73. }
  74. };
  75. if (!Array) {
  76. const _component_Layout = common_vendor.resolveComponent("Layout");
  77. _component_Layout();
  78. }
  79. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  80. return {
  81. a: $data.statusBarHeight,
  82. b: common_vendor.o((...args) => $options.back && $options.back(...args)),
  83. c: $data.baseUrl + "/images/ques.png",
  84. d: $data.menuLeft,
  85. e: $data.baseUrl + "/images/tongue.png",
  86. f: $data.device,
  87. g: common_vendor.o((...args) => $options.error && $options.error(...args)),
  88. h: common_vendor.o($options.handleInstruct),
  89. i: common_vendor.o(($event) => $options.switchCamera()),
  90. j: common_vendor.o($options.takePhoto)
  91. };
  92. }
  93. var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4814c2d2"], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/components/CustomCamera/WeChat/index.vue"]]);
  94. wx.createComponent(Component);