s-menu-button.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../index.js");
  4. require("../../url/index.js");
  5. require("../../store/index.js");
  6. require("../../store/app.js");
  7. require("../../api/promotion/diy.js");
  8. require("../../request/index.js");
  9. require("../../config/index.js");
  10. require("../../platform/index.js");
  11. require("../../platform/provider/wechat/index.js");
  12. require("../../platform/provider/wechat/miniProgram.js");
  13. require("../../api/member/auth.js");
  14. require("../../api/member/social.js");
  15. require("../../api/member/user.js");
  16. require("../../platform/provider/apple/index.js");
  17. require("../../platform/share.js");
  18. require("../../router/index.js");
  19. require("../../hooks/useModal.js");
  20. require("../../helper/index.js");
  21. require("../../helper/test.js");
  22. require("../../helper/digit.js");
  23. require("../../helper/throttle.js");
  24. require("../../platform/pay.js");
  25. require("../../api/pay/order.js");
  26. require("../../store/user.js");
  27. require("../../store/cart.js");
  28. require("../../api/trade/cart.js");
  29. require("../../api/pay/wallet.js");
  30. require("../../api/trade/order.js");
  31. require("../../api/promotion/coupon.js");
  32. require("../../store/sys.js");
  33. require("../../store/modal.js");
  34. require("../../config/zIndex.js");
  35. const _sfc_main = {
  36. __name: "s-menu-button",
  37. props: {
  38. data: {
  39. type: Object,
  40. default() {
  41. }
  42. },
  43. styles: {
  44. type: Object,
  45. default() {
  46. }
  47. },
  48. circular: {
  49. type: Boolean,
  50. default: true
  51. },
  52. autoplay: {
  53. type: Boolean,
  54. default: false
  55. },
  56. interval: {
  57. type: Number,
  58. default: 5e3
  59. },
  60. duration: {
  61. type: Number,
  62. default: 500
  63. },
  64. ui: {
  65. type: String,
  66. default: ""
  67. },
  68. mode: {
  69. //default
  70. type: String,
  71. default: "default"
  72. },
  73. dotStyle: {
  74. type: String,
  75. default: "long"
  76. //default long tag
  77. },
  78. dotCur: {
  79. type: String,
  80. default: "ui-BG-Main"
  81. },
  82. bg: {
  83. type: String,
  84. default: "bg-none"
  85. },
  86. height: {
  87. type: Number,
  88. default: 300
  89. },
  90. // 是否有边框
  91. hasBorder: {
  92. type: Boolean,
  93. default: true
  94. },
  95. // 边框颜色
  96. borderColor: {
  97. type: String,
  98. default: "red"
  99. },
  100. background: {
  101. type: String,
  102. default: "blue"
  103. },
  104. hoverClass: {
  105. type: String,
  106. default: "ss-hover-class"
  107. //'none'为没有hover效果
  108. },
  109. // 一排宫格数
  110. col: {
  111. type: [Number, String],
  112. default: 3
  113. },
  114. iconSize: {
  115. type: Number,
  116. default: 80
  117. },
  118. color: {
  119. type: String,
  120. default: "#000"
  121. }
  122. },
  123. setup(__props) {
  124. const props = __props;
  125. const state = common_vendor.reactive({
  126. cur: 0
  127. });
  128. const menuList = common_vendor.computed(() => splitData(props.data.list, props.data.row * props.data.column));
  129. const swiperHeight = common_vendor.computed(() => props.data.row * (props.data.layout === "iconText" ? 200 : 180));
  130. sheep_index.sheep.$platform.device.windowWidth;
  131. const swiperChange = (e) => {
  132. state.cur = e.detail.current;
  133. };
  134. const splitData = (oArr = [], length = 1) => {
  135. let arr = [];
  136. let minArr = [];
  137. oArr.forEach((c) => {
  138. if (minArr.length === length) {
  139. minArr = [];
  140. }
  141. if (minArr.length === 0) {
  142. arr.push(minArr);
  143. }
  144. minArr.push(c);
  145. });
  146. return arr;
  147. };
  148. return (_ctx, _cache) => {
  149. return common_vendor.e({
  150. a: common_vendor.f(common_vendor.unref(menuList), (arr, index, i0) => {
  151. return {
  152. a: common_vendor.f(arr, (item, index2, i1) => {
  153. return common_vendor.e({
  154. a: item.badge.show
  155. }, item.badge.show ? {
  156. b: common_vendor.t(item.badge.text),
  157. c: common_vendor.s({
  158. background: item.badge.bgColor,
  159. color: item.badge.textColor
  160. })
  161. } : {}, {
  162. d: item.iconUrl
  163. }, item.iconUrl ? {
  164. e: common_vendor.s({
  165. width: props.iconSize + "rpx",
  166. height: props.iconSize + "rpx"
  167. }),
  168. f: common_vendor.unref(sheep_index.sheep).$url.cdn(item.iconUrl)
  169. } : {}, __props.data.layout === "iconText" ? {
  170. g: common_vendor.t(item.title),
  171. h: common_vendor.s({
  172. color: item.titleColor
  173. })
  174. } : {}, {
  175. i: index2,
  176. j: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go(item.url), index2)
  177. });
  178. }),
  179. b: index,
  180. c: state.cur == index ? 1 : ""
  181. };
  182. }),
  183. b: __props.data.layout === "iconText",
  184. c: common_vendor.s({
  185. width: `${100 * (1 / __props.data.column)}%`,
  186. height: "200rpx"
  187. }),
  188. d: props.circular,
  189. e: state.cur,
  190. f: props.autoplay,
  191. g: props.interval,
  192. h: props.duration,
  193. i: common_vendor.s({
  194. height: common_vendor.unref(swiperHeight) + "rpx"
  195. }),
  196. j: common_vendor.o(swiperChange),
  197. k: common_vendor.unref(menuList).length > 1
  198. }, common_vendor.unref(menuList).length > 1 ? common_vendor.e({
  199. l: props.dotStyle != "tag"
  200. }, props.dotStyle != "tag" ? {
  201. m: common_vendor.f(common_vendor.unref(menuList).length, (item, index, i0) => {
  202. return {
  203. a: index,
  204. b: common_vendor.n(state.cur == index ? "cur" : "")
  205. };
  206. }),
  207. n: common_vendor.n(props.dotCur),
  208. o: common_vendor.n(props.dotStyle)
  209. } : {}, {
  210. p: props.dotStyle == "tag"
  211. }, props.dotStyle == "tag" ? {
  212. q: common_vendor.t(state.cur + 1),
  213. r: common_vendor.t(common_vendor.unref(menuList).length),
  214. s: common_vendor.n(props.dotCur),
  215. t: common_vendor.n(props.dotStyle)
  216. } : {}) : {}, {
  217. v: common_vendor.n(props.mode),
  218. w: common_vendor.n(props.bg),
  219. x: common_vendor.n(props.ui),
  220. y: common_vendor.s({
  221. height: common_vendor.unref(swiperHeight) + (common_vendor.unref(menuList).length > 1 ? 50 : 0) + "rpx"
  222. })
  223. });
  224. };
  225. }
  226. };
  227. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-75f856ac"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/components/s-menu-button/s-menu-button.vue"]]);
  228. wx.createComponent(Component);