submit_1.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. ismore: false,
  7. msg: ""
  8. };
  9. },
  10. methods: {
  11. //获取高度方法
  12. getElementHeight() {
  13. const query = common_vendor.index.createSelectorQuery().in(this);
  14. query.select(".submit").boundingClientRect((data) => {
  15. this.$emit("heights", data.height);
  16. }).exec();
  17. },
  18. //文字发送
  19. inputs() {
  20. if (this.msg.length > 0) {
  21. let msg = this.msg.replace(/[\r\n]/g, "");
  22. this.send(msg, "0");
  23. }
  24. },
  25. // 输入框聚焦
  26. focus() {
  27. this.ismore = false;
  28. setTimeout(() => {
  29. this.getElementHeight();
  30. }, 10);
  31. },
  32. //更多功能
  33. more() {
  34. this.ismore = !this.ismore;
  35. setTimeout(() => {
  36. this.getElementHeight();
  37. }, 10);
  38. },
  39. //图片发送
  40. sendImg(e) {
  41. const that = this;
  42. let serverUrl = that.$config.serverFile;
  43. that.$emit("choseImg", true);
  44. common_vendor.index.chooseImage({
  45. count: 1,
  46. sizeType: ["original", "compressed"],
  47. sourceType: ["album", "camera"],
  48. success: async function(res) {
  49. that.$emit("choseImg", true);
  50. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  51. const arr = await that.$apifile(`/travel/applet/upload`, "file", tempFile[0], "file");
  52. if (arr.errcode == "0") {
  53. let filePaths = serverUrl + arr.uri;
  54. that.send(filePaths, "1");
  55. } else {
  56. that.$emit("choseImg", false);
  57. common_vendor.index.showToast({
  58. title: arr.errmsg,
  59. icon: "none"
  60. });
  61. }
  62. }
  63. });
  64. },
  65. //发送
  66. send(msg, type) {
  67. let data = {
  68. message: msg,
  69. type
  70. };
  71. this.$emit("inputs", data);
  72. setTimeout(() => {
  73. this.msg = "";
  74. }, 0);
  75. }
  76. }
  77. };
  78. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  79. return common_vendor.e({
  80. a: common_vendor.o((...args) => $options.focus && $options.focus(...args)),
  81. b: $data.msg,
  82. c: common_vendor.o(($event) => $data.msg = $event.detail.value),
  83. d: common_vendor.o((...args) => $options.more && $options.more(...args)),
  84. e: $data.msg
  85. }, $data.msg ? {
  86. f: common_vendor.o((...args) => $options.inputs && $options.inputs(...args))
  87. } : {}, {
  88. g: common_vendor.o(($event) => $options.sendImg("album")),
  89. h: !$data.ismore ? 1 : ""
  90. });
  91. }
  92. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cccf71ac"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/customer/common/submit_1.vue"]]);
  93. wx.createComponent(Component);