index.vue 71 KB

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