su-swiper.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = 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. if (!Array) {
  66. const _easycom_su_video2 = common_vendor.resolveComponent("su-video");
  67. _easycom_su_video2();
  68. }
  69. const _easycom_su_video = () => "../su-video/su-video.js";
  70. if (!Math) {
  71. _easycom_su_video();
  72. }
  73. const _sfc_main = {
  74. __name: "su-swiper",
  75. props: {
  76. circular: {
  77. type: Boolean,
  78. default: true
  79. },
  80. autoplay: {
  81. type: Boolean,
  82. default: false
  83. },
  84. interval: {
  85. type: Number,
  86. default: 3e3
  87. },
  88. duration: {
  89. type: Number,
  90. default: 500
  91. },
  92. mode: {
  93. type: String,
  94. default: "default"
  95. },
  96. imageMode: {
  97. type: String,
  98. default: "scaleToFill"
  99. },
  100. list: {
  101. type: Array,
  102. default() {
  103. return [];
  104. }
  105. },
  106. dotStyle: {
  107. type: String,
  108. default: "long"
  109. //default long tag
  110. },
  111. dotCur: {
  112. type: String,
  113. default: "ss-bg-opactity-block"
  114. },
  115. bg: {
  116. type: String,
  117. default: "bg-none"
  118. },
  119. height: {
  120. type: Number,
  121. default: 0
  122. },
  123. imgHeight: {
  124. type: Number,
  125. default: 0
  126. },
  127. imgTopRadius: {
  128. type: Number,
  129. default: 0
  130. },
  131. imgBottomRadius: {
  132. type: Number,
  133. default: 0
  134. },
  135. isPreview: {
  136. type: Boolean,
  137. default: false
  138. },
  139. seizeHeight: {
  140. type: Number,
  141. default: 200
  142. }
  143. },
  144. setup(__props) {
  145. const state = common_vendor.reactive({
  146. imgHeight: 0,
  147. cur: 0,
  148. moveX: 0,
  149. videoPlaySataus: false,
  150. heightList: []
  151. });
  152. const refs = common_vendor.reactive({
  153. videoRef: {}
  154. });
  155. const props = __props;
  156. const swiperChange = (e) => {
  157. if (e.detail.source !== "touch" && e.detail.source !== "autoplay")
  158. return;
  159. state.cur = e.detail.current;
  160. state.videoPlaySataus = false;
  161. if (props.list[state.cur].type === "video") {
  162. refs.videoRef[`video_${state.cur}`].pausePlay();
  163. }
  164. };
  165. const onSwiperItem = (item) => {
  166. if (item.type === "video") {
  167. state.videoPlaySataus = true;
  168. } else {
  169. sheep_index.sheep.$router.go(item.url);
  170. onPreview();
  171. }
  172. };
  173. const onPreview = () => {
  174. if (!props.isPreview)
  175. return;
  176. let previewImage = common_vendor.lodashExports.clone(props.list);
  177. previewImage.forEach((item, index) => {
  178. if (item.type === "video") {
  179. previewImage.splice(index, 1);
  180. }
  181. });
  182. common_vendor.index.previewImage({
  183. urls: previewImage.length < 1 ? [props.src] : previewImage.reduce((pre, cur) => {
  184. pre.push(cur.src);
  185. return pre;
  186. }, []),
  187. current: state.cur
  188. // longPressActions: {
  189. // itemList: ['发送给朋友', '保存图片', '收藏'],
  190. // success: function (data) {
  191. // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  192. // },
  193. // fail: function (err) {
  194. // console.log(err.errMsg);
  195. // },
  196. // },
  197. });
  198. };
  199. const transition = (e) => {
  200. };
  201. const animationfinish = (e) => {
  202. state.moveX = 0;
  203. };
  204. const videoTimeupdate = (e) => {
  205. props.list[state.cur].currentTime = e.detail.currentTime;
  206. };
  207. const customStyle = common_vendor.computed(() => {
  208. let height;
  209. if (props.height !== 0) {
  210. height = props.height;
  211. }
  212. if (props.height === 0) {
  213. if (state.imgHeight !== 0) {
  214. height = state.imgHeight;
  215. } else if (props.seizeHeight !== 0) {
  216. height = props.seizeHeight;
  217. }
  218. }
  219. return {
  220. height: height + "rpx"
  221. };
  222. });
  223. function onImgLoad(e) {
  224. if (props.height === 0) {
  225. let newHeight = e.detail.height / e.detail.width * 750;
  226. if (state.imgHeight < newHeight) {
  227. state.imgHeight = newHeight;
  228. }
  229. }
  230. }
  231. return (_ctx, _cache) => {
  232. return common_vendor.e({
  233. a: common_vendor.f(props.list, (item, index, i0) => {
  234. return common_vendor.e({
  235. a: item.type === "image"
  236. }, item.type === "image" ? {
  237. b: props.imageMode,
  238. c: item.src,
  239. d: common_vendor.o(onImgLoad, index)
  240. } : {
  241. e: common_vendor.sr((el) => refs.videoRef[`video_${index}`] = el, "b37b3c30-0-" + i0, {
  242. "f": 1
  243. }),
  244. f: (el) => refs.videoRef[`video_${index}`] = el,
  245. g: common_vendor.o(videoTimeupdate, index),
  246. h: "b37b3c30-0-" + i0,
  247. i: common_vendor.p({
  248. poster: common_vendor.unref(sheep_index.sheep).$url.cdn(item.poster),
  249. src: common_vendor.unref(sheep_index.sheep).$url.cdn(item.src),
  250. index,
  251. moveX: state.moveX,
  252. initialTime: item.currentTime || 0,
  253. height: __props.seizeHeight
  254. })
  255. }, {
  256. j: index,
  257. k: state.cur == index ? 1 : "",
  258. l: common_vendor.o(($event) => onSwiperItem(item), index)
  259. });
  260. }),
  261. b: props.circular,
  262. c: state.cur,
  263. d: props.autoplay && !state.videoPlaySataus,
  264. e: props.interval,
  265. f: props.duration,
  266. g: common_vendor.o(transition),
  267. h: common_vendor.o(animationfinish),
  268. i: common_vendor.s(customStyle.value),
  269. j: common_vendor.o(swiperChange),
  270. k: !state.videoPlaySataus
  271. }, !state.videoPlaySataus ? common_vendor.e({
  272. l: props.dotStyle != "tag"
  273. }, props.dotStyle != "tag" ? {
  274. m: common_vendor.f(props.list, (item, index, i0) => {
  275. return {
  276. a: index,
  277. b: common_vendor.n(state.cur == index ? "cur" : "")
  278. };
  279. }),
  280. n: common_vendor.n(props.dotCur),
  281. o: common_vendor.n(props.dotStyle)
  282. } : {}, {
  283. p: props.dotStyle == "tag"
  284. }, props.dotStyle == "tag" ? {
  285. q: common_vendor.t(state.cur + 1),
  286. r: common_vendor.t(props.list.length),
  287. s: common_vendor.n(props.dotCur),
  288. t: common_vendor.n(props.dotStyle)
  289. } : {}) : {}, {
  290. v: common_vendor.n(props.mode),
  291. w: common_vendor.n(props.bg),
  292. x: common_vendor.n(props.ui)
  293. });
  294. };
  295. }
  296. };
  297. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b37b3c30"], ["__file", "D:/zx/mall-front-app/sheep/ui/su-swiper/su-swiper.vue"]]);
  298. wx.createComponent(Component);