index.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
  1. var util = require('../../utils/util.js');
  2. var status = require('../../utils/index.js');
  3. var a = require("../../utils/public");
  4. var countDownInit = require("../../utils/countDown");
  5. var wcache = require('../../utils/wcache.js');
  6. var app = getApp();
  7. var timerOut = '';
  8. Page({
  9. mixins: [countDownInit.default, require('../../mixin/globalMixin.js'), require('../../mixin/compoentCartMixin.js')],
  10. data: {
  11. needAuth: false,
  12. stopClick: false,
  13. community: {},
  14. rushList: [],
  15. commingList: [],
  16. countDownMap: [],
  17. actEndMap: [],
  18. skuList: [],
  19. pageNum: 1,
  20. notice_list: [],
  21. slider_list: [],
  22. shop_info: {},
  23. showEmpty: false,
  24. indexBottomImage: '',
  25. classification: {
  26. tabs: [],
  27. activeIndex: -1
  28. },
  29. commingClassification: {
  30. tabs: [],
  31. activeIndex: -1
  32. },
  33. isShowCommingClassification: true,
  34. isShowClassification: true,
  35. showChangeCommunity: false,
  36. isTipShow: false,
  37. isShowGuide: false,
  38. index_lead_image: '',
  39. theme: 0,
  40. cartNum: 0,
  41. navigat: [],
  42. navigatSwiper: {page: 1, current:0, totnav: 0},
  43. tabIdx: 0,
  44. scrollDirect: "",
  45. isSticky: false,
  46. showCommingEmpty: false,
  47. stopNotify: true,
  48. reduction: {},
  49. is_share_html: true,
  50. commingNum: 0,
  51. couponRefresh: false,
  52. index_change_cate_btn: 0,
  53. newComerRefresh: false,
  54. showCouponModal: false,
  55. copy_text_arr: [],
  56. showCopyText: false,
  57. totalAlertMoney: 0,
  58. groupInfo: {
  59. group_name: '社区',
  60. owner_name: '团长'
  61. },
  62. needPosition: true,
  63. typeTopicList: [],
  64. pinList: {},
  65. cube: [],
  66. secRushList: [],
  67. secKillGoodsIndex: 1,
  68. isblack: 0,
  69. imageSize: {
  70. imageWidth: "100%",
  71. imageHeight: 600
  72. },
  73. fmShow: true,
  74. presale_index_info: '',
  75. isDiy: 0,
  76. diyManyGoodsList: []
  77. },
  78. isFirst: 0,
  79. $data: {
  80. stickyFlag: false,
  81. scrollTop: 0,
  82. overPageNum: 1,
  83. loadOver: false,
  84. hasOverGoods: false,
  85. countDownMap: {},
  86. actEndMap: {},
  87. timer: {},
  88. scrollHeight: 1300,
  89. stickyTop: 0,
  90. hasCommingGoods: true
  91. },
  92. tpage: 1,
  93. hasRefeshin: false,
  94. postion: {},
  95. options: '',
  96. focusFlag: false,
  97. /**
  98. * 监控滚动事件
  99. */
  100. onPageScroll: function (t) {
  101. if (!this.$data.isLoadData) {
  102. if (t.scrollTop < this.$data.scrollHeight) {
  103. if (t.scrollTop > this.$data.scrollTop) {
  104. "down" !== this.data.scrollDirect && this.setData({
  105. scrollDirect: "down"
  106. })
  107. } else {
  108. "up" != this.data.scrollDirect && this.setData({
  109. scrollDirect: "up"
  110. })
  111. }
  112. } else {
  113. "down" !== this.data.scrollDirect && this.setData({
  114. scrollDirect: "down"
  115. })
  116. }
  117. if (t.scrollTop > this.$data.stickyTop) {
  118. this.data.isSticky || (this.setData({
  119. isSticky: true
  120. }), this.$data.stickyFlag = true)
  121. } else {
  122. t.scrollTop < this.$data.stickyBackTop && this.data.isSticky && (this.setData({
  123. isSticky: false
  124. }), this.$data.stickyFlag = false)
  125. }
  126. this.$data.scrollTop = t.scrollTop
  127. }
  128. },
  129. onLoad: function(options) {
  130. app.setShareConfig();
  131. wx.hideTabBar();
  132. var that = this;
  133. var token = wx.getStorageSync('token');
  134. status.setNavBgColor();
  135. status.setGroupInfo().then((groupInfo) => { that.setData({ groupInfo }) });
  136. console.log('step1');
  137. let community = wx.getStorageSync('community');
  138. let community_id = community.communityId || '';
  139. let isparse_formdata = wx.getStorageSync('isparse_formdata') || 0;
  140. if (isparse_formdata != 1) {
  141. // this.get_index_info();
  142. if (options && Object.keys(options).length != 0) {
  143. console.log('step2');
  144. var scene = decodeURIComponent(options.scene);
  145. if (scene != 'undefined') {
  146. var opt_arr = scene.split("_");
  147. options.community_id = opt_arr[0];
  148. wcache.put('share_id', opt_arr[1]);
  149. }
  150. that.options = options;
  151. if (options.share_id != 'undefined' && options.share_id > 0) wcache.put('share_id', options.share_id);
  152. if (options.community_id != 'undefined' && options.community_id > 0) {
  153. console.log('step3');
  154. util.getCommunityById(options.community_id).then((res)=>{
  155. if (res.code == 0) {
  156. console.log('step4');
  157. var shareCommunity = res.data;
  158. console.log('分享community_id', options.community_id);
  159. console.log('历史community_id', community_id);
  160. let sdata = {};
  161. if (res.open_danhead_model == 1) {
  162. console.log('开启单社区', res.default_head_info);
  163. sdata.community = res.default_head_info;
  164. sdata.open_danhead_model = res.open_danhead_model;
  165. token && that.addhistory(res.default_head_info.communityId || '');
  166. wx.setStorageSync('community', res.default_head_info);
  167. } else if (shareCommunity){
  168. if (options.community_id != community_id) {
  169. if (community_id) {
  170. sdata.showChangeCommunity = true;
  171. sdata.changeCommunity = shareCommunity;
  172. sdata.community = community;
  173. } else {
  174. sdata.community = shareCommunity;
  175. sdata.shareCommunity = shareCommunity;
  176. wcache.put('community', shareCommunity);
  177. }
  178. } else {
  179. sdata.community = community;
  180. }
  181. }
  182. sdata.hidetip = false;
  183. sdata.token = token;
  184. sdata.showEmpty = false;
  185. sdata.needPosition = false;
  186. that.setData(sdata, ()=>{
  187. that.loadPage();
  188. });
  189. } else {
  190. console.log('step5');
  191. that.loadPage();
  192. that.setData({
  193. hidetip: false,
  194. token: token,
  195. showEmpty: false,
  196. needPosition: false
  197. })
  198. }
  199. token && that.addhistory();
  200. })
  201. } else {
  202. util.getCommunityById(options.community_id).then((res) => {
  203. if (res.code == 0) {
  204. if (res.open_danhead_model == 1) {
  205. console.log('开启单社区step6');
  206. that.setData({ community: res.default_head_info, open_danhead_model: res.open_danhead_model })
  207. token && that.addhistory(res.default_head_info.communityId || '');
  208. wx.setStorageSync('community', res.default_head_info);
  209. }
  210. console.log('step6');
  211. that.loadPage();
  212. }
  213. }).catch(() => {
  214. that.loadPage();
  215. })
  216. }
  217. } else {
  218. util.getCommunityById(options.community_id).then((res) => {
  219. if (res.code == 0) {
  220. if (res.open_danhead_model == 1) {
  221. console.log('开启单社区step7');
  222. that.setData({ community: res.default_head_info, open_danhead_model: res.open_danhead_model })
  223. token && that.addhistory(res.default_head_info.communityId || '');
  224. wx.setStorageSync('community', res.default_head_info);
  225. }
  226. that.loadPage();
  227. }
  228. }).catch(()=>{
  229. that.loadPage();
  230. })
  231. console.log('step7');
  232. that.setData({
  233. hidetip: false,
  234. token: token,
  235. showEmpty: false,
  236. community
  237. })
  238. }
  239. }
  240. },
  241. addhistory: function (id=0) {
  242. console.log('step13');
  243. let community_id = 0;
  244. if (id==0) {
  245. var community = wx.getStorageSync('community');
  246. community_id = community.communityId;
  247. } else {
  248. community_id = id;
  249. }
  250. console.log('history community_id=' + community_id);
  251. var token = wx.getStorageSync('token');
  252. let that = this;
  253. community_id !==void 0 && app.util.request({
  254. 'url': 'entry/wxapp/index',
  255. 'data': {
  256. controller: 'index.addhistory_community',
  257. community_id: community_id,
  258. 'token': token
  259. },
  260. dataType: 'json',
  261. success: function(res) {
  262. if(id!=0) that.getHistoryCommunity(), console.log('addhistory+id', id);
  263. }
  264. })
  265. },
  266. loadPage: function() {
  267. wx.showLoading();
  268. console.log('step8');
  269. let that = this;
  270. that.get_index_info();
  271. if(this.data.isDiy==0) {
  272. that.get_type_topic();
  273. that.getNavigat();
  274. that.getPinList();
  275. } else {
  276. this.getDiyInfo();
  277. }
  278. that.getCoupon();
  279. status.loadStatus().then(function() {
  280. let appLoadStatus = app.globalData.appLoadStatus;
  281. console.log('appLoadStatus',appLoadStatus)
  282. if (appLoadStatus == 0) {
  283. // wx.hideLoading();
  284. setTimeout(function(){ wx.hideLoading(); },1000);
  285. that.setData({ needAuth: true, couponRefresh: false });
  286. that.data.isDiy==0&&that.load_goods_data();
  287. } else if (appLoadStatus == 2) {
  288. console.log('step9');
  289. that.getHistoryCommunity();
  290. } else {
  291. console.log('step12');
  292. let community = wx.getStorageSync('community');
  293. community || (community=app.globalData.community);
  294. if (!community){
  295. util.getCommunityInfo().then((res) => {
  296. that.setData({
  297. community: that.fliterCommunity(res)
  298. })
  299. })
  300. } else {
  301. that.setData({
  302. community: that.fliterCommunity(community)
  303. })
  304. }
  305. console.log('step18');
  306. that.data.isDiy==0&&that.load_goods_data();
  307. }
  308. });
  309. },
  310. // 不显示社区省份
  311. fliterCommunity: function (community){
  312. let resArr = community && community.fullAddress && community.fullAddress.split('省');
  313. if (resArr) {
  314. return Object.assign({}, community, { address: resArr[1] || resArr[0] });
  315. } else {
  316. return community;
  317. }
  318. },
  319. onReady: function (res) {
  320. this.videoContext = wx.createVideoContext('myVideo');
  321. },
  322. onShow: function() {
  323. // 页面显示
  324. let that = this;
  325. console.log('isblack', app.globalData.isblack)
  326. this.setData({ stopNotify: false, tabbarRefresh: true, isblack: app.globalData.isblack || 0 })
  327. util.check_login_new().then((res) => {
  328. if(res) {
  329. that.setData({ needAuth: false })
  330. } else {
  331. this.setData({ needAuth: true, couponRefresh: false });
  332. return;
  333. }
  334. })
  335. app.globalData.timer.start();
  336. var token = wx.getStorageSync('token');
  337. token&&(0, status.cartNum)('', true).then((res)=>{
  338. res.code == 0 && that.setData({ cartNum: res.data })
  339. });
  340. if (app.globalData.changedCommunity) {
  341. console.log('change')
  342. app.globalData.goodsListCarCount = [];
  343. let community = app.globalData.community;
  344. this.setData({
  345. community: that.fliterCommunity(community),
  346. newComerRefresh: false
  347. });
  348. this.getCommunityPos(community.communityId);
  349. this.hasRefeshin = false;
  350. this.setData({
  351. newComerRefresh: true,
  352. rushList: [],
  353. pageNum: 1,
  354. classificationId: null,
  355. "classification.activeIndex": -1
  356. }, () => {
  357. this.setData({
  358. "classification.activeIndex": 0
  359. })
  360. })
  361. this.$data = {
  362. ...this.$data, ...{
  363. overPageNum: 1,
  364. loadOver: false,
  365. hasOverGoods: false,
  366. countDownMap: {},
  367. actEndMap: {},
  368. timer: {},
  369. stickyFlag: false,
  370. hasCommingGoods: true
  371. }
  372. }
  373. app.globalData.changedCommunity = false, this.get_index_info(), this.addhistory();
  374. this.load_goods_data(), this.get_type_topic(),this.getPinList();
  375. } else {
  376. console.log('nochange')
  377. if (that.isFirst>=1){
  378. this.setData({ loadOver: true })
  379. this.changeRushListNum();
  380. }
  381. }
  382. if (that.isFirst==0) {
  383. this.setData({ couponRefresh: true });
  384. } else {
  385. this.getCoupon();
  386. let cid = app.globalData.indexCateId || '';
  387. cid && this.goIndexType(cid);
  388. app.globalData.indexCateId = '';
  389. }
  390. that.isFirst++;
  391. },
  392. /**
  393. * 动态变化列表购物车数量
  394. */
  395. changeRushListNum: function(){
  396. let that = this;
  397. let goodsListCarCount = app.globalData.goodsListCarCount;
  398. let rushList = this.data.rushList;
  399. let changeCarCount = false;
  400. this.setData({ changeCarCount })
  401. if (goodsListCarCount.length > 0 && rushList.length > 0) {
  402. goodsListCarCount.forEach(function (item) {
  403. let k = that.arrayHasElement(rushList, item.actId);
  404. if (k[0] != -1 && rushList[k[0]][k[1]].skuList.length === 0) {
  405. let newNum = item.num * 1;
  406. rushList[k[0]][k[1]].car_count = newNum >= 0 ? newNum : 0;
  407. changeCarCount = true;
  408. }
  409. })
  410. // goodsListCarCount.forEach(function (item) {
  411. // let k = rushList.findIndex((n) => n.actId == item.actId);
  412. // if (k != -1 && rushList[k].skuList.length === 0) {
  413. // let newNum = item.num * 1;
  414. // rushList[k].car_count = newNum >= 0 ? newNum : 0;
  415. // changeCarCount = true;
  416. // }
  417. // })
  418. this.setData({ rushList, changeCarCount })
  419. }
  420. },
  421. arrayHasElement: function(array, element) {
  422. let el=array;
  423. for(let number in el){
  424. if (el[number].length > 0) {
  425. for (var index in el[number]) {
  426. if (el[number][index].actId == element) {
  427. return [number, index]
  428. }
  429. }
  430. }
  431. }
  432. return [-1, -1];
  433. },
  434. changeNotListCartNum: function (t) {
  435. let that = this;
  436. let e = t.detail;
  437. (0, status.cartNum)(that.setData({ cartNum: e }));
  438. this.changeRushListNum();
  439. },
  440. onHide: function() {
  441. this.setData({ stopNotify: true, tabbarRefresh: false, changeCarCount: false })
  442. console.log('详情页', this.data.stopNotify)
  443. app.globalData.timer.stop();
  444. console.log('onHide')
  445. },
  446. /**
  447. * 授权成功回调
  448. */
  449. authSuccess: function() {
  450. console.log('authSuccess');
  451. let that = this;
  452. this.tpage = 1;
  453. this.hasRefeshin = false;
  454. this.setData({
  455. rushList: [],
  456. pageNum: 1,
  457. needAuth: false,
  458. newComerRefresh: false,
  459. couponRefresh: true,
  460. isblack: app.globalData.isblack || 0,
  461. diyLoaded: false
  462. })
  463. this.$data = {
  464. ...this.$data, ...{
  465. overPageNum: 1,
  466. loadOver: false,
  467. hasOverGoods: false,
  468. countDownMap: {},
  469. actEndMap: {},
  470. timer: {},
  471. hasCommingGoods: true
  472. }
  473. }
  474. status.getInNum().then((isCan) => {
  475. if (isCan) {
  476. that.setData({ isTipShow: true })
  477. timerOut = setTimeout(() => { that.setData({ isTipShow: false }) }, 7000);
  478. }
  479. })
  480. this.loadPage();
  481. this.data.isTipShow && (timerOut = setTimeout(() => { that.setData({ isTipShow: false }) }, 7000));
  482. },
  483. authModal: function (e = {}) {
  484. let needAuth = (e && e.detail) || this.data.needAuth;
  485. if (this.data.needAuth || e.detail) {
  486. this.setData({
  487. showAuthModal: !this.data.showAuthModal,
  488. needAuth
  489. });
  490. return false;
  491. }
  492. return true;
  493. },
  494. //获取历史社区
  495. getHistoryCommunity: function () {
  496. let that = this;
  497. var token = wx.getStorageSync('token');
  498. app.util.request({
  499. 'url': 'entry/wxapp/index',
  500. 'data': {
  501. controller: 'index.load_history_community',
  502. token: token
  503. },
  504. dataType: 'json',
  505. success: function (res) {
  506. console.log('step14');
  507. if (res.data.code == 0) {
  508. console.log('getHistoryCommunity');
  509. let history_communities = res.data.list;
  510. let isNotHistory = false;
  511. if (Object.keys(history_communities).length == 0 || history_communities.communityId == 0) isNotHistory = true;
  512. let resArr = history_communities && history_communities.fullAddress && history_communities.fullAddress.split('省');
  513. history_communities = Object.assign({}, history_communities, { address: resArr[1] })
  514. that.setData({
  515. community: history_communities
  516. })
  517. wcache.put('community', history_communities);
  518. app.globalData.community = history_communities;
  519. if (token && !isNotHistory) {
  520. let lastCommunity = wx.getStorageSync('lastCommunity');
  521. let lastCommunityId = lastCommunity.communityId || '';
  522. if (lastCommunityId != '' && lastCommunityId != history_communities.communityId) {
  523. that.setData({
  524. showChangeCommunity: true,
  525. changeCommunity: lastCommunity
  526. }, ()=> {
  527. wx.removeStorageSync('lastCommunity');
  528. })
  529. }
  530. }
  531. that.setData({
  532. community: app.globalData.community
  533. })
  534. that.load_goods_data();
  535. } else {
  536. let options = that.options;
  537. if (options !== void 0 && options.community_id) {
  538. console.log('新人加入分享进来的社区id:', that.options);
  539. that.addhistory(options.community_id);
  540. } else if (res.data.code == 1) {
  541. console.log('获取历史社区');
  542. wx.redirectTo({
  543. url: "/lionfish_comshop/pages/position/community"
  544. })
  545. } else {
  546. that.setData({ needAuth: true })
  547. }
  548. }
  549. }
  550. })
  551. },
  552. getScrollHeight: function () {
  553. wx.createSelectorQuery().select('.rush-list-box').boundingClientRect((rect) => {
  554. rect && rect.height && (this.$data.scrollHeight = rect.height || 1300);
  555. console.log(this.$data.scrollHeight)
  556. }).exec()
  557. },
  558. /**
  559. * 引导页切换
  560. */
  561. handleProxy: function(){
  562. clearTimeout(timerOut);
  563. this.setData({
  564. isTipShow: false,
  565. isShowGuide: true
  566. })
  567. wcache.put('inNum', 4);
  568. },
  569. handleHideProxy: function(){
  570. this.setData({
  571. isTipShow: false,
  572. isShowGuide: false
  573. })
  574. },
  575. /**
  576. * 获取首页信息
  577. */
  578. get_index_info: function() {
  579. let that = this;
  580. let community = wx.getStorageSync('community');
  581. let communityId = community && community.communityId || '';
  582. let token = wx.getStorageSync('token');
  583. app.util.request({
  584. url: 'entry/wxapp/index',
  585. data: {
  586. controller: 'index.index_info',
  587. communityId,
  588. token
  589. },
  590. dataType: 'json',
  591. success: function(res) {
  592. let rdata = res.data;
  593. let groupInfo = that.data.groupInfo;
  594. if (rdata.code == 0) {
  595. if (!res.data.is_community && communityId && !that.data.needAuth) {
  596. let changeCommunity = that.data.changeCommunity || {};
  597. let changeCommunityId = changeCommunity.communityId || '';
  598. if (changeCommunityId) {
  599. wcache.put('community', changeCommunity);
  600. that.addhistory(changeCommunity.community_id);
  601. that.setData({
  602. community: changeCommunity,
  603. showChangeCommunity: false
  604. })
  605. that.loadPage();
  606. } else {
  607. wx.showModal({
  608. title: '提示',
  609. content: `该${groupInfo.group_name}不在,请重新选择${groupInfo.group_name}`,
  610. showCancel: false,
  611. confirmColor: '#F75451',
  612. success(res) {
  613. if (res.confirm) {
  614. wx.redirectTo({
  615. url: '/lionfish_comshop/pages/position/community',
  616. })
  617. }
  618. }
  619. })
  620. }
  621. }
  622. let notice_list = rdata.notice_list;
  623. let slider_list = rdata.slider_list;
  624. let index_lead_image = rdata.index_lead_image;
  625. if(index_lead_image){
  626. status.getInNum().then((isCan)=>{
  627. if (isCan) {
  628. that.setData({ isTipShow: true },()=>{
  629. timerOut = setTimeout(() => { that.setData({ isTipShow: false }) }, 9000);
  630. })
  631. }
  632. })
  633. } else {
  634. that.setData({ isTipShow: false })
  635. }
  636. let common_header_backgroundimage = rdata.common_header_backgroundimage;
  637. app.globalData.common_header_backgroundimage = common_header_backgroundimage;
  638. let order_notify_switch = rdata.order_notify_switch;
  639. let index_list_top_image_on = rdata.index_list_top_image_on;
  640. let index_change_cate_btn = rdata.index_change_cate_btn || 0;
  641. let default_img = '../../images/rush-title.png';
  642. // if (index_list_top_image_on == 1) default_img='';
  643. let index_list_top_image = rdata.index_list_top_image ? rdata.index_list_top_image : default_img;
  644. let shop_info = {
  645. shoname: rdata.shoname,
  646. shop_index_share_image: rdata.shop_index_share_image,
  647. index_list_top_image: index_list_top_image,
  648. title: rdata.title,
  649. common_header_backgroundimage,
  650. order_notify_switch,
  651. index_top_img_bg_open: rdata.index_top_img_bg_open || 0,
  652. index_top_font_color: rdata.index_top_font_color || '#fff',
  653. index_communityinfo_showtype: rdata.index_communityinfo_showtype || 0,
  654. index_list_top_image_on
  655. }
  656. app.globalData.placeholdeImg = rdata.index_loading_image || '';
  657. let placeholdeImg = rdata.index_loading_image || '';
  658. wcache.put('shopname', rdata.shoname);
  659. wx.setNavigationBarTitle({ title: rdata.shoname });
  660. let category_list = rdata.category_list || [];
  661. let index_type_first_name = rdata.index_type_first_name || '全部';
  662. if (category_list.length > 0) {
  663. category_list.unshift({
  664. name: index_type_first_name,
  665. id: 0
  666. })
  667. that.setData({
  668. isShowClassification: true,
  669. "classification.tabs": category_list
  670. })
  671. } else {
  672. that.setData({
  673. isShowClassification: false
  674. })
  675. }
  676. let theme = rdata.theme || 0;
  677. let rushEndTime = rdata.rushtime*1000 || 0;
  678. let isShowShareBtn = rdata.index_share_switch || 0;
  679. let isShowListCount = rdata.is_show_list_count || 0;
  680. let isShowListTimer = rdata.is_show_list_timer || 0;
  681. let isShowContactBtn = rdata.index_service_switch || 0;
  682. let index_switch_search = rdata.index_switch_search || 0;
  683. let ishow_index_gotop = rdata.ishow_index_gotop || 0;
  684. if (rdata.is_comunity_rest == 1 && !that.data.needAuth) {
  685. wx.showModal({
  686. title: '温馨提示',
  687. content: `${groupInfo.owner_name}休息中,欢迎下次光临!`,
  688. showCancel: false,
  689. confirmColor: '#F75451',
  690. confirmText: '好的',
  691. success(res) { }
  692. })
  693. }
  694. that.postion = rdata.postion;
  695. //秒杀
  696. let { scekill_time_arr, seckill_bg_color, seckill_is_open, seckill_is_show_index, hide_community_change_word,index_qgtab_counttime, hide_index_type } = rdata;
  697. let myDate = new Date();
  698. let curHour = myDate.getHours(); // 当前时间
  699. console.log('当前时间:', curHour);
  700. let curSeckillIdx = 0; //当前时间索引
  701. let scekillTimeArr = []; //显示的时间段
  702. if (scekill_time_arr.length > 3) {
  703. let timeLen = scekill_time_arr.length;
  704. curSeckillIdx = scekill_time_arr.findIndex(item => {
  705. return item >= curHour;
  706. });
  707. console.log('当前时间索引:', curSeckillIdx)
  708. //取三个时间段
  709. if (curSeckillIdx === -1) {
  710. //没有进行或者未开始 取最后三个
  711. scekillTimeArr = scekill_time_arr.slice(-3);
  712. } else if (curSeckillIdx === 0) {
  713. //全部未开始 取最前三个
  714. scekillTimeArr = scekill_time_arr.slice(0, 3);
  715. } else if ((curSeckillIdx + 1) == timeLen) {
  716. //剩最后一个 取最后三个
  717. scekillTimeArr = scekill_time_arr.slice(-3);
  718. } else {
  719. scekillTimeArr = scekill_time_arr.slice(curSeckillIdx - 1, curSeckillIdx + 2);
  720. }
  721. } else {
  722. scekillTimeArr = scekill_time_arr;
  723. }
  724. //判断各个时段状态
  725. let scekillTimeList = [];
  726. let secKillActiveIdx = 0;
  727. if(scekillTimeArr.length){
  728. scekillTimeArr.forEach((item, idx) => {
  729. let secObj = {};
  730. //state: 0已开抢 1疯抢中 2即将开抢
  731. if (item == curHour) {
  732. secObj.state = 1;
  733. secObj.desc = '疯抢中';
  734. secKillActiveIdx = idx;
  735. } else if (item < curHour) {
  736. secObj.state = 0;
  737. secObj.desc = '已开抢';
  738. } else {
  739. secObj.state = 2;
  740. secObj.desc = '即将开抢';
  741. }
  742. secObj.timeStr = (item < 10 ? '0' + item : item) + ':00';
  743. secObj.timeArr = [item < 10 ? '0' + item : item, '00'];
  744. secObj.seckillTime = item;
  745. scekillTimeList.push(secObj);
  746. })
  747. //获取当前秒杀商品
  748. that.getSecKillGoods(scekillTimeArr[secKillActiveIdx]);
  749. }
  750. let index_video_arr = rdata.index_video_arr;
  751. // 预售信息
  752. let presale_index_info = rdata.presale_index_info || '';
  753. if(presale_index_info&&presale_index_info.goods_list) {
  754. let goods_list = presale_index_info.goods_list;
  755. let nowtime = Date.parse(new Date())/1000;
  756. goods_list.forEach((item, idx)=>{
  757. let { presale_ding_money, actPrice, presale_deduction_money, presale_type, presale_ding_time_start_int, presale_ding_time_end_int } = item;
  758. if(presale_type==0) {
  759. presale_deduction_money = presale_deduction_money>0?presale_deduction_money:presale_ding_money;
  760. let goodsPrice = (actPrice[0]+'.'+actPrice[1])*1;
  761. presale_index_info.goods_list[idx].weikuan = (goodsPrice - presale_deduction_money*1).toFixed(2);
  762. presale_ding_money = presale_ding_money.toFixed(2);
  763. presale_index_info.goods_list[idx].dingArr = (presale_ding_money+'').split('.');
  764. presale_index_info.goods_list[idx].presale_deduction_money = presale_deduction_money;
  765. }
  766. let saleStatus = 1; //客付定金 0未开始 2已结束
  767. if(nowtime<presale_ding_time_start_int) {
  768. saleStatus = 0;
  769. } else if(nowtime>presale_ding_time_end_int) {
  770. saleStatus = 2;
  771. }
  772. presale_index_info.goods_list[idx].saleStatus = saleStatus;
  773. })
  774. }
  775. let isDiy = rdata.open_diy_index_page || 0;
  776. wx.setStorageSync('is_diy', isDiy);
  777. (isDiy==1)&&that.getDiyInfo();
  778. // 礼品卡
  779. let virtualcard_info = rdata.virtualcard_info || '';
  780. if(virtualcard_info&&virtualcard_info.goods_list) {
  781. var timestamp = Date.parse(new Date())/1000;
  782. let newList = [];
  783. if(Object.keys(virtualcard_info.goods_list).length) {
  784. virtualcard_info.goods_list.forEach(item=>{
  785. (item.end_time<timestamp)&&(item.actEnd = 1);
  786. newList.push(item);
  787. })
  788. }
  789. virtualcard_info.goods_list = newList;
  790. }
  791. console.log(theme,'111')
  792. that.setData({
  793. notice_list,
  794. slider_list,
  795. index_lead_image,
  796. theme,
  797. indexBottomImage: rdata.index_bottom_image || '',
  798. shop_info: shop_info,
  799. loadOver: true,
  800. rushEndTime,
  801. commingNum: rdata.comming_goods_total,
  802. isShowShareBtn,
  803. isShowListCount,
  804. isShowListTimer,
  805. is_comunity_rest: rdata.is_comunity_rest,
  806. index_change_cate_btn,
  807. isShowContactBtn,
  808. index_switch_search,
  809. is_show_new_buy: rdata.is_show_new_buy || 0,
  810. qgtab: res.data.qgtab || {},
  811. notice_setting: rdata.notice_setting || {},
  812. index_hide_headdetail_address: rdata.index_hide_headdetail_address || 0,
  813. is_show_spike_buy: rdata.is_show_spike_buy || 0,
  814. hide_community_change_btn: rdata.hide_community_change_btn || 0,
  815. hide_top_community: rdata.hide_top_community || 0,
  816. index_qgtab_text: rdata.index_qgtab_text,
  817. ishow_index_copy_text: rdata.ishow_index_copy_text || 0,
  818. newComerRefresh: true,
  819. cube: rdata.cube,
  820. placeholdeImg,
  821. seckill_bg_color,
  822. seckill_is_open,
  823. seckill_is_show_index,
  824. scekillTimeList,
  825. secKillActiveIdx,
  826. hide_community_change_word,
  827. ishow_index_gotop,
  828. ishow_index_pickup_time: rdata.ishow_index_pickup_time || 0,
  829. index_video_arr,
  830. index_qgtab_counttime,
  831. hide_index_type,
  832. show_index_wechat_oa: rdata.show_index_wechat_oa,
  833. ishide_index_goodslist: rdata.ishide_index_goodslist,
  834. can_index_notice_alert: rdata.can_index_notice_alert,
  835. presale_index_info,
  836. isDiy,
  837. virtualcard_info
  838. })
  839. }
  840. }
  841. })
  842. },
  843. /**
  844. * 确认切换社区
  845. */
  846. confrimChangeCommunity: function() {
  847. let community = this.data.changeCommunity;
  848. app.globalData.community = community;
  849. wcache.put('community', community);
  850. this.$data = {
  851. ...this.$data, ...{
  852. overPageNum: 1,
  853. loadOver: false,
  854. hasOverGoods: false,
  855. countDownMap: {},
  856. actEndMap: {},
  857. timer: {},
  858. stickyFlag: false
  859. }
  860. }
  861. this.hasRefeshin = false;
  862. this.setData({
  863. showChangeCommunity: false,
  864. community: community,
  865. rushList: [],
  866. pageNum: 1
  867. }, () => {
  868. this.loadPage();
  869. this.addhistory();
  870. })
  871. },
  872. /**
  873. * 关闭切换社区
  874. */
  875. closeChangeCommunity: function(){
  876. this.setData({
  877. showChangeCommunity: false
  878. })
  879. },
  880. /**
  881. * 获取商品列表
  882. */
  883. load_goods_data: function() {
  884. var token = wx.getStorageSync('token');
  885. var that = this;
  886. var cur_community = wx.getStorageSync('community');
  887. var gid = that.data.classificationId;
  888. this.$data.isLoadData = true;
  889. console.log('load_goods_begin ');
  890. if (!that.hasRefeshin && !that.$data.loadOver) {
  891. console.log('load_goods_in ');
  892. this.hasRefeshin = true;
  893. that.setData({
  894. loadMore: true
  895. });
  896. app.util.request({
  897. 'url': 'entry/wxapp/index',
  898. 'data': {
  899. controller: 'index.load_gps_goodslist',
  900. token: token,
  901. pageNum: that.data.pageNum,
  902. head_id: cur_community.communityId,
  903. gid,
  904. per_page: 12
  905. },
  906. dataType: 'json',
  907. success: function(res) {
  908. console.log(res,'111111')
  909. if (that.data.pageNum == 1) {
  910. that.setData({ cate_info: res.data.cate_info || {} })
  911. }
  912. if (res.data.code == 0) {
  913. let rushList = [];
  914. if (res.data.is_show_list_timer==1) {
  915. rushList = that.transTime(res.data.list);
  916. for (let s in that.$data.countDownMap) that.initCountDown(that.$data.countDownMap[s]);
  917. } else {
  918. rushList = that.data.rushList;
  919. rushList[that.data.pageNum-1] = res.data.list;
  920. }
  921. let rdata = res.data;
  922. let { full_money, full_reducemoney, is_open_fullreduction, is_open_vipcard_buy, is_vip_card_member, is_member_level_buy } = rdata;
  923. let reduction = { full_money, full_reducemoney, is_open_fullreduction }
  924. // 是否可以会员折扣购买
  925. let canLevelBuy = false;
  926. if (is_open_vipcard_buy == 1) {
  927. if (is_vip_card_member != 1 && is_member_level_buy == 1) canLevelBuy = true;
  928. } else {
  929. (is_member_level_buy == 1) && (canLevelBuy = true);
  930. }
  931. if (that.data.pageNum==1) that.setData({ copy_text_arr: rdata.copy_text_arr || [] })
  932. that.hasRefeshin = false;
  933. that.setData({
  934. rushList: rushList,
  935. pageNum: that.data.pageNum + 1,
  936. loadMore: false,
  937. reduction,
  938. tip: '',
  939. is_open_vipcard_buy: is_open_vipcard_buy || 0,
  940. is_vip_card_member,
  941. is_member_level_buy,
  942. canLevelBuy
  943. }, ()=>{
  944. if (that.isFirst == 1) {
  945. that.isFirst++;
  946. }
  947. if (rushList.length && !that.$data.stickyTop) {
  948. wx.createSelectorQuery().select(".tab-nav-query").boundingClientRect(function (t) {
  949. if (t && t.top){
  950. wcache.put('tabPos', t);
  951. that.$data.stickyTop = t.top + t.height, that.$data.stickyBackTop = t.top;
  952. } else {
  953. let tabpos = wcache.get('tabPos', false);
  954. if (tabpos) that.$data.stickyTop = tabpos.top + tabpos.height, that.$data.stickyBackTop = tabpos.top;
  955. }
  956. }).exec();
  957. that.$data.scrollTop > that.$data.stickyTop && wx.pageScrollTo({
  958. duration: 0,
  959. scrollTop: that.$data.stickyTop + 4
  960. });
  961. }
  962. that.getScrollHeight();
  963. if (that.data.pageNum == 2 && res.data.list.length < 10) {
  964. console.log('load_over_goods_list_begin')
  965. that.$data.loadOver = true;
  966. that.hasRefeshin = true;
  967. that.setData({
  968. loadMore: true
  969. }, () => {
  970. that.load_over_gps_goodslist();
  971. });
  972. }
  973. });
  974. } else if (res.data.code == 1) {
  975. that.$data.loadOver = true;
  976. that.load_over_gps_goodslist();
  977. } else if (res.data.code == 2) {
  978. //no login
  979. that.setData({ needAuth: true, couponRefresh: false })
  980. }
  981. },
  982. complete: function() {
  983. that.$data.isLoadData = false;
  984. // wx.hideLoading();
  985. setTimeout(function(){ wx.hideLoading(); },1000);
  986. }
  987. })
  988. } else {
  989. that.load_over_gps_goodslist();
  990. }
  991. },
  992. /**
  993. * 组合倒计时时间
  994. */
  995. transTime: function(list) {
  996. let that = this;
  997. let e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
  998. e === 0 && list.map(function(t) {
  999. t.end_time *= 1000;
  1000. that.$data.countDownMap[t.end_time] = t.end_time, that.$data.actEndMap[t.end_time] = t.end_time <= new Date().getTime() || t.spuCanBuyNum == 0;
  1001. })
  1002. let rushList = that.data.rushList;
  1003. let idx = that.data.pageNum+that.$data.overPageNum-2;
  1004. rushList[idx] = list;
  1005. return rushList;
  1006. // return that.data.rushList.concat(list);
  1007. },
  1008. /**
  1009. * 获取售罄商品
  1010. */
  1011. load_over_gps_goodslist: function() {
  1012. var token = wx.getStorageSync('token');
  1013. var that = this;
  1014. var cur_community = wx.getStorageSync('community');
  1015. var gid = that.data.classificationId;
  1016. if (!that.$data.hasOverGoods && that.$data.loadOver) {
  1017. that.$data.hasOverGoods = true;
  1018. that.setData({
  1019. loadMore: true
  1020. });
  1021. app.util.request({
  1022. 'url': 'entry/wxapp/index',
  1023. 'data': {
  1024. controller: 'index.load_over_gps_goodslist',
  1025. token: token,
  1026. pageNum: that.$data.overPageNum,
  1027. head_id: cur_community.communityId,
  1028. gid,
  1029. is_index_show: 1
  1030. },
  1031. dataType: 'json',
  1032. success: function(res) {
  1033. if (res.data.code == 0) {
  1034. let rushList = that.transTime(res.data.list);
  1035. for (let s in that.$data.countDownMap) that.initCountDown(that.$data.countDownMap[s]);
  1036. that.$data.hasOverGoods = false;
  1037. that.$data.overPageNum += 1;
  1038. that.setData({
  1039. rushList: rushList,
  1040. loadMore: false,
  1041. tip: ''
  1042. }, ()=>{
  1043. if (that.isFirst == 1) {
  1044. that.isFirst++;
  1045. if (rushList.length && !that.$data.stickyTop) {
  1046. wx.createSelectorQuery().select(".tab-nav-query").boundingClientRect(function (t) {
  1047. if (t && t.top) {
  1048. wcache.put('tabPos', t);
  1049. that.$data.stickyTop = t.top + t.height, that.$data.stickyBackTop = t.top;
  1050. } else {
  1051. let tabpos = wcache.get('tabPos', false);
  1052. if (tabpos) that.$data.stickyTop = tabpos.top + tabpos.height, that.$data.stickyBackTop = tabpos.top;
  1053. }
  1054. }).exec();
  1055. that.$data.scrollTop > that.$data.stickyTop && wx.pageScrollTo({
  1056. duration: 0,
  1057. scrollTop: that.$data.stickyTop + 4
  1058. });
  1059. }
  1060. that.getScrollHeight();
  1061. }
  1062. });
  1063. } else if (res.data.code == 1) {
  1064. if (that.$data.overPageNum == 1 && that.data.rushList.length == 0) that.setData({
  1065. showEmpty: true
  1066. })
  1067. that.setData({
  1068. loadMore: false,
  1069. tip: '^_^已经到底了'
  1070. })
  1071. } else if (res.data.code == 2) {
  1072. that.setData({ needAuth: true, couponRefresh: false })
  1073. }
  1074. that.$data.isLoadData = false;
  1075. }
  1076. })
  1077. } else {
  1078. that.$data.isLoadData = false;
  1079. }
  1080. },
  1081. /**
  1082. * 监控分类导航
  1083. */
  1084. classificationChange: function(t, autoScroll=0) {
  1085. console.log(t.detail.e)
  1086. wx.showLoading();
  1087. var that = this;
  1088. this.$data = {...this.$data, ...{
  1089. overPageNum: 1,
  1090. loadOver: false,
  1091. hasOverGoods: false,
  1092. countDownMap: {},
  1093. actEndMap: {},
  1094. timer: {}
  1095. }
  1096. }, this.hasRefeshin = false, this.setData({
  1097. rushList: [],
  1098. showEmpty: false,
  1099. pageNum: 1,
  1100. "classification.activeIndex": t.detail.e,
  1101. classificationId: t.detail.a
  1102. }, function() {
  1103. if ((this.$data.stickyFlag && (that.$data.scrollTop != that.$data.stickyTop+5)) || autoScroll){
  1104. console.log('滚动了')
  1105. let windowWidth = app.globalData.systemInfo && app.globalData.systemInfo.windowWidth || 375;
  1106. let taBH = windowWidth/750*72;
  1107. wx.pageScrollTo({ scrollTop: that.$data.stickyTop - taBH, duration: 0 })
  1108. }
  1109. that.load_goods_data();
  1110. });
  1111. },
  1112. /**
  1113. * 监控即将抢购分类导航
  1114. */
  1115. commingClassificationChange: function (t) {
  1116. wx.showLoading();
  1117. var that = this;
  1118. that.tpage = 1;
  1119. this.$data = {...this.$data, ...{hasCommingGoods: true} },
  1120. this.setData({
  1121. showCommingEmpty: false,
  1122. commingList: [],
  1123. "commingClassification.activeIndex": t.detail.e,
  1124. commingClassificationId: t.detail.a
  1125. }, function () {
  1126. if (this.$data.stickyFlag && (that.$data.scrollTop != that.$data.stickyTop + 5)) {
  1127. wx.pageScrollTo({ scrollTop: that.$data.stickyTop + 5, duration: 0 })
  1128. }
  1129. that.getCommingList();
  1130. });
  1131. },
  1132. // 抢购切换
  1133. tabSwitch: function (t) {
  1134. var that = this;
  1135. var tabIdx = 1 * t.currentTarget.dataset.idx;
  1136. this.setData({ tabIdx: tabIdx }, ()=>{
  1137. if (tabIdx == 1) {
  1138. if (that.$data.stickyFlag && (that.$data.scrollTop != that.$data.stickyTop + 5)) {
  1139. wx.pageScrollTo({ scrollTop: that.$data.stickyTop + 5, duration: 0 })
  1140. }
  1141. if (that.tpage == 1) {
  1142. that.getCommingList();
  1143. }
  1144. }
  1145. })
  1146. },
  1147. /**
  1148. * 即将开抢列表
  1149. */
  1150. getCommingList: function(){
  1151. this.data.commigLoadMore && wx.showLoading();
  1152. var token = wx.getStorageSync('token');
  1153. var that = this;
  1154. var cur_community = wx.getStorageSync('community');
  1155. var gid = this.data.commingClassificationId || 0;
  1156. that.$data.isLoadData = true;
  1157. if (that.$data.hasCommingGoods) {
  1158. that.$data.hasCommingGoods = false;
  1159. that.setData({ commigLoadMore: true });
  1160. app.util.request({
  1161. url: 'entry/wxapp/index',
  1162. data: {
  1163. controller: 'index.load_comming_goodslist',
  1164. token: token,
  1165. pageNum: that.tpage,
  1166. head_id: cur_community.communityId,
  1167. gid
  1168. },
  1169. dataType: 'json',
  1170. success: function (res) {
  1171. wx.hideLoading();
  1172. if (res.data.code == 0) {
  1173. let commingList = res.data.list;
  1174. commingList = that.data.commingList.concat(commingList);
  1175. that.$data.hasCommingGoods = true;
  1176. that.tpage += 1;
  1177. that.setData({
  1178. commingList: commingList,
  1179. commigLoadMore: false,
  1180. commigTip: ''
  1181. },()=>{
  1182. that.getScrollHeight();
  1183. });
  1184. } else if (res.data.code == 1) {
  1185. if (that.tpage == 1 && that.data.commingList.length == 0) that.setData({
  1186. showCommingEmpty: true
  1187. })
  1188. that.setData({
  1189. commigLoadMore: false,
  1190. commigTip: '^_^已经到底了'
  1191. })
  1192. } else if (res.data.code == 2) {
  1193. that.setData({ needAuth: true, couponRefresh: false })
  1194. }
  1195. that.$data.isLoadData = false;
  1196. }
  1197. })
  1198. } else{
  1199. that.$data.isLoadData = false;
  1200. !that.data.commigLoadMore && wx.hideLoading();
  1201. }
  1202. },
  1203. /**
  1204. * 返回顶部
  1205. */
  1206. backTop: function() {
  1207. this.stickyFlag = false, wx.pageScrollTo({
  1208. scrollTop: 0,
  1209. duration: 500
  1210. });
  1211. },
  1212. goLink: function(event) {
  1213. let url = event.currentTarget.dataset.link;
  1214. let needauth = event.currentTarget.dataset.needauth || '';
  1215. console.log(needauth)
  1216. if(needauth){ if (!this.authModal()) return; }
  1217. url && wx.navigateTo({ url })
  1218. },
  1219. /**
  1220. * 导航小图标
  1221. */
  1222. getNavigat: function(){
  1223. let that = this;
  1224. app.util.request({
  1225. 'url': 'entry/wxapp/index',
  1226. 'data': {
  1227. controller: 'index.get_navigat'
  1228. },
  1229. dataType: 'json',
  1230. success: function (res) {
  1231. if (res.data.code == 0) {
  1232. let navigat = res.data.data || [];
  1233. let navigatEmpty = [];
  1234. let navigatSwiper = {page: 1, current:0, totnav: 0};
  1235. let chunks = [];
  1236. if (navigat.length>0) {
  1237. let len = (5-navigat.length%5) || 0;
  1238. if(len<5&&len>0) navigatEmpty = new Array(len);
  1239. for(let i=0;i<navigat.length;i=i+10){
  1240. chunks.push(navigat.slice(i,i+10));
  1241. }
  1242. navigatSwiper.page = chunks.length;
  1243. navigatSwiper.totnav = navigat.length;
  1244. }
  1245. that.setData({ navigat: chunks, navigatEmpty, navigatSwiper })
  1246. }
  1247. }
  1248. })
  1249. },
  1250. navigatSwiperChange: function(t) {
  1251. this.setData({
  1252. "navigatSwiper.current": t.detail.current
  1253. });
  1254. },
  1255. /**
  1256. * 导航图标跳转
  1257. */
  1258. goNavUrl: function(t) {
  1259. let idx = t.currentTarget.dataset.idx;
  1260. console.log(idx)
  1261. let { navigat, needAuth, navigatSwiper } = this.data;
  1262. let sidx = navigatSwiper.current;
  1263. navigat = navigat[sidx];
  1264. if (navigat.length > 0) {
  1265. let url = navigat[idx].link;
  1266. let type = navigat[idx].type;
  1267. if(util.checkRedirectTo(url, needAuth)){
  1268. this.authModal();
  1269. return;
  1270. }
  1271. if (type== 0){
  1272. // 跳转webview
  1273. wx.navigateTo({
  1274. url: '/lionfish_comshop/pages/web-view?url=' + encodeURIComponent(url),
  1275. })
  1276. } else if (type==1) {
  1277. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  1278. wx.switchTab({ url: url })
  1279. } else {
  1280. wx.navigateTo({ url: url })
  1281. }
  1282. } else if (type==2){
  1283. // 跳转小程序
  1284. let appid = navigat[idx].appid;
  1285. appid && wx.navigateToMiniProgram({
  1286. appId: navigat[idx].appid,
  1287. path: url,
  1288. extraData: {},
  1289. envVersion: 'release',
  1290. success(res) {
  1291. // 打开成功
  1292. },
  1293. fail(error) {
  1294. console.log(error)
  1295. }
  1296. })
  1297. } else if (type == 3){
  1298. //首页分类
  1299. // t.detail.e 选中索引
  1300. // t.detail.a 选中id
  1301. let classification = this.data.classification;
  1302. let tabs = classification && classification.tabs;
  1303. let cid = url;
  1304. let activeIdx = tabs.findIndex((p) => { return p.id == cid });
  1305. if (activeIdx!=-1) {
  1306. let cateInfo = {
  1307. detail: { e: activeIdx, a: cid }
  1308. };
  1309. this.classificationChange(cateInfo, 1);
  1310. } else {
  1311. wx.showToast({
  1312. title: '分类不存在或已关闭',
  1313. icon: 'none'
  1314. })
  1315. }
  1316. } else if (type == 4) {
  1317. //独立分类
  1318. app.globalData.typeCateId = url;
  1319. wx.switchTab({
  1320. url: '/lionfish_comshop/pages/type/index'
  1321. })
  1322. } else if (type == 6) {
  1323. //领券
  1324. let url = navigat[idx].link;
  1325. wx.navigateTo({
  1326. url: '/lionfish_comshop/moduleA/coupon/getCoupon?id='+url
  1327. })
  1328. }
  1329. }
  1330. },
  1331. /**
  1332. * 幻灯片跳转
  1333. */
  1334. goBannerUrl: function (t) {
  1335. let idx = t.currentTarget.dataset.idx;
  1336. let { slider_list, needAuth } = this.data;
  1337. if (slider_list.length > 0) {
  1338. let url = slider_list[idx].link;
  1339. let type = slider_list[idx].linktype;
  1340. if (util.checkRedirectTo(url, needAuth)) {
  1341. this.authModal();
  1342. return;
  1343. }
  1344. if (type == 0) {
  1345. // 跳转webview
  1346. url && wx.navigateTo({ url: '/lionfish_comshop/pages/web-view?url=' + encodeURIComponent(url) })
  1347. } else if (type == 1) {
  1348. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  1349. url && wx.switchTab({ url: url })
  1350. } else {
  1351. url && wx.navigateTo({ url: url })
  1352. }
  1353. } else if (type == 2) {
  1354. // 跳转小程序
  1355. let appid = slider_list[idx].appid;
  1356. appid && wx.navigateToMiniProgram({
  1357. appId: slider_list[idx].appid,
  1358. path: url,
  1359. extraData: {},
  1360. envVersion: 'release',
  1361. success(res) {
  1362. // 打开成功
  1363. },
  1364. fail(error) {
  1365. console.log(error)
  1366. }
  1367. })
  1368. } else if (type == 6) {
  1369. //领券
  1370. wx.navigateTo({
  1371. url: '/lionfish_comshop/moduleA/coupon/getCoupon?id='+url
  1372. })
  1373. }
  1374. }
  1375. },
  1376. /**
  1377. * 页面相关事件处理函数--监听用户下拉动作
  1378. */
  1379. onPullDownRefresh: function () {
  1380. this.setData({ couponRefresh: false, newComerRefresh: false, stopNotify: true });
  1381. this.tpage = 1;
  1382. this.$data = {
  1383. ...this.$data, ...{
  1384. overPageNum: 1,
  1385. loadOver: false,
  1386. hasOverGoods: false,
  1387. countDownMap: {},
  1388. actEndMap: {},
  1389. timer: {},
  1390. stickyFlag: false,
  1391. hasCommingGoods: true
  1392. }
  1393. }
  1394. this.hasRefeshin = false;
  1395. this.setData({
  1396. rushList: [],
  1397. commingList: [],
  1398. tabIdx: 0,
  1399. pageNum: 1,
  1400. couponRefresh: true,
  1401. newComerRefresh: true,
  1402. stopNotify: false,
  1403. rushEndTime: 0,
  1404. diyLoaded: false
  1405. }, ()=>{
  1406. this.loadPage();
  1407. })
  1408. wx.stopPullDownRefresh();
  1409. },
  1410. onReachBottom: function(e) {
  1411. if(this.data.ishide_index_goodslist==1||this.data.isDiy==1) return;
  1412. if (this.data.tabIdx==0){
  1413. this.load_goods_data();
  1414. } else {
  1415. this.getCommingList();
  1416. }
  1417. },
  1418. /**
  1419. * 获取团长位置
  1420. */
  1421. getCommunityPos: function (community_id){
  1422. let that = this;
  1423. app.util.request({
  1424. 'url': 'entry/wxapp/user',
  1425. 'data': {
  1426. controller: 'index.get_community_position',
  1427. communityId: community_id
  1428. },
  1429. dataType: 'json',
  1430. method: 'POST',
  1431. success: function (res) {
  1432. if (res.data.code == 0) {
  1433. that.postion = res.data.postion;
  1434. }
  1435. }
  1436. })
  1437. },
  1438. /**
  1439. * 查看地图
  1440. */
  1441. gotoMap: function () {
  1442. let community = this.data.community;
  1443. let postion = this.postion || {lat: 0, lon: 0};
  1444. let longitude = parseFloat(postion.lon),
  1445. latitude = parseFloat(postion.lat),
  1446. name = community.disUserName,
  1447. address = `${community.fullAddress}(${community.communityName})`;
  1448. wx.openLocation({
  1449. latitude: latitude,
  1450. longitude: longitude,
  1451. name: name,
  1452. address: address,
  1453. scale: 28
  1454. })
  1455. },
  1456. share_handler: function () {
  1457. this.setData({
  1458. is_share_html: false
  1459. })
  1460. },
  1461. hide_share_handler: function () {
  1462. this.setData({
  1463. is_share_html: true
  1464. })
  1465. },
  1466. // 搜索
  1467. goResult: function (e) {
  1468. let value = e.detail.value.keyword ? e.detail.value.keyword : e.detail.value;
  1469. let keyword = value.replace(/\s+/g, '');
  1470. if (!keyword) {
  1471. wx.showToast({
  1472. title: '请输入关键词',
  1473. icon: 'none'
  1474. })
  1475. return;
  1476. }
  1477. wx.navigateTo({
  1478. url: '/lionfish_comshop/pages/type/result?keyword=' + keyword,
  1479. })
  1480. },
  1481. /**
  1482. * 新人优惠券显示开关
  1483. */
  1484. toggleCoupon: function(e){
  1485. let auth = e.currentTarget.dataset.auth || '';
  1486. let needAuth = this.data.needAuth || '';
  1487. if(needAuth && auth) {
  1488. this.setData({
  1489. showAuthModal: true,
  1490. showCouponModal: false
  1491. })
  1492. } else {
  1493. this.setData({
  1494. showCouponModal: !this.data.showCouponModal,
  1495. hasAlertCoupon: false
  1496. })
  1497. }
  1498. },
  1499. changeCartNum: function(t) {
  1500. let that = this;
  1501. let e = t.detail;
  1502. (0, status.cartNum)(that.setData({ cartNum: e }));
  1503. },
  1504. /**
  1505. * 一键复制文本
  1506. */
  1507. copyText: function (e) {
  1508. let copy_text_arr = this.data.copy_text_arr;
  1509. let community = this.data.community;
  1510. let communityName = community.communityName;
  1511. let disUserName = community.disUserName;
  1512. let communityAddress = community.address || community.communityAddress || community.fullAddress;
  1513. let data = '-团长信息-\r\n小区:' + communityName + '\r\n团长:' + disUserName + '\r\n自提点:' + communityAddress + '\r\n\r\n今日推荐\r\n';
  1514. if (copy_text_arr.length) {
  1515. copy_text_arr.forEach(function(item, index){
  1516. data += (index + 1) + '.【' + item.goods_name + '】 团购价' + item.price + '\r\n';
  1517. data += '~~~~~~~~~~~~~~~~~~~~\r\n';
  1518. })
  1519. }
  1520. let that = this;
  1521. wx.setClipboardData({
  1522. data: data,
  1523. success: function (res) {
  1524. wx.getClipboardData({
  1525. success: function (res) {
  1526. that.setData({ showCopyText: false })
  1527. wx.showToast({
  1528. title: '复制成功'
  1529. })
  1530. }
  1531. })
  1532. }
  1533. })
  1534. },
  1535. /**
  1536. * 显示关闭复制文本
  1537. */
  1538. showCopyTextHandle: function(e){
  1539. if (!this.authModal()) return;
  1540. let showCopyText = e.currentTarget.dataset.status;
  1541. this.setData({ showCopyText })
  1542. },
  1543. /**
  1544. * 优惠券获取
  1545. */
  1546. getCoupon: function () {
  1547. let that = this;
  1548. let token = wx.getStorageSync('token');
  1549. app.util.request({
  1550. url: 'entry/wxapp/index',
  1551. data: { controller: 'goods.get_seller_quan', token },
  1552. dataType: 'json',
  1553. success: function (res) {
  1554. let list = res.data.quan_list;
  1555. let hasCoupon = false;
  1556. let hasAlertCoupon = false;
  1557. if (Object.prototype.toString.call(list) == '[object Object]' && Object.keys(list).length > 0) hasCoupon = true;
  1558. if (Object.prototype.toString.call(list) == '[object Array]' && list.length > 0) hasCoupon = true;
  1559. let alert_quan_list = res.data.alert_quan_list || [];
  1560. if (Object.prototype.toString.call(alert_quan_list) == '[object Object]' && Object.keys(alert_quan_list).length > 0) hasAlertCoupon = true;
  1561. if (Object.prototype.toString.call(alert_quan_list) == '[object Array]' && alert_quan_list.length > 0) hasAlertCoupon = true;
  1562. let totalAlertMoney = 0;
  1563. if (Object.prototype.toString.call(alert_quan_list) == '[object Object]' && Object.keys(alert_quan_list).length > 0) {
  1564. Object.keys(alert_quan_list).forEach(function(item){
  1565. totalAlertMoney += alert_quan_list[item].credit*1;
  1566. })
  1567. } else if (Object.prototype.toString.call(alert_quan_list) == '[object Array]' && alert_quan_list.length > 0) {
  1568. alert_quan_list.forEach(function (item) {
  1569. totalAlertMoney += item.credit * 1;
  1570. })
  1571. }
  1572. that.setData({
  1573. quan: res.data.quan_list || [],
  1574. alert_quan_list,
  1575. hasCoupon,
  1576. hasAlertCoupon,
  1577. showCouponModal: hasAlertCoupon,
  1578. totalAlertMoney: totalAlertMoney.toFixed(2)
  1579. })
  1580. }
  1581. });
  1582. },
  1583. receiveCoupon: function (event) {
  1584. if (!this.authModal()) return;
  1585. let quan_id = event.currentTarget.dataset.quan_id;
  1586. let type = event.currentTarget.dataset.type || 0;
  1587. var token = wx.getStorageSync('token');
  1588. var quan_list = [];
  1589. if(type==1) {
  1590. quan_list = this.data.alert_quan_list;
  1591. } else {
  1592. quan_list = this.data.quan;
  1593. }
  1594. var that = this;
  1595. app.util.request({
  1596. url: 'entry/wxapp/index',
  1597. data: { controller: 'goods.getQuan', token, quan_id },
  1598. dataType: 'json',
  1599. success: function (msg) {
  1600. //1 被抢光了 2 已领过 3 领取成功
  1601. if (msg.data.code == 0) {
  1602. wx.showToast({
  1603. title: msg.data.msg || '被抢光了',
  1604. icon: 'none'
  1605. })
  1606. } else if (msg.data.code == 1) {
  1607. wx.showToast({
  1608. title: '被抢光了',
  1609. icon: 'none'
  1610. })
  1611. } else if (msg.data.code == 2) {
  1612. wx.showToast({
  1613. title: '已领取',
  1614. icon: 'none'
  1615. })
  1616. var new_quan = [];
  1617. for (var i in quan_list) {
  1618. if (quan_list[i].id == quan_id) quan_list[i].is_get = 1;
  1619. new_quan.push(quan_list[i]);
  1620. }
  1621. that.setData({ quan: new_quan })
  1622. }
  1623. else if (msg.data.code == 4) {
  1624. wx.showToast({
  1625. title: '新人专享',
  1626. icon: 'none'
  1627. })
  1628. }
  1629. else if (msg.data.code == 3) {
  1630. var new_quan = [];
  1631. for (var i in quan_list) {
  1632. if (quan_list[i].id == quan_id){
  1633. quan_list[i].is_get = 1;
  1634. quan_list[i].is_hide = msg.data.is_hide;
  1635. }
  1636. new_quan.push(quan_list[i]);
  1637. }
  1638. if(type==1) {
  1639. that.setData({ alert_quan_list: new_quan })
  1640. } else {
  1641. that.setData({ quan: new_quan })
  1642. }
  1643. wx.showToast({
  1644. title: '领取成功',
  1645. })
  1646. } else if (msg.data.code == 4) {
  1647. // 未登录
  1648. }
  1649. }
  1650. })
  1651. },
  1652. goUse: function (e) {
  1653. this.setData({ showCouponModal: false, hasAlertCoupon: false })
  1654. let idx = e.currentTarget.dataset.idx;
  1655. let quan = this.data.alert_quan_list || [];
  1656. console.log(Object.keys(quan).length)
  1657. if (Object.keys(quan).length >= idx) {
  1658. if (quan[idx].is_limit_goods_buy == 0) {
  1659. wx.switchTab({
  1660. url: '/lionfish_comshop/pages/index/index',
  1661. })
  1662. } else if (quan[idx].is_limit_goods_buy == 1) {
  1663. let id = quan[idx].limit_goods_list;
  1664. let ids = id.split(',');
  1665. let url = '';
  1666. if (ids.length > 1) {
  1667. url = '/lionfish_comshop/pages/type/result?type=2&good_ids=' + id;
  1668. } else {
  1669. url = '/lionfish_comshop/pages/goods/goodsDetail?id=' + id;
  1670. }
  1671. wx.navigateTo({ url: url })
  1672. } else if (quan[idx].is_limit_goods_buy == 2) {
  1673. let gid = quan[idx].goodscates || 0;
  1674. wx.navigateTo({
  1675. url: '/lionfish_comshop/pages/type/result?type=1&gid=' + gid,
  1676. })
  1677. }
  1678. }
  1679. },
  1680. /**
  1681. * 分类专题
  1682. */
  1683. get_type_topic: function () {
  1684. let that = this;
  1685. var cur_community = wx.getStorageSync('community');
  1686. var token = wx.getStorageSync('token');
  1687. app.util.request({
  1688. url: 'entry/wxapp/index',
  1689. data: {
  1690. controller: 'goods.get_category_col_list',
  1691. head_id: cur_community.communityId,
  1692. token
  1693. },
  1694. dataType: 'json',
  1695. success: function (res) {
  1696. console.log(res)
  1697. if(res.data.code == 0) {
  1698. let typeTopicList = res.data.data || [];
  1699. that.setData({ typeTopicList })
  1700. }
  1701. }
  1702. })
  1703. },
  1704. /**
  1705. * 拼团列表
  1706. */
  1707. getPinList: function () {
  1708. let that = this;
  1709. var community = wx.getStorageSync('community');
  1710. let head_id = community.communityId || '';
  1711. var token = wx.getStorageSync('token');
  1712. app.util.request({
  1713. url: 'entry/wxapp/index',
  1714. data: {
  1715. controller: 'group.get_pintuan_list',
  1716. is_index: 1,
  1717. head_id,
  1718. token
  1719. },
  1720. dataType: 'json',
  1721. success: function (res) {
  1722. if (res.data.code == 0) {
  1723. let pinList = {};
  1724. let { list, pintuan_index_coming_img, pintuan_index_show } = res.data;
  1725. pinList.list = list || [];
  1726. pinList.img = pintuan_index_coming_img || '';
  1727. pinList.show = pintuan_index_show || 0;
  1728. that.setData({ pinList })
  1729. }
  1730. }
  1731. })
  1732. },
  1733. /**
  1734. * 魔方图标跳转
  1735. */
  1736. goCube: function (t) {
  1737. let idx = t.currentTarget.dataset.idx; // 当前链接索引
  1738. let index = t.currentTarget.dataset.index; // 当前魔方索引
  1739. let { cube, needAuth } = this.data;
  1740. console.log(cube)
  1741. if (cube.length > 0) {
  1742. let url = cube[index].thumb.link[idx];
  1743. let url2 = cube[index].thumb.outlink[idx];
  1744. let type = (cube[index].thumb.linktype && cube[index].thumb.linktype[idx]);
  1745. (type === (void 0)) && (type = 1);
  1746. if (util.checkRedirectTo(url, needAuth)) {
  1747. this.authModal();
  1748. return;
  1749. }
  1750. if (type == 0) {
  1751. // 跳转webview
  1752. url = cube[index].thumb.webview[idx];
  1753. wx.navigateTo({
  1754. url: '/lionfish_comshop/pages/web-view?url=' + encodeURIComponent(url)
  1755. })
  1756. } else if (type == 1) {
  1757. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  1758. url && wx.switchTab({
  1759. url,
  1760. fail: (err)=>{
  1761. wx.showToast({
  1762. title: err.errMsg,
  1763. icon: 'none'
  1764. })
  1765. }
  1766. })
  1767. } else {
  1768. url && wx.navigateTo({
  1769. url,
  1770. fail: (err)=>{
  1771. wx.showToast({
  1772. title: err.errMsg,
  1773. icon: 'none'
  1774. })
  1775. }
  1776. })
  1777. }
  1778. } else if (type == 2) {
  1779. // 跳转小程序
  1780. let appid = navigat[idx].appid;
  1781. appid && wx.navigateToMiniProgram({
  1782. appId: navigat[idx].appid,
  1783. path: url,
  1784. extraData: {},
  1785. envVersion: 'release',
  1786. success(res) {
  1787. // 打开成功
  1788. },
  1789. fail(error) {
  1790. console.log(error)
  1791. }
  1792. })
  1793. } else if (type == 3) {
  1794. let cid = cube[index].thumb.cateid[idx];
  1795. this.goIndexType(cid);
  1796. } else if (type == 4) {
  1797. //独立分类
  1798. let url = cube[index].thumb.cateid[idx];
  1799. app.globalData.typeCateId = url;
  1800. wx.switchTab({
  1801. url: '/lionfish_comshop/pages/type/index'
  1802. })
  1803. }else if (type==5){
  1804. // 跳转小程序
  1805. let appid = cube[index].thumb.appid[idx];
  1806. appid && wx.navigateToMiniProgram({
  1807. appId: appid,
  1808. path: url2,
  1809. extraData: {},
  1810. envVersion: 'release',
  1811. success(res) {
  1812. // 打开成功
  1813. },
  1814. fail(error) {
  1815. console.log(error)
  1816. }
  1817. })
  1818. } else if (type == 6) {
  1819. //领券
  1820. wx.navigateTo({
  1821. url: '/lionfish_comshop/moduleA/coupon/getCoupon?id='+url
  1822. })
  1823. }
  1824. }
  1825. },
  1826. goIndexType: function(cid){
  1827. if(cid.detail) {
  1828. cid = cid.detail;
  1829. }
  1830. let classification = this.data.classification;
  1831. let tabs = classification && classification.tabs;
  1832. let activeIdx = tabs.findIndex((p) => { return p.id == cid });
  1833. if (activeIdx != -1) {
  1834. let cateInfo = {
  1835. detail: { e: activeIdx, a: cid }
  1836. };
  1837. this.classificationChange(cateInfo, 1);
  1838. }
  1839. },
  1840. getSecKillGoods: function (seckill_time){
  1841. var that = this;
  1842. var cur_community = wx.getStorageSync('community');
  1843. var token = wx.getStorageSync('token');
  1844. app.util.request({
  1845. url: 'entry/wxapp/index',
  1846. data: {
  1847. controller: 'index.load_gps_goodslist',
  1848. token: token,
  1849. pageNum: 1,
  1850. head_id: cur_community.communityId,
  1851. seckill_time,
  1852. is_seckill: 1,
  1853. per_page: 10000
  1854. },
  1855. dataType: 'json',
  1856. success: function (res) {
  1857. console.log('限时秒杀')
  1858. if(res.data.code==0) {
  1859. let secRushList = res.data.list || [];
  1860. that.setData({ secRushList })
  1861. }
  1862. }
  1863. })
  1864. },
  1865. scrollSecKillGoodsChange: function (t) {
  1866. this.setData({
  1867. secKillGoodsIndex: t.detail.current + 1
  1868. });
  1869. },
  1870. /**
  1871. * 显示秒杀时间切换
  1872. */
  1873. changeSecKillTime(t){
  1874. let that = this;
  1875. let seckill_time = t.currentTarget.dataset.time;
  1876. let secKillActiveIdx = t.currentTarget.dataset.idx;
  1877. this.setData({
  1878. secRushList: [],
  1879. secKillActiveIdx
  1880. }, ()=>{
  1881. that.getSecKillGoods(seckill_time);
  1882. })
  1883. },
  1884. /**
  1885. * 图片信息
  1886. */
  1887. imageLoad: function (e) {
  1888. var imageSize = util.imageUtil(e)
  1889. this.setData({
  1890. imageSize
  1891. })
  1892. },
  1893. /**
  1894. * 播放视频隐藏封面图
  1895. */
  1896. btnPlay: function () {
  1897. this.setData({
  1898. fmShow: false
  1899. })
  1900. this.videoContext.play();
  1901. },
  1902. videEnd: function () {
  1903. this.setData({
  1904. fmShow: true
  1905. })
  1906. },
  1907. bindload: function(t){
  1908. console.log(t.detail)
  1909. },
  1910. binderror: function(t){
  1911. this.setData({ hideMpAccount: true })
  1912. console.log(t.detail)
  1913. },
  1914. closeMpaccount: function(){
  1915. this.setData({ show_index_wechat_oa: 0 })
  1916. },
  1917. showNoticeTextHandle: function(e){
  1918. if(this.data.can_index_notice_alert==1) {
  1919. let showNoticeText = e.currentTarget.dataset.status;
  1920. let noticeIdx = e.currentTarget.dataset.idx;
  1921. this.setData({ showNoticeText, noticeIdx })
  1922. }
  1923. },
  1924. /**
  1925. * DIY公用链接跳转
  1926. */
  1927. goDiysliderUrl: function(t) {
  1928. let link = t.currentTarget.dataset.link;
  1929. let needAuth = this.data.needAuth;
  1930. if (Object.keys(link).length > 0) {
  1931. let type = link.parents;
  1932. if (util.checkRedirectTo(link.wap_url, needAuth)) {
  1933. this.authModal();
  1934. return;
  1935. }
  1936. switch(type) {
  1937. case "WEBVIEW":
  1938. let url = link.wap_url;
  1939. url && wx.navigateTo({ url: '/lionfish_comshop/pages/web-view?url=' + encodeURIComponent(url) });
  1940. break;
  1941. case "MALL_LINK":
  1942. url = link.wap_url;
  1943. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  1944. url && wx.switchTab({ url })
  1945. } else {
  1946. url && wx.navigateTo({ url })
  1947. }
  1948. break;
  1949. case "OTHER_APPLET":
  1950. // 跳转小程序
  1951. let appId = link.appid;
  1952. let path = link.wap_url;
  1953. appId && wx.navigateToMiniProgram({
  1954. appId,
  1955. path,
  1956. extraData: {},
  1957. envVersion: 'release',
  1958. success(res) {},
  1959. fail(error) { wx.showModal({ title: "提示", content: error.errMsg, showCancel: false }) }
  1960. })
  1961. break;
  1962. case "CUSTOM_LINK":
  1963. url = link.wap_url;
  1964. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  1965. url && wx.switchTab({ url })
  1966. } else {
  1967. url && wx.navigateTo({ url })
  1968. }
  1969. break;
  1970. case "GOODS_CATEGORY":
  1971. //独立分类
  1972. let cateId = link.id;
  1973. app.globalData.typeCateId = cateId;
  1974. wx.switchTab({
  1975. url: '/lionfish_comshop/pages/type/index'
  1976. })
  1977. break;
  1978. default:
  1979. url = link.wap_url;
  1980. url && wx.navigateTo({ url })
  1981. break;
  1982. }
  1983. }
  1984. },
  1985. /**
  1986. * DIY商品列表组获取
  1987. */
  1988. getDiyGoodsList(res) {
  1989. console.log('getDiyGoodsList', res)
  1990. let data = res.detail.data;
  1991. let idx = res.detail.id;
  1992. let diyGoodsList = [];
  1993. let is_open_vipcard_buy = 0;
  1994. if(data.code==0) {
  1995. let resGoodsList = data.list;
  1996. if (data.is_show_list_timer==1&&resGoodsList.length>0) {
  1997. diyGoodsList = this.transTime(resGoodsList);
  1998. for (let s in this.$data.countDownMap) this.initCountDown(this.$data.countDownMap[s]);
  1999. } else {
  2000. diyGoodsList[0] = resGoodsList;
  2001. }
  2002. is_open_vipcard_buy = data.is_open_vipcard_buy;
  2003. }
  2004. let list = this.data.diyGoodsList;
  2005. list[idx] = diyGoodsList;
  2006. this.setData({ diyGoodsList: list, is_open_vipcard_buy })
  2007. },
  2008. getDiyManyGoodsList(res) {
  2009. let data = res.detail.data;
  2010. let list = [];
  2011. if(data.code==0) {
  2012. let resGoodsList = data.list;
  2013. if (data.is_show_list_timer==1&&resGoodsList.length>0) {
  2014. list = this.transTime(resGoodsList);
  2015. for (let s in this.$data.countDownMap) this.initCountDown(this.$data.countDownMap[s]);
  2016. } else {
  2017. list[0] = resGoodsList;
  2018. }
  2019. }
  2020. this.setData({ diyManyGoodsList: list })
  2021. },
  2022. /**
  2023. * DIY数据
  2024. */
  2025. getDiyInfo: function() {
  2026. app.util.ProReq('index.get_diy_info').then(res => {
  2027. console.log(res.global)
  2028. let { diyJson, global } = res;
  2029. global.title && wx.setNavigationBarTitle({ title: global.title });
  2030. wx.setNavigationBarColor({
  2031. backgroundColor: global.topNavColor,
  2032. frontColor: global.textNavColor,
  2033. })
  2034. let diyGoodsList = Array.from(Array(diyJson.length), () => '');
  2035. this.setData({
  2036. diyJson, globalDiyData: global, diyGoodsList, diyLoaded: true
  2037. })
  2038. })
  2039. },
  2040. onShareAppMessage: function(res) {
  2041. this.setData({ is_share_html: true });
  2042. var community = wx.getStorageSync('community');
  2043. var community_id = community.communityId;
  2044. var member_id = wx.getStorageSync('member_id');
  2045. console.log('首页分享地址:');
  2046. console.log(community_id, member_id);
  2047. return {
  2048. title: this.data.shop_info.title,
  2049. path: "lionfish_comshop/pages/index/index?community_id=" + community_id + '&share_id=' + member_id,
  2050. imageUrl: this.data.shop_info.shop_index_share_image,
  2051. success: function() {},
  2052. fail: function() {}
  2053. };
  2054. },
  2055. onShareTimeline: function(res) {
  2056. var community = wx.getStorageSync('community');
  2057. var community_id = community.communityId;
  2058. var share_id = wx.getStorageSync('member_id');
  2059. var query= `share_id=${share_id}&community_id=${community_id}`;
  2060. return {
  2061. title: this.data.shop_info.title,
  2062. query,
  2063. imageUrl: this.data.shop_info.shop_index_share_image,
  2064. success: function() {},
  2065. fail: function() {}
  2066. };
  2067. }
  2068. })