su-swiper.js 7.6 KB

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