uni-fab.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. "use strict";
  2. const sheep_index = require("../../../../sheep/index.js");
  3. const common_vendor = require("../../../../common/vendor.js");
  4. require("../../../../sheep/url/index.js");
  5. require("../../../../sheep/store/index.js");
  6. require("../../../../sheep/store/app.js");
  7. require("../../../../sheep/api/promotion/diy.js");
  8. require("../../../../sheep/request/index.js");
  9. require("../../../../sheep/config/index.js");
  10. require("../../../../sheep/platform/index.js");
  11. require("../../../../sheep/platform/provider/wechat/index.js");
  12. require("../../../../sheep/platform/provider/wechat/miniProgram.js");
  13. require("../../../../sheep/api/member/auth.js");
  14. require("../../../../sheep/api/member/social.js");
  15. require("../../../../sheep/api/member/user.js");
  16. require("../../../../sheep/platform/provider/apple/index.js");
  17. require("../../../../sheep/platform/share.js");
  18. require("../../../../sheep/router/index.js");
  19. require("../../../../sheep/hooks/useModal.js");
  20. require("../../../../sheep/helper/index.js");
  21. require("../../../../sheep/helper/test.js");
  22. require("../../../../sheep/helper/digit.js");
  23. require("../../../../sheep/helper/throttle.js");
  24. require("../../../../sheep/platform/pay.js");
  25. require("../../../../sheep/api/pay/order.js");
  26. require("../../../../sheep/store/user.js");
  27. require("../../../../sheep/store/cart.js");
  28. require("../../../../sheep/api/trade/cart.js");
  29. require("../../../../sheep/api/pay/wallet.js");
  30. require("../../../../sheep/api/trade/order.js");
  31. require("../../../../sheep/api/promotion/coupon.js");
  32. require("../../../../sheep/store/sys.js");
  33. require("../../../../sheep/store/modal.js");
  34. require("../../../../sheep/config/zIndex.js");
  35. sheep_index.sheep.$platform.device;
  36. let platform = "other";
  37. const _sfc_main = {
  38. name: "UniFab",
  39. emits: ["fabClick", "trigger"],
  40. props: {
  41. pattern: {
  42. type: Array,
  43. default() {
  44. return [];
  45. }
  46. },
  47. horizontal: {
  48. type: String,
  49. default: "left"
  50. },
  51. vertical: {
  52. type: String,
  53. default: "bottom"
  54. },
  55. direction: {
  56. type: String,
  57. default: "horizontal"
  58. },
  59. content: {
  60. type: Array,
  61. default() {
  62. return [];
  63. }
  64. },
  65. show: {
  66. type: Boolean,
  67. default: false
  68. },
  69. popMenu: {
  70. type: Boolean,
  71. default: true
  72. }
  73. },
  74. data() {
  75. return {
  76. fabShow: false,
  77. isShow: false,
  78. isAndroidNvue: platform === "android",
  79. styles: [
  80. {
  81. // color: '#3c3e49',
  82. // selectedColor: '#007AFF',
  83. // backgroundColor: '#fff',
  84. // buttonColor: '#007AFF',
  85. // iconColor: '#fff'
  86. }
  87. ]
  88. };
  89. },
  90. computed: {
  91. contentWidth(e) {
  92. return (this.content.length + 1) * 130 + "rpx";
  93. },
  94. contentWidthMin() {
  95. return "100rpx";
  96. },
  97. // 动态计算宽度
  98. boxWidth() {
  99. return this.getPosition(3, "horizontal");
  100. },
  101. // 动态计算高度
  102. boxHeight() {
  103. return this.getPosition(3, "vertical");
  104. },
  105. // 计算左下位置
  106. leftBottom() {
  107. return this.getPosition(0, "left", "bottom");
  108. },
  109. // 计算右下位置
  110. rightBottom() {
  111. return this.getPosition(0, "right", "bottom");
  112. },
  113. // 计算左上位置
  114. leftTop() {
  115. return this.getPosition(0, "left", "top");
  116. },
  117. rightTop() {
  118. return this.getPosition(0, "right", "top");
  119. },
  120. flexDirectionStart() {
  121. return this.getPosition(1, "vertical", "top");
  122. },
  123. flexDirectionEnd() {
  124. return this.getPosition(1, "vertical", "bottom");
  125. },
  126. horizontalLeft() {
  127. return this.getPosition(2, "horizontal", "left");
  128. },
  129. horizontalRight() {
  130. return this.getPosition(2, "horizontal", "right");
  131. }
  132. },
  133. watch: {
  134. // pattern: {
  135. // handler(val, oldVal) {
  136. // this.styles = Object.assign({}, this.styles, val)
  137. // },
  138. // deep: true
  139. // }
  140. },
  141. created() {
  142. this.isShow = this.show;
  143. if (this.top === 0) {
  144. this.fabShow = true;
  145. }
  146. },
  147. methods: {
  148. _onClick() {
  149. this.$emit("fabClick");
  150. if (!this.popMenu) {
  151. return;
  152. }
  153. this.isShow = !this.isShow;
  154. },
  155. open() {
  156. this.isShow = true;
  157. },
  158. close() {
  159. this.isShow = false;
  160. },
  161. /**
  162. * 按钮点击事件
  163. */
  164. _onItemClick(index, item) {
  165. this.$emit("trigger", {
  166. index,
  167. item
  168. });
  169. },
  170. /**
  171. * 获取 位置信息
  172. */
  173. getPosition(types, paramA, paramB) {
  174. if (types === 0) {
  175. return this.horizontal === paramA && this.vertical === paramB;
  176. } else if (types === 1) {
  177. return this.direction === paramA && this.vertical === paramB;
  178. } else if (types === 2) {
  179. return this.direction === paramA && this.horizontal === paramB;
  180. } else {
  181. return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin;
  182. }
  183. }
  184. }
  185. };
  186. if (!Array) {
  187. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  188. _easycom_uni_icons2();
  189. }
  190. const _easycom_uni_icons = () => "../../../uni-icons/components/uni-icons/uni-icons.js";
  191. if (!Math) {
  192. _easycom_uni_icons();
  193. }
  194. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  195. return common_vendor.e({
  196. a: $props.popMenu && ($options.leftBottom || $options.rightBottom || $options.leftTop || $options.rightTop) && $props.content.length > 0
  197. }, $props.popMenu && ($options.leftBottom || $options.rightBottom || $options.leftTop || $options.rightTop) && $props.content.length > 0 ? common_vendor.e({
  198. b: $options.flexDirectionStart || $options.horizontalLeft
  199. }, $options.flexDirectionStart || $options.horizontalLeft ? {} : {}, {
  200. c: common_vendor.f($props.content, (item, index, i0) => {
  201. return {
  202. a: item.active ? item.selectedIconPath : item.iconPath,
  203. b: common_vendor.t(item.text),
  204. c: $props.pattern[index].color,
  205. d: index,
  206. e: common_vendor.o(($event) => $options._onItemClick(index, item), index)
  207. };
  208. }),
  209. d: $props.direction == "vertical" ? 1 : "",
  210. e: $data.isShow ? 1 : "",
  211. f: $props.direction == "horizontal" ? 1 : "",
  212. g: $options.flexDirectionEnd || $options.horizontalRight
  213. }, $options.flexDirectionEnd || $options.horizontalRight ? {} : {}, {
  214. h: $props.horizontal === "left" ? 1 : "",
  215. i: $props.horizontal === "right" ? 1 : "",
  216. j: $props.direction === "vertical" ? 1 : "",
  217. k: $options.flexDirectionStart ? 1 : "",
  218. l: $options.flexDirectionEnd ? 1 : "",
  219. m: !$data.isAndroidNvue ? 1 : "",
  220. n: $options.boxWidth,
  221. o: $options.boxHeight,
  222. p: $options.leftBottom ? 1 : "",
  223. q: $options.rightBottom ? 1 : "",
  224. r: $options.leftTop ? 1 : "",
  225. s: $options.rightTop ? 1 : ""
  226. }) : {}, {
  227. t: $data.isShow && $props.content.length > 0 ? 1 : "",
  228. v: common_vendor.p({
  229. type: "plusempty",
  230. color: "#fff",
  231. size: "20"
  232. }),
  233. w: $options.leftBottom ? 1 : "",
  234. x: $options.rightBottom ? 1 : "",
  235. y: $options.leftTop ? 1 : "",
  236. z: $options.rightTop ? 1 : "",
  237. A: !$data.isAndroidNvue ? 1 : "",
  238. B: common_vendor.o((...args) => $options._onClick && $options._onClick(...args))
  239. });
  240. }
  241. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/uni_modules/uni-fab/components/uni-fab/uni-fab.vue"]]);
  242. wx.createComponent(Component);