main.vue 72 KB

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