su-notice-bar.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. require("../../index.js");
  4. require("../../api/index.js");
  5. require("../../api/distri/score.js");
  6. require("../../request/index.js");
  7. require("../../config/index.js");
  8. require("../../store/index.js");
  9. require("../../store/app.js");
  10. require("../../api/promotion/diy.js");
  11. require("../../platform/index.js");
  12. require("../../platform/provider/wechat/index.js");
  13. require("../../platform/provider/wechat/miniProgram.js");
  14. require("../../api/member/auth.js");
  15. require("../../api/member/social.js");
  16. require("../../api/member/user.js");
  17. require("../../platform/provider/apple/index.js");
  18. require("../../platform/share.js");
  19. require("../../router/index.js");
  20. require("../../hooks/useModal.js");
  21. require("../../helper/index.js");
  22. require("../../helper/test.js");
  23. require("../../helper/digit.js");
  24. require("../../api/member/signin.js");
  25. require("../../helper/throttle.js");
  26. require("../../url/index.js");
  27. require("../../platform/pay.js");
  28. require("../../api/pay/order.js");
  29. require("../../store/user.js");
  30. require("../../store/cart.js");
  31. require("../../api/trade/cart.js");
  32. require("../../api/pay/wallet.js");
  33. require("../../api/trade/order.js");
  34. require("../../api/promotion/coupon.js");
  35. require("../../store/sys.js");
  36. require("../../store/modal.js");
  37. require("../../api/distri/share.js");
  38. require("../../api/distri/team.js");
  39. require("../../api/infra/file.js");
  40. require("../../api/member/address.js");
  41. require("../../api/member/point.js");
  42. require("../../api/migration/app.js");
  43. require("../../api/migration/chat.js");
  44. require("../../api/migration/index.js");
  45. require("../../api/migration/third.js");
  46. require("../../api/pay/channel.js");
  47. require("../../api/product/category.js");
  48. require("../../api/product/comment.js");
  49. require("../../api/product/favorite.js");
  50. require("../../api/product/history.js");
  51. require("../../api/product/spu.js");
  52. require("../../api/promotion/activity.js");
  53. require("../../api/promotion/article.js");
  54. require("../../api/promotion/bargain.js");
  55. require("../../api/promotion/combination.js");
  56. require("../../api/promotion/rewardActivity.js");
  57. require("../../api/promotion/seckill.js");
  58. require("../../api/system/area.js");
  59. require("../../api/system/voice.js");
  60. require("../../api/trade/afterSale.js");
  61. require("../../api/trade/brokerage.js");
  62. require("../../api/trade/config.js");
  63. require("../../api/trade/delivery.js");
  64. require("../../config/zIndex.js");
  65. const _sfc_main = {
  66. name: "UniNoticeBar",
  67. emits: ["click", "getmore", "close"],
  68. props: {
  69. text: {
  70. type: String,
  71. default: ""
  72. },
  73. moreText: {
  74. type: String,
  75. default: ""
  76. },
  77. backgroundColor: {
  78. type: String,
  79. default: ""
  80. },
  81. speed: {
  82. // 默认1s滚动100px
  83. type: Number,
  84. default: 100
  85. },
  86. color: {
  87. type: String,
  88. default: "var(--ui-BG-Main)"
  89. },
  90. moreColor: {
  91. type: String,
  92. default: "#FF9A43"
  93. },
  94. single: {
  95. // 是否单行
  96. type: [Boolean, String],
  97. default: false
  98. },
  99. scrollable: {
  100. // 是否滚动,添加后控制单行效果取消
  101. type: [Boolean, String],
  102. default: false
  103. },
  104. showIcon: {
  105. // 是否显示左侧icon
  106. type: [Boolean, String],
  107. default: false
  108. },
  109. showGetMore: {
  110. // 是否显示右侧查看更多
  111. type: [Boolean, String],
  112. default: false
  113. },
  114. showClose: {
  115. // 是否显示左侧关闭按钮
  116. type: [Boolean, String],
  117. default: false
  118. }
  119. },
  120. data() {
  121. const elId = `Uni_${Math.ceil(Math.random() * 1e6).toString(36)}`;
  122. const elIdBox = `Uni_${Math.ceil(Math.random() * 1e6).toString(36)}`;
  123. return {
  124. textWidth: 0,
  125. boxWidth: 0,
  126. wrapWidth: "",
  127. webviewHide: false,
  128. elId,
  129. elIdBox,
  130. show: true,
  131. animationDuration: "none",
  132. animationPlayState: "paused",
  133. animationDelay: "0s"
  134. };
  135. },
  136. mounted() {
  137. this.$nextTick(() => {
  138. this.initSize();
  139. });
  140. },
  141. methods: {
  142. initSize() {
  143. if (this.scrollable) {
  144. let query = [];
  145. let textQuery = new Promise((resolve, reject) => {
  146. common_vendor.index.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {
  147. this.textWidth = ret[0].width;
  148. resolve();
  149. });
  150. });
  151. let boxQuery = new Promise((resolve, reject) => {
  152. common_vendor.index.createSelectorQuery().in(this).select(`#${this.elIdBox}`).boundingClientRect().exec((ret) => {
  153. this.boxWidth = ret[0].width;
  154. resolve();
  155. });
  156. });
  157. query.push(textQuery);
  158. query.push(boxQuery);
  159. Promise.all(query).then(() => {
  160. this.animationDuration = `${this.textWidth / this.speed}s`;
  161. this.animationDelay = `-${this.boxWidth / this.speed}s`;
  162. setTimeout(() => {
  163. this.animationPlayState = "running";
  164. }, 1e3);
  165. });
  166. }
  167. },
  168. loopAnimation() {
  169. },
  170. clickMore() {
  171. this.$emit("getmore");
  172. },
  173. close() {
  174. this.show = false;
  175. this.$emit("close");
  176. },
  177. onClick() {
  178. this.$emit("click");
  179. }
  180. }
  181. };
  182. if (!Array) {
  183. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  184. _easycom_uni_icons2();
  185. }
  186. const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  187. if (!Math) {
  188. _easycom_uni_icons();
  189. }
  190. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  191. return common_vendor.e({
  192. a: $data.show
  193. }, $data.show ? common_vendor.e({
  194. b: $props.showIcon === true || $props.showIcon === "true"
  195. }, $props.showIcon === true || $props.showIcon === "true" ? {
  196. c: common_vendor.p({
  197. type: "sound",
  198. color: $props.color,
  199. size: "22"
  200. })
  201. } : {}, {
  202. d: common_vendor.t($props.text),
  203. e: $data.elId,
  204. f: $props.scrollable ? 1 : "",
  205. g: !$props.scrollable && ($props.single || $props.showGetMore) ? 1 : "",
  206. h: $props.color,
  207. i: $data.wrapWidth + "px",
  208. j: $data.animationDuration,
  209. k: $data.animationDuration,
  210. l: $data.webviewHide ? "paused" : $data.animationPlayState,
  211. m: $data.webviewHide ? "paused" : $data.animationPlayState,
  212. n: $data.animationDelay,
  213. o: $data.animationDelay,
  214. p: $data.elIdBox,
  215. q: $props.scrollable ? 1 : "",
  216. r: !$props.scrollable && ($props.single || $props.moreText) ? 1 : "",
  217. s: $props.scrollable ? 1 : "",
  218. t: !$props.scrollable && ($props.single || $props.moreText) ? 1 : "",
  219. v: $props.showGetMore === true || $props.showGetMore === "true"
  220. }, $props.showGetMore === true || $props.showGetMore === "true" ? common_vendor.e({
  221. w: $props.moreText.length > 0
  222. }, $props.moreText.length > 0 ? {
  223. x: common_vendor.t($props.moreText),
  224. y: $props.moreColor
  225. } : {
  226. z: common_vendor.p({
  227. type: "right",
  228. color: $props.moreColor,
  229. size: "16"
  230. })
  231. }, {
  232. A: common_vendor.o((...args) => $options.clickMore && $options.clickMore(...args))
  233. }) : {}, {
  234. B: ($props.showClose === true || $props.showClose === "true") && ($props.showGetMore === false || $props.showGetMore === "false")
  235. }, ($props.showClose === true || $props.showClose === "true") && ($props.showGetMore === false || $props.showGetMore === "false") ? {
  236. C: common_vendor.p({
  237. type: "closeempty",
  238. color: $props.color,
  239. size: "16"
  240. }),
  241. D: common_vendor.o((...args) => $options.close && $options.close(...args))
  242. } : {}, {
  243. E: $props.backgroundColor,
  244. F: common_vendor.o((...args) => $options.onClick && $options.onClick(...args))
  245. }) : {});
  246. }
  247. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-8eee8640"], ["__file", "D:/zx/mall-front-app/sheep/ui/su-notice-bar/su-notice-bar.vue"]]);
  248. wx.createComponent(Component);