s-menu-button.js 6.4 KB

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