index.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. // pages/find/find.js
  2. var app = getApp();
  3. var imgSrcHttp = 'https://www.daliangzao.net/images/';
  4. var tabImgList = [
  5. {
  6. imageFooterTitle : '我们的作品',
  7. imgList:[
  8. { imageSrc: imgSrcHttp + 'find_tab_1/1-benchilaganxiang.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-benchi.jpg', url:''},
  9. { imageSrc: imgSrcHttp + 'find_tab_1/2-duoleshi.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-duoleshi.jpg', url: ''},
  10. { imageSrc: imgSrcHttp + 'find_tab_1/3-hagendasifengyebijiben.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-hagendasi.jpg', url: ''},
  11. { imageSrc: imgSrcHttp + 'find_tab_1/4-hagendasishuijingqiu.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-hagendasi.jpg', url: ''},
  12. { imageSrc: imgSrcHttp + 'find_tab_1/5-hagendasiyaoshikou.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-hagendasi.jpg', url: ''},
  13. { imageSrc: imgSrcHttp + 'find_tab_1/6-hanshulihe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-hanshu.jpg', url: ''},
  14. { imageSrc: imgSrcHttp + 'find_tab_1/7-huishi.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-huishi.jpg', url: ''},
  15. { imageSrc: imgSrcHttp + 'find_tab_1/8-huishigonghuiruhuilihe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-huishi.jpg', url: ''},
  16. { imageSrc: imgSrcHttp + 'find_tab_1/9-jiandabinfenle.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-jianda.jpg', url: ''},
  17. { imageSrc: imgSrcHttp + 'find_tab_1/10-kafeibeiyinyuehe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  18. { imageSrc: imgSrcHttp + 'find_tab_1/11-kaidilake.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-kaidilake.jpg', url: ''},
  19. { imageSrc: imgSrcHttp + 'find_tab_1/12-kaidilakexiangkuang.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-kaidilake.jpg', url: ''},
  20. { imageSrc: imgSrcHttp + 'find_tab_1/13-miqilinluntai.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-miqilinluntai.jpg', url: ''},
  21. { imageSrc: imgSrcHttp + 'find_tab_1/14-motianlunyinyuehe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  22. { imageSrc: imgSrcHttp + 'find_tab_1/15-qingrenjieyaoshikou.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  23. { imageSrc: imgSrcHttp + 'find_tab_1/16-shengdanyinyuelihe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  24. { imageSrc: imgSrcHttp + 'find_tab_1/17-taipingyangkafei.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-taipingyangkafei.jpg', url: ''},
  25. { imageSrc: imgSrcHttp + 'find_tab_1/18-xingbakebijiben.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  26. { imageSrc: imgSrcHttp + 'find_tab_1/19-xingbakebingxiangtie.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  27. { imageSrc: imgSrcHttp + 'find_tab_1/20-xingbakechengshixiong.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  28. { imageSrc: imgSrcHttp + 'find_tab_1/21-xingbakeqioakelilihe.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  29. { imageSrc: imgSrcHttp + 'find_tab_1/22-xingbakeshoulian.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  30. { imageSrc: imgSrcHttp + 'find_tab_1/23-xingbakeshuijingbei.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  31. { imageSrc: imgSrcHttp + 'find_tab_1/24-xingbakeyinghuaxilie.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  32. { imageSrc: imgSrcHttp + 'find_tab_1/25-xiongbakeyinghuaxilie.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  33. { imageSrc: imgSrcHttp + 'find_tab_1/26-xingxiangkabingxiangtie.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: ''},
  34. { imageSrc: imgSrcHttp + 'find_tab_1/27-xuefulan.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xuefulan.jpg', url: '' },
  35. { imageSrc: imgSrcHttp + 'find_tab_1/28-yinghuashuqian.jpg', imgLogo: imgSrcHttp + 'find_tab_1/logo-xingbake.jpg', url: '' }
  36. ]
  37. },
  38. {
  39. imageFooterTitle: '佳节好礼',
  40. imgList: [
  41. { imageSrc: imgSrcHttp + 'find_tab_2/zt_1.jpg', url: '/pages/articleInfor/articleInfor?id=2923' },
  42. { imageSrc: imgSrcHttp + 'find_tab_2/zt_3.jpg', url: '/pages/articleInfor/articleInfor?id=2926' },
  43. { imageSrc: imgSrcHttp + 'find_tab_2/zt_4.jpg', url: '/pages/articleInfor/articleInfor?id=2927' },
  44. { imageSrc: imgSrcHttp + 'find_tab_2/zt_5.png', url: '/pages/articleInfor/articleInfor?id=2928' },
  45. { imageSrc: imgSrcHttp + 'find_tab_2/zt_2.png', url: '/pages/articleInfor/articleInfor?id=2917' },
  46. ]
  47. },
  48. {
  49. imageFooterTitle: '',
  50. imgList: []
  51. }
  52. ];
  53. Page({
  54. data: {
  55. imgSrcHttp:'https://www.daliangzao.net/images/',
  56. navList: [],
  57. contentList:[],
  58. imgList:[],
  59. tabImgList: tabImgList, //经典案例
  60. imgWidth : 0,
  61. imgHeight : 0,
  62. screenWidth:0,
  63. imageWidth: 0,
  64. imageHeight: 0,
  65. phoneWidth: 0, //屏幕宽 根据屏幕的宽度,三分之一为li的宽度
  66. phoneHeight: 0, //屏幕高
  67. swiperWidth: 0,
  68. imgindex: 23,//中间的下标 重点
  69. imgindex2: 4,//中间显示需要改的位置1
  70. middlePhoneWidthMarLeft: 0, //背景的图片的margin-left=-aaa
  71. middlePhoneWidth: 0, //背景
  72. swiperUlWidth: 0, //移动的ul的宽度
  73. swiperLiWidth: 0, //移动的li的宽度
  74. swiperLeft: 0, //移动的定位left
  75. firstLeft : 0,
  76. swiperUlWidth2: 0, //移动的ul的宽度
  77. swiperLiWidth2: 0, //移动的li的宽度
  78. swiperLeft2: 0, //移动的定位left
  79. firstLeft2: 0,
  80. animationData: {},//运动
  81. animationData2: {},//运动
  82. startClientX: 0,//点击开始 X 轴位置
  83. endClientX: 0,//点击结束 X 轴位置
  84. images: [], //图片的数据
  85. images2 : [],
  86. styleArr: [], //所有图片的样式数组 对中间的图片放大的操作组
  87. styleArr2: [], //所有图片的样式数组 对中间的图片放大的操作组
  88. duration: 1000, //动画时间
  89. bigImgWidth : 0,//中间大图的宽度
  90. bigImgHeight : 0,
  91. smallImgWidth : 0 ,
  92. smallImgHeight : 0,
  93. bigImgWidth2: 0,//中间大图的宽度
  94. bigImgHeight2: 0,
  95. smallImgWidth2: 0,
  96. smallImgHeight2: 0,
  97. imagesTitle : '',
  98. smallTop : 0, //小图距离顶部距离
  99. top : 0,
  100. urlTop : 182,//外围view的top值
  101. addTop : 208,//带有logo标的,外围高度增加
  102. tab : 0 ,
  103. imgLeft : 0,
  104. imgRight : 0,
  105. prop : 0, //当前屏幕下,rpx与px的比例
  106. prop2 : 0,
  107. systemInfor : '',
  108. pixelRatio : '',
  109. prorpNew :'',
  110. tabVal :0 //默认tab选中值
  111. },
  112. onLoad: function () {
  113. var that = this;
  114. var host = getApp().globalData.servsers;
  115. //品牌定制
  116. wx.request({
  117. url: host+"findclassifyapi/findclassifyxcx",
  118. data: {},
  119. method: 'GET',
  120. header: {
  121. 'Accept': 'application/json'
  122. },
  123. success: function (res) {
  124. var size = res.data.total;
  125. that.setData({
  126. navList: res.data.rows
  127. });
  128. console.log(res.data.rows);
  129. if (res == null || res.data == null) {
  130. console.error('网络请求失败');
  131. return;
  132. }
  133. }
  134. })
  135. //品牌定制
  136. wx.request({
  137. url: host + "findapi/findall",
  138. data: {},
  139. method: 'GET',
  140. header: {
  141. 'Accept': 'application/json'
  142. },
  143. success: function (res) {
  144. var size = res.data.total;
  145. that.setData({
  146. contentList: res.data.rows
  147. });
  148. if (res == null || res.data == null) {
  149. console.error('网络请求失败');
  150. return;
  151. }
  152. }
  153. })
  154. //===取屏幕宽度=======
  155. wx.getSystemInfo({
  156. success: function (res) {
  157. that.setData({
  158. phoneWidth: res.windowWidth,
  159. systemInfor: res.platform,
  160. pixelRatio : res.pixelRatio
  161. })
  162. console.log("--" + res.pixelRatio);
  163. }
  164. });
  165. var phoneWidth = that.data.phoneWidth;
  166. var bigImgWidth = parseInt(phoneWidth * 0.68);
  167. var bigImgHeight = parseInt(1246 * bigImgWidth / 1024);
  168. var bigImgWidth2 = parseInt(phoneWidth * 0.68);
  169. var bigImgHeight2 = parseInt(800 * bigImgWidth / 526);
  170. var smallImgWidth = parseInt(phoneWidth * 0.58);
  171. var smallImgHeight = parseInt(1246 * smallImgWidth / 1024);
  172. var smallImgWidth2 = parseInt(phoneWidth * 0.58);
  173. var smallImgHeight2 = parseInt(800 * smallImgWidth / 526);
  174. var imgLeft = parseInt(phoneWidth * 0.08);
  175. var imgRight = parseInt(phoneWidth * 0.04);
  176. var prop = phoneWidth/750;
  177. var prop2 = 750 / phoneWidth;
  178. var prorpNew = '';
  179. var systemInfor = that.data.systemInfor;
  180. console.log(systemInfor);
  181. if (systemInfor == 'ios'){
  182. prorpNew = that.data.pixelRatio * 0.1;
  183. console.log(prorpNew);
  184. }else{
  185. prorpNew = that.data.pixelRatio / 2;
  186. }
  187. // var smallTop = parseInt((bigImgHeight - 502)/2);
  188. var smallTop = parseInt((bigImgHeight - smallImgHeight));
  189. that.setData({
  190. images: that.data.tabImgList[0].imgList,
  191. images2: that.data.tabImgList[1].imgList,
  192. imagesTitle: that.data.tabImgList[0].imageFooterTitle,
  193. persNub: 27,
  194. swiperLeft:0,
  195. swiperLeft2 : 0,
  196. firstLeft: 0,
  197. smallTop: smallTop,
  198. imgLeft: imgLeft
  199. })
  200. let swiperLiWidth = that.data.swiperLiWidth;//li宽
  201. swiperLiWidth = phoneWidth * 0.66 ; //li的宽度赋值
  202. var arrimages = that.data.images;//获取图片Arr的数组
  203. var arrimages2 = that.data.images2;//获取图片Arr的数组
  204. let swiperUlWidth = that.data.swiperUlWidth; //移动的ul 的宽度
  205. let swiperUlWidth2 = that.data.swiperUlWidth2; //移动的ul 的宽度
  206. swiperUlWidth = swiperLiWidth * arrimages.length + phoneWidth * 0.1; //赋值移动的ul 的宽度
  207. swiperUlWidth2 = swiperLiWidth * arrimages2.length + phoneWidth * 0.1; //赋值移动的ul 的宽度
  208. //初始化所有的图片的宽高
  209. let styleArr = that.data.styleArr;
  210. for (let i = 0; i < arrimages.length; i++) {
  211. var obj = {
  212. imgwidth: smallImgWidth,
  213. imgheight: smallImgHeight,
  214. top: that.data.smallTop,
  215. animationliscal: ""
  216. }
  217. styleArr.push(obj)
  218. }
  219. styleArr[22] = {
  220. imgwidth: bigImgWidth,
  221. imgheight: bigImgHeight,
  222. top: 0,
  223. animationliscal: ""
  224. };
  225. let styleArr2 = that.data.styleArr2;
  226. for (let i = 0; i < arrimages2.length; i++) {
  227. var obj = {
  228. imgwidth: smallImgWidth2,
  229. imgheight: smallImgHeight2,
  230. top: that.data.smallTop,
  231. animationliscal: ""
  232. }
  233. styleArr2.push(obj)
  234. }
  235. styleArr2[3] = {//中间显示需要改的位置2
  236. imgwidth: bigImgWidth2,
  237. imgheight: bigImgHeight2,
  238. top: 0,
  239. animationliscal: ""
  240. };
  241. that.setData({
  242. styleArr: styleArr,
  243. styleArr2: styleArr2,
  244. swiperUlWidth: swiperUlWidth,
  245. swiperUlWidth2: swiperUlWidth2,
  246. swiperLiWidth: swiperLiWidth,
  247. bigImgWidth: bigImgWidth,
  248. bigImgHeight: bigImgHeight,
  249. smallImgWidth: smallImgWidth,
  250. smallImgHeight: smallImgHeight,
  251. bigImgWidth2: bigImgWidth2,
  252. bigImgHeight2: bigImgHeight2,
  253. smallImgWidth2: smallImgWidth2,
  254. smallImgHeight2: smallImgHeight2,
  255. phoneWidth: phoneWidth,
  256. prop: prop,
  257. prop2: prop2,
  258. prorpNew: prorpNew,
  259. swiperLeft: - (that.data.phoneWidth * 0.66 - prorpNew) * 22 ,
  260. swiperLeft2: - (that.data.phoneWidth * 0.66 - prorpNew) * 3 //中间显示需要改的位置3
  261. })
  262. },
  263. startTou: function (e) {
  264. let that = this;
  265. that.data.startClientX = e.touches[0].clientX; //触摸按下 距离屏幕左边的值
  266. },
  267. scroll: function (e) {
  268. let that = this;
  269. that.data.endClientX = e.touches[0].clientX; //滑动值
  270. },
  271. endTou: function (e) {
  272. let that = this;
  273. var animation = wx.createAnimation({
  274. duration: 1000,
  275. timingFunction: 'linear',
  276. })
  277. //大图宽高
  278. var bigImgWidth = that.data.bigImgWidth;
  279. var bigImgHeight = that.data.bigImgHeight;
  280. var smallImgWidth = that.data.smallImgWidth;
  281. var smallImgHeight = that.data.smallImgHeight;
  282. var prop = that.data.prop;
  283. var prorpNew = that.data.prorpNew;
  284. var prop2 = prorpNew;
  285. var swiperLiWidthLeft = that.data.swiperLiWidth;
  286. this.animation = animation;
  287. let startClientX = that.data.startClientX;
  288. let endClientX = that.data.endClientX;
  289. let phoneWidth = that.data.phoneWidth;
  290. if (endClientX == 0) { //move的值为0 时定为点击
  291. if (startClientX < phoneWidth / 2 - 70) { //点击开始的位置,与图片的一半减70px 为左边点击
  292. this.animation = animation;
  293. animation.left(that.data.swiperLeft).step({ duration: 1000 }) //移动动画
  294. let imgindex = that.data.imgindex - 1; //下标值
  295. if (imgindex < 1) {
  296. console.log("超出了最小数组长度")
  297. return;
  298. }
  299. that.setData({
  300. swiperLeft: Math.floor(that.data.swiperLeft + phoneWidth * 0.66 - prop2), //ul向右移动值
  301. imgindex: that.data.imgindex - 1, //下标值
  302. animationData: animation.export()
  303. })
  304. let styleArr = that.data.styleArr;
  305. var arrimages = that.data.images;//获取图片Arr的数组
  306. for (let i = 0; i < arrimages.length; i++) {
  307. styleArr[i] = {
  308. imgwidth: smallImgWidth,
  309. imgheight: smallImgHeight,
  310. top: that.data.smallTop,
  311. animationliscal: ""
  312. }
  313. }
  314. var imgindex = that.data.imgindex;
  315. styleArr[imgindex] = {
  316. imgwidth: bigImgWidth,
  317. imgheight: bigImgHeight,
  318. top : 0 ,
  319. animationliscal: ""
  320. };
  321. that.setData({
  322. styleArr: styleArr
  323. })
  324. console.log("左边点击1:" + that.data.imgindex)
  325. } else if (startClientX > phoneWidth / 2 + 70) { //点击开始的位置,与图片的一半减70px 为右边点击
  326. let imgindex = that.data.imgindex + 1;
  327. if (imgindex > that.data.images.length ) {
  328. console.log("超出了数组最大长度")
  329. return;
  330. }
  331. let styleArr = that.data.styleArr;
  332. var arrimages = that.data.images;//获取图片Arr的数组
  333. for (let i = 0; i < arrimages.length; i++) {
  334. styleArr[i] = {
  335. imgwidth: smallImgWidth,
  336. imgheight: smallImgHeight,
  337. top : that.data.smallTop,
  338. animationliscal: ""
  339. }
  340. }
  341. styleArr[imgindex] = {
  342. imgwidth: bigImgWidth,
  343. imgheight: bigImgHeight,
  344. top: 0,
  345. animationliscal: ""
  346. };
  347. that.setData({
  348. styleArr: styleArr
  349. })
  350. console.log("右边点击1:" + that.data.imgindex)
  351. animation.left(that.data.swiperLeft).step({ duration: 1000 }) //移动动画
  352. that.setData({
  353. swiperLeft: Math.floor(that.data.swiperLeft - phoneWidth * 0.66 + prop2),//UL向左移动
  354. imgindex: that.data.imgindex + 1, //下标的值
  355. animationData: animation.export()
  356. })
  357. } else { //点击中间的大图,带参跳入图片的详情
  358. var tab = that.data.tab;
  359. if(tab == 1){
  360. let imgindexclick = that.data.imgindex;
  361. let url = that.data.images[imgindexclick].url;
  362. url = 2917;
  363. wx.navigateTo({
  364. url: '/pages/articleInfor/articleInfor?id=' + url
  365. })
  366. }
  367. }
  368. } else { //滑动左边 ul向左移动 右边的小图放大 滑动右边ul向右移动 右边的小图放大
  369. if (endClientX - startClientX > 0) {
  370. let imgindex = that.data.imgindex - 1;
  371. if (imgindex < 1) {
  372. console.log("超出了")
  373. return;
  374. }
  375. animation.left(that.data.swiperLeft).step({ duration: 1000 }) //移动动画
  376. that.setData({
  377. swiperLeft: Math.floor(that.data.swiperLeft + phoneWidth * 0.66 - prop2), //右边滑动 ul向右移动
  378. imgindex: that.data.imgindex - 1,
  379. animationData: animation.export()
  380. })
  381. let styleArr = that.data.styleArr;
  382. var arrimages = that.data.images;//获取图片Arr的数组
  383. for (let i = 0; i < arrimages.length; i++) {
  384. styleArr[i] = {
  385. imgwidth: smallImgWidth,
  386. imgheight: smallImgHeight,
  387. top: that.data.smallTop,
  388. animationliscal: ""
  389. }
  390. }
  391. var imgindex = that.data.imgindex;
  392. styleArr[imgindex-1] = {
  393. imgwidth:bigImgWidth,
  394. imgheight: bigImgHeight,
  395. top: 0,
  396. animationliscal: ""
  397. };
  398. that.setData({
  399. styleArr: styleArr
  400. })
  401. console.log("右边滑动2:" + that.data.imgindex)
  402. }
  403. if (endClientX - startClientX < 0) {
  404. let imgindex = that.data.imgindex + 1;
  405. if (imgindex > that.data.images.length ) {
  406. console.log("超出了")
  407. return;
  408. }
  409. this.animation = animation;
  410. animation.left(that.data.swiperLeft).step({ duration: 1000 }) //移动动画
  411. that.setData({
  412. swiperLeft: Math.floor(that.data.swiperLeft - phoneWidth * 0.66 + prop2), //左边滑动 ul向左移动
  413. imgindex: that.data.imgindex + 1, //下标的值
  414. animationData: animation.export()
  415. })
  416. let styleArr = that.data.styleArr;
  417. var arrimages = that.data.images;//获取图片Arr的数组
  418. for (let i = 0; i < arrimages.length; i++) {
  419. styleArr[i] = {
  420. imgwidth: smallImgWidth,
  421. imgheight: smallImgHeight,
  422. top: that.data.smallTop
  423. }
  424. }
  425. var imgindex = that.data.imgindex;
  426. styleArr[imgindex-1] = {
  427. imgwidth: bigImgWidth,
  428. imgheight: bigImgHeight,
  429. top: 0
  430. };
  431. that.setData({
  432. styleArr: styleArr
  433. })
  434. console.log("左边滑动2:" + that.data.imgindex);
  435. }
  436. }
  437. let NewstyleArr = that.data.styleArr;
  438. that.setData({
  439. startClientX: 0,
  440. endClientX: 0,
  441. styleArr: NewstyleArr
  442. })
  443. },
  444. endTou2: function (e) {
  445. let that = this;
  446. var animation = wx.createAnimation({
  447. duration: 1000,
  448. timingFunction: 'linear',
  449. })
  450. //大图宽高
  451. var bigImgWidth2 = that.data.bigImgWidth2;
  452. var bigImgHeight2 = that.data.bigImgHeight2;
  453. var smallImgWidth2 = that.data.smallImgWidth2;
  454. var smallImgHeight2 = that.data.smallImgHeight2;
  455. var prop = that.data.prop;
  456. var prop2 = prop;
  457. var swiperLiWidthLeft = that.data.swiperLiWidth;
  458. this.animation = animation;
  459. let startClientX = that.data.startClientX;
  460. let endClientX = that.data.endClientX;
  461. let phoneWidth = that.data.phoneWidth;
  462. if (endClientX == 0) { //move的值为0 时定为点击
  463. if (startClientX < phoneWidth / 2 - 70) { //点击开始的位置,与图片的一半减70px 为左边点击
  464. this.animation = animation;
  465. animation.left(that.data.swiperLeft2).step({ duration: 1000 }) //移动动画
  466. let imgindex = that.data.imgindex2 - 1; //下标值
  467. if (imgindex < 1) {
  468. console.log("超出了最小数组长度")
  469. return;
  470. }
  471. that.setData({
  472. swiperLeft2: Math.floor(that.data.swiperLeft2 + phoneWidth * 0.66  - prop2), //ul向右移动值
  473. imgindex2: that.data.imgindex2 - 1, //下标值
  474. animationData2: animation.export()
  475. })
  476. let styleArr2 = that.data.styleArr2;
  477. var arrimages2 = that.data.images2;//获取图片Arr的数组
  478. for (let i = 0; i < arrimages2.length; i++) {
  479. styleArr2[i] = {
  480. imgwidth: smallImgWidth2,
  481. imgheight: smallImgHeight2,
  482. top: that.data.smallTop,
  483. animationliscal: ""
  484. }
  485. }
  486. var imgindex = that.data.imgindex2;
  487. styleArr2[imgindex] = {
  488. imgwidth: bigImgWidth2,
  489. imgheight: bigImgHeight2,
  490. top: 0,
  491. animationliscal: ""
  492. };
  493. that.setData({
  494. styleArr2: styleArr2
  495. })
  496. console.log("左边点击1:" + that.data.imgindex2)
  497. } else if (startClientX > phoneWidth / 2 + 70) { //点击开始的位置,与图片的一半减70px 为右边点击
  498. let imgindex = that.data.imgindex2 + 1;
  499. if (imgindex > that.data.images.length) {
  500. console.log("超出了数组最大长度")
  501. return;
  502. }
  503. let styleArr2 = that.data.styleArr2;
  504. var arrimages2 = that.data.images2;//获取图片Arr的数组
  505. for (let i = 0; i < arrimages2.length; i++) {
  506. styleArr2[i] = {
  507. imgwidth: smallImgWidth2,
  508. imgheight: smallImgHeight2,
  509. top: that.data.smallTop,
  510. animationliscal: ""
  511. }
  512. }
  513. styleArr2[imgindex] = {
  514. imgwidth: bigImgWidth2,
  515. imgheight: bigImgHeight2,
  516. top: 0,
  517. animationliscal: ""
  518. };
  519. that.setData({
  520. styleArr2: styleArr2
  521. })
  522. console.log("右边点击1:" + that.data.imgindex2)
  523. animation.left(that.data.swiperLeft).step({ duration: 1000 }) //移动动画
  524. that.setData({
  525. swiperLeft2: Math.floor(that.data.swiperLeft2 - phoneWidth * 0.66 + prop2),//UL向左移动
  526. imgindex2: that.data.imgindex2 + 1, //下标的值
  527. animationData2: animation.export()
  528. })
  529. } else { //点击中间的大图,带参跳入图片的详情
  530. var tab = that.data.tab;
  531. if (tab == 1) {
  532. // let imgindexclick = that.data.imgindex2;
  533. // console.log(that.data.images2);
  534. // let url = that.data.images2[imgindexclick].url;
  535. // url = 2923;
  536. // wx.navigateTo({
  537. // url: '/pages/articleInfor/articleInfor?id=' + url
  538. // })
  539. }
  540. }
  541. } else { //滑动左边 ul向左移动 右边的小图放大 滑动右边ul向右移动 右边的小图放大
  542. if (endClientX - startClientX > 0) {
  543. let imgindex = that.data.imgindex2 - 1;
  544. if (imgindex < 1) {
  545. console.log("超出了")
  546. return;
  547. }
  548. animation.left(that.data.swiperLeft2).step({ duration: 1000 }) //移动动画
  549. that.setData({
  550. swiperLeft2: Math.floor(that.data.swiperLeft2 + phoneWidth * 0.66 - prop2), //右边滑动 ul向右移动
  551. imgindex2: that.data.imgindex2 - 1,
  552. animationData2: animation.export()
  553. })
  554. let styleArr2 = that.data.styleArr2;
  555. var arrimages2 = that.data.images2;//获取图片Arr的数组
  556. for (let i = 0; i < arrimages2.length; i++) {
  557. styleArr2[i] = {
  558. imgwidth: smallImgWidth2,
  559. imgheight: smallImgHeight2,
  560. top: that.data.smallTop,
  561. animationliscal: ""
  562. }
  563. }
  564. var imgindex = that.data.imgindex2;
  565. styleArr2[imgindex - 1] = {
  566. imgwidth: bigImgWidth2,
  567. imgheight: bigImgHeight2,
  568. top: 0,
  569. animationliscal: ""
  570. };
  571. that.setData({
  572. styleArr2: styleArr2
  573. })
  574. console.log("右边滑动2:" + that.data.imgindex2)
  575. }
  576. if (endClientX - startClientX < 0) {
  577. let imgindex = that.data.imgindex2 + 1;
  578. if (imgindex > that.data.images.length) {
  579. console.log("超出了")
  580. return;
  581. }
  582. this.animation = animation;
  583. animation.left(that.data.swiperLeft2).step({ duration: 1000 }) //移动动画
  584. that.setData({
  585. swiperLeft2: Math.floor(that.data.swiperLeft2 - phoneWidth * 0.66 + prop2), //左边滑动 ul向左移动
  586. imgindex2: that.data.imgindex2 + 1, //下标的值
  587. animationData2: animation.export()
  588. })
  589. let styleArr2 = that.data.styleArr2;
  590. var arrimages2 = that.data.images2;//获取图片Arr的数组
  591. for (let i = 0; i < arrimages2.length; i++) {
  592. styleArr2[i] = {
  593. imgwidth: smallImgWidth2,
  594. imgheight: smallImgHeight2,
  595. top: that.data.smallTop
  596. }
  597. }
  598. var imgindex = that.data.imgindex2;
  599. styleArr2[imgindex - 1] = {
  600. imgwidth: bigImgWidth2,
  601. imgheight: bigImgHeight2,
  602. top: 0
  603. };
  604. that.setData({
  605. styleArr2: styleArr2
  606. })
  607. console.log("左边滑动2:" + that.data.imgindex2);
  608. }
  609. }
  610. let NewstyleArr2 = that.data.styleArr2;
  611. that.setData({
  612. startClientX: 0,
  613. endClientX: 0,
  614. styleArr2: NewstyleArr2
  615. })
  616. },
  617. //tab切换图片内容
  618. changeTab:function(e){
  619. var that = this;
  620. var index = e.currentTarget.dataset.index;
  621. var images=0 , imagesTitle=0 , addTop=0 , urlTop=0 , tab=0;
  622. if(index == 0){
  623. addTop = 208;
  624. urlTop = 182;
  625. images = that.data.tabImgList[index].imgList;
  626. imagesTitle = that.data.tabImgList[index].imageFooterTitle;
  627. } else if (index == 1){
  628. addTop = 80;
  629. urlTop = 50;
  630. images = that.data.tabImgList[index].imgList;
  631. imagesTitle = that.data.tabImgList[index].imageFooterTitle;
  632. }else{
  633. images = [];
  634. imagesTitle = '';
  635. }
  636. that.setData({
  637. images: images,
  638. imagesTitle: imagesTitle,
  639. addTop: addTop,
  640. urlTop : urlTop,
  641. tab : index,
  642. tabVal: index
  643. });
  644. },
  645. onPullDownRefresh: function (e) {
  646. wx.stopPullDownRefresh();
  647. }
  648. })
  649. var contentList = []
  650. var that;
  651. var Util = require('../../utils/util.js');