index.vue 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452
  1. <template>
  2. <view>
  3. <view :class="'top-fixed' + (skinNotColor ? ' not-color' : '')" :style="'height: '+ systems.barHeight + 'rpx;'">
  4. <block v-if="about.CONFIG_PROJECT_TITLE_BG && about.CONFIG_PROJECT_TITLE_PIC">
  5. <image :src="about.CONFIG_PROJECT_TITLE_BG" class="topbg"></image>
  6. <view class="top-title" :style="'height: '+ systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
  7. <image :src="about.CONFIG_PROJECT_TITLE_PIC" mode="heightFix"></image>
  8. </view>
  9. </block>
  10. <view class="top-title" :style="'line-height: '+ systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'" v-else>
  11. {{about.CONFIG_PROJECT_TITLE?about.CONFIG_PROJECT_TITLE:''}}
  12. </view>
  13. </view>
  14. <view :style="'height: '+ systems.barHeight + 'rpx;'"></view>
  15. <!-- <view @click="saoma()" style="z-index: 999;position: relative;">扫码</view> -->
  16. <view v-for="(item, index) in contact" :key="index">
  17. <storeOptions
  18. v-if="item == 'store_options' || (item == 'sou' && top) || (item == 'type_district' && top_type)"
  19. :storeTemplate="storeTemplate"
  20. :merchant="merchant"
  21. :about="about"
  22. :guarantee="guarantee"
  23. :sousuoTemplate="sousuoTemplate"
  24. :typeDistrictTemplate="typeDistrictTemplate"
  25. :url="site"
  26. :web="url"
  27. :cloud="header.appId == 'ZQ1VK5oc17I387E' ? 'default' : ''"
  28. ></storeOptions>
  29. <!-- 多门店选择模板和搜索模板 -->
  30. <popAd
  31. v-if="item == 'home_pop_up_ads'"
  32. :first="first"
  33. :popAdTemplate="popAdTemplate"
  34. :isLayerAd="isLayerAd"
  35. :popAdList="popAdList"
  36. :iscouponAd="iscouponAd"
  37. :storeShow="storeShow"
  38. ></popAd>
  39. <!-- 弹窗广告 -->
  40. <banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url" :config="about" :districtTemplate="districtTemplate"></banner>
  41. <!-- 走马灯 -->
  42. <bargain v-if="item == 'bargain' && bargainShow" :bargainList="bargainList" :url="site" :web="url" :bargainTemplate="bargainTemplate"></bargain>
  43. <!-- 砍价 -->
  44. <customers v-if="item == 'New_customers' && customersShow" :customersList="customersList" :url="site" :web="url" :customersTemplate="customersTemplate"></customers>
  45. <!-- 新客 -->
  46. <homecolumn v-if="item == 'homecolumn'" :homecolumnimg="homecolumnimg"></homecolumn>
  47. <!-- 首页专区 -->
  48. <joingroup v-if="item == 'joingroup' && joingroupShow" :joingroupList="joingroupList" :url="site" :web="url" :joingroupTemplate="joingroupTemplate"></joingroup>
  49. <!-- 拼团 -->
  50. <group
  51. v-if="item == 'group' && activityGroupShow"
  52. :activityGroup="activityGroup"
  53. :url="site"
  54. :web="url"
  55. :groupTemplate="groupTemplate"
  56. :merchant="merchant"
  57. :freshen="freshen"
  58. ></group>
  59. <!-- 社区团购 -->
  60. <pCategoryList
  61. v-if="item == 'p_list'"
  62. :homeTemplate="homeTemplate"
  63. :url="site"
  64. :web="url"
  65. :about="about"
  66. :templateType="templateType"
  67. :merchant="merchant"
  68. :freshen="freshen"
  69. :pCategoryList="pCategoryList"
  70. :pCategorShow="pCategorShow"
  71. ></pCategoryList>
  72. <!-- 分类 -->
  73. <recommend
  74. v-if="item == 'recommend' && recommendShow"
  75. :pageList="pageList"
  76. :recommendTemplate="recommendTemplate"
  77. :url="site"
  78. :web="url"
  79. :about="about"
  80. :categoryList="categoryList"
  81. ></recommend>
  82. <!-- 推荐 -->
  83. <seckill v-if="item == 'seckill' && seckillShow" :seckillList="seckillList" :url="site" :web="url" :seckillTemplate="seckillTemplate"></seckill>
  84. <!-- 秒杀 -->
  85. <selected v-if="item == 'chosen' && boutiqueShow" :boutiqueList="boutiqueList" :chosenTemplate="chosenTemplate" :url="site" :web="url" :about="about"></selected>
  86. <!-- 精选 -->
  87. <arrivals
  88. v-if="item == 'new_arrivals' && arrivalsShow"
  89. :arrivalsList="arrivalsList"
  90. :arrivalsTemplate="arrivalsTemplate"
  91. :url="site"
  92. :web="url"
  93. :about="about"
  94. ></arrivals>
  95. <!-- 新品上架 -->
  96. <hot v-if="item == 'hot_money' && hotShow" :hotList="hotList" :hotTemplate="hotTemplate" :url="site" :web="url" :about="about"></hot>
  97. <!-- 热门爆款 -->
  98. <specialTopic v-if="item == 'special'" :specialList="specialList"></specialTopic>
  99. <!-- 专题 -->
  100. <redEnvelopes
  101. v-if="item == 'red_envelopes'"
  102. :storeShow="storeShow"
  103. :iscouponAd="iscouponAd"
  104. :first="first"
  105. :couponAd="couponAd"
  106. @iscouponAd="hidecouponAd"
  107. ></redEnvelopes>
  108. <!-- 红包 -->
  109. <supplier
  110. v-if="item == 'supplier_premium' && supplierShow"
  111. :supplierTemplate="supplierTemplate"
  112. :web="merchant.type == 5 ? web : url"
  113. :supplierList="supplierList"
  114. :about="about"
  115. ></supplier>
  116. <!-- 供应商优品 -->
  117. <district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url" :couponList="couponList" :districtTemplate="districtTemplate"></district>
  118. <!-- 九宫格 金刚区 -->
  119. <suppliers
  120. v-if="item == 'sup_recommend' && supRecommendShow"
  121. :supRecommendList="supRecommendList"
  122. :url="site"
  123. :web="url"
  124. :supRecommendTemplate="supRecommendTemplate"
  125. ></suppliers>
  126. <!-- 供应商推荐 -->
  127. <single
  128. v-if="item == 'single_product' && singleShow"
  129. :pageList="singleList"
  130. :singleTemplate="singleTemplate"
  131. :merchant="merchant"
  132. :url="site"
  133. :web="url"
  134. :about="about"
  135. :categoryList="categoryList"
  136. ></single>
  137. <!-- 单产品推荐 -->
  138. </view>
  139. <switchStore v-if="switchStoreShow && contact.length > 0 && merchant.id" :first="first" :merchant="merchant" :storeShow="storeShow" @onFather="click"></switchStore>
  140. <!-- <component v-for="(item,index) in contact" ></component> -->
  141. <!-- <ad></ad> -->
  142. <block v-if="contactShow">
  143. <view class="spinner">
  144. <view class="spinner-container container1">
  145. <view class="circle1"></view>
  146. <view class="circle2"></view>
  147. <view class="circle3"></view>
  148. <view class="circle4"></view>
  149. </view>
  150. <view class="spinner-container container2">
  151. <view class="circle1"></view>
  152. <view class="circle2"></view>
  153. <view class="circle3"></view>
  154. <view class="circle4"></view>
  155. </view>
  156. <view class="spinner-container container3">
  157. <view class="circle1"></view>
  158. <view class="circle2"></view>
  159. <view class="circle3"></view>
  160. <view class="circle4"></view>
  161. </view>
  162. </view>
  163. <view class="lond">加载中···</view>
  164. </block>
  165. <footer-copyright v-if="logo"></footer-copyright>
  166. <!-- 订单购买轮播 -->
  167. <view :class="(marqueeOrderItem ? 'roll-notice ' : '') + 'dflex'" v-if="marqueeOrderItem">
  168. <image :src="marqueeOrderItem.avatar"></image>
  169. <view class="flex">{{ marqueeOrderItem.time }} 购买了{{ marqueeOrderItem.productName }}</view>
  170. </view>
  171. <contact-button img-url="/static/pages/images/kfico1_1.png" class-name="contact_index" button-text="客服"></contact-button>
  172. <view class="guide" @tap="hideGuide" v-if="first"><image src="/static/pages/images/guide.png" mode="widthFix"></image></view>
  173. <!-- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view> -->
  174. <foot channel="home" :isUpdate="isUpdate"></foot>
  175. </view>
  176. </template>
  177. <script>
  178. //index.js
  179. //获取应用实例
  180. const app = getApp();
  181. const req = require('../../utils/request.js');
  182. const api = require('../../utils/api.js');
  183. const utils = require('../../utils/util.js');
  184. const mes = require('../../utils/requestmessage.js');
  185. const route = require('../../utils/route');
  186. const QQMapWX = require("../../utils/qqmap.js");
  187. import foot from '../../components/nav-bar/index';
  188. import footerCopyright from '../../components/footer-copyright/footer-copyright';
  189. import popAd from '../../template/popAd/popAd';
  190. import group from '../../template/activityGroup/activityGroup';
  191. import banner from '../../template/banner/banner';
  192. import bargain from '../../template/bargain/bargain';
  193. import customers from '../../template/customers/customers';
  194. import homecolumn from '../../template/homecolumn/homecolumn';
  195. import joingroup from '../../template/joingroup/joingroup';
  196. import pCategoryList from '../../template/pCategoryList/pCategoryList';
  197. import recommend from '../../template/recommend/recommend';
  198. import seckill from '../../template/seckill/seckill';
  199. import selected from '../../template/selected/selected';
  200. import arrivals from '../../template/arrivals/arrivals';
  201. import hot from '../../template/hot/hot';
  202. import specialTopic from '../../template/specialTopic/specialTopic';
  203. import storeOptions from '../../template/store_options/store_options';
  204. import redEnvelopes from '../../template/red_envelopes/index';
  205. import supplier from '../../template/supplier/supplier';
  206. import district from '../../template/king_kong_district/king_kong_district';
  207. import switchStore from '../../template/switchStore/switchStore';
  208. import suppliers from '../../template/suppliers/suppliers';
  209. import single from '../../template/single/single';
  210. export default {
  211. data() {
  212. return {
  213. skinNotColor: req.public.skinNotColor,
  214. systems: {},
  215. header: req.header,
  216. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  217. swiperCurrent: 0,
  218. swiperGrid: 0,
  219. bannerList: [],
  220. categoryList: [],
  221. //产品分类列表
  222. page: 1,
  223. boutiqueList: {},
  224. //精品榜单
  225. arrivalsList: {},
  226. hotList: {},
  227. pageList: {},
  228. //产品列表
  229. isLoad: true,
  230. hasmore: true,
  231. merchant: {},
  232. activityGroup: {
  233. products: []
  234. },
  235. couponList: {},
  236. //优惠券,
  237. isRemind: false,
  238. isUpdate: false,
  239. // 是否更新消息
  240. first: true,
  241. //是否显示提示加入我的小程序
  242. isLayerAd: true,
  243. //广告
  244. homeTemplate: [],
  245. //首页栏目配置
  246. pCategoryList: [],
  247. storeShow: true,
  248. templateType: {
  249. module_ad: 'ad',
  250. //广告
  251. module_type_district: 'type_district',
  252. //分类导航
  253. module_p_list: 'p_list',
  254. //品类专区
  255. module_group: 'group',
  256. //团购
  257. module_live: 'live',
  258. //直播
  259. module_sou: 'sou',
  260. //搜索
  261. module_special: 'special',
  262. //专题
  263. module_chosen: 'chosen',
  264. //精选
  265. module_new_arrivals: 'new_arrivals',
  266. //新品上架
  267. module_hot_money: 'hot_money',
  268. //热门爆款
  269. module_recommend: 'recommend',
  270. //推荐产品
  271. module_store_options: 'store_options',
  272. //多门店选择
  273. module_home_pop_up_ads: 'home_pop_up_ads',
  274. //首页弹窗广告
  275. module_joingroup: 'joingroup',
  276. //拼团
  277. module_seckill: 'seckill',
  278. //秒杀
  279. module_bargain: 'bargain',
  280. //砍价
  281. module_customers: 'New_customers',
  282. //新客
  283. module_homecolumn: 'homecolumn',
  284. //首页专区
  285. module_Timely_delivery_open: 'Timely_delivery_open',
  286. //及时达页面
  287. module_supplier_premium: 'supplier_premium', //供应商模块
  288. module_red_envelopes: 'red_envelopes', //优惠券
  289. module_king_kong_district: 'king_kong_district', //金刚区
  290. module_sup_recommend: 'sup_recommend', //供应商推荐
  291. module_single_product: 'single_product' //供应商推荐
  292. },
  293. buyOrderMarqueeList: [],
  294. listI: -1,
  295. isNotice: false,
  296. TabList: [
  297. {
  298. //秒杀时间
  299. label: '今天',
  300. active: true,
  301. state: '抢购中',
  302. dayType: 1,
  303. time: ''
  304. },
  305. {
  306. label: '明天',
  307. state: '预热中',
  308. active: false,
  309. time: '',
  310. dayType: 2
  311. },
  312. {
  313. label: '后天',
  314. state: '预热中',
  315. dayType: 3,
  316. time: ''
  317. },
  318. {
  319. label: '',
  320. state: '预热中',
  321. dayType: 4,
  322. active: false,
  323. time: ''
  324. },
  325. {
  326. label: '',
  327. state: '预热中',
  328. dayType: 5,
  329. active: false,
  330. time: ''
  331. }
  332. ],
  333. joingroupList: {
  334. products: []
  335. },
  336. //拼团
  337. bargainList: {
  338. products: []
  339. },
  340. //砍价
  341. customersList: {
  342. products: []
  343. },
  344. //新客
  345. freshen: true,
  346. swiperHeight: 0,
  347. url: '',
  348. web: '',
  349. site: '',
  350. internet: '',
  351. storeTemplate: {},
  352. typeDistrictTemplate: {},
  353. sousuoTemplate: {},
  354. popAdTemplate: {},
  355. districtTemplate: {},
  356. Timelyimg: '',
  357. timelyTemplate: {},
  358. homecolumnimg: [],
  359. customersTemplate: {},
  360. joingroupTemplate: {},
  361. supplierTemplate: {},
  362. seckillTemplate: {},
  363. bargainTemplate: {},
  364. specialTemplate: {},
  365. chosenTemplate: {},
  366. arrivalsTemplate: {},
  367. hotTemplate: {},
  368. groupTemplate: {},
  369. recommendTemplate: {},
  370. supRecommendTemplate: {},
  371. singleTemplate: {},
  372. specialList: [],
  373. contact: [],
  374. seckillList: {
  375. products: []
  376. },
  377. about: {},
  378. Is_Store_Price_Stock: '',
  379. guarantee: [],
  380. current: '',
  381. animationData: '',
  382. content: '',
  383. popAdList: {},
  384. supplierList: {},
  385. supRecommendList: {},
  386. singlePage: 1,
  387. isLoadSingle: true,
  388. hasmoreSingle: true,
  389. singleList: {},
  390. iscouponAd: false,
  391. couponAd: {},
  392. logo: false,
  393. top: Boolean,
  394. top_type: Boolean,
  395. switchStoreShow: Boolean,
  396. bargainShow: Boolean,
  397. contactShow: true,
  398. seckillShow: false,
  399. joingroupShow: false,
  400. activityGroupShow: false,
  401. customersShow: false,
  402. districtShow: false,
  403. recommendShow: false,
  404. boutiqueShow: false,
  405. arrivalsShow: false,
  406. hotShow: false,
  407. supplierShow: false,
  408. supRecommendShow: false,
  409. singleShow: false,
  410. pCategorShow: false,
  411. bannerShow: false,
  412. List: [],
  413. marqueeOrderItemIndex: 0,
  414. marqueeOrderItem: '',
  415. // isShowTime: false
  416. };
  417. },
  418. components: {
  419. foot,
  420. footerCopyright,
  421. banner,
  422. group,
  423. bargain,
  424. popAd,
  425. customers,
  426. homecolumn,
  427. joingroup,
  428. pCategoryList,
  429. recommend,
  430. seckill,
  431. selected,
  432. arrivals,
  433. hot,
  434. specialTopic,
  435. storeOptions,
  436. redEnvelopes,
  437. supplier,
  438. district,
  439. switchStore,
  440. suppliers,
  441. single
  442. },
  443. props: {},
  444. onLoad: async function(options) {
  445. // console.log("扫码进去参数===" + JSON.stringify(options));
  446. // if (options.scene) {
  447. // // this.scene = options.scene || '1290926887903780865';
  448. // this.scene = options.scene;
  449. // await this.loadCodeParams();
  450. // }
  451. // wx.setNavigationBarColor({
  452. // frontColor: '#ffffff',
  453. // backgroundColor: req.public.titleTopBgColor,
  454. // })
  455. // this.getPopAd()
  456. this.query = options;
  457. req.silenceLogin(options.userId, '');
  458. if (options.custom_params) {
  459. let obj = decodeURIComponent(opt.custom_params);
  460. obj = JSON.parse(obj);
  461. // console.log(obj)
  462. req.setStorage('pidCode', obj.userId);
  463. }
  464. if (options.isShare) {
  465. if (options.userId) {
  466. req.setStorage('pidCode', options.userId);
  467. }
  468. }
  469. setInterval(() => {
  470. this.setData({
  471. isNotice: true
  472. });
  473. }, 10000); // this.init();
  474. QQMapWX.initMap();
  475. req.getLocation(res => {
  476. const to = {
  477. latitude: res.latitude,
  478. longitude: res.longitude
  479. };
  480. QQMapWX.reverseGeocoder(to, resp => {
  481. });
  482. });
  483. },
  484. async onShow() {
  485. let _ts = this;
  486. await this.getConfig().then(res => {
  487. // console.log("debug1", res);
  488. _ts.getMerchant();
  489. });
  490. await this.getHomeTemplateConfig();
  491. await this.getCoupon();
  492. uni.setNavigationBarColor({
  493. frontColor: this.skinNotColor?'#000':'#ffffff',
  494. backgroundColor: req.public.titleTopBgColor
  495. });
  496. _ts.setData({
  497. isUpdate: !_ts.isUpdate
  498. });
  499. // console.log('this.freshen=='+this.freshen)
  500. let first = req.getStorage('first');
  501. if (first !== false)
  502. _ts.setData({
  503. first: true
  504. });
  505. else
  506. _ts.setData({
  507. first: false
  508. });
  509. },
  510. onUnload() {
  511. // this.isShowTime = false;
  512. this.clearAllTimer(1);
  513. this.clearAllTimer(2);
  514. this.clearAllTimer(3);
  515. this.clearAllTimer(4);
  516. },
  517. onHide() {
  518. // this.isShowTime = false;
  519. this.clearAllTimer(1);
  520. this.clearAllTimer(2);
  521. this.clearAllTimer(3);
  522. this.clearAllTimer(4);
  523. },
  524. onShareAppMessage: function() {
  525. let path = '/pages/index/index?isShare=' + true;
  526. if (req.getStorage('userInfo')) {
  527. path += '&userId=' + req.getStorage('userInfo').id;
  528. }
  529. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  530. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  531. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  532. path += '&shopId=' + req.getStorage('smallShop').id;
  533. }
  534. }
  535. let title = '';
  536. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  537. title = this.merchant.title;
  538. } else {
  539. title = this.about.CONFIG_PROJECT_TITLE;
  540. }
  541. console.log(title);
  542. // console.log(path);
  543. return {
  544. title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage('userInfo').nickName) : '') + '为你推荐' + title,
  545. // imageUrl: this.data.seckill[0].pic
  546. // path: '/product/detail/detail?id=' + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id
  547. path: path
  548. };
  549. },
  550. onShareTimeline() {
  551. let path = 'isShare=' + true;
  552. if (req.getStorage('userInfo')) {
  553. path += '&userId=' + req.getStorage('userInfo').id;
  554. }
  555. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  556. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  557. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  558. path += '&shopId=' + req.getStorage('smallShop').id;
  559. }
  560. }
  561. let title = '';
  562. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  563. title = this.merchant.title;
  564. } else {
  565. title = this.about.CONFIG_PROJECT_TITLE;
  566. }
  567. // console.log(path);
  568. return {
  569. title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage('userInfo').nickName) : '') + '为你推荐' + title,
  570. // imageUrl: this.data.seckill[0].pic
  571. // path: '/product/detail/detail?id=' + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id
  572. query: path
  573. };
  574. },
  575. onReachBottom() {},
  576. methods: {
  577. hidecouponAd(iscouponAd) {
  578. this.iscouponAd = false;
  579. app.globalData.isredenvelopes = false;
  580. },
  581. getMerchant() {
  582. let _ts = this;
  583. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  584. // 默认门店
  585. let merchant = req.getStorage('defaultMerchant');
  586. var timestamp = Date.parse(new Date());
  587. merchant.time = timestamp + 1 * 60 * 1000;
  588. if (merchant) {
  589. req.setStorage('MERCHANT', merchant);
  590. _ts.setData({
  591. merchant: merchant
  592. });
  593. console.log('》》》》获取当前的门店>>>>>>>>', merchant);
  594. _ts.init(merchant);
  595. } else {
  596. return new Promise((resolve, reject) => {
  597. req.getRequest(
  598. '/api/merchant/list',
  599. {
  600. page: 0,
  601. limit: 10000
  602. },
  603. res => {
  604. console.log('获取到门店列表>>>>>>>>', res);
  605. var data = res.filter(it => it.isDefault == 1);
  606. var timestamp = Date.parse(new Date());
  607. res[0].time = timestamp + 1 * 60 * 1000;
  608. _ts.setData({
  609. merchant: data[0]
  610. });
  611. // console.log(data)
  612. console.log('缓存当前的门店>>>>>>>>', data[0]);
  613. req.setStorage('defaultMerchant', data[0]);
  614. req.setStorage('MERCHANT', data[0]);
  615. _ts.init(data[0]);
  616. resolve();
  617. }
  618. );
  619. });
  620. }
  621. } else {
  622. return new Promise((resolve, reject) => {
  623. api.getMerchant(_ts.query, req, data => {
  624. console.log('data==',data)
  625. if (data == 1) {
  626. uni.showModal({
  627. title: '温馨提示',
  628. content: '获取定位失败,请前往设置打开定位权限',
  629. showCancel: false,
  630. success(res) {
  631. if (res.confirm) {
  632. // console.log('用户点击确定');
  633. uni.openSetting({
  634. success(res) {
  635. console.log(res.authSetting); // res.authSetting = {
  636. }
  637. });
  638. }
  639. }
  640. });
  641. } else {
  642. _ts.merchant = data;
  643. _ts.init(data);
  644. }
  645. resolve();
  646. });
  647. });
  648. }
  649. },
  650. getBuyOrderMarquee(isToTime) {
  651. console.log('getBuyOrderMarquee数据获取>>>>>>');
  652. req.getRequest('/api/product/buyDynamic', {}, data => {
  653. this.isShowTime = true;
  654. this.buyOrderMarqueeList = data;
  655. if (isToTime) {
  656. console.log('1111111111getBuyOrderMarquee数据获取>>>>>>');
  657. if (this.buyOrderMarqueeList && this.buyOrderMarqueeList.length > 0) {
  658. this.marqueeOrderItem = this.buyOrderMarqueeList[this.marqueeOrderItemIndex];
  659. this.marqueeOrderItemIndex++;
  660. this.getMarqueeOrderItem();
  661. }
  662. }
  663. });
  664. },
  665. // 首页轮播最新购买记录
  666. getMarqueeOrderItem() {
  667. var tha = this;
  668. setTimeout(function() {
  669. // console.log('数据tha.marqueeOrderItemIndex>>>>', tha.marqueeOrderItemIndex);
  670. tha.marqueeOrderItem = tha.buyOrderMarqueeList[tha.marqueeOrderItemIndex];
  671. if (tha.marqueeOrderItemIndex >= tha.buyOrderMarqueeList.length - 1) {
  672. tha.marqueeOrderItemIndex = 0;
  673. } else {
  674. tha.marqueeOrderItemIndex++;
  675. }
  676. tha.getMarqueeOrderItem();
  677. }, 5000);
  678. },
  679. async init(merchant) {
  680. // this.getHomeTemplateConfig();
  681. // console.log(this.Is_Store_Price_Stock, this.Is_Store_Price_Stock, this.about);
  682. let url = '';
  683. let web = '';
  684. let site = '';
  685. let internet = '';
  686. if (merchant.type == 5) {
  687. url = '&merchantId=' + merchant.merchantDTO.id + '&shopId=' + merchant.id;
  688. web = '&smallShop=true';
  689. site = '?merchantId=' + merchant.merchantDTO.id + '&shopId=' + merchant.id;
  690. internet = '?smallShop=true';
  691. } else {
  692. url = '&merchantId=' + merchant.id;
  693. web = '&merchantId=' + merchant.id;
  694. site = '?merchantId=' + merchant.id;
  695. internet = '?merchantId=' + merchant.id;
  696. }
  697. // console.log(url, web);
  698. this.setData({
  699. url: url,
  700. web: web,
  701. site: site,
  702. internet: internet
  703. }); // await this.getConfig();
  704. // await this.getCategory(); // await this.getCoupon();
  705. },
  706. // getpCategoryList: function(e) {
  707. // console.log(e.detail, "qqqqq")
  708. // this.pCategoryList = e.detail
  709. // },
  710. // getPopAd(){
  711. // //弹窗广告
  712. // let popAd = that.data.homeTemplate.filter(it => it.module == that.data.templateType.module_home_pop_up_ads);
  713. // if (popAd && popAd.length > 0 && popAd[0].state == 0) {
  714. // that.setData({ popAdTemplate: popAd[0] });
  715. // await this.getBannerList(popAd[0].module, popAd[0].contentId);
  716. // }
  717. // },
  718. async getRqeDatas() {
  719. console.log('getRqeDatas');
  720. this.getBuyOrderMarquee(!this.isShowTime);
  721. let that = this; //多门店
  722. let store = that.homeTemplate.filter(it => it.module == that.templateType.module_store_options);
  723. that.setData({
  724. storeTemplate: store[0]
  725. }); //搜索
  726. let sousuo = that.homeTemplate.filter(it => it.module == that.templateType.module_sou);
  727. that.setData({
  728. sousuoTemplate: sousuo[0]
  729. });
  730. //分类导航
  731. let typeDistrict = that.homeTemplate.filter(it => it.module == that.templateType.module_type_district);
  732. that.setData({
  733. typeDistrictTemplate: typeDistrict[0]
  734. });
  735. //弹窗广告
  736. let popAd = that.homeTemplate.filter(it => it.module == that.templateType.module_home_pop_up_ads);
  737. if (popAd && popAd.length > 0 && popAd[0].state == 0) {
  738. that.setData({
  739. popAdTemplate: popAd[0]
  740. });
  741. if (that.freshen) {
  742. await that.getBannerList(popAd[0].module, popAd[0].contentId);
  743. }
  744. } // 及时达
  745. // let Timely = that.data.homeTemplate.filter(it => it.module == that.data.templateType.module_Timely_delivery_open);
  746. // if (Timely && Timely.length > 0 && Timely[0].state == 0) {
  747. // that.setData({ TimelyTemplate: Timely[0] });
  748. // await this.getTimelyList(Timely[0].module, Timely[0].contentId);
  749. // }
  750. let Timely = that.homeTemplate.filter(it => it.module == that.templateType.module_Timely_delivery_open);
  751. if (Timely.length > 0 && Timely[0].state == 0) {
  752. // console.log(Timely);
  753. let Timelyimg = Timely[0].contentId.split(','); // if (Timely[0] != '' && Timely[1] != '' && Timely[2] != '') {
  754. // if (Timely.length == 3) {
  755. that.setData({
  756. Timelyimg: Timelyimg[0],
  757. timelyTemplate: Timely[0]
  758. });
  759. // console.log(Timelyimg); // }
  760. // }
  761. }
  762. // 金刚区
  763. let district = that.homeTemplate.filter(it => it.module == that.templateType.module_king_kong_district);
  764. if (district && district.length > 0 && district[0].state == 0) {
  765. let data = district[0];
  766. data.content = JSON.parse(district[0].content);
  767. that.districtTemplate = data;
  768. if (data.contentId == 2) {
  769. that.districtShow = true;
  770. }
  771. console.log(that.districtTemplate, '=============');
  772. }
  773. //顶部banner
  774. let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
  775. if (ad && ad.length > 0 && ad[0].state == 0) {
  776. if (that.freshen) {
  777. await that.getBannerList(ad[0].module, ad[0].contentId);
  778. }
  779. } //首页专区
  780. let homecolumn = that.homeTemplate.filter(it => it.module == that.templateType.module_homecolumn);
  781. if (homecolumn.length > 0 && homecolumn[0].state == 0) {
  782. let homecolumnimg = homecolumn[0].contentId.split(',');
  783. if (homecolumnimg[0] != '' && homecolumnimg[1] != '' && homecolumnimg[2] != '') {
  784. if (homecolumnimg.length == 3) {
  785. // console.log(homecolumnimg);
  786. that.setData({
  787. homecolumnimg: homecolumnimg
  788. });
  789. }
  790. }
  791. } // 新客
  792. let customers = that.homeTemplate.filter(it => it.module == that.templateType.module_customers);
  793. if (customers && customers.length > 0 && customers[0].state == 0) {
  794. that.setData({
  795. customersTemplate: customers[0]
  796. });
  797. await that.customersListFun(customers[0]);
  798. } //拼团
  799. let joingroup = that.homeTemplate.filter(it => it.module == that.templateType.module_joingroup);
  800. if (joingroup && joingroup.length > 0 && joingroup[0].state == 0) {
  801. that.setData({
  802. joingroupTemplate: joingroup[0]
  803. });
  804. await that.joingroupListFun(joingroup[0]);
  805. } // 供应商
  806. let supplier = that.homeTemplate.filter(it => it.module == that.templateType.module_supplier_premium);
  807. if (supplier && supplier.length > 0 && supplier[0].state == 0) {
  808. that.setData({
  809. supplierTemplate: supplier[0]
  810. });
  811. if (that.freshen) {
  812. await that.getsupplierList(supplier[0]);
  813. }
  814. } //秒杀
  815. let seckill = that.homeTemplate.filter(it => it.module == that.templateType.module_seckill);
  816. if (seckill && seckill.length > 0 && seckill[0].state == 0) {
  817. that.setData({
  818. seckillTemplate: seckill[0]
  819. });
  820. await that.seckillListFun(seckill[0]);
  821. } //砍价
  822. let bargain = that.homeTemplate.filter(it => it.module == that.templateType.module_bargain);
  823. if (bargain && bargain.length > 0 && bargain[0].state == 0) {
  824. that.setData({
  825. bargainTemplate: bargain[0]
  826. });
  827. await that.bargainListFun(bargain[0]);
  828. } //专题
  829. let special = that.homeTemplate.filter(it => it.module == that.templateType.module_special);
  830. if (special && special.length > 0 && special[0].state == 0) {
  831. that.setData({
  832. specialTemplate: special[0]
  833. });
  834. if (that.freshen) {
  835. await that.getSpecialList(special[0]);
  836. }
  837. } //精选
  838. let chosen = that.homeTemplate.filter(it => it.module == that.templateType.module_chosen);
  839. if (chosen && chosen.length > 0 && chosen[0].state == 0) {
  840. that.setData({
  841. chosenTemplate: chosen[0]
  842. });
  843. if (that.freshen) {
  844. await that.getBoutiqueList(chosen[0]);
  845. } // }
  846. } //团购
  847. //新品上架
  848. let arrivals = that.homeTemplate.filter(it => it.module == that.templateType.module_new_arrivals);
  849. if (arrivals && arrivals.length > 0 && arrivals[0].state == 0) {
  850. that.setData({
  851. arrivalsTemplate: arrivals[0]
  852. });
  853. if (that.freshen) {
  854. await that.getArrivalsList(arrivals[0]);
  855. } // }
  856. }
  857. //热门爆款
  858. let hot = that.homeTemplate.filter(it => it.module == that.templateType.module_hot_money);
  859. if (hot && hot.length > 0 && hot[0].state == 0) {
  860. that.setData({
  861. hotTemplate: hot[0]
  862. });
  863. if (that.freshen) {
  864. await that.getHotList(hot[0]);
  865. } // }
  866. }
  867. let group = that.homeTemplate.filter(it => it.module == that.templateType.module_group);
  868. if (group && group.length > 0 && group[0].state == 0) {
  869. that.setData({
  870. groupTemplate: group[0]
  871. });
  872. await that.loadGroup(group[0]);
  873. }
  874. //推荐产品
  875. let recommend = that.homeTemplate.filter(it => it.module == that.templateType.module_recommend);
  876. if (recommend && recommend.length > 0 && recommend[0].state == 0) {
  877. that.setData({
  878. recommendTemplate: recommend[0]
  879. });
  880. if (that.freshen) {
  881. await that.getPageList();
  882. }
  883. }
  884. //单产品推荐
  885. let single = that.homeTemplate.filter(it => it.module == that.templateType.module_single_product);
  886. if (single && single.length > 0 && single[0].state == 0) {
  887. that.setData({
  888. singleTemplate: single[0]
  889. });
  890. if (that.freshen) {
  891. await that.getSinglePageList();
  892. }
  893. }
  894. //品类专区
  895. let p_list = that.homeTemplate.filter(it => it.module == that.templateType.module_p_list && it.state == 0);
  896. // that.pCategoryList = p_list;
  897. that.List = p_list;
  898. console.log('p_list==',p_list)
  899. if (that.freshen) {
  900. if (!that.pCategorShow) {
  901. for (var i = 0; i < that.List.length; i++) {
  902. await that.getPListProduct(that.List[i], i).then(data => {
  903. data = data.map(it => {
  904. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  905. return it;
  906. });
  907. var res = {
  908. displayStyle: that.List[i].theme,
  909. lineNumber: that.List[i].lineNumber,
  910. products: data
  911. };
  912. that.List[i].productList = res;
  913. let arr = [];
  914. that.List.forEach(it => {
  915. if (it.productList) {
  916. arr.push(it);
  917. }
  918. });
  919. that.pCategoryList = that.List;
  920. if (arr.length == that.List.length) {
  921. that.pCategorShow = true;
  922. }
  923. });
  924. await that.getCateCoupon(that.List[i],i).then(suc=>{
  925. that.List[i].couponList = suc;
  926. })
  927. }
  928. }
  929. }
  930. // 红包优惠券
  931. let coupon = that.homeTemplate.filter(it => it.module == that.templateType.module_red_envelopes && app.globalData.isredenvelopes);
  932. if (coupon && coupon.length > 0 && coupon[0].state == 0) {
  933. if (!req.getStorage('userInfo')) {
  934. that.setData({
  935. iscouponAd: true,
  936. couponAd: coupon[0]
  937. });
  938. } else {
  939. req.getRequest(
  940. '/api/coupon/checkCoupon',
  941. {
  942. id: coupon[0].contentId
  943. },
  944. res => {
  945. if (res == 1) {
  946. that.setData({
  947. iscouponAd: true,
  948. couponAd: coupon[0]
  949. });
  950. } else if (res == 0) {
  951. that.setData({
  952. iscouponAd: false
  953. });
  954. }
  955. }
  956. );
  957. }
  958. // console.log(coupon[0])
  959. } else {
  960. that.setData({
  961. iscouponAd: false
  962. });
  963. }
  964. // 供应商推荐
  965. let supRecommend = that.homeTemplate.filter(it => it.module == that.templateType.module_sup_recommend);
  966. if (supRecommend && supRecommend.length > 0 && supRecommend[0].state == 0) {
  967. that.setData({
  968. supRecommendTemplate: supRecommend[0]
  969. });
  970. if (that.freshen) {
  971. await that.getSupRecommendList();
  972. }
  973. }
  974. that.getCategory();
  975. that.setData({
  976. freshen: false
  977. });
  978. that.logo = true;
  979. },
  980. //产品分类优惠券
  981. getCateCoupon(pCategory,idx){
  982. let form = {
  983. page: 1,
  984. limit: 2,
  985. categoryId: pCategory.contentId,
  986. bindType: 'use'
  987. }
  988. return new Promise((resolve, reject) => {
  989. req.getRequest('/api/coupon/list',form,data=>{
  990. resolve(data);
  991. })
  992. })
  993. },
  994. // 动态产品分类
  995. getPListProduct(pCategory, idx) {
  996. // return new Promise((resolve, reject) => {
  997. // console.log(idx)
  998. let that = this;
  999. let pList = [];
  1000. let form = {
  1001. limit: pCategory.number,
  1002. categoryId: pCategory.contentId // isRecommend:1
  1003. };
  1004. // //小店
  1005. if ((that.merchant && that.merchant.type == 5) || (that.shopId && that.merchantId)) {
  1006. form.merchantId = that.merchant.merchantDTO.id;
  1007. var sid = that.merchant.id;
  1008. if (that.shopId && that.merchantId) (form.merchantId = that.merchantId), (form.sid = that.shopId);
  1009. return new Promise((resolve, reject) => {
  1010. req.getRequest('/api/shopProduct/list', form, data => {
  1011. resolve(data);
  1012. });
  1013. });
  1014. }
  1015. //非小店
  1016. if (that.merchant && that.merchant.type != 5) {
  1017. form.merchantId = that.merchant.id;
  1018. return new Promise((resolve, reject) => {
  1019. req.getRequest('/api/product/list', form, data => {
  1020. resolve(data);
  1021. });
  1022. });
  1023. }
  1024. // })
  1025. },
  1026. //新客
  1027. customersListFun(customersTemplate) {
  1028. let _ts = this;
  1029. _ts.clearAllTimer(4);
  1030. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1031. let from = {
  1032. page: this.page,
  1033. limit: customersTemplate.number,
  1034. type: 6,
  1035. merchantId: this.merchant.merchantDTO.id,
  1036. sid: this.merchant.id
  1037. };
  1038. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1039. req.getRequest('/api/shopProduct/list', from, res => {
  1040. res = res.list.map(it => {
  1041. it.isRemind = it.remindId;
  1042. return it;
  1043. });
  1044. let arrObjFilter;
  1045. arrObjFilter = {
  1046. displayStyle: customersTemplate.theme,
  1047. lineNumber: customersTemplate.lineNumber,
  1048. products: res.filter(ele => ele.end == false)
  1049. };
  1050. this.setData({
  1051. customersList: arrObjFilter,
  1052. customersShow: true
  1053. });
  1054. _ts.initGroupTimer(4);
  1055. });
  1056. }
  1057. if (this.merchant && this.merchant.type != 5) {
  1058. let from = {
  1059. page: 1,
  1060. limit: customersTemplate.number,
  1061. type: 4,
  1062. tag: 'home'
  1063. };
  1064. from.merchantId = this.merchant.id;
  1065. req.getRequest('/api/activity/list', from, data => {
  1066. data = data.map(it => {
  1067. it.isRemind = it.remindId;
  1068. return it;
  1069. });
  1070. let arrObjFilter;
  1071. arrObjFilter = {
  1072. displayStyle: customersTemplate.theme,
  1073. lineNumber: customersTemplate.lineNumber,
  1074. products: data.filter(ele => ele.end == false)
  1075. };
  1076. _ts.setData({
  1077. customersList: arrObjFilter,
  1078. customersShow: true
  1079. });
  1080. _ts.initGroupTimer(4);
  1081. });
  1082. }
  1083. },
  1084. getSupRecommendList() {
  1085. return new Promise((resolve, reject) => {
  1086. req.getRequest('/api/supplier/recommend', {}, res => {
  1087. if (res && res.length > 0) {
  1088. this.supRecommendList = res;
  1089. this.supRecommendShow = true;
  1090. }
  1091. });
  1092. });
  1093. },
  1094. // 获取专题
  1095. getSpecialList(special) {
  1096. let that = this;
  1097. let form = {
  1098. page: 1,
  1099. limit: special.number
  1100. };
  1101. req.getRequest('/api/special/list', form, data => {
  1102. if (data) {
  1103. that.setData({
  1104. specialList: data
  1105. });
  1106. }
  1107. });
  1108. },
  1109. getUrl2(e) {
  1110. // 2 普通产品详情 4社区团购产品详情 5优惠券列表 6直播列表 7社区团购列表 9分类列表 10直播间 11拼团列表 12秒杀列表 13砍价列表 14新客列表 15新客详情 16秒杀详情 17砍价详情 18 拼团详情
  1111. var dt = e.currentTarget.dataset;
  1112. var url = '';
  1113. var id = '';
  1114. var acid = '';
  1115. if (dt.content != '') {
  1116. let conunt = dt.content.split('_');
  1117. id = conunt[1];
  1118. acid = conunt[0];
  1119. }
  1120. if (dt.type * 1 == 2 && dt.content != '') {
  1121. url = 'product/detail/detail?id=' + dt.content;
  1122. } else if (dt.type * 1 == 4) {
  1123. url = 'product/groupDetail/groupDetail?acid=' + acid + '&id=' + id;
  1124. } else if (dt.type * 1 == 5) {
  1125. url = 'product/coupon/coupon';
  1126. } else if (dt.type * 1 == 6) {
  1127. url = 'pages/live/live';
  1128. } else if (dt.type * 1 == 7) {
  1129. url = 'product/groupList/groupList' + dt.merchant;
  1130. } else if (dt.type * 1 == 9 && dt.content != '') {
  1131. url = 'product/list/list?id=' + dt.content;
  1132. } else if (dt.type * 1 == 10) {
  1133. url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + dt.content;
  1134. // console.log(
  1135. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  1136. } else if (dt.type * 1 == 11) {
  1137. url = 'activity/group/index/index' + dt.merchant;
  1138. } else if (dt.type * 1 == 12) {
  1139. url = 'activity/seckill/seckill' + dt.merchant;
  1140. } else if (dt.type * 1 == 13) {
  1141. url = 'activity/bargain/index/index' + dt.merchant;
  1142. } else if (dt.type * 1 == 14) {
  1143. url = 'activity/newbornZone/newbornZone' + dt.merchant;
  1144. } else if (dt.type * 1 == 15 && dt.content != '') {
  1145. url = 'activity/newbornDetails/newbornDetails?acid=' + acid + '&id=' + id;
  1146. } else if (dt.type * 1 == 16 && dt.content != '') {
  1147. url = 'activity/seckillDetails/seckillDetails?acid=' + acid + '&id=' + id;
  1148. } else if (dt.type * 1 == 17 && dt.content != '') {
  1149. url = 'activity/bargain/detail/detail?acid=' + acid + '&id=' + id;
  1150. } else if (dt.type * 1 == 18 && dt.content != '') {
  1151. url = 'activity/group/detail/detail?acid=' + acid + '&id=' + id;
  1152. } else {
  1153. url = '';
  1154. }
  1155. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  1156. else app.globalData.openPage(url);
  1157. this.hideAd();
  1158. },
  1159. //获取首页模板配置
  1160. getHomeTemplateConfig() {
  1161. let _ts = this;
  1162. let page = 'index';
  1163. //荣康模板配置、小店产品==门店产品
  1164. // if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) page = 'shopIndex'
  1165. req.getRequest(
  1166. '/api/template/getTemplate',
  1167. {
  1168. page: page
  1169. },
  1170. data => {
  1171. let arr = [];
  1172. data.forEach(it => {
  1173. arr.push(it.module);
  1174. });
  1175. this.setData({
  1176. contact: [...new Set(arr)],
  1177. contactShow: false
  1178. });
  1179. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
  1180. this.top = false;
  1181. } else {
  1182. this.top = true;
  1183. }
  1184. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
  1185. this.top_type = false;
  1186. } else {
  1187. this.top_type = true;
  1188. }
  1189. console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1, this.contact.indexOf('type_district') != -1, this.top);
  1190. console.log(this.contact);
  1191. this.setData({
  1192. homeTemplate: data
  1193. });
  1194. this.getRqeDatas();
  1195. }
  1196. );
  1197. },
  1198. //社区团购商品
  1199. loadGroup(groupTemplate) {
  1200. let _ts = this;
  1201. _ts.clearAllTimer(1);
  1202. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1203. let from = {
  1204. page: this.page,
  1205. limit: groupTemplate.number,
  1206. type: 2,
  1207. merchantId: this.merchant.merchantDTO.id,
  1208. sid: this.merchant.id
  1209. };
  1210. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1211. req.getRequest('/api/shopProduct/list', from, res => {
  1212. res = res.list.map(it => {
  1213. it.isRemind = it.remindId;
  1214. return it;
  1215. });
  1216. let arrObjFilter;
  1217. arrObjFilter = {
  1218. displayStyle: groupTemplate.theme,
  1219. lineNumber: groupTemplate.lineNumber,
  1220. products: res.filter(ele => ele.end == false)
  1221. };
  1222. this.setData({
  1223. activityGroup: arrObjFilter,
  1224. activityGroupShow: true
  1225. });
  1226. _ts.initGroupTimer(1);
  1227. });
  1228. }
  1229. if (this.merchant && this.merchant.type != 5) {
  1230. let from = {
  1231. page: 1,
  1232. limit: groupTemplate.number,
  1233. type: 1,
  1234. tag: 'home'
  1235. };
  1236. from.merchantId = this.merchant.id;
  1237. req.getRequest('/api/activity/list', from, data => {
  1238. data = data.map(it => {
  1239. it.isRemind = it.remindId;
  1240. return it;
  1241. });
  1242. data = {
  1243. displayStyle: groupTemplate.theme,
  1244. lineNumber: groupTemplate.lineNumber,
  1245. products: data
  1246. };
  1247. _ts.setData({
  1248. activityGroup: data,
  1249. activityGroupShow: true
  1250. });
  1251. _ts.initGroupTimer(1);
  1252. });
  1253. }
  1254. },
  1255. //拼团商品
  1256. joingroupListFun(joingroupTemplate) {
  1257. let _ts = this;
  1258. _ts.clearAllTimer(2);
  1259. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1260. let from = {
  1261. page: this.page,
  1262. limit: joingroupTemplate.number,
  1263. type: 4,
  1264. merchantId: this.merchant.merchantDTO.id,
  1265. sid: this.merchant.id
  1266. };
  1267. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1268. req.getRequest('/api/shopProduct/list', from, res => {
  1269. res = res.list.map(it => {
  1270. it.isRemind = it.remindId;
  1271. return it;
  1272. });
  1273. let arrObjFilter;
  1274. arrObjFilter = {
  1275. displayStyle: joingroupTemplate.theme,
  1276. lineNumber: joingroupTemplate.lineNumber,
  1277. products: res.filter(ele => ele.end == false)
  1278. };
  1279. this.setData({
  1280. joingroupList: arrObjFilter,
  1281. joingroupShow: true
  1282. });
  1283. _ts.initGroupTimer(2);
  1284. });
  1285. }
  1286. if (this.merchant && this.merchant.type != 5) {
  1287. let from = {
  1288. page: 1,
  1289. limit: joingroupTemplate.number,
  1290. type: 3,
  1291. dayType: 1,
  1292. tag: 'home'
  1293. };
  1294. from.merchantId = this.merchant.id;
  1295. req.getRequest('/api/activity/listNew', from, data => {
  1296. data = data.list.map(it => {
  1297. it.isRemind = it.remindId;
  1298. return it;
  1299. });
  1300. let arrObjFilter;
  1301. arrObjFilter = {
  1302. displayStyle: joingroupTemplate.theme,
  1303. lineNumber: joingroupTemplate.lineNumber,
  1304. products: data.filter(ele => ele.end == false)
  1305. };
  1306. _ts.setData({
  1307. joingroupList: arrObjFilter,
  1308. joingroupShow: true
  1309. });
  1310. _ts.initGroupTimer(2);
  1311. });
  1312. }
  1313. },
  1314. //砍价
  1315. bargainListFun(bargainTemplate) {
  1316. let _ts = this;
  1317. _ts.clearAllTimer(3);
  1318. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1319. let from = {
  1320. page: this.page,
  1321. limit: bargainTemplate.number,
  1322. type: 7,
  1323. merchantId: this.merchant.merchantDTO.id,
  1324. sid: this.merchant.id
  1325. };
  1326. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1327. req.getRequest('/api/shopProduct/list', from, res => {
  1328. res = res.list.map(it => {
  1329. it.isRemind = it.remindId;
  1330. return it;
  1331. });
  1332. let arrObjFilter;
  1333. arrObjFilter = {
  1334. displayStyle: bargainTemplate.theme,
  1335. lineNumber: bargainTemplate.lineNumber,
  1336. products: res.filter(ele => ele.end == false)
  1337. };
  1338. this.setData({
  1339. bargainList: arrObjFilter,
  1340. bargainShow: true
  1341. });
  1342. _ts.initGroupTimer(3);
  1343. });
  1344. }
  1345. if (this.merchant && this.merchant.type != 5) {
  1346. let from = {
  1347. page: 1,
  1348. limit: bargainTemplate.number,
  1349. type: 5,
  1350. tag: 'home'
  1351. };
  1352. from.merchantId = this.merchant.id;
  1353. req.getRequest('/api/activity/listNew', from, data => {
  1354. data = data.list.map(it => {
  1355. it.isRemind = it.remindId;
  1356. return it;
  1357. });
  1358. let arrObjFilter;
  1359. arrObjFilter = {
  1360. displayStyle: bargainTemplate.theme,
  1361. lineNumber: bargainTemplate.lineNumber,
  1362. products: data.filter(ele => ele.end == false)
  1363. };
  1364. _ts.setData({
  1365. bargainList: arrObjFilter,
  1366. bargainShow: true
  1367. });
  1368. _ts.initGroupTimer(3);
  1369. });
  1370. }
  1371. },
  1372. //秒杀商品
  1373. seckillListFun(seckillTemplate) {
  1374. let _ts = this;
  1375. _ts.clearAllTimer(5);
  1376. //获取小店推荐的产品
  1377. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1378. let from = {
  1379. page: this.page,
  1380. limit: seckillTemplate.number,
  1381. type: 3,
  1382. merchantId: this.merchant.merchantDTO.id,
  1383. sid: this.merchant.id
  1384. };
  1385. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1386. req.getRequest('/api/shopProduct/list', from, res => {
  1387. res = res.list.map(it => {
  1388. it.isRemind = it.remindId;
  1389. return it;
  1390. });
  1391. let arrObjFilter;
  1392. arrObjFilter = {
  1393. displayStyle: seckillTemplate.theme,
  1394. lineNumber: seckillTemplate.lineNumber,
  1395. products: res.filter(ele => ele.end == false)
  1396. };
  1397. this.setData({
  1398. seckillList: arrObjFilter,
  1399. seckillShow: true
  1400. });
  1401. _ts.initGroupTimer(5);
  1402. });
  1403. }
  1404. //获取门店推荐的产品
  1405. if (this.merchant && this.merchant.type != 5) {
  1406. let from = {
  1407. page: 1,
  1408. limit: seckillTemplate.number,
  1409. type: 2,
  1410. tag: 'home'
  1411. };
  1412. from.merchantId = this.merchant.id;
  1413. req.getRequest('/api/activity/list', from, res => {
  1414. res = res.map(it => {
  1415. it.num = (it.sellStock / it.quantity) * 100;
  1416. it.isRemind = it.remindId;
  1417. return it;
  1418. });
  1419. res.sort(function(a, b) {
  1420. return Date.parse(a.startTime) - Date.parse(b.startTime);
  1421. });
  1422. let arrObjFilter;
  1423. arrObjFilter = {
  1424. displayStyle: seckillTemplate.theme,
  1425. lineNumber: seckillTemplate.lineNumber,
  1426. products: res.filter(ele => ele.end == false)
  1427. };
  1428. _ts.setData({
  1429. seckillList: arrObjFilter,
  1430. seckillShow: true
  1431. });
  1432. _ts.initGroupTimer(5);
  1433. });
  1434. }
  1435. },
  1436. getConfig() {
  1437. var _this = this;
  1438. return new Promise((res, rej) => {
  1439. req.g(
  1440. '/api/config',
  1441. data => {
  1442. req.setStorage('configRes', JSON.stringify(data));
  1443. this.about = data;
  1444. if (!data.Index_Store_Confirm || data.Index_Store_Confirm == 0) {
  1445. _this.setData({
  1446. switchStoreShow: false,
  1447. storeShow: false
  1448. });
  1449. } else {
  1450. _this.setData({
  1451. switchStoreShow: true
  1452. });
  1453. }
  1454. // console.log(data.Index_Store_Confirm, "====", !data.Index_Store_Confirm, typeof(res
  1455. // .Index_Store_Confirm))
  1456. uni.setNavigationBarTitle({
  1457. // title: res['CONFIG_PROJECT_TITLE'],
  1458. title: data['CONFIG_PROJECT_TITLE']
  1459. });
  1460. // console.log(data.Is_Store_Price_Stock);
  1461. if (data.Is_Store_Price_Stock) {
  1462. this.Is_Store_Price_Stock = data.Is_Store_Price_Stock;
  1463. }
  1464. this.setData({
  1465. Is_Store_Price_Stock: data.Is_Store_Price_Stock
  1466. });
  1467. if (data.b2c_service_guarantee && data.b2c_service_guarantee != null) {
  1468. this.setData({
  1469. guarantee: data.b2c_service_guarantee.split(';').filter(it => {
  1470. return (it = it && it.trim());
  1471. })
  1472. });
  1473. }
  1474. req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
  1475. req.setStorage('productDiy', data['Product_Foot-Diy']);
  1476. res(data);
  1477. },
  1478. true
  1479. );
  1480. });
  1481. },
  1482. //1为社区团购,2为拼团,3为砍价
  1483. initGroupTimer(type) {
  1484. //社区拼图定时器
  1485. let _ts = this;
  1486. let list = [];
  1487. if (type == 1) list = this.activityGroup.products;
  1488. else if (type == 2) list = this.joingroupList.products;
  1489. else if (type == 3) list = this.bargainList.products;
  1490. else if (type == 4) list = this.customersList.products;
  1491. else if (type == 5) list = this.seckillList.products;
  1492. if (list && list.length > 0) {
  1493. // let activityGroup = this.data.activityGroup;
  1494. for (let i = 0, len = list.length; i < len; i++) {
  1495. let group = list[i];
  1496. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  1497. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  1498. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  1499. if (!group.start) endTime = startTime;
  1500. let times = parseInt((endTime - nowTime) / 1000);
  1501. let timer = setInterval(() => {
  1502. times--;
  1503. let data = {};
  1504. if (times === 0) {
  1505. //重新加载列表
  1506. if (type == 1) data['activityGroup.products[' + i + '].end'] = true;
  1507. else if (type == 2) data['joingroupList.products[' + i + '].end'] = true;
  1508. else if (type == 3) data['bargainList.products[' + i + '].end'] = true;
  1509. else if (type == 4) data['customersList.products[' + i + '].end'] = true;
  1510. else if (type == 5) data['seckillList.products[' + i + '].end'] = true;
  1511. clearInterval(timer);
  1512. } else {
  1513. let n = utils.formatDayTimes(times);
  1514. if (type == 1) data['activityGroup.products[' + i + '].times'] = n;
  1515. else if (type == 2) data['joingroupList.products[' + i + '].times'] = n;
  1516. else if (type == 3) data['bargainList.products[' + i + '].times'] = n.split(/:|天/g);
  1517. else if (type == 4) data['customersList.products[' + i + '].times'] = n;
  1518. else if (type == 5) data['seckillList.products[' + i + '].times'] = n;
  1519. }
  1520. _ts.setData(data);
  1521. }, 1000);
  1522. if (type == 1) this.activityGroup.products[i]['timer'] = timer;
  1523. else if (type == 2) this.joingroupList.products[i]['timer'] = timer;
  1524. else if (type == 3) this.bargainList.products[i]['timer'] = timer;
  1525. else if (type == 4) this.customersList.products[i]['timer'] = timer;
  1526. // let fs = [];
  1527. else if (type == 5) this.seckillList.products[i]['timer'] = timer;
  1528. // fs['activityGroup[' + i + '].timer'] = timer;
  1529. // _ts.setData(fs);
  1530. }
  1531. }
  1532. },
  1533. /**
  1534. * 轮播切换
  1535. */
  1536. // swiperChange({
  1537. // detail
  1538. // }) {
  1539. // // if (detail.source !== "touch") return;
  1540. // if (this.current == 0 && this.swiperCurrent > 1) {
  1541. // //卡死时,重置current为正确索引
  1542. // this.setData({
  1543. // current: this.swiperCurrent
  1544. // });
  1545. // } else {
  1546. // //正常轮转时,记录正确页码索引
  1547. // this.setData({
  1548. // swiperCurrent: detail.current
  1549. // });
  1550. // } // this.setData({
  1551. // // swiperCurrent: detail.current
  1552. // // })
  1553. // },
  1554. /**
  1555. * 轮播dots点击轮播
  1556. */
  1557. // dotEvent(e) {
  1558. // this.setData({
  1559. // current: e.currentTarget.dataset.current
  1560. // });
  1561. // },
  1562. search() {
  1563. // app.openPage('pages/search/search')
  1564. app.globalData.openPage('pages/search/search?merchantId=' + this.merchant.id);
  1565. },
  1566. merchantFun() {
  1567. app.globalData.openPage('pages/nearby/nearby');
  1568. },
  1569. saoma() {
  1570. var _this = this; // 允许从相机和相册扫码
  1571. uni.scanCode({
  1572. success: res => {
  1573. uni.navigateTo({
  1574. url: '/' + res.path
  1575. }); // this.scene = '1290926887903780865';
  1576. this.loadCodeParams();
  1577. }
  1578. });
  1579. },
  1580. update(content) {
  1581. var that = this;
  1582. var animation = uni.createAnimation(); // 旧消息向上平移
  1583. animation.translateY(-50).step({
  1584. duration: 1000,
  1585. timingFunction: 'ease-in'
  1586. }); // 为了实现下一条新内容向上平移的效果,必须把内容很快平移到下方,并且不能被用户看见,这里其原理类似轮播图的思路。
  1587. // 实现方法:动画时间设置为1ms,过渡效果设置为’动画第一帧就跳至结束状态直到结束‘
  1588. animation
  1589. .opacity(0)
  1590. .translateY(50)
  1591. .step({
  1592. duration: 1000,
  1593. timingFunction: 'step-start'
  1594. }); // 新消息向上平移的同时恢复透明
  1595. animation
  1596. .opacity(1)
  1597. .translateY(0)
  1598. .step({
  1599. duration: 1000,
  1600. timingFunction: 'ease-out'
  1601. });
  1602. that.setData({
  1603. animationData: animation.export()
  1604. }); // 更新内容的延时必须大于第一步动画时间
  1605. setTimeout(() => {
  1606. that.setData({
  1607. content: content
  1608. });
  1609. }, 500000);
  1610. },
  1611. getListInfo() {
  1612. if (this.listI >= this.contentList.length - 1) {
  1613. this.listI = -1;
  1614. this.getListInfo();
  1615. } else {
  1616. this.listI++;
  1617. }
  1618. return this.contentList[this.listI];
  1619. },
  1620. loadCodeParams() {
  1621. let _ts = this;
  1622. return new Promise((resolve, reject) => {
  1623. if (!_ts.scene) {
  1624. resolve();
  1625. return false;
  1626. }
  1627. req.getRequest(
  1628. '/api/code/params',
  1629. {
  1630. scene: _ts.scene
  1631. },
  1632. data => {
  1633. req.setStorage('pidCode', data.userId);
  1634. resolve();
  1635. }
  1636. );
  1637. });
  1638. },
  1639. getBannerList(module, contentId) {
  1640. //banner图
  1641. let that = this;
  1642. req.getRequest(
  1643. '/api/banner',
  1644. {
  1645. groupId: contentId
  1646. },
  1647. data => {
  1648. if (module == that.templateType.module_ad) {
  1649. that.setData({
  1650. bannerList: data,
  1651. bannerShow: true
  1652. });
  1653. } else {
  1654. that.setData({
  1655. popAdList: data[0]
  1656. });
  1657. }
  1658. }
  1659. );
  1660. },
  1661. getCategory() {
  1662. //产品分类
  1663. let that = this;
  1664. // if (this.districtTemplate) {
  1665. // } else {
  1666. req.getRequest(
  1667. '/api/category/list',
  1668. {
  1669. pid: 0
  1670. },
  1671. res => {
  1672. res = res.map((it, index) => {
  1673. it.index = index;
  1674. return it;
  1675. });
  1676. let newList = this.group(res, 8);
  1677. let data = newList; // .filter(it => it.length >= 8)
  1678. // console.log(newList, data, data.length);
  1679. if (data && data.length > 0 && data[0].length <= 4) {
  1680. this.setData({
  1681. swiperHeight: '100px'
  1682. });
  1683. } else {
  1684. this.setData({
  1685. swiperHeight: '200px'
  1686. });
  1687. }
  1688. that.setData({
  1689. categoryList: data
  1690. });
  1691. }
  1692. );
  1693. // }
  1694. },
  1695. getCoupon() {
  1696. return new Promise((resolve,reject)=>{
  1697. req.getRequest('/api/coupon/list', { page: 1, limit: 3 }, res => {
  1698. this.couponList = res;
  1699. resolve();
  1700. })
  1701. })
  1702. },
  1703. toCoupon() {
  1704. req.isLogin().then(success => {
  1705. if (success) {
  1706. app.globalData.openPage('product/coupon/coupon');
  1707. }
  1708. });
  1709. },
  1710. recieveCoupon(e) {
  1711. let index = e.currentTarget.dataset.index;
  1712. const coupon = this.couponList[index];
  1713. if (coupon.userReceive > -1 && coupon.userCount >= coupon.userReceive) {
  1714. return req.msg('超出优惠券领取限制,无法领取');
  1715. }
  1716. let _ts = this;
  1717. req.postRequest(
  1718. '/api/coupon/receive',
  1719. {
  1720. id: coupon.id
  1721. },
  1722. res => {
  1723. req.msg('领取成功', () => {
  1724. this.getCoupon();
  1725. });
  1726. }
  1727. );
  1728. },
  1729. getsupplierList(supplierTemplate) {
  1730. let form = {
  1731. page: 1,
  1732. limit: supplierTemplate.number,
  1733. merchantId: this.merchant.id,
  1734. supplier: supplierTemplate.contentId
  1735. }; // form.supplier="1351512705560240130"
  1736. req.getRequest('/api/product/list', form, res => {
  1737. res = res.map(it => {
  1738. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1739. return it;
  1740. });
  1741. res = {
  1742. displayStyle: supplierTemplate.theme,
  1743. lineNumber: supplierTemplate.lineNumber,
  1744. products: res
  1745. };
  1746. this.setData({
  1747. supplierList: res,
  1748. supplierShow: true
  1749. });
  1750. });
  1751. },
  1752. getBoutiqueList(boutiqueTemplate) {
  1753. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1754. let from = {
  1755. page: this.page,
  1756. limit: boutiqueTemplate.number,
  1757. type: 1,
  1758. merchantId: this.merchant.merchantDTO.id,
  1759. sid: this.merchant.id,
  1760. attr: 'boutique'
  1761. };
  1762. if (boutiqueTemplate.content != '') {
  1763. from.contentId = boutiqueTemplate.contentId;
  1764. }
  1765. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1766. req.getRequest('/api/shopProduct/list', from, res => {
  1767. res = res.map(it => {
  1768. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1769. return it;
  1770. });
  1771. res = {
  1772. displayStyle: boutiqueTemplate.theme,
  1773. lineNumber: boutiqueTemplate.lineNumber,
  1774. products: res
  1775. };
  1776. this.setData({
  1777. boutiqueList: res,
  1778. boutiqueShow: true
  1779. });
  1780. });
  1781. }
  1782. if (this.merchant && this.merchant.type != 5) {
  1783. let form = {
  1784. page: 1,
  1785. limit: boutiqueTemplate.number,
  1786. attr: 'boutique',
  1787. merchantId: this.merchant.id
  1788. };
  1789. if (boutiqueTemplate.content != '') {
  1790. form.contentId = boutiqueTemplate.contentId;
  1791. }
  1792. req.getRequest('/api/product/list', form, res => {
  1793. res = res.map(it => {
  1794. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1795. return it;
  1796. });
  1797. res = {
  1798. displayStyle: boutiqueTemplate.theme,
  1799. lineNumber: boutiqueTemplate.lineNumber,
  1800. products: res
  1801. };
  1802. this.setData({
  1803. boutiqueList: res,
  1804. boutiqueShow: true
  1805. });
  1806. });
  1807. }
  1808. },
  1809. // 新品上架
  1810. getArrivalsList(arrivalsTemplate) {
  1811. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1812. let from = {
  1813. page: this.page,
  1814. limit: arrivalsTemplate.number,
  1815. type: 1,
  1816. merchantId: this.merchant.merchantDTO.id,
  1817. sid: this.merchant.id,
  1818. attr: 'news'
  1819. };
  1820. if (arrivalsTemplate.content != '') {
  1821. from.contentId = arrivalsTemplate.contentId;
  1822. }
  1823. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1824. req.getRequest('/api/shopProduct/list', from, res => {
  1825. res = res.map(it => {
  1826. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1827. return it;
  1828. });
  1829. res = {
  1830. displayStyle: arrivalsTemplate.theme,
  1831. lineNumber: arrivalsTemplate.lineNumber,
  1832. products: res
  1833. };
  1834. this.setData({
  1835. arrivalsList: res,
  1836. arrivalsShow: true
  1837. });
  1838. });
  1839. }
  1840. if (this.merchant && this.merchant.type != 5) {
  1841. let form = {
  1842. page: 1,
  1843. limit: arrivalsTemplate.number,
  1844. attr: 'news',
  1845. merchantId: this.merchant.id
  1846. };
  1847. if (arrivalsTemplate.content != '') {
  1848. form.contentId = arrivalsTemplate.contentId;
  1849. }
  1850. req.getRequest('/api/product/list', form, res => {
  1851. res = res.map(it => {
  1852. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1853. return it;
  1854. });
  1855. res = {
  1856. displayStyle: arrivalsTemplate.theme,
  1857. lineNumber: arrivalsTemplate.lineNumber,
  1858. products: res
  1859. };
  1860. this.setData({
  1861. arrivalsList: res,
  1862. arrivalsShow: true
  1863. });
  1864. });
  1865. }
  1866. },
  1867. // 热门爆款
  1868. getHotList(hotTemplate) {
  1869. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1870. let from = {
  1871. page: this.page,
  1872. limit: hotTemplate.number,
  1873. type: 1,
  1874. merchantId: this.merchant.merchantDTO.id,
  1875. sid: this.merchant.id,
  1876. attr: 'sell_well'
  1877. };
  1878. if (hotTemplate.content != '') {
  1879. from.contentId = hotTemplate.contentId;
  1880. }
  1881. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1882. req.getRequest('/api/shopProduct/list', from, res => {
  1883. res = res.map(it => {
  1884. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1885. return it;
  1886. });
  1887. res = {
  1888. displayStyle: hotTemplate.theme,
  1889. lineNumber: hotTemplate.lineNumber,
  1890. products: res
  1891. };
  1892. this.setData({
  1893. hotList: res,
  1894. hotShow: true
  1895. });
  1896. });
  1897. }
  1898. if (this.merchant && this.merchant.type != 5) {
  1899. let form = {
  1900. page: 1,
  1901. limit: hotTemplate.number,
  1902. attr: 'sell_well',
  1903. merchantId: this.merchant.id
  1904. };
  1905. if (hotTemplate.content != '') {
  1906. form.contentId = hotTemplate.contentId;
  1907. }
  1908. req.getRequest('/api/product/list', form, res => {
  1909. res = res.map(it => {
  1910. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1911. return it;
  1912. });
  1913. res = {
  1914. displayStyle: hotTemplate.theme,
  1915. lineNumber: hotTemplate.lineNumber,
  1916. products: res
  1917. };
  1918. this.setData({
  1919. hotList: res,
  1920. hotShow: true
  1921. });
  1922. });
  1923. }
  1924. },
  1925. getPageList() {
  1926. //Recommend
  1927. // console.log(this.isLoad); // if (!this.data.isLoad) return false;
  1928. // this.data.isLoad = false;
  1929. let that = this;
  1930. console.log('门店' + this.merchantId);
  1931. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1932. let from = {
  1933. page: that.page,
  1934. limit: that.recommendTemplate.number,
  1935. type: 1,
  1936. merchantId: this.merchant.merchantDTO.id,
  1937. sid: this.merchant.id,
  1938. attr: 'Recommend'
  1939. };
  1940. if (that.recommendTemplate.content != '') {
  1941. from.contentId = that.recommendTemplate.contentId;
  1942. }
  1943. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  1944. req.getRequest('/api/shopProduct/list', from, data => {
  1945. if (data && data.length >= 10) that.isLoad = true;
  1946. if (that.page > 1) data = that.pageList.concat(data);
  1947. // console.log(data);
  1948. data = data.map(it => {
  1949. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1950. return it;
  1951. });
  1952. data = {
  1953. displayStyle: that.recommendTemplate.theme,
  1954. lineNumber: that.recommendTemplate.lineNumber,
  1955. products: data
  1956. };
  1957. that.setData({
  1958. pageList: data,
  1959. hasmore: data && data.length > 0,
  1960. recommendShow: true
  1961. });
  1962. });
  1963. }
  1964. if (this.merchant && this.merchant.type != 5) {
  1965. let form = {
  1966. page: that.page,
  1967. limit: that.recommendTemplate.number,
  1968. attr: 'Recommend',
  1969. merchantId: this.merchant.id
  1970. };
  1971. if (that.recommendTemplate.content != '') {
  1972. form.contentId = that.recommendTemplate.contentId;
  1973. }
  1974. req.getRequest('/api/product/list', form, res => {
  1975. if (res && res.length >= 10) that.isLoad = true;
  1976. if (that.page > 1) res = that.pageList.concat(res);
  1977. res = res.map(it => {
  1978. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  1979. return it;
  1980. });
  1981. res = {
  1982. displayStyle: that.recommendTemplate.theme,
  1983. lineNumber: that.recommendTemplate.lineNumber,
  1984. products: res
  1985. };
  1986. that.setData({
  1987. pageList: res,
  1988. hasmore: res && res.length > 0,
  1989. recommendShow: true
  1990. });
  1991. });
  1992. }
  1993. },
  1994. getSinglePageList() {
  1995. //Recommend
  1996. // console.log(this.isLoad); // if (!this.data.isLoad) return false;
  1997. // this.data.isLoad = false;
  1998. let that = this;
  1999. console.log('门店' + this.merchantId);
  2000. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2001. let from = {
  2002. page: that.singlePage,
  2003. limit: that.singleTemplate.number,
  2004. type: 1,
  2005. merchantId: this.merchant.merchantDTO.id,
  2006. sid: this.merchant.id
  2007. };
  2008. if (that.singleTemplate.content != '') {
  2009. from.contentId = that.singleTemplate.contentId;
  2010. delete from.attr;
  2011. } else {
  2012. from.attr = 'Recommend';
  2013. }
  2014. if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
  2015. req.getRequest('/api/shopProduct/list', from, data => {
  2016. if (data && data.length >= 10) that.isLoadSingle = true;
  2017. if (that.singlePage > 1) data = that.singleList.concat(data);
  2018. // console.log(data);
  2019. data = data.map(it => {
  2020. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  2021. return it;
  2022. });
  2023. data = {
  2024. displayStyle: that.singleTemplate.theme,
  2025. lineNumber: that.singleTemplate.lineNumber,
  2026. products: data
  2027. };
  2028. that.setData({
  2029. singleList: data,
  2030. hasmoreSingle: data && data.length > 0,
  2031. singleShow: true
  2032. });
  2033. });
  2034. }
  2035. if (this.merchant && this.merchant.type != 5) {
  2036. let form = {
  2037. page: that.singlePage,
  2038. limit: that.singleTemplate.number,
  2039. merchantId: this.merchant.id
  2040. };
  2041. if (that.singleTemplate.content != '') {
  2042. form.contentId = that.singleTemplate.contentId;
  2043. delete form.attr;
  2044. } else {
  2045. form.attr = 'Recommend';
  2046. }
  2047. req.getRequest('/api/product/list', form, res => {
  2048. if (res && res.length >= 10) that.isLoadSingle = true;
  2049. if (that.singlePage > 1) res = that.singleList.concat(res);
  2050. res = res.map(it => {
  2051. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  2052. return it;
  2053. });
  2054. res = {
  2055. displayStyle: that.singleTemplate.theme,
  2056. lineNumber: that.singleTemplate.lineNumber,
  2057. products: res
  2058. };
  2059. that.setData({
  2060. singleList: res,
  2061. hasmoreSingle: res && res.length > 0,
  2062. singleShow: true
  2063. });
  2064. });
  2065. }
  2066. },
  2067. toDetail(e) {
  2068. let id = e.currentTarget.dataset.id;
  2069. let url = e.currentTarget.dataset.url;
  2070. app.globalData.openPage('product/detail/detail?id=' + id + url); // app.openPage("product/detail/detail?id=" + id)
  2071. },
  2072. // 新客列表
  2073. tocustomersList(event) {
  2074. const index = event.currentTarget.dataset.index;
  2075. const activity = this.customersList.products[index];
  2076. const url = event.currentTarget.dataset.url;
  2077. app.globalData.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + "&id=" + activity.productId);
  2078. },
  2079. addShopCart(e) {
  2080. let state = e.currentTarget.dataset.state;
  2081. let skuId = e.currentTarget.dataset.skuid;
  2082. let id = e.currentTarget.dataset.id;
  2083. let _ts = this;
  2084. let params = {
  2085. skuId: skuId,
  2086. quantity: 1,
  2087. merchantId: this.merchant.id,
  2088. productId: id
  2089. }; // if(state!=1){
  2090. // return req.msg('您来晚了,商品已经下架')
  2091. // }
  2092. req.postRequest('/api/purchase/cart', params, res => {
  2093. _ts.setData({
  2094. isUpdate: !_ts.isUpdate
  2095. });
  2096. req.msg('加入购物车成功');
  2097. });
  2098. },
  2099. toGroupRemind(event) {
  2100. const index = event.currentTarget.dataset.index;
  2101. const activity = this.activityGroup.products[index];
  2102. const url = event.currentTarget.dataset.url;
  2103. app.globalData.openPage('product/groupDetail/groupDetail?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('product/groupDetail/groupDetail?acid=' + activity.id + "&id=" + activity.productId);
  2104. },
  2105. toSeckillList(event) {
  2106. const index = event.currentTarget.dataset.index;
  2107. const activity = this.seckillList[index];
  2108. const url = event.currentTarget.dataset.url;
  2109. app.globalData.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + "&id=" + activity.productId);
  2110. },
  2111. addActivityRemind(event) {
  2112. const index = event.currentTarget.dataset.index;
  2113. const id = event.currentTarget.dataset.id;
  2114. const type = event.currentTarget.dataset.type; // if(req.getStorage('userInfo')){
  2115. // }
  2116. req.postRequest(
  2117. '/api/activity/remind',
  2118. {
  2119. activityId: id
  2120. },
  2121. res => {
  2122. mes.remind().then(res => res);
  2123. // mes.remind().then(res=>res)
  2124. // mes.requsetmessage()
  2125. req.msg('订阅提醒成功');
  2126. let data = {};
  2127. if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = true;
  2128. else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = true;
  2129. else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = true;
  2130. else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = true;
  2131. else if (type == 5) data['customersList.products[' + index + '].isRemind'] = true;
  2132. this.setData(data);
  2133. }
  2134. );
  2135. },
  2136. // 九宫格
  2137. // dotGrid(e) {
  2138. // if (!this.districtTemplate) {
  2139. // if (this.categoryList[e.currentTarget.dataset.current].length <= 4) {
  2140. // this.setData({
  2141. // swiperHeight: '100px'
  2142. // })
  2143. // } else {
  2144. // this.setData({
  2145. // swiperHeight: '200px'
  2146. // })
  2147. // }
  2148. // } else {
  2149. // if (that.districtTemplate.content.lines == 2) {
  2150. // if (that.districtTemplate.lineNumber == 3) {
  2151. // if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset.current].flat(
  2152. // Infinity).length <= 3) {
  2153. // that.setData({
  2154. // swiperHeight: '120px'
  2155. // })
  2156. // } else {
  2157. // that.setData({
  2158. // swiperHeight: '216px'
  2159. // })
  2160. // }
  2161. // }
  2162. // if (that.districtTemplate.lineNumber == 4) {
  2163. // if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset.current].flat(
  2164. // Infinity).length <= 4) {
  2165. // that.setData({
  2166. // swiperHeight: '100px'
  2167. // })
  2168. // } else {
  2169. // that.setData({
  2170. // swiperHeight: '200px'
  2171. // })
  2172. // }
  2173. // }
  2174. // }
  2175. // }
  2176. // this.setData({
  2177. // swiperGrid: e.currentTarget.dataset.current
  2178. // });
  2179. // },
  2180. group(array, subGroupLength) {
  2181. let index = 0;
  2182. let newArray = [];
  2183. while (index < array.length) {
  2184. newArray.push(array.slice(index, (index += subGroupLength)));
  2185. }
  2186. return newArray;
  2187. },
  2188. cancelActivityRemind(event) {
  2189. const index = event.currentTarget.dataset.index;
  2190. const id = event.currentTarget.dataset.id;
  2191. const type = event.currentTarget.dataset.type;
  2192. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  2193. } else {
  2194. req.postRequest(
  2195. '/api/activity/cancel/remind',
  2196. {
  2197. id: id
  2198. },
  2199. res => {
  2200. req.msg('取消提醒成功');
  2201. let data = {};
  2202. if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = false;
  2203. else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = false;
  2204. else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = false;
  2205. else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = false;
  2206. else if (type == 5) data['customersList.products[' + index + '].isRemind'] = false;
  2207. this.setData(data);
  2208. }
  2209. );
  2210. }
  2211. },
  2212. clearAllTimer(type) {
  2213. // console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
  2214. if (type == 1) {
  2215. this.activityGroup.products.forEach(it => clearInterval(it.timer));
  2216. this.activityGroup.products.forEach(it => clearInterval(it.times));
  2217. } else if (type == 2) {
  2218. this.joingroupList.products.forEach(it => clearInterval(it.timer));
  2219. this.joingroupList.products.forEach(it => clearInterval(it.times));
  2220. } else if (type == 3) {
  2221. this.bargainList.products.forEach(it => clearInterval(it.timer));
  2222. this.bargainList.products.forEach(it => clearInterval(it.times));
  2223. } else if (type == 4) {
  2224. this.customersList.products.forEach(it => clearInterval(it.timer));
  2225. this.customersList.products.forEach(it => clearInterval(it.times));
  2226. } else if (type == 5) {
  2227. this.seckillList.products.forEach(it => clearInterval(it.timer));
  2228. this.seckillList.products.forEach(it => clearInterval(it.times));
  2229. }
  2230. },
  2231. hideGuide() {
  2232. //关闭提示加入我的小程序
  2233. this.setData({
  2234. first: false
  2235. });
  2236. req.setStorage('first', false);
  2237. },
  2238. hideAd() {
  2239. //关闭广告
  2240. // if(this.data.first==false){
  2241. this.setData({
  2242. isLayerAd: false
  2243. }); // }
  2244. app.globalData.isLayerAd = false;
  2245. },
  2246. click(e) {
  2247. // console.log(e)
  2248. this.storeShow = e;
  2249. },
  2250. goUrl(event) {
  2251. //跳转链接
  2252. let url = event.currentTarget.dataset.url;
  2253. app.globalData.openPage(url);
  2254. },
  2255. },
  2256. mounted() {
  2257. const systemInfo = uni.getSystemInfoSync();
  2258. // px转换到rpx的比例
  2259. let pxToRpxScale = 750 / systemInfo.windowWidth;
  2260. let systems = {
  2261. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  2262. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  2263. };
  2264. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  2265. this.systems = systems;
  2266. }
  2267. };
  2268. </script>
  2269. <style>
  2270. @import './index.css';
  2271. </style>