uni-fab.js 8.8 KB

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