index.vue 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803
  1. <template>
  2. <view :style="[mainStyle]" v-if="showPage" style="background:#fff;">
  3. <view :class="'top-f' + (isScroll ? ' top-background' : '')" :style="'height:' + systems.barHeight + 'rpx;'"
  4. v-if="isSoution || (config&&config.is_hide_searchBox != 1)">
  5. <!-- #ifdef MP-WEIXIN -->
  6. <view class="top-nav ddflex"
  7. :style="'height:' + systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
  8. <view class="top-home ddflex" @click="jumpHome()" v-if="isSoution">
  9. <image :src="picUrlss+'lvluo/home_ico.png'"></image>
  10. </view>
  11. <view class="search ddflex" @click="jumpUrl('/pages/search/search')"
  12. v-if="config&&config.is_hide_searchBox != 1">
  13. <image src="../../static/pages/images/ssico_white.png"></image>
  14. <view>找药品/搜品牌</view>
  15. </view>
  16. </view>
  17. <!-- #endif -->
  18. <!-- #ifndef MP-WEIXIN -->
  19. <view class="top-navc ddflex"
  20. :style="'height:' + systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
  21. <view class="searchc ddflex" @click="jumpUrl('/pages/search/search')"
  22. v-if="config&&config.is_hide_searchBox != 1">
  23. <image src="../../static/pages/images/ssico_white.png"></image>
  24. <view>找药品/搜品牌</view>
  25. </view>
  26. </view>
  27. <!-- #endif -->
  28. </view>
  29. <view @touchstart="touchStart" @touchmove="move" @touchend="end">
  30. <view class="cons">
  31. <view :class="'banner'+(config.only_show_card == 1?' banner-bg':'')">
  32. <image :src="merchant.mainGraph" mode="aspectFill" :style="'height:'+(500+conTop) + 'rpx;'"
  33. :class="isPlay==1?'isPlay':isPlay==2?'isPlaasf':''"></image>
  34. </view>
  35. <!-- <view @click="saoma()" style="z-index: 999;position: relative;">扫码</view> -->
  36. <view class="con-ss" :style="'top:'+conTop+'rpx'">
  37. <view class="top">
  38. <view class="merchant ddflex" v-if="merchant">
  39. <image :src="merchant.logo" mode="aspectFill" class="m-logo"></image>
  40. <view class="fflex" v-if="merchant && merchant.title">
  41. <view class="m-name ddflex">
  42. <view class="fflex tover" @click="jumpUrl('/topic/about/about?id='+merchant.id)">
  43. {{ getMerchantTitle() }}
  44. </view>
  45. <view class="change ddflex" @click="merchantFun()" v-if="config.Many_Store == 1">
  46. <image src="../../static/pages/images/change.png"></image>
  47. </view>
  48. </view>
  49. <view class="poi" v-if="merchant.addressBrief || merchant.mDistance || merchant.range">
  50. <block v-if="merchant.addressBrief">{{merchant.addressBrief}}<text
  51. v-if="merchant.addressBrief&&(merchant.mDistance||merchant.range)">·</text>
  52. </block>
  53. <block v-if="merchant.mDistance||merchant.range">
  54. 距离{{merchant.mDistance < 1000 ? merchant.mDistance+'m' : merchant.range+'km'}}
  55. </block>
  56. </view>
  57. <view class="m-bot ddflex" v-if="merchant.label">
  58. <view class="m-tag ddflex fflex">
  59. <text v-for="(it,idx) in merchant.label.split(',')" :key="idx">{{it}}</text>
  60. </view>
  61. <!-- <image :src="picUrlss+'lvluo/gsjs_ico.png'" class="gsjs-ico" @click.stop="jumpUrl('/topic/about/about')"></image> -->
  62. </view>
  63. </view>
  64. <view class="fflex" v-else>
  65. <view class="m-name ddflex">
  66. 绿萝云·私域诊所系统
  67. <image src="../../static/pages/images/change.png"></image>
  68. </view>
  69. <view class="m-bot ddflex">
  70. <view class="m-tag ddflex fflex">
  71. <text>医疗营业许可</text>
  72. <text>到店分期</text>
  73. </view>
  74. <image :src="picUrlss+'lvluo/gsjs_ico.png'" class="gsjs-ico"
  75. @click.stop="jumpUrl('/topic/about/about')"></image>
  76. </view>
  77. </view>
  78. </view>
  79. <view :class="'card'+(config.only_show_card == 1?' card-spe':'')"
  80. :style="'height:'+cardHeight+'rpx;'">
  81. <image :src="picUrlss+'lvluo/logo_lv.png'" class="logo"></image>
  82. <image :src="picUrlss+'lvluo/card_logo.png'" mode="heightFix" class="card-logo"></image>
  83. <view class="card-top">
  84. <view class="card-no">NO.{{userinfoVip.userCode?userinfoVip.userCode:'000000'}}</view>
  85. <view class="card-info ddflex">
  86. <view class="fflex">
  87. <view class="card-name">{{userinfoVip.levelName?userinfoVip.levelName:'会员卡'}}
  88. </view>
  89. <view class="card-user">
  90. {{userinfoVip.realName?userinfoVip.realName:userinfoVip.nickName?userinfoVip.nickName:'代名'}}<text>{{userinfoVip.cardNo ? userinfoVip.cardNo:'8888**********8888'}}</text>
  91. </view>
  92. </view>
  93. <image :src="picUrlss +config.mainIconPath+ 'card_ma.png'" class="card-ma"
  94. @click="checkUpdate('/mine/payCode/payCode')" v-if="config.mainIconPath">
  95. </image>
  96. <image :src="picUrlss+ 'lvluo/card_ma.png'" class="card-ma"
  97. @click="checkUpdate('/mine/payCode/payCode')" v-else></image>
  98. </view>
  99. <image :src="userinfoVip.icon" mode="heightFix" class="vip-img" v-if="userinfoVip.icon">
  100. </image>
  101. </view>
  102. <view class="card-bot">
  103. <view class="datas ddflex">
  104. <view class="li" @click="checkUpdate('/wallet/index/index')">
  105. <view class="numbers" v-if="isShowBalance">
  106. {{userInfo.balance ? userInfo.balance : 0}}
  107. </view>
  108. <view class="numbers" v-else>****</view>
  109. <view class="ddflex">余额
  110. <image
  111. :src="picUrlss +config.mainIconPath+(isShowBalance?'eye_shows.png':'eye_hides.png')"
  112. class="card-eye" @click.stop="optBalance" v-if="config.mainIconPath">
  113. </image>
  114. <image
  115. :src="picUrlss +(isShowBalance?'lvluo/eye_shows.png':'lvluo/eye_hides.png')"
  116. class="card-eye" @click.stop="optBalance" v-else></image>
  117. </view>
  118. </view>
  119. <view class="li" @click="jumpUrl('/service/secondCard/secondCard')">
  120. <view class="numbers">{{cardCount?cardCount:0}}</view>
  121. <view>权益卡</view>
  122. </view>
  123. <view class="li" @click="jumpUrl('/mine/coupons/coupons')">
  124. <view class="numbers">{{userInfo.coupon?userInfo.coupon:0}}</view>
  125. <view>优惠券</view>
  126. </view>
  127. </view>
  128. <block v-if="config.is_not_fixed_contact == 1">
  129. <view class="zhuanshu-box" v-if="advisor&&advisor.id">
  130. <view class="zhuanshu-t ddflex">
  131. <image :src="picUrlss+config.mainIconPath+'card_zhuanshu.png'"
  132. v-if="config.mainIconPath"></image>
  133. <image :src="picUrlss+'lvluo/card_zhuanshu.png'" v-else></image>
  134. </view>
  135. <view class="zhuanshu-info ddflex" @click="jumpSingleChatRoom()">
  136. <image
  137. :src="advisor.headUrl ? advisor.headUrl : picUrlss+'lvluo/zhuanshu_img.png'"
  138. mode="aspectFill" class="zhuanshu-img"></image>
  139. <view class="fflex">
  140. <view class="zhuanshu-name ddflex">{{advisor.realName}}<text
  141. v-if="advisor.label">
  142. <block v-for="(it,idx) in advisor.label.split(',')" :key="idx"
  143. v-if="idx == 0">{{it}}</block>
  144. </text></view>
  145. <view class="zhuanshu-mobile tover">
  146. <!-- {{advisor.mobile}} -->{{advisor.merchantTitle}}
  147. </view>
  148. </view>
  149. <image :src="picUrlss+config.mainIconPath+'zhuanshu_weixin.png'"
  150. class="zhuanshu-weixin" v-if="config.mainIconPath"></image>
  151. <image :src="picUrlss+'lvluo/zhuanshu_weixin.png'" class="zhuanshu-weixin"
  152. v-else></image>
  153. </view>
  154. </view>
  155. <button open-type="contact" hover-class="none" class="zhuanshu-box" v-else>
  156. <view class="zhuanshu-t ddflex">
  157. <image :src="picUrlss+config.mainIconPath+'card_zhuanshu.png'"
  158. v-if="config.mainIconPath"></image>
  159. <image :src="picUrlss+'lvluo/card_zhuanshu.png'" v-else></image>
  160. </view>
  161. <view class="zhuanshu-info ddflex">
  162. <image :src="picUrlss+'lvluo/zhuanshu_img.png'" mode="aspectFill"
  163. class="zhuanshu-img"></image>
  164. <view class="fflex">
  165. <view class="zhuanshu-name ddflex">官方客服</view>
  166. </view>
  167. <image :src="picUrlss+config.mainIconPath+'zhuanshu_weixin.png'"
  168. class="zhuanshu-weixin" v-if="config.mainIconPath"></image>
  169. <image :src="picUrlss+'lvluo/zhuanshu_weixin.png'" class="zhuanshu-weixin"
  170. v-else></image>
  171. </view>
  172. </button>
  173. </block>
  174. <block v-else>
  175. <view class="zhuanshu-box" v-if="doctor&&doctor.id">
  176. <view class="zhuanshu-t1 ddflex">
  177. <image :src="picUrlss+config.mainIconPath+'card_zhuanshu.png'"
  178. v-if="config.mainIconPath"></image>
  179. <image :src="picUrlss+'lvluo/card_zhuanshu.png'" v-else></image>
  180. </view>
  181. <view class="zhuanshu-info ddflex"
  182. @click="jumpUrl('/topic/teacherDet/teacherDet?id='+doctor.id)">
  183. <image
  184. :src="doctor.headUrl ? doctor.headUrl : picUrlss+'lvluo/zhuanshu_img.png'"
  185. mode="aspectFill" class="zhuanshu-img"></image>
  186. <view class="fflex">
  187. <view class="zhuanshu-name ddflex">{{doctor.username}}<text
  188. v-if="doctor.label">
  189. <block v-for="(it,idx) in doctor.label.split(',')" :key="idx"
  190. v-if="idx == 0">{{it}}</block>
  191. </text></view>
  192. <view class="zhuanshu-mobile">{{doctor.mobile}}</view>
  193. </view>
  194. <image :src="picUrlss+config.mainIconPath+'zhuanshu_weixin.png'"
  195. class="zhuanshu-weixin" v-if="config.mainIconPath"></image>
  196. <image :src="picUrlss+'lvluo/zhuanshu_weixin.png'" class="zhuanshu-weixin"
  197. v-else></image>
  198. </view>
  199. </view>
  200. </block>
  201. </view>
  202. <!-- #ifdef MP-WEIXIN -->
  203. <button class="open-card ddflex" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
  204. hover-class="none"
  205. v-if="!userinfoVip.levelGrade || (userinfoVip.levelGrade > 0 && userinfoVip.end)">
  206. <image :src="picUrlss+'lvluo/open_ico.png'"></image>
  207. <view>一键领取会员卡</view>
  208. </button>
  209. <!-- #endif -->
  210. <!-- #ifndef MP-WEIXIN -->
  211. <view class="open-card ddflex" @click="getGVip()" hover-class="none"
  212. v-if="!userinfoVip.levelGrade || (userinfoVip.levelGrade > 0 && userinfoVip.end)">
  213. <image :src="picUrlss+'lvluo/open_ico.png'"></image>
  214. <view>一键领取会员卡</view>
  215. </view>
  216. <!-- #endif -->
  217. </view>
  218. </view>
  219. <view v-for="(item, index) in contact" :key="index">
  220. <storeOptions
  221. v-if="item == 'store_options' || (item == 'sou' && top) || (item == 'type_district' && top_type)"
  222. :storeTemplate="storeTemplate" :merchant="merchant" :about="about" :guarantee="guarantee"
  223. :sousuoTemplate="sousuoTemplate" :typeDistrictTemplate="typeDistrictTemplate" :url="site"
  224. :web="url" :cloud="header.appId == 'ZQ1VK5oc17I387E' ? 'default' : ''"></storeOptions>
  225. <!-- 多门店选择模板和搜索模板 -->
  226. <popAd v-if="item == 'home_pop_up_ads'" :first="first" :popAdTemplate="popAdTemplate"
  227. :isLayerAd="isLayerAd" :popAdList="popAdList" :iscouponAd="iscouponAd"
  228. :storeShow="storeShow"></popAd>
  229. <!-- 弹窗广告 -->
  230. <banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url"
  231. :config="about" :couponList="couponList" :officeList="officeList"
  232. :districtTemplate="districtTemplate"></banner>
  233. <!-- 走马灯 -->
  234. <bargain v-if="item == 'bargain' && bargainShow" :bargainList="bargainList" :url="site"
  235. :web="url" :bargainTemplate="bargainTemplate"></bargain>
  236. <!-- 砍价 -->
  237. <customers v-if="item == 'New_customers' && customersShow" :customersList="customersList"
  238. :url="site" :web="url" :customersTemplate="customersTemplate"></customers>
  239. <!-- 新客 -->
  240. <homecolumn v-if="item == 'homecolumn' && homecolumnShow" :homecolumnimg="homecolumnimg"
  241. :merchant-list="merchantList" :config="about"></homecolumn>
  242. <!-- 首页专区 -->
  243. <joingroup v-if="item == 'joingroup' && joingroupShow" :joingroupList="joingroupList"
  244. :url="site" :web="url" :joingroupTemplate="joingroupTemplate"></joingroup>
  245. <!-- 拼团 -->
  246. <group v-if="item == 'group' && activityGroupShow" :activityGroup="activityGroup" :url="site"
  247. :web="url" :groupTemplate="groupTemplate" :merchant="merchant" :freshen="freshen"></group>
  248. <!-- 社区团购 -->
  249. <!-- <pCategoryList
  250. v-if="item == 'p_list'"
  251. :homeTemplate="homeTemplate"
  252. :url="site"
  253. :web="url"
  254. :about="about"
  255. :templateType="templateType"
  256. :merchant="merchant"
  257. :freshen="freshen"
  258. :pCategoryList="pCategoryList"
  259. :pCategorShow="pCategorShow"
  260. ></pCategoryList> -->
  261. <block v-if="item == 'p_list'">
  262. <block v-for="(categoryItem, idx) in pCategoryList" :key="idx">
  263. <pCategoryList :homeTemplate="homeTemplate" :url="site" :web="url" :about="about"
  264. :templateType="templateType" :merchant="merchant" :freshen="freshen"
  265. :pCategorShow="categoryItem.pCategorShow" :categoryItem="categoryItem">
  266. </pCategoryList>
  267. </block>
  268. </block>
  269. <!-- 分类 -->
  270. <recommend v-if="item == 'recommend' && recommendShow" :pageList="pageList"
  271. :recommendTemplate="recommendTemplate" :url="site" :web="url" :about="about"
  272. :categoryList="categoryList"></recommend>
  273. <!-- 推荐 -->
  274. <seckill v-if="item == 'seckill' && seckillShow" :seckillList="seckillList" :url="site"
  275. :web="url" :seckillTemplate="seckillTemplate"></seckill>
  276. <!-- 秒杀 -->
  277. <selected v-if="item == 'chosen' && boutiqueShow" :boutiqueList="boutiqueList"
  278. :chosenTemplate="chosenTemplate" :url="site" :web="url" :about="about"></selected>
  279. <!-- 精选 -->
  280. <arrivals v-if="item == 'new_arrivals' && arrivalsShow" :arrivalsList="arrivalsList"
  281. :arrivalsTemplate="arrivalsTemplate" :url="site" :web="url" :about="about"></arrivals>
  282. <!-- 新品上架 -->
  283. <hot v-if="item == 'hot_money' && hotShow" :hotList="hotList" :hotTemplate="hotTemplate"
  284. :url="site" :web="url" :about="about"></hot>
  285. <!-- 热门爆款 -->
  286. <specialTopic v-if="item == 'special'" :specialList="specialList"></specialTopic>
  287. <!-- 专题 -->
  288. <redEnvelopes v-if="item == 'red_envelopes'" :storeShow="storeShow" :iscouponAd="iscouponAd"
  289. :first="first" :couponAd="couponAd" @iscouponAd="hidecouponAd"></redEnvelopes>
  290. <!-- 红包 -->
  291. <supplier v-if="item == 'supplier_premium' && supplierShow" :supplierTemplate="supplierTemplate"
  292. :web="merchant.type == 5 ? web : url" :supplierList="supplierList" :about="about">
  293. </supplier>
  294. <!-- 供应商优品 -->
  295. <district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url"
  296. :districtTemplate="districtTemplate"></district>
  297. <!-- 九宫格 金刚区 -->
  298. <suppliers v-if="item == 'sup_recommend' && supRecommendShow"
  299. :supRecommendList="supRecommendList" :url="site" :web="url"
  300. :supRecommendTemplate="supRecommendTemplate"></suppliers>
  301. <!-- 供应商推荐 -->
  302. <single v-if="item == 'single_product' && singleShow" :pageList="singleList"
  303. :singleTemplate="singleTemplate" :merchant="merchant" :url="site" :web="url" :about="about"
  304. :categoryList="categoryList"></single>
  305. <!-- 单产品推荐 -->
  306. </view>
  307. <content-list :pageList="contentList" :config="about" :content-obj="contentObj"
  308. v-if="contentList.length > 0"></content-list>
  309. <view class="bottom" v-if="config.company_permit">
  310. <view class="bot-name">{{config.company_permit.split(',')[0]}} </view>
  311. <view class="bot-xuke ddflex" v-if="config.company_permit.split(',').length>0">
  312. {{config.company_permit.split(',')[1]}}
  313. <image :src="picUrlss+'lvluo/bot_xuke.png'" @click="scanCode()"></image>
  314. </view>
  315. </view>
  316. </view>
  317. </view>
  318. </view>
  319. <block v-if="config.is_not_fixed_contact != 1">
  320. <block v-if="config.only_show_card == 1">
  321. <!-- :url="'/other/contact/index?id='+advisor.id" -->
  322. <navigator @click="jumpSingleChatRoom()" hover-class="none" class="contact contact-spe"
  323. v-if="advisor&&advisor.id">
  324. <image :src="advisor.headUrl ? advisor.headUrl : picUrlss+'lvluo/fixed_img1.png'" mode="aspectFill">
  325. </image>
  326. <view class="contact-text">
  327. <view class="tover">{{advisor.realName}}</view><text>服务顾问</text>
  328. </view>
  329. <view v-if="unReadSpotNum>0" class="newsDot"></view>
  330. </navigator>
  331. <button open-type="contact" hover-class="none" class="contact contact-spe" v-else>
  332. <image :src="picUrlss+'lvluo/fixed_img1.png'"></image>
  333. <view class="contact-text">杨经理<text>服务顾问</text></view>
  334. </button>
  335. </block>
  336. <block v-else>
  337. <!-- :url="'/other/contact/index?id='+advisor.id" -->
  338. <navigator @click="jumpSingleChatRoom()" hover-class="none" class="contact ddflex"
  339. v-if="advisor&&advisor.id">
  340. <image :src="advisor.headUrl ? advisor.headUrl : picUrlss+'lvluo/fixed_img1.png'" mode="aspectFill">
  341. </image>
  342. <view class="contact-text">服务<text>顾问</text></view>
  343. <view v-if="unReadSpotNum>0" style="left: 55rpx;" class="newsDot"></view>
  344. </navigator>
  345. <button open-type="contact" hover-class="none" class="contact ddflex" v-else>
  346. <image :src="picUrlss+'lvluo/fixed_img1.png'"></image>
  347. <view class="contact-text">服务<text>顾问</text></view>
  348. </button>
  349. </block>
  350. </block>
  351. <view class="more-fa ddflex" @click="jumpHome()" v-if="query.isJump">
  352. <image :src="picUrlss+'back_white.png'"></image>更多方案
  353. </view>
  354. <footer-copyright></footer-copyright>
  355. <!-- #ifndef APP-PLUS -->
  356. <foot channel="home" :isUpdate="isUpdate"></foot>
  357. <!-- #endif -->
  358. <view style="height: 170rpx;" v-if="(newsList.length>0 || unReadSpotNum>0)&&isShowNews"></view>
  359. <view class="bot-gg savepadding ddflex" :class="specClass"
  360. v-if="(newsList.length>0 || unReadSpotNum>0)&&isShowNews">
  361. <view class="gg-ico ddflex" v-if="unReadSpotNum>0&&swiperNewsCurrent!=0">
  362. <image src="../../static/images/ggico2.png"></image>
  363. </view>
  364. <view class="gg-ico ddflex" v-else>
  365. <image src="../../static/images/ggico1.png"></image>
  366. </view>
  367. <view class="fflex">
  368. <swiper class="shishic" vertical="true" :autoplay="true" duration="500" interval="4000" circular="true"
  369. :disable-touch="disableTouch" @change="swiperNewsChange">
  370. <swiper-item v-if="unReadSpotNum>0" class="li"
  371. @tap="jumpConversation()">您有{{unReadSpotNum}}条新消息</swiper-item>
  372. <block v-for="(item, index) in newsList" :key="index">
  373. <swiper-item class="li"
  374. @tap="jumpUrlNews('/'+item.url)">{{item.title}}:{{item.brief}}</swiper-item>
  375. </block>
  376. </swiper>
  377. </view>
  378. <image src="../../static/images/close1.png" class="gg-close" @click="closeNews"></image>
  379. </view>
  380. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate"
  381. @closeUpdate="closeUpdate"></update-userinfo>
  382. <privacy :is-update="true" @getLocations="initLocation"></privacy>
  383. </view>
  384. </template>
  385. <script>
  386. //index.js
  387. //获取应用实例
  388. const app = getApp();
  389. const req = require('../../utils/request.js');
  390. const api = require('../../utils/api.js');
  391. const utils = require('../../utils/util.js');
  392. const mes = require('../../utils/requestmessage.js');
  393. const route = require('../../utils/route');
  394. const QQMapWX = require('../../utils/qqmap.js');
  395. var timer; //定时器状态
  396. // let disp = require("../../hxChatSDK/utils/broadcast");
  397. import foot from '../../components/nav-bar/index';
  398. import footerCopyright from '../../components/footer-copyright/footer-copyright';
  399. import popAd from '../../template/popAd/popAd';
  400. import group from '../../template/activityGroup/activityGroup';
  401. import banner from '../../template/banner/banner';
  402. import bargain from '../../template/bargain/bargain';
  403. import customers from '../../template/customers/customers';
  404. import homecolumn from '../../template/homecolumn/homecolumn';
  405. import joingroup from '../../template/joingroup/joingroup';
  406. import pCategoryList from '../../template/pCategoryList/pCategoryList';
  407. import recommend from '../../template/recommend/recommend';
  408. import seckill from '../../template/seckill/seckill';
  409. import selected from '../../template/selected/selected';
  410. import arrivals from '../../template/arrivals/arrivals';
  411. import hot from '../../template/hot/hot';
  412. import specialTopic from '../../template/specialTopic/specialTopic';
  413. import storeOptions from '../../template/store_options/store_options';
  414. import redEnvelopes from '../../template/red_envelopes/index';
  415. import supplier from '../../template/supplier/supplier';
  416. import district from '../../template/king_kong_district/king_kong_district';
  417. import switchStore from '../../template/switchStore/switchStore';
  418. import suppliers from '../../template/suppliers/suppliers';
  419. import single from '../../template/single/single';
  420. import contentList from '../../template/contentList/index';
  421. export default {
  422. components: {
  423. foot,
  424. footerCopyright,
  425. banner,
  426. group,
  427. bargain,
  428. popAd,
  429. customers,
  430. homecolumn,
  431. joingroup,
  432. pCategoryList,
  433. recommend,
  434. seckill,
  435. selected,
  436. arrivals,
  437. hot,
  438. specialTopic,
  439. storeOptions,
  440. redEnvelopes,
  441. supplier,
  442. district,
  443. switchStore,
  444. suppliers,
  445. single,
  446. contentList
  447. },
  448. data() {
  449. return {
  450. mainStyle: app.globalData.mainStyle,
  451. isSoution: req.env[req.env.NODE_ENV].isSolution, //是否是方案库
  452. showPage: false,
  453. picUrlss: req.public.picUrls,
  454. isUpdate: false, // 是否更新消息
  455. query: '',
  456. config: '',
  457. systems: {},
  458. isScroll: false,
  459. merchant: '',
  460. cardHeight: 528,
  461. userinfoVip: {},
  462. userInfo: {},
  463. clientData: {
  464. // 用户手指Y轴
  465. clientStartY: '', //开始按下的位置
  466. clientMoveY: '', //按下
  467. clientEndY: '', //抬起
  468. // 页面Y轴
  469. pageY: ''
  470. },
  471. sheight: 100,
  472. isPlay: 0, //是否播放动画
  473. isRefresh: true,
  474. cardCount: '', //次卡数量
  475. isShowBalance: true,
  476. chatPrams: '', //客服类型
  477. conTop: '',
  478. pxToRpxScale: '', //比例
  479. doctor: '', //专属医生
  480. advisor: '', //服务顾问
  481. sessionKey: '',
  482. scene: '',
  483. poi: '',
  484. contact: [],
  485. bannerList: [],
  486. categoryList: [], //产品分类列表
  487. page: 1,
  488. boutiqueList: {}, //精品榜单
  489. arrivalsList: {},
  490. hotList: {},
  491. pageList: {}, //产品列表
  492. isLoad: true,
  493. hasmore: true,
  494. activityGroup: {
  495. products: []
  496. },
  497. couponList: {}, //优惠券,
  498. isRemind: false,
  499. first: true, //是否显示提示加入我的小程序
  500. isFirstLoadLocation: true, //加载定位并且拉取门店信息
  501. isLayerAd: true, //广告
  502. homeTemplate: [], //首页栏目配置
  503. pCategoryList: [],
  504. storeShow: true,
  505. joingroupList: {
  506. products: []
  507. },
  508. //拼团
  509. bargainList: {
  510. products: []
  511. },
  512. //砍价
  513. customersList: {
  514. products: []
  515. },
  516. //新客
  517. freshen: true,
  518. swiperHeight: 0,
  519. url: '',
  520. web: '',
  521. site: '',
  522. internet: '',
  523. storeTemplate: {},
  524. typeDistrictTemplate: {},
  525. sousuoTemplate: {},
  526. popAdTemplate: {},
  527. districtTemplate: {},
  528. timelyTemplate: {},
  529. homecolumnimg: [],
  530. customersTemplate: {},
  531. joingroupTemplate: {},
  532. supplierTemplate: {},
  533. seckillTemplate: {},
  534. bargainTemplate: {},
  535. specialTemplate: {},
  536. chosenTemplate: {},
  537. arrivalsTemplate: {},
  538. hotTemplate: {},
  539. groupTemplate: {},
  540. recommendTemplate: {},
  541. supRecommendTemplate: {},
  542. singleTemplate: {},
  543. specialList: [],
  544. seckillList: {
  545. products: []
  546. },
  547. about: {},
  548. Is_Store_Price_Stock: '',
  549. guarantee: [],
  550. current: '',
  551. animationData: '',
  552. content: '',
  553. popAdList: {},
  554. supplierList: {},
  555. supRecommendList: {},
  556. singlePage: 1,
  557. isLoadSingle: true,
  558. hasmoreSingle: true,
  559. singleList: {},
  560. iscouponAd: false,
  561. couponAd: {},
  562. logo: false,
  563. top: Boolean,
  564. top_type: Boolean,
  565. switchStoreShow: Boolean,
  566. bargainShow: Boolean,
  567. contactShow: true,
  568. seckillShow: false,
  569. joingroupShow: false,
  570. activityGroupShow: false,
  571. customersShow: false,
  572. homecolumnShow: false,
  573. districtShow: false,
  574. recommendShow: false,
  575. boutiqueShow: false,
  576. arrivalsShow: false,
  577. hotShow: false,
  578. supplierShow: false,
  579. supRecommendShow: false,
  580. singleShow: false,
  581. pCategorShow: false,
  582. bannerShow: false,
  583. List: [],
  584. marqueeOrderItemIndex: 0,
  585. marqueeOrderItem: '',
  586. officeList: [], //互动
  587. templateType: {
  588. module_ad: 'ad', //广告
  589. module_type_district: 'type_district', //分类导航
  590. module_p_list: 'p_list', //品类专区
  591. module_group: 'group', //团购
  592. module_live: 'live', //直播
  593. module_sou: 'sou', //搜索
  594. module_special: 'special', //专题
  595. module_chosen: 'chosen', //精选
  596. module_new_arrivals: 'new_arrivals', //新品上架
  597. module_hot_money: 'hot_money', //热门爆款
  598. module_recommend: 'recommend', //推荐产品
  599. module_store_options: 'store_options', //多门店选择
  600. module_home_pop_up_ads: 'home_pop_up_ads', //首页弹窗广告
  601. module_joingroup: 'joingroup', //拼团
  602. module_seckill: 'seckill', //秒杀
  603. module_bargain: 'bargain', //砍价
  604. module_customers: 'New_customers', //新客
  605. module_homecolumn: 'homecolumn', //首页专区
  606. module_supplier_premium: 'supplier_premium', //供应商模块
  607. module_red_envelopes: 'red_envelopes', //优惠券
  608. module_king_kong_district: 'king_kong_district', //金刚区
  609. module_sup_recommend: 'sup_recommend', //供应商推荐
  610. module_single_product: 'single_product' //供应商推荐
  611. },
  612. merchantList: [],
  613. specClass: 'hide',
  614. isShowNews: false,
  615. newsList: [], //公告
  616. unReadSpotNum: 0,
  617. swiperNewsCurrent: 0,
  618. isShowUpdate: false,
  619. isUpdateInfo: false,
  620. isUpdateMobile: false,
  621. contentList: [], //资讯
  622. contentObj: '', //资讯标题
  623. };
  624. },
  625. onLoad: async function(options) {
  626. // 如果是tab页面不往下执行跳转tab缓存页面
  627. await this.getConfig().then(async res => {
  628. if (req.isTabPage('home', this.config.solution_name)) {
  629. req.toTabBar('home', options)
  630. return false
  631. } else {
  632. console.log('onLoad onLoadPage options', options)
  633. this.onLoadPage(options)
  634. }
  635. });
  636. },
  637. onHide() {
  638. if (this.isPlay == 1) {
  639. this.isPlay = 2;
  640. }
  641. },
  642. async onShow() {
  643. // 如果是tab页面不往下执行跳转tab缓存页面
  644. await this.getConfig().then(async res => {
  645. if (req.isTabPage('home', this.config.solution_name)) {
  646. return false
  647. } else {
  648. this.onShowPage()
  649. }
  650. });
  651. },
  652. onShareAppMessage: function() {
  653. return {
  654. title: this.getShareTitle(),
  655. path: this.getSharePath()
  656. };
  657. },
  658. onShareTimeline() {
  659. return {
  660. title: this.getShareTitle(),
  661. query: this.getSharePath()
  662. };
  663. },
  664. onUnload() {
  665. this.isPlay = 2;
  666. },
  667. methods: {
  668. onLoadPage: async function(options) {
  669. console.log('options', options)
  670. if (options.appId) req.setStorage('appId', options.appId);
  671. this.query = options;
  672. // 获取配色后渲染页面
  673. if (app.globalData.mainStyle && Object.keys(app.globalData.mainStyle).length === 0)
  674. await app.globalData.upColor()
  675. this.mainStyle = app.globalData.mainStyle
  676. this.showPage = true
  677. if (options.scene) {
  678. this.scene = options.scene;
  679. await this.loadCode();
  680. } else {
  681. await req.silenceLogin(options.userId, '');
  682. }
  683. let isAuth = req.isAuth()
  684. console.log('req.isAuth() isAuth', isAuth)
  685. if (req.isAuth()) {
  686. this.getuserVip();
  687. this.getCardCount();
  688. await this.getUserInfo();
  689. this.getNews();
  690. this.onChatPageUnreadspot()
  691. }
  692. app.globalData.getCheckSessoin(json => {
  693. this.sessionKey = json.session_key;
  694. });
  695. },
  696. async onShowPage() {
  697. let _ts = this;
  698. _ts.getChatPrams();
  699. console.log('req.isAuth()==', req.isAuth())
  700. let isLogin = req.isAuth();
  701. if (isLogin) {
  702. _ts.getUserInfo();
  703. _ts.getuserVip();
  704. _ts.getCardCount();
  705. _ts.getNews();
  706. _ts.onChatPageUnreadspot()
  707. }
  708. await this.getConfig().then(async res => {
  709. // console.log('加载数据===========')
  710. // if (_ts.first && _ts.about.Many_Store == 1){
  711. // _ts.getLocation();
  712. // }
  713. if (_ts.isFirstLoadLocation) {
  714. _ts.isFirstLoadLocation = false;
  715. this.initLocation();
  716. }
  717. });
  718. },
  719. getToutiaoList() {
  720. let form = {
  721. page: 1,
  722. limit: 5,
  723. code: 'toutiao'
  724. }
  725. this.getToutiaoName();
  726. req.getRequest('/api/content/list', form, data => {
  727. this.contentList = data;
  728. })
  729. },
  730. getToutiaoName() {
  731. req.getRequest('/api/v2/category/list', {}, data => {
  732. if (data && data.length > 0) {
  733. data.map(it => {
  734. if (it.code == 'toutiao') this.contentObj = it
  735. })
  736. }
  737. })
  738. },
  739. getLocation() {
  740. // console.log('req.public.mapLBSKEY》》》》》》》》',req.public.mapLBSKEY);
  741. QQMapWX.initMap(req.public.mapLBSKEY);
  742. req.getLocation(res => {
  743. const to = {
  744. latitude: res.latitude,
  745. longitude: res.longitude
  746. };
  747. QQMapWX.reverseGeocoder(to, async resp => {});
  748. });
  749. },
  750. async initLocation() {
  751. let _ts = this;
  752. _ts.getMerchant();
  753. _ts.getToutiaoList();
  754. // await _ts.getMerchantList();
  755. if (this.config.only_show_card != 1) {
  756. await _ts.getHomeTemplateConfig();
  757. }
  758. if (this.isRefresh && this.config.only_show_card == 1) {
  759. await _ts.getViewInfo();
  760. }
  761. if (this.config.is_not_fixed_contact != 1) {
  762. await _ts.getDoctor();
  763. }
  764. await _ts.getAdvisor();
  765. console.log('数据>>>>>initLocation>>>>>44444')
  766. },
  767. onPageScrollPage(e) {
  768. this.clientData.pageY = e.scrollTop;
  769. if (e.scrollTop > this.sheight) {
  770. if (this.isPlay == 1) {
  771. this.isPlay = 2;
  772. }
  773. }
  774. if (this.isSoution || (this.config && this.config.is_hide_searchBox != 1)) {
  775. let height = this.systems.barHeight / this.pxToRpxScale;
  776. if (e.scrollTop > height) {
  777. this.isScroll = true;
  778. } else {
  779. this.isScroll = false;
  780. }
  781. }
  782. // console.log('开始滚动');
  783. // 只要滚动就清除状态
  784. clearTimeout(timer);
  785. // 告知标识 -> 开始滚动
  786. this.flag = false;
  787. this.specClass = 'show';
  788. // 检测是否停留了 N 秒
  789. // 如果停留则表示滚动结束
  790. // N: 500(定时器时间 毫秒) -> 0.5秒算停止滚动
  791. // 滚动后多长时间算停止滚动
  792. timer = setTimeout(() => {
  793. // console.log('结束滚动');
  794. // 告知标识 -> 结束滚动
  795. this.flag = true;
  796. this.specClass = 'hide';
  797. }, 500);
  798. this.$forceUpdate();
  799. },
  800. onShareAppMessagePage: function() {
  801. console.log('onShareAppMessagePage')
  802. return {
  803. title: this.getShareTitle(),
  804. path: this.getSharePath()
  805. };
  806. },
  807. onShareTimelinePage() {
  808. return {
  809. title: this.getShareTitle(),
  810. query: this.getSharePath()
  811. };
  812. },
  813. closeNews() {
  814. this.isShowNews = false;
  815. },
  816. // 公告
  817. getNews() {
  818. req.getRequest('/api/message/announcement', {}, data => {
  819. this.newsList = data;
  820. this.isShowNews = true
  821. })
  822. },
  823. // 消息
  824. onChatPageUnreadspot(message) {
  825. this.unReadSpotNum = getApp().globalData.unReadMessageNum > 99 ?
  826. "99+" : getApp().globalData.unReadMessageNum;
  827. if (this.unReadSpotNum > 0) this.isShowNews = true
  828. // setTimeout(()=>{
  829. // console.log('-------------------------------->onChatPageUnreadspot<---------------------------')
  830. // this.unReadSpotNum = 2
  831. // this.isShowNews = true
  832. // },1000)
  833. },
  834. jumpConversation() {
  835. if (!this.getUpdate()) return false;
  836. req.jumpConversation();
  837. },
  838. jumpSingleChatRoom() {
  839. if (!this.getUpdate()) return false;
  840. if (this.advisor) {
  841. req.jumpSingleChatRoom(this.advisor.id, this.advisor.headUrl, this.advisor
  842. .realName);
  843. }
  844. },
  845. swiperNewsChange(e) {
  846. this.swiperNewsCurrent = e.detail.current
  847. },
  848. jumpUrlNews(url, type) {
  849. if (!req.isLogin()) return false;
  850. if (type == 1) {
  851. uni.switchTab({
  852. url: url
  853. })
  854. } else {
  855. uni.navigateTo({
  856. url: url
  857. })
  858. }
  859. },
  860. loadCode() {
  861. let _ts = this;
  862. console.log('解码参数scene==', _ts.scene)
  863. return new Promise((resolve, reject) => {
  864. let form = {
  865. scene: _ts.scene
  866. };
  867. req.getRequest('/api/code/params', form, data => {
  868. console.log('解码参数==', data)
  869. req.silenceLogin(data.userId, '');
  870. req.setStorage('pidCode', data.userId);
  871. resolve();
  872. });
  873. });
  874. },
  875. getPhoneNumber(event) {
  876. // console.log('绑定手机号==',event)
  877. const detail = event.detail;
  878. const _ts = this;
  879. if (!detail || !detail.encryptedData || !detail.iv) return false;
  880. req.postRequest('/api/weixin/mobile', {
  881. encryptedData: detail.encryptedData,
  882. iv: detail.iv,
  883. sessionKey: _ts.sessionKey
  884. }, res => {
  885. console.log('res==', res)
  886. if (res.mobile) {
  887. var userInfo = req.getStorage('userInfo');
  888. userInfo.mobile = res.mobile;
  889. req.setStorage('userInfo', userInfo);
  890. _ts.jumpUrl('/open/info/index');
  891. }
  892. });
  893. },
  894. getGVip() {
  895. var userInfo = req.getStorage('userInfo');
  896. if (req.isLogins(true)) {
  897. if (userInfo.mobile) {
  898. this.jumpUrl('/open/info/index');
  899. } else { //弹出绑定手机号的窗口
  900. uni.showModal({
  901. title: '提示',
  902. content: '绑定手机号完成领取',
  903. cancelText: '取消',
  904. confirmText: '绑定领取',
  905. success(res) {
  906. if (res.confirm) {
  907. uni.navigateTo({
  908. url: '/topic/bind/index'
  909. })
  910. }
  911. }
  912. })
  913. }
  914. }
  915. },
  916. getDoctor() {
  917. return new Promise((resolve, reject) => {
  918. req.getRequest('/api/v3/user/doctor', {}, data => {
  919. console.log('医生==', data)
  920. this.doctor = data;
  921. resolve();
  922. })
  923. })
  924. },
  925. getAdvisor() {
  926. return new Promise((resolve, reject) => {
  927. req.getRequest('/api/distribution/advisorInfo', {}, data => {
  928. console.log('服务顾问==', data)
  929. this.advisor = data;
  930. resolve();
  931. })
  932. })
  933. },
  934. customerServiceChat() {
  935. let chatPrams = this.chatPrams;
  936. wx.openCustomerServiceChat({
  937. extInfo: {
  938. url: chatPrams.url
  939. },
  940. corpId: chatPrams.enterpriseId,
  941. success(res) {
  942. console.log('调用微信客服')
  943. }
  944. })
  945. },
  946. getChatPrams() {
  947. let that = this;
  948. let chatPrams = req.getStorage('chatService');
  949. if (chatPrams) {
  950. that.chatPrams = chatPrams;
  951. that.type = chatPrams.type;
  952. console.log('type==', that.type)
  953. that.$forceUpdate();
  954. }
  955. },
  956. optBalance() {
  957. this.isShowBalance = !this.isShowBalance;
  958. req.setStorage('isShowBalance', this.isShowBalance);
  959. },
  960. touchStart(e) {
  961. // console.log('开始移动==',e)
  962. this.clientData.clientStartY = e.changedTouches[0].clientY;
  963. },
  964. move(e) {
  965. // console.log('触摸移动==',e);
  966. if (this.clientData.pageY < 1) {
  967. let distance = e.changedTouches[0].clientY - this.clientData.clientStartY;
  968. if (this.isPlay != 1) {
  969. if (distance > 0) {
  970. if (distance > this.sheight) {
  971. this.conTop = this.sheight * this.pxToRpxScale;
  972. } else {
  973. this.conTop = distance * this.pxToRpxScale;
  974. }
  975. }
  976. }
  977. if (distance > this.sheight) {
  978. this.isPlay = 1;
  979. this.conTop = 0;
  980. } else {
  981. return;
  982. }
  983. }
  984. },
  985. // 手指抬起
  986. end(e) {
  987. let endY = e.changedTouches[0].clientY;
  988. let subY = endY - this.clientData.clientStartY;
  989. this.conTop = 0;
  990. if (subY < -50) {
  991. console.log('上滑')
  992. if (subY * -1 > this.sheight) {
  993. if (this.isPlay == 1) {
  994. uni.pageScrollTo({
  995. duration: 300,
  996. scrollTop: 0
  997. })
  998. this.isPlay = 2;
  999. }
  1000. }
  1001. } else if (subY > 50 && this.clientData.pageY < 1) {
  1002. console.log('下滑')
  1003. if (subY > this.sheight) {
  1004. this.isPlay = 1;
  1005. } else {
  1006. uni.pageScrollTo({
  1007. duration: 300,
  1008. scrollTop: 0
  1009. })
  1010. }
  1011. } else {
  1012. if (this.isPlay == 1) {
  1013. uni.pageScrollTo({
  1014. duration: 300,
  1015. scrollTop: 0
  1016. })
  1017. }
  1018. }
  1019. },
  1020. getUserInfo() {
  1021. return new Promise((resolve, reject) => {
  1022. req.getRequest('/api/user/my', {}, data => {
  1023. console.log('data==', data)
  1024. if (data && (data.avatar || data.mobile || data.nickName)) {
  1025. let userInfo = req.getStorage('userInfo');
  1026. if (data.avatar) userInfo.avatar = data.avatar;
  1027. if (data.mobile) userInfo.mobile = data.mobile;
  1028. if (data.nickName) userInfo.nickName = data.nickName;
  1029. req.setStorage('userInfo', userInfo)
  1030. }
  1031. this.userInfo = data;
  1032. if (req.getStorage('isShowBalance') != '') {
  1033. this.isShowBalance = req.getStorage('isShowBalance');
  1034. } else {
  1035. this.isShowBalance = true;
  1036. }
  1037. resolve();
  1038. })
  1039. })
  1040. },
  1041. getCardCount() {
  1042. req.getRequest('/api/v3/secondary/card/count', {}, data => {
  1043. this.cardCount = data;
  1044. })
  1045. },
  1046. getuserVip() {
  1047. return new Promise((resolve, reject) => {
  1048. req.getRequest('/api/user/levelDetails', {}, data => {
  1049. let expireTime = Array;
  1050. if (data.expireTime) {
  1051. expireTime = data.expireTime.split(' ');
  1052. data.expireTime = data.expireTime.replace(/-/g, '/');
  1053. }
  1054. let nowTime = new Date().getTime();
  1055. let endTime = new Date(data.expireTime).getTime();
  1056. let times = parseInt((endTime - nowTime) / 1000);
  1057. if (data.cardNo) data.cardNo = data.cardNo.replace(/(.{4}).*(.{4})/,
  1058. '$1********$2');
  1059. this.userinfoVip = data;
  1060. this.userinfoVip.expireTime = expireTime[0];
  1061. if (times <= 0) {
  1062. this.userinfoVip.end = true;
  1063. } else {
  1064. this.userinfoVip.end = false;
  1065. }
  1066. resolve();
  1067. });
  1068. })
  1069. },
  1070. getSharePath() {
  1071. let path = '';
  1072. let isSolution = '';
  1073. // #ifndef H5
  1074. isSolution = req.env[req.env.NODE_ENV].isSolution;
  1075. // #endif
  1076. // #ifdef H5
  1077. isSolution = false;
  1078. // #endif
  1079. if (isSolution) {
  1080. console.log('方案')
  1081. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + req.getStorage('userInfo')
  1082. .id;
  1083. } else {
  1084. path = '/pages/index/index?isShare=' + true + '&appId=' + req.getStorage('appId');
  1085. if (req.getStorage('userInfo')) {
  1086. path += '&userId=' + req.getStorage('userInfo').id;
  1087. }
  1088. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  1089. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  1090. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  1091. path += '&shopId=' + req.getStorage('smallShop').id;
  1092. }
  1093. }
  1094. }
  1095. console.log('path==', path)
  1096. return path;
  1097. },
  1098. getShareTitle() {
  1099. let title = '';
  1100. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  1101. title = this.merchant.title;
  1102. } else {
  1103. title = this.config.CONFIG_PROJECT_TITLE;
  1104. }
  1105. console.log('getShareTitle>>>>>>>>>' + title);
  1106. return (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage(
  1107. 'userInfo').nickName) : '') + '为你推荐' + title;
  1108. },
  1109. /**
  1110. * 显示门店标题
  1111. */
  1112. getMerchantTitle() {
  1113. let title = '';
  1114. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  1115. // if (this.merchant.title.length > 12) {
  1116. // title = this.merchant.title.substring(0, 12) + '...';
  1117. // } else {
  1118. title = this.merchant.title + (this.merchant.titleBrief ? '(' + this.merchant.titleBrief + ')' : '');
  1119. // }
  1120. } else {
  1121. title = this.config.CONFIG_PROJECT_TITLE;
  1122. }
  1123. return title;
  1124. },
  1125. callPhone() {
  1126. uni.makePhoneCall({
  1127. phoneNumber: this.merchant.phone
  1128. });
  1129. },
  1130. merchantFun() {
  1131. app.globalData.openPage('merchant/nearby/nearby');
  1132. },
  1133. getConfig() {
  1134. return new Promise((resolve, reject) => {
  1135. req.getRequest('/api/config', {}, data => {
  1136. req.setStorage('configRes', JSON.stringify(data));
  1137. this.config = data;
  1138. this.about = data;
  1139. resolve(data);
  1140. });
  1141. });
  1142. },
  1143. getMerchantList() {
  1144. let that = this;
  1145. let form = {
  1146. page: 1,
  1147. limie: 5
  1148. }
  1149. form.isBusiness = 1;
  1150. if (req.getStorage('loctionAddressMap')) {
  1151. form.lng = req.getStorage('loctionAddressMap').location.lng;
  1152. form.lat = req.getStorage('loctionAddressMap').location.lat;
  1153. }
  1154. req.getRequest('/api/merchant/page', form, data => {
  1155. console.log('门店列表==', data)
  1156. data.map(it => {
  1157. if (it.range > 0) it.range = parseFloat(it.range).toFixed(2), it.mDistance =
  1158. parseFloat(it.mDistance).toFixed(0);
  1159. return it;
  1160. });
  1161. that.merchantList = data
  1162. });
  1163. },
  1164. getMerchant() {
  1165. let _ts = this;
  1166. //获取默认的门店,确保进入到页面后能立即渲染数据
  1167. api.defaultMerchant(req, '', defaultRes => {
  1168. _ts.merchant = defaultRes;
  1169. console.log('获取的默认门店_ts.merchant======', defaultRes);
  1170. });
  1171. //使用定位获取门店
  1172. api.getMerchant('', req, data => {
  1173. console.log('===', data);
  1174. if (data == 1) {
  1175. if (_ts.about.Many_Store == 1) {
  1176. api.locationShow()
  1177. } else {
  1178. if (req.getStorage('defaultMerchant')) {
  1179. _ts.merchant = req.getStorage('defaultMerchant');
  1180. }
  1181. }
  1182. } else {
  1183. _ts.merchant = data;
  1184. }
  1185. console.log('通过定位逻辑再获取到的默认门店_ts.merchant======', _ts.merchant);
  1186. });
  1187. },
  1188. getViewInfo() {
  1189. let that = this;
  1190. const systemInfo = uni.getSystemInfoSync();
  1191. let pxToRpxScale = 750 / systemInfo.windowWidth;
  1192. return new Promise((resolve, reject) => {
  1193. const query = uni.createSelectorQuery().in(this);
  1194. query.select('.merchant').boundingClientRect(res => {
  1195. let height = res.height * pxToRpxScale + res.top * pxToRpxScale + 40
  1196. that.cardHeight = that.systems.windowHeight - height;
  1197. }).exec();
  1198. setTimeout(res => {
  1199. query.select('.bottom').boundingClientRect(data => {
  1200. let height = data.height * pxToRpxScale;
  1201. that.cardHeight = that.cardHeight - height - 115 - that.systems
  1202. .safeBottomHeight;
  1203. that.isRefresh = false;
  1204. }).exec();
  1205. }, 200)
  1206. resolve();
  1207. })
  1208. },
  1209. jumpVip(url) {
  1210. if (req.isLogins(true)) {
  1211. let userInfo = req.getStorage('userInfo');
  1212. if (userInfo.levelId && userInfo.levelId > 0) {
  1213. uni.navigateTo({
  1214. url: '/mine/vip/vip'
  1215. });
  1216. } else {
  1217. uni.navigateTo({
  1218. url: url
  1219. });
  1220. }
  1221. }
  1222. },
  1223. jumpUrl(url) {
  1224. if (req.isLogins(true)) {
  1225. uni.navigateTo({
  1226. url: url
  1227. });
  1228. }
  1229. },
  1230. scanCode() {
  1231. var _this = this; // 允许从相机和相册扫码
  1232. uni.scanCode({
  1233. success: res => {
  1234. console.log('扫码结果1111==', res)
  1235. let path = res.path.split('?scene=')[0];
  1236. let scene = res.path.split('?scene=')[1];
  1237. let paths = '/' + path + '?scene=' + encodeURIComponent(scene);
  1238. console.log('paths===', paths)
  1239. uni.navigateTo({
  1240. url: paths
  1241. });
  1242. }
  1243. });
  1244. },
  1245. jumpUrlColumn(item) {
  1246. app.globalData.clickBanner(item);
  1247. },
  1248. //获取首页模板配置
  1249. getHomeTemplateConfig() {
  1250. let _ts = this;
  1251. let page = 'shopIndex';
  1252. //荣康模板配置、小店产品==门店产品
  1253. req.getRequest(
  1254. '/api/template/getTemplate', {
  1255. page: page
  1256. },
  1257. data => {
  1258. let arr = [];
  1259. data.forEach(it => {
  1260. arr.push(it.module);
  1261. });
  1262. this.setData({
  1263. contact: [...new Set(arr)],
  1264. contactShow: false
  1265. });
  1266. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
  1267. this.top = false;
  1268. } else {
  1269. this.top = true;
  1270. }
  1271. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
  1272. this.top_type = false;
  1273. } else {
  1274. this.top_type = true;
  1275. }
  1276. console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1,
  1277. this.contact.indexOf('type_district') != -1, this.top);
  1278. console.log(this.contact);
  1279. this.setData({
  1280. homeTemplate: data
  1281. });
  1282. this.getRqeDatas();
  1283. }
  1284. );
  1285. },
  1286. async getRqeDatas() {
  1287. let that = this; //多门店
  1288. await that.getCategory();
  1289. let store = that.homeTemplate.filter(it => it.module == that.templateType.module_store_options);
  1290. that.setData({
  1291. storeTemplate: store[0]
  1292. }); //搜索
  1293. let sousuo = that.homeTemplate.filter(it => it.module == that.templateType.module_sou);
  1294. that.setData({
  1295. sousuoTemplate: sousuo[0]
  1296. });
  1297. //分类导航
  1298. let typeDistrict = that.homeTemplate.filter(it => it.module == that.templateType.module_type_district);
  1299. that.setData({
  1300. typeDistrictTemplate: typeDistrict[0]
  1301. });
  1302. //弹窗广告
  1303. let popAd = that.homeTemplate.filter(it => it.module == that.templateType.module_home_pop_up_ads);
  1304. if (popAd && popAd.length > 0 && popAd[0].state == 0) {
  1305. that.setData({
  1306. popAdTemplate: popAd[0]
  1307. });
  1308. if (that.freshen) {
  1309. await that.getBannerList(popAd[0].module, popAd[0].contentId);
  1310. }
  1311. }
  1312. // 金刚区
  1313. let district = that.homeTemplate.filter(it => it.module == that.templateType
  1314. .module_king_kong_district);
  1315. if (district && district.length > 0 && district[0].state == 0) {
  1316. let data = district[0];
  1317. data.content = JSON.parse(district[0].content);
  1318. that.districtTemplate = data;
  1319. if (data.contentId == 2) {
  1320. that.districtShow = true;
  1321. }
  1322. console.log(that.districtTemplate, '=============');
  1323. }
  1324. //顶部banner
  1325. let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
  1326. if (ad && ad.length > 0 && ad[0].state == 0) {
  1327. if (that.freshen) {
  1328. await that.getBannerList(ad[0].module, ad[0].contentId);
  1329. }
  1330. } //首页专区
  1331. let homecolumn = that.homeTemplate.filter(it => it.module == that.templateType.module_homecolumn);
  1332. if (homecolumn.length > 0 && homecolumn[0].state == 0) {
  1333. let homecolumnimg = JSON.parse(homecolumn[0].content).selectDataKingLength;
  1334. that.homecolumnimg = homecolumnimg;
  1335. that.homecolumnShow = true;
  1336. } // 新客
  1337. let customers = that.homeTemplate.filter(it => it.module == that.templateType.module_customers);
  1338. if (customers && customers.length > 0 && customers[0].state == 0) {
  1339. that.setData({
  1340. customersTemplate: customers[0]
  1341. });
  1342. await that.customersListFun(customers[0]);
  1343. } //拼团
  1344. let joingroup = that.homeTemplate.filter(it => it.module == that.templateType.module_joingroup);
  1345. if (joingroup && joingroup.length > 0 && joingroup[0].state == 0) {
  1346. that.setData({
  1347. joingroupTemplate: joingroup[0]
  1348. });
  1349. await that.joingroupListFun(joingroup[0]);
  1350. } // 供应商
  1351. let supplier = that.homeTemplate.filter(it => it.module == that.templateType.module_supplier_premium);
  1352. if (supplier && supplier.length > 0 && supplier[0].state == 0) {
  1353. that.setData({
  1354. supplierTemplate: supplier[0]
  1355. });
  1356. if (that.freshen) {
  1357. await that.getsupplierList(supplier[0]);
  1358. }
  1359. } //秒杀
  1360. let seckill = that.homeTemplate.filter(it => it.module == that.templateType.module_seckill);
  1361. if (seckill && seckill.length > 0 && seckill[0].state == 0) {
  1362. that.setData({
  1363. seckillTemplate: seckill[0]
  1364. });
  1365. await that.seckillListFun(seckill[0]);
  1366. } //砍价
  1367. let bargain = that.homeTemplate.filter(it => it.module == that.templateType.module_bargain);
  1368. if (bargain && bargain.length > 0 && bargain[0].state == 0) {
  1369. that.setData({
  1370. bargainTemplate: bargain[0]
  1371. });
  1372. await that.bargainListFun(bargain[0]);
  1373. } //专题
  1374. let special = that.homeTemplate.filter(it => it.module == that.templateType.module_special);
  1375. if (special && special.length > 0 && special[0].state == 0) {
  1376. that.setData({
  1377. specialTemplate: special[0]
  1378. });
  1379. if (that.freshen) {
  1380. await that.getSpecialList(special[0]);
  1381. }
  1382. } //精选
  1383. let chosen = that.homeTemplate.filter(it => it.module == that.templateType.module_chosen);
  1384. if (chosen && chosen.length > 0 && chosen[0].state == 0) {
  1385. that.setData({
  1386. chosenTemplate: chosen[0]
  1387. });
  1388. if (that.freshen) {
  1389. await that.getBoutiqueList(chosen[0]);
  1390. } // }
  1391. } //团购
  1392. //新品上架
  1393. let arrivals = that.homeTemplate.filter(it => it.module == that.templateType.module_new_arrivals);
  1394. if (arrivals && arrivals.length > 0 && arrivals[0].state == 0) {
  1395. that.setData({
  1396. arrivalsTemplate: arrivals[0]
  1397. });
  1398. if (that.freshen) {
  1399. await that.getArrivalsList(arrivals[0]);
  1400. } // }
  1401. }
  1402. //热门爆款
  1403. let hot = that.homeTemplate.filter(it => it.module == that.templateType.module_hot_money);
  1404. if (hot && hot.length > 0 && hot[0].state == 0) {
  1405. that.setData({
  1406. hotTemplate: hot[0]
  1407. });
  1408. if (that.freshen) {
  1409. await that.getHotList(hot[0]);
  1410. } // }
  1411. }
  1412. let group = that.homeTemplate.filter(it => it.module == that.templateType.module_group);
  1413. if (group && group.length > 0 && group[0].state == 0) {
  1414. that.setData({
  1415. groupTemplate: group[0]
  1416. });
  1417. await that.loadGroup(group[0]);
  1418. }
  1419. //推荐产品
  1420. let recommend = that.homeTemplate.filter(it => it.module == that.templateType.module_recommend);
  1421. if (recommend && recommend.length > 0 && recommend[0].state == 0) {
  1422. that.setData({
  1423. recommendTemplate: recommend[0]
  1424. });
  1425. if (that.freshen) {
  1426. await that.getPageList();
  1427. }
  1428. }
  1429. //单产品推荐
  1430. let single = that.homeTemplate.filter(it => it.module == that.templateType.module_single_product);
  1431. if (single && single.length > 0 && single[0].state == 0) {
  1432. that.setData({
  1433. singleTemplate: single[0]
  1434. });
  1435. if (that.freshen) {
  1436. await that.getSinglePageList();
  1437. }
  1438. }
  1439. //品类专区
  1440. let p_list = that.homeTemplate.filter(it => it.module == that.templateType.module_p_list && it.state ==
  1441. 0);
  1442. that.List = p_list;
  1443. if (that.freshen) {
  1444. // if (!that.pCategorShow) {
  1445. for (var i = 0; i < that.List.length; i++) {
  1446. await that.getPListProduct(that.List[i], i).then(data => {
  1447. data = data.map(it => {
  1448. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  1449. .isJs = true;
  1450. return it;
  1451. });
  1452. var res = {
  1453. displayStyle: that.List[i].theme,
  1454. lineNumber: that.List[i].lineNumber,
  1455. products: data
  1456. };
  1457. that.List[i].productList = res;
  1458. let arr = [];
  1459. that.List.forEach(it => {
  1460. if (it.productList) {
  1461. it.pCategorShow = true;
  1462. arr.push(it);
  1463. }
  1464. });
  1465. that.pCategoryList = that.List;
  1466. if (arr.length == that.List.length) {
  1467. that.pCategorShow = true;
  1468. }
  1469. });
  1470. await that.getCateCoupon(that.List[i], i).then(suc => {
  1471. that.List[i].couponList = suc;
  1472. })
  1473. }
  1474. }
  1475. // 红包优惠券
  1476. let coupon = that.homeTemplate.filter(it => it.module == that.templateType.module_red_envelopes && app
  1477. .globalData.isredenvelopes);
  1478. if (coupon && coupon.length > 0 && coupon[0].state == 0) {
  1479. if (!req.getStorage('userInfo')) {
  1480. that.setData({
  1481. iscouponAd: true,
  1482. couponAd: coupon[0]
  1483. });
  1484. } else {
  1485. req.getRequest(
  1486. '/api/coupon/checkCoupon', {
  1487. id: coupon[0].contentId
  1488. },
  1489. res => {
  1490. if (res == 1) {
  1491. that.setData({
  1492. iscouponAd: true,
  1493. couponAd: coupon[0]
  1494. });
  1495. } else if (res == 0) {
  1496. that.setData({
  1497. iscouponAd: false
  1498. });
  1499. }
  1500. }
  1501. );
  1502. }
  1503. } else {
  1504. that.iscouponAd = false;
  1505. }
  1506. // 供应商推荐
  1507. let supRecommend = that.homeTemplate.filter(it => it.module == that.templateType.module_sup_recommend);
  1508. if (supRecommend && supRecommend.length > 0 && supRecommend[0].state == 0) {
  1509. that.setData({
  1510. supRecommendTemplate: supRecommend[0]
  1511. });
  1512. if (that.freshen) {
  1513. await that.getSupRecommendList();
  1514. }
  1515. }
  1516. that.setData({
  1517. freshen: false
  1518. });
  1519. that.logo = true;
  1520. },
  1521. getBannerList(module, contentId) {
  1522. //banner图
  1523. let that = this;
  1524. return new Promise((resolve, reject) => {
  1525. req.getRequest(
  1526. '/api/banner', {
  1527. groupId: contentId
  1528. },
  1529. data => {
  1530. if (module == that.templateType.module_ad) {
  1531. that.setData({
  1532. bannerList: data,
  1533. bannerShow: true
  1534. });
  1535. } else {
  1536. that.setData({
  1537. popAdList: data[0]
  1538. });
  1539. }
  1540. resolve();
  1541. }
  1542. );
  1543. })
  1544. },
  1545. getCategory() {
  1546. //产品分类
  1547. let that = this;
  1548. return new Promise((resolve, reject) => {
  1549. req.getRequest(
  1550. '/api/category/list', {
  1551. pid: 0
  1552. },
  1553. res => {
  1554. if (res && res.length > 0) {
  1555. res = res.map((it, index) => {
  1556. it.index = index;
  1557. return it;
  1558. });
  1559. let newList = this.group(res, 8);
  1560. let data = newList;
  1561. if (data && data.length > 0 && data[0].length <= 4) {
  1562. this.setData({
  1563. swiperHeight: '100px'
  1564. });
  1565. } else {
  1566. this.setData({
  1567. swiperHeight: '200px'
  1568. });
  1569. }
  1570. that.setData({
  1571. categoryList: data
  1572. });
  1573. }
  1574. resolve();
  1575. }
  1576. );
  1577. })
  1578. },
  1579. //产品分类优惠券
  1580. getCateCoupon(pCategory, idx) {
  1581. let form = {
  1582. page: 1,
  1583. limit: 2,
  1584. categoryId: pCategory.contentId,
  1585. bindType: 'use'
  1586. }
  1587. return new Promise((resolve, reject) => {
  1588. req.getRequest('/api/coupon/list', form, data => {
  1589. resolve(data);
  1590. })
  1591. })
  1592. },
  1593. // 动态产品分类
  1594. getPListProduct(pCategory, idx) {
  1595. let that = this;
  1596. let pList = [];
  1597. let form = {
  1598. limit: pCategory.number,
  1599. categoryId: pCategory.contentId // isRecommend:1
  1600. };
  1601. //非小店
  1602. if (that.merchant && that.merchant.type != 5) {
  1603. form.merchantId = that.merchant.id;
  1604. return new Promise((resolve, reject) => {
  1605. req.getRequest('/api/product/list', form, data => {
  1606. resolve(data);
  1607. });
  1608. });
  1609. }
  1610. },
  1611. //新客
  1612. customersListFun(customersTemplate) {
  1613. let _ts = this;
  1614. _ts.clearAllTimer(4);
  1615. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1616. let from = {
  1617. page: this.page,
  1618. limit: customersTemplate.number,
  1619. type: 6,
  1620. merchantId: this.merchant.merchantDTO.id,
  1621. sid: this.merchant.id
  1622. };
  1623. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  1624. return new Promise((resolve, reject) => {
  1625. req.getRequest('/api/shopProduct/list', from, res => {
  1626. res = res.list.map(it => {
  1627. it.isRemind = it.remindId;
  1628. return it;
  1629. });
  1630. let arrObjFilter;
  1631. arrObjFilter = {
  1632. displayStyle: customersTemplate.theme,
  1633. lineNumber: customersTemplate.lineNumber,
  1634. products: res.filter(ele => ele.end == false)
  1635. };
  1636. this.setData({
  1637. customersList: arrObjFilter,
  1638. customersShow: true
  1639. });
  1640. _ts.initGroupTimer(4);
  1641. resolve();
  1642. });
  1643. })
  1644. }
  1645. if (this.merchant && this.merchant.type != 5) {
  1646. let from = {
  1647. page: 1,
  1648. limit: customersTemplate.number,
  1649. type: 4,
  1650. tag: 'home'
  1651. };
  1652. from.merchantId = this.merchant.id;
  1653. return new Promise((resolve, reject) => {
  1654. req.getRequest('/api/activity/list', from, data => {
  1655. data = data.map(it => {
  1656. it.isRemind = it.remindId;
  1657. return it;
  1658. });
  1659. let arrObjFilter;
  1660. arrObjFilter = {
  1661. displayStyle: customersTemplate.theme,
  1662. lineNumber: customersTemplate.lineNumber,
  1663. products: data.filter(ele => ele.end == false)
  1664. };
  1665. _ts.setData({
  1666. customersList: arrObjFilter,
  1667. customersShow: true
  1668. });
  1669. _ts.initGroupTimer(4);
  1670. resolve();
  1671. });
  1672. })
  1673. }
  1674. },
  1675. getSupRecommendList() {
  1676. return new Promise((resolve, reject) => {
  1677. req.getRequest('/api/supplier/recommend', {}, res => {
  1678. if (res && res.length > 0) {
  1679. this.supRecommendList = res;
  1680. this.supRecommendShow = true;
  1681. }
  1682. });
  1683. });
  1684. },
  1685. // 获取专题
  1686. getSpecialList(special) {
  1687. let that = this;
  1688. let form = {
  1689. page: 1,
  1690. limit: special.number
  1691. };
  1692. return new Promise((resolve, reject) => {
  1693. req.getRequest('/api/special/list', form, async data => {
  1694. if (data) {
  1695. for (var i = 0; i < data.length; i++) {
  1696. await that.getSpecialProduct(data[i].id).then(datas => {
  1697. var res = {
  1698. displayStyle: datas.displayStyle,
  1699. lineNumber: datas.lineNumber,
  1700. products: datas.products
  1701. };
  1702. data[i].productList = res;
  1703. that.specialList = data
  1704. });
  1705. }
  1706. }
  1707. resolve();
  1708. });
  1709. })
  1710. },
  1711. getSpecialProduct(id) {
  1712. let form = {
  1713. id: id,
  1714. page: 1,
  1715. limit: 6
  1716. }
  1717. return new Promise((resolve, reject) => {
  1718. req.getRequest('/api/special/detail', form, data => {
  1719. resolve(data);
  1720. })
  1721. })
  1722. },
  1723. //社区团购商品
  1724. loadGroup(groupTemplate) {
  1725. let _ts = this;
  1726. _ts.clearAllTimer(1);
  1727. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1728. let from = {
  1729. page: this.page,
  1730. limit: groupTemplate.number,
  1731. type: 2,
  1732. merchantId: this.merchant.merchantDTO.id,
  1733. sid: this.merchant.id
  1734. };
  1735. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  1736. return new Promise((resolve, reject) => {
  1737. req.getRequest('/api/shopProduct/list', from, res => {
  1738. res = res.list.map(it => {
  1739. it.isRemind = it.remindId;
  1740. return it;
  1741. });
  1742. let arrObjFilter;
  1743. arrObjFilter = {
  1744. displayStyle: groupTemplate.theme,
  1745. lineNumber: groupTemplate.lineNumber,
  1746. products: res.filter(ele => ele.end == false)
  1747. };
  1748. this.setData({
  1749. activityGroup: arrObjFilter,
  1750. activityGroupShow: true
  1751. });
  1752. _ts.initGroupTimer(1);
  1753. resolve();
  1754. });
  1755. })
  1756. }
  1757. if (this.merchant && this.merchant.type != 5) {
  1758. let from = {
  1759. page: 1,
  1760. limit: groupTemplate.number,
  1761. type: 1,
  1762. tag: 'home'
  1763. };
  1764. from.merchantId = this.merchant.id;
  1765. return new Promise((resolve, reject) => {
  1766. req.getRequest('/api/activity/list', from, data => {
  1767. data = data.map(it => {
  1768. it.isRemind = it.remindId;
  1769. return it;
  1770. });
  1771. data = {
  1772. displayStyle: groupTemplate.theme,
  1773. lineNumber: groupTemplate.lineNumber,
  1774. products: data
  1775. };
  1776. _ts.setData({
  1777. activityGroup: data,
  1778. activityGroupShow: true
  1779. });
  1780. _ts.initGroupTimer(1);
  1781. resolve();
  1782. });
  1783. })
  1784. }
  1785. },
  1786. //拼团商品
  1787. joingroupListFun(joingroupTemplate) {
  1788. let _ts = this;
  1789. _ts.clearAllTimer(2);
  1790. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1791. let from = {
  1792. page: this.page,
  1793. limit: joingroupTemplate.number,
  1794. type: 4,
  1795. merchantId: this.merchant.merchantDTO.id,
  1796. sid: this.merchant.id
  1797. };
  1798. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  1799. return new Promise((resolve, reject) => {
  1800. req.getRequest('/api/shopProduct/list', from, res => {
  1801. res = res.list.map(it => {
  1802. it.isRemind = it.remindId;
  1803. return it;
  1804. });
  1805. let arrObjFilter;
  1806. arrObjFilter = {
  1807. displayStyle: joingroupTemplate.theme,
  1808. lineNumber: joingroupTemplate.lineNumber,
  1809. products: res.filter(ele => ele.end == false)
  1810. };
  1811. this.setData({
  1812. joingroupList: arrObjFilter,
  1813. joingroupShow: true
  1814. });
  1815. _ts.initGroupTimer(2);
  1816. resolve();
  1817. });
  1818. })
  1819. }
  1820. if (this.merchant && this.merchant.type != 5) {
  1821. let from = {
  1822. page: 1,
  1823. limit: joingroupTemplate.number,
  1824. type: 3,
  1825. dayType: 1,
  1826. tag: 'home'
  1827. };
  1828. from.merchantId = this.merchant.id;
  1829. return new Promise((resolve, reject) => {
  1830. req.getRequest('/api/activity/listNew', from, data => {
  1831. data = data.list.map(it => {
  1832. it.isRemind = it.remindId;
  1833. return it;
  1834. });
  1835. let arrObjFilter;
  1836. arrObjFilter = {
  1837. displayStyle: joingroupTemplate.theme,
  1838. lineNumber: joingroupTemplate.lineNumber,
  1839. products: data.filter(ele => ele.end == false)
  1840. };
  1841. _ts.setData({
  1842. joingroupList: arrObjFilter,
  1843. joingroupShow: true
  1844. });
  1845. _ts.initGroupTimer(2);
  1846. resolve();
  1847. });
  1848. })
  1849. }
  1850. },
  1851. //砍价
  1852. bargainListFun(bargainTemplate) {
  1853. let _ts = this;
  1854. _ts.clearAllTimer(3);
  1855. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1856. let from = {
  1857. page: this.page,
  1858. limit: bargainTemplate.number,
  1859. type: 7,
  1860. merchantId: this.merchant.merchantDTO.id,
  1861. sid: this.merchant.id
  1862. };
  1863. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  1864. return new Promise((resolve, reject) => {
  1865. req.getRequest('/api/shopProduct/list', from, res => {
  1866. res = res.list.map(it => {
  1867. it.isRemind = it.remindId;
  1868. return it;
  1869. });
  1870. let arrObjFilter;
  1871. arrObjFilter = {
  1872. displayStyle: bargainTemplate.theme,
  1873. lineNumber: bargainTemplate.lineNumber,
  1874. products: res.filter(ele => ele.end == false)
  1875. };
  1876. this.setData({
  1877. bargainList: arrObjFilter,
  1878. bargainShow: true
  1879. });
  1880. _ts.initGroupTimer(3);
  1881. resolve();
  1882. });
  1883. })
  1884. }
  1885. if (this.merchant && this.merchant.type != 5) {
  1886. let from = {
  1887. page: 1,
  1888. limit: bargainTemplate.number,
  1889. type: 5,
  1890. tag: 'home'
  1891. };
  1892. from.merchantId = this.merchant.id;
  1893. return new Promise((resolve, reject) => {
  1894. req.getRequest('/api/activity/listNew', from, data => {
  1895. data = data.list.map(it => {
  1896. it.isRemind = it.remindId;
  1897. return it;
  1898. });
  1899. let arrObjFilter;
  1900. arrObjFilter = {
  1901. displayStyle: bargainTemplate.theme,
  1902. lineNumber: bargainTemplate.lineNumber,
  1903. products: data.filter(ele => ele.end == false)
  1904. };
  1905. _ts.setData({
  1906. bargainList: arrObjFilter,
  1907. bargainShow: true
  1908. });
  1909. _ts.initGroupTimer(3);
  1910. resolve();
  1911. });
  1912. })
  1913. }
  1914. },
  1915. //秒杀商品
  1916. seckillListFun(seckillTemplate) {
  1917. let _ts = this;
  1918. _ts.clearAllTimer(5);
  1919. //获取小店推荐的产品
  1920. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  1921. let from = {
  1922. page: this.page,
  1923. limit: seckillTemplate.number,
  1924. type: 3,
  1925. merchantId: this.merchant.merchantDTO.id,
  1926. sid: this.merchant.id
  1927. };
  1928. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  1929. return new Promise((resolve, reject) => {
  1930. req.getRequest('/api/shopProduct/list', from, res => {
  1931. res = res.list.map(it => {
  1932. it.isRemind = it.remindId;
  1933. return it;
  1934. });
  1935. let arrObjFilter;
  1936. arrObjFilter = {
  1937. displayStyle: seckillTemplate.theme,
  1938. lineNumber: seckillTemplate.lineNumber,
  1939. products: res.filter(ele => ele.end == false)
  1940. };
  1941. this.setData({
  1942. seckillList: arrObjFilter,
  1943. seckillShow: true
  1944. });
  1945. _ts.initGroupTimer(5);
  1946. resolve();
  1947. });
  1948. })
  1949. }
  1950. //获取门店推荐的产品
  1951. if (this.merchant && this.merchant.type != 5) {
  1952. let from = {
  1953. page: 1,
  1954. limit: seckillTemplate.number,
  1955. type: 2,
  1956. tag: 'home'
  1957. };
  1958. from.merchantId = this.merchant.id;
  1959. return new Promise((resolve, reject) => {
  1960. req.getRequest('/api/activity/list', from, res => {
  1961. res = res.map(it => {
  1962. it.num = (it.sellStock / it.quantity) * 100;
  1963. it.isRemind = it.remindId;
  1964. return it;
  1965. });
  1966. res.sort(function(a, b) {
  1967. return Date.parse(a.startTime) - Date.parse(b.startTime);
  1968. });
  1969. let arrObjFilter;
  1970. arrObjFilter = {
  1971. displayStyle: seckillTemplate.theme,
  1972. lineNumber: seckillTemplate.lineNumber,
  1973. products: res.filter(ele => ele.end == false)
  1974. };
  1975. _ts.setData({
  1976. seckillList: arrObjFilter,
  1977. seckillShow: true
  1978. });
  1979. _ts.initGroupTimer(5);
  1980. resolve();
  1981. });
  1982. })
  1983. }
  1984. },
  1985. //1为社区团购,2为拼团,3为砍价
  1986. initGroupTimer(type) {
  1987. //社区拼图定时器
  1988. let _ts = this;
  1989. let list = [];
  1990. if (type == 1) list = this.activityGroup.products;
  1991. else if (type == 2) list = this.joingroupList.products;
  1992. else if (type == 3) list = this.bargainList.products;
  1993. else if (type == 4) list = this.customersList.products;
  1994. else if (type == 5) list = this.seckillList.products;
  1995. if (list && list.length > 0) {
  1996. // let activityGroup = this.data.activityGroup;
  1997. for (let i = 0, len = list.length; i < len; i++) {
  1998. let group = list[i];
  1999. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  2000. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  2001. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  2002. if (!group.start) endTime = startTime;
  2003. let times = parseInt((endTime - nowTime) / 1000);
  2004. let timer = setInterval(() => {
  2005. times--;
  2006. let data = {};
  2007. if (times === 0) {
  2008. //重新加载列表
  2009. if (type == 1) data['activityGroup.products[' + i + '].end'] = true;
  2010. else if (type == 2) data['joingroupList.products[' + i + '].end'] = true;
  2011. else if (type == 3) data['bargainList.products[' + i + '].end'] = true;
  2012. else if (type == 4) data['customersList.products[' + i + '].end'] = true;
  2013. else if (type == 5) data['seckillList.products[' + i + '].end'] = true;
  2014. clearInterval(timer);
  2015. } else {
  2016. let n = utils.formatDayTimes(times);
  2017. if (type == 1) data['activityGroup.products[' + i + '].times'] = n;
  2018. else if (type == 2) data['joingroupList.products[' + i + '].times'] = n;
  2019. else if (type == 3) data['bargainList.products[' + i + '].times'] = n.split(
  2020. /:|天/g);
  2021. else if (type == 4) data['customersList.products[' + i + '].times'] = n;
  2022. else if (type == 5) data['seckillList.products[' + i + '].times'] = n;
  2023. }
  2024. _ts.setData(data);
  2025. }, 1000);
  2026. if (type == 1) this.activityGroup.products[i]['timer'] = timer;
  2027. else if (type == 2) this.joingroupList.products[i]['timer'] = timer;
  2028. else if (type == 3) this.bargainList.products[i]['timer'] = timer;
  2029. else if (type == 4) this.customersList.products[i]['timer'] = timer;
  2030. // let fs = [];
  2031. else if (type == 5) this.seckillList.products[i]['timer'] = timer;
  2032. // fs['activityGroup[' + i + '].timer'] = timer;
  2033. // _ts.setData(fs);
  2034. }
  2035. }
  2036. },
  2037. getsupplierList(supplierTemplate) {
  2038. let form = {
  2039. page: 1,
  2040. limit: supplierTemplate.number,
  2041. merchantId: this.merchant.id,
  2042. supplier: supplierTemplate.contentId
  2043. }; // form.supplier="1351512705560240130"
  2044. return new Promise((resolve, reject) => {
  2045. req.getRequest('/api/product/list', form, res => {
  2046. res = res.map(it => {
  2047. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2048. .isJs = true;
  2049. return it;
  2050. });
  2051. res = {
  2052. displayStyle: supplierTemplate.theme,
  2053. lineNumber: supplierTemplate.lineNumber,
  2054. products: res
  2055. };
  2056. this.setData({
  2057. supplierList: res,
  2058. supplierShow: true
  2059. });
  2060. resolve();
  2061. });
  2062. })
  2063. },
  2064. getBoutiqueList(boutiqueTemplate) {
  2065. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2066. let from = {
  2067. page: this.page,
  2068. limit: boutiqueTemplate.number,
  2069. type: 1,
  2070. merchantId: this.merchant.merchantDTO.id,
  2071. sid: this.merchant.id,
  2072. attr: 'boutique'
  2073. };
  2074. if (boutiqueTemplate.content != '') {
  2075. from.contentId = boutiqueTemplate.contentId;
  2076. }
  2077. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  2078. return new Promise((resolve, reject) => {
  2079. req.getRequest('/api/shopProduct/list', from, res => {
  2080. res = res.map(it => {
  2081. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2082. .isJs = true;
  2083. return it;
  2084. });
  2085. res = {
  2086. displayStyle: boutiqueTemplate.theme,
  2087. lineNumber: boutiqueTemplate.lineNumber,
  2088. products: res
  2089. };
  2090. this.setData({
  2091. boutiqueList: res,
  2092. boutiqueShow: true
  2093. });
  2094. resolve();
  2095. });
  2096. })
  2097. }
  2098. if (this.merchant && this.merchant.type != 5) {
  2099. let form = {
  2100. page: 1,
  2101. limit: boutiqueTemplate.number,
  2102. attr: 'boutique',
  2103. merchantId: this.merchant.id
  2104. };
  2105. if (boutiqueTemplate.content != '') {
  2106. form.contentId = boutiqueTemplate.contentId;
  2107. }
  2108. return new Promise((resolve, reject) => {
  2109. req.getRequest('/api/product/list', form, res => {
  2110. res = res.map(it => {
  2111. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2112. .isJs = true;
  2113. return it;
  2114. });
  2115. res = {
  2116. displayStyle: boutiqueTemplate.theme,
  2117. lineNumber: boutiqueTemplate.lineNumber,
  2118. products: res
  2119. };
  2120. this.setData({
  2121. boutiqueList: res,
  2122. boutiqueShow: true
  2123. });
  2124. resolve();
  2125. });
  2126. })
  2127. }
  2128. },
  2129. // 新品上架
  2130. getArrivalsList(arrivalsTemplate) {
  2131. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2132. let from = {
  2133. page: this.page,
  2134. limit: arrivalsTemplate.number,
  2135. type: 1,
  2136. merchantId: this.merchant.merchantDTO.id,
  2137. sid: this.merchant.id,
  2138. attr: 'news'
  2139. };
  2140. if (arrivalsTemplate.content != '') {
  2141. from.contentId = arrivalsTemplate.contentId;
  2142. }
  2143. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  2144. return new Promise((resolve, reject) => {
  2145. req.getRequest('/api/shopProduct/list', from, res => {
  2146. res = res.map(it => {
  2147. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2148. .isJs = true;
  2149. return it;
  2150. });
  2151. res = {
  2152. displayStyle: arrivalsTemplate.theme,
  2153. lineNumber: arrivalsTemplate.lineNumber,
  2154. products: res
  2155. };
  2156. this.setData({
  2157. arrivalsList: res,
  2158. arrivalsShow: true
  2159. });
  2160. resolve();
  2161. });
  2162. })
  2163. }
  2164. if (this.merchant && this.merchant.type != 5) {
  2165. let form = {
  2166. page: 1,
  2167. limit: arrivalsTemplate.number,
  2168. attr: 'news',
  2169. merchantId: this.merchant.id
  2170. };
  2171. if (arrivalsTemplate.content != '') {
  2172. form.contentId = arrivalsTemplate.contentId;
  2173. }
  2174. return new Promise((resolve, reject) => {
  2175. req.getRequest('/api/product/list', form, res => {
  2176. res = res.map(it => {
  2177. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2178. .isJs = true;
  2179. return it;
  2180. });
  2181. res = {
  2182. displayStyle: arrivalsTemplate.theme,
  2183. lineNumber: arrivalsTemplate.lineNumber,
  2184. products: res
  2185. };
  2186. this.setData({
  2187. arrivalsList: res,
  2188. arrivalsShow: true
  2189. });
  2190. resolve();
  2191. });
  2192. })
  2193. }
  2194. },
  2195. // 热门爆款
  2196. getHotList(hotTemplate) {
  2197. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2198. let from = {
  2199. page: this.page,
  2200. limit: hotTemplate.number,
  2201. type: 1,
  2202. merchantId: this.merchant.merchantDTO.id,
  2203. sid: this.merchant.id,
  2204. attr: 'sell_well'
  2205. };
  2206. if (hotTemplate.content != '') {
  2207. from.contentId = hotTemplate.contentId;
  2208. }
  2209. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  2210. return new Promise((resolve, reject) => {
  2211. req.getRequest('/api/shopProduct/list', from, res => {
  2212. res = res.map(it => {
  2213. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2214. .isJs = true;
  2215. return it;
  2216. });
  2217. res = {
  2218. displayStyle: hotTemplate.theme,
  2219. lineNumber: hotTemplate.lineNumber,
  2220. products: res
  2221. };
  2222. this.setData({
  2223. hotList: res,
  2224. hotShow: true
  2225. });
  2226. resolve();
  2227. });
  2228. })
  2229. }
  2230. if (this.merchant && this.merchant.type != 5) {
  2231. let form = {
  2232. page: 1,
  2233. limit: hotTemplate.number,
  2234. attr: 'sell_well',
  2235. merchantId: this.merchant.id
  2236. };
  2237. if (hotTemplate.content != '') {
  2238. form.contentId = hotTemplate.contentId;
  2239. }
  2240. return new Promise((resolve, reject) => {
  2241. req.getRequest('/api/product/list', form, res => {
  2242. res = res.map(it => {
  2243. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2244. .isJs = true;
  2245. return it;
  2246. });
  2247. res = {
  2248. displayStyle: hotTemplate.theme,
  2249. lineNumber: hotTemplate.lineNumber,
  2250. products: res
  2251. };
  2252. this.setData({
  2253. hotList: res,
  2254. hotShow: true
  2255. });
  2256. resolve();
  2257. });
  2258. })
  2259. }
  2260. },
  2261. getPageList() {
  2262. //Recommend
  2263. // console.log(this.isLoad); // if (!this.data.isLoad) return false;
  2264. // this.data.isLoad = false;
  2265. let that = this;
  2266. console.log('门店' + this.merchantId);
  2267. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2268. let from = {
  2269. page: that.page,
  2270. limit: that.recommendTemplate.number,
  2271. type: 1,
  2272. merchantId: this.merchant.merchantDTO.id,
  2273. sid: this.merchant.id,
  2274. attr: 'Recommend'
  2275. };
  2276. if (that.recommendTemplate.content != '') {
  2277. from.contentId = that.recommendTemplate.contentId;
  2278. }
  2279. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  2280. return new Promise((resolve, reject) => {
  2281. req.getRequest('/api/shopProduct/list', from, data => {
  2282. if (data && data.length >= 10) that.isLoad = true;
  2283. if (that.page > 1) data = that.pageList.concat(data);
  2284. // console.log(data);
  2285. data = data.map(it => {
  2286. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2287. .isJs = true;
  2288. return it;
  2289. });
  2290. data = {
  2291. displayStyle: that.recommendTemplate.theme,
  2292. lineNumber: that.recommendTemplate.lineNumber,
  2293. products: data
  2294. };
  2295. that.setData({
  2296. pageList: data,
  2297. hasmore: data && data.length > 0,
  2298. recommendShow: true
  2299. });
  2300. resolve();
  2301. });
  2302. })
  2303. }
  2304. if (this.merchant && this.merchant.type != 5) {
  2305. let form = {
  2306. page: that.page,
  2307. limit: that.recommendTemplate.number,
  2308. attr: 'Recommend',
  2309. merchantId: this.merchant.id
  2310. };
  2311. if (that.recommendTemplate.content != '') {
  2312. form.contentId = that.recommendTemplate.contentId;
  2313. }
  2314. return new Promise((resolve, reject) => {
  2315. req.getRequest('/api/product/list', form, res => {
  2316. if (res && res.length >= 10) that.isLoad = true;
  2317. if (that.page > 1) res = that.pageList.concat(res);
  2318. res = res.map(it => {
  2319. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2320. .isJs = true;
  2321. return it;
  2322. });
  2323. res = {
  2324. displayStyle: that.recommendTemplate.theme,
  2325. lineNumber: that.recommendTemplate.lineNumber,
  2326. products: res
  2327. };
  2328. that.setData({
  2329. pageList: res,
  2330. hasmore: res && res.length > 0,
  2331. recommendShow: true
  2332. });
  2333. resolve();
  2334. });
  2335. })
  2336. }
  2337. },
  2338. getSinglePageList() {
  2339. //Recommend
  2340. // console.log(this.isLoad); // if (!this.data.isLoad) return false;
  2341. // this.data.isLoad = false;
  2342. let that = this;
  2343. console.log('门店' + this.merchantId);
  2344. if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
  2345. let from = {
  2346. page: that.singlePage,
  2347. limit: that.singleTemplate.number,
  2348. type: 1,
  2349. merchantId: this.merchant.merchantDTO.id,
  2350. sid: this.merchant.id
  2351. };
  2352. if (that.singleTemplate.content != '') {
  2353. from.contentId = that.singleTemplate.contentId;
  2354. delete from.attr;
  2355. } else {
  2356. from.attr = 'Recommend';
  2357. }
  2358. if (this.shopId && this.merchantId)(from.merchantId = this.merchantId), (from.sid = this.shopId);
  2359. return new Promise((resolve, reject) => {
  2360. req.getRequest('/api/shopProduct/list', from, data => {
  2361. if (data && data.length >= 10) that.isLoadSingle = true;
  2362. if (that.singlePage > 1) data = that.singleList.concat(data);
  2363. // console.log(data);
  2364. data = data.map(it => {
  2365. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2366. .isJs = true;
  2367. return it;
  2368. });
  2369. data = {
  2370. displayStyle: that.singleTemplate.theme,
  2371. lineNumber: that.singleTemplate.lineNumber,
  2372. products: data
  2373. };
  2374. that.setData({
  2375. singleList: data,
  2376. hasmoreSingle: data && data.length > 0,
  2377. singleShow: true
  2378. });
  2379. resolve();
  2380. });
  2381. })
  2382. }
  2383. if (this.merchant && this.merchant.type != 5) {
  2384. let form = {
  2385. page: that.singlePage,
  2386. limit: that.singleTemplate.number,
  2387. merchantId: this.merchant.id
  2388. };
  2389. if (that.singleTemplate.content != '') {
  2390. form.contentId = that.singleTemplate.contentId;
  2391. delete form.attr;
  2392. } else {
  2393. form.attr = 'Recommend';
  2394. }
  2395. return new Promise((resolve, reject) => {
  2396. req.getRequest('/api/product/list', form, res => {
  2397. if (res && res.length >= 10) that.isLoadSingle = true;
  2398. if (that.singlePage > 1) res = that.singleList.concat(res);
  2399. res = res.map(it => {
  2400. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it
  2401. .isJs = true;
  2402. return it;
  2403. });
  2404. res = {
  2405. displayStyle: that.singleTemplate.theme,
  2406. lineNumber: that.singleTemplate.lineNumber,
  2407. products: res
  2408. };
  2409. that.setData({
  2410. singleList: res,
  2411. hasmoreSingle: res && res.length > 0,
  2412. singleShow: true
  2413. });
  2414. resolve();
  2415. });
  2416. })
  2417. }
  2418. },
  2419. getOfficeList() {
  2420. let form = {
  2421. page: 1,
  2422. limit: 4,
  2423. orderType: 1
  2424. }
  2425. return new Promise((resolve, reject) => {
  2426. req.getRequest('/api/v3/moments/list', form, res => {
  2427. if (res && res.length > 0) {
  2428. res.map(it => {
  2429. if (it.url) {
  2430. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  2431. if (h.indexOf('mp4') < 0 && h.indexOf('MP4') < 0) {
  2432. it.url = it.url.split(',');
  2433. } else {
  2434. it.isHaveVideo = true
  2435. it.isControls = false
  2436. it.isShowPlayBtn = true
  2437. }
  2438. }
  2439. it.content =
  2440. '<div style="overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;word-break: break-all;">' +
  2441. it.content + '</div>'
  2442. return it;
  2443. })
  2444. }
  2445. this.officeList = res;
  2446. resolve();
  2447. })
  2448. })
  2449. },
  2450. toDetail(e) {
  2451. let id = e.currentTarget.dataset.id;
  2452. let url = e.currentTarget.dataset.url;
  2453. app.globalData.openPage('product/detail/detail?id=' + id +
  2454. url); // app.openPage("product/detail/detail?id=" + id)
  2455. },
  2456. // 新客列表
  2457. tocustomersList(event) {
  2458. const index = event.currentTarget.dataset.index;
  2459. const activity = this.customersList.products[index];
  2460. const url = event.currentTarget.dataset.url;
  2461. app.globalData.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + '&id=' + activity
  2462. .productId + url
  2463. ); // app.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + "&id=" + activity.productId);
  2464. },
  2465. addShopCart(e) {
  2466. let state = e.currentTarget.dataset.state;
  2467. let skuId = e.currentTarget.dataset.skuid;
  2468. let id = e.currentTarget.dataset.id;
  2469. let _ts = this;
  2470. let params = {
  2471. skuId: skuId,
  2472. quantity: 1,
  2473. merchantId: this.merchant.id,
  2474. productId: id
  2475. }; // if(state!=1){
  2476. // return req.msg('您来晚了,商品已经下架')
  2477. // }
  2478. req.postRequest('/api/purchase/cart', params, res => {
  2479. _ts.setData({
  2480. isUpdate: !_ts.isUpdate
  2481. });
  2482. req.msg('加入购物车成功');
  2483. });
  2484. },
  2485. toGroupRemind(event) {
  2486. const index = event.currentTarget.dataset.index;
  2487. const activity = this.activityGroup.products[index];
  2488. const url = event.currentTarget.dataset.url;
  2489. app.globalData.openPage('product/groupDetail/groupDetail?acid=' + activity.id + '&id=' + activity
  2490. .productId + url
  2491. ); // app.openPage('product/groupDetail/groupDetail?acid=' + activity.id + "&id=" + activity.productId);
  2492. },
  2493. toSeckillList(event) {
  2494. const index = event.currentTarget.dataset.index;
  2495. const activity = this.seckillList[index];
  2496. const url = event.currentTarget.dataset.url;
  2497. app.globalData.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + '&id=' + activity
  2498. .productId + url
  2499. ); // app.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + "&id=" + activity.productId);
  2500. },
  2501. addActivityRemind(event) {
  2502. const index = event.currentTarget.dataset.index;
  2503. const id = event.currentTarget.dataset.id;
  2504. const type = event.currentTarget.dataset.type; // if(req.getStorage('userInfo')){
  2505. // }
  2506. req.postRequest(
  2507. '/api/activity/remind', {
  2508. activityId: id
  2509. },
  2510. res => {
  2511. mes.remind().then(res => res);
  2512. // mes.remind().then(res=>res)
  2513. // mes.requsetmessage()
  2514. req.msg('订阅提醒成功');
  2515. let data = {};
  2516. if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = true;
  2517. else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = true;
  2518. else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = true;
  2519. else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = true;
  2520. else if (type == 5) data['customersList.products[' + index + '].isRemind'] = true;
  2521. this.setData(data);
  2522. }
  2523. );
  2524. },
  2525. group(array, subGroupLength) {
  2526. let index = 0;
  2527. let newArray = [];
  2528. while (index < array.length) {
  2529. newArray.push(array.slice(index, (index += subGroupLength)));
  2530. }
  2531. return newArray;
  2532. },
  2533. cancelActivityRemind(event) {
  2534. const index = event.currentTarget.dataset.index;
  2535. const id = event.currentTarget.dataset.id;
  2536. const type = event.currentTarget.dataset.type;
  2537. if (req.header.appId == 'ZQ1VK5oc17I387E') {} else {
  2538. req.postRequest(
  2539. '/api/activity/cancel/remind', {
  2540. id: id
  2541. },
  2542. res => {
  2543. req.msg('取消提醒成功');
  2544. let data = {};
  2545. if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = false;
  2546. else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = false;
  2547. else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = false;
  2548. else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = false;
  2549. else if (type == 5) data['customersList.products[' + index + '].isRemind'] = false;
  2550. this.setData(data);
  2551. }
  2552. );
  2553. }
  2554. },
  2555. clearAllTimer(type) {
  2556. // console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
  2557. if (type == 1) {
  2558. this.activityGroup.products.forEach(it => clearInterval(it.timer));
  2559. this.activityGroup.products.forEach(it => clearInterval(it.times));
  2560. } else if (type == 2) {
  2561. this.joingroupList.products.forEach(it => clearInterval(it.timer));
  2562. this.joingroupList.products.forEach(it => clearInterval(it.times));
  2563. } else if (type == 3) {
  2564. this.bargainList.products.forEach(it => clearInterval(it.timer));
  2565. this.bargainList.products.forEach(it => clearInterval(it.times));
  2566. } else if (type == 4) {
  2567. this.customersList.products.forEach(it => clearInterval(it.timer));
  2568. this.customersList.products.forEach(it => clearInterval(it.times));
  2569. } else if (type == 5) {
  2570. this.seckillList.products.forEach(it => clearInterval(it.timer));
  2571. this.seckillList.products.forEach(it => clearInterval(it.times));
  2572. }
  2573. },
  2574. hideGuide() {
  2575. //关闭提示加入我的小程序
  2576. this.setData({
  2577. first: false
  2578. });
  2579. req.setStorage('first', false);
  2580. },
  2581. hideAd() {
  2582. //关闭广告
  2583. // if(this.data.first==false){
  2584. this.setData({
  2585. isLayerAd: false
  2586. }); // }
  2587. app.globalData.isLayerAd = false;
  2588. },
  2589. click(e) {
  2590. // console.log(e)
  2591. this.storeShow = e;
  2592. },
  2593. goUrl(event) {
  2594. //跳转链接
  2595. let url = event.currentTarget.dataset.url;
  2596. app.globalData.openPage(url);
  2597. },
  2598. jumpHome() {
  2599. app.globalData.reLaunchTo('pages/home/index');
  2600. },
  2601. getUpdate() {
  2602. let userInfos = req.getStorage('userInfo');
  2603. if (!userInfos.mobile) {
  2604. console.log('没有手机号')
  2605. this.isShowUpdate = true;
  2606. this.isUpdateMobile = true;
  2607. req.setStorage('isShowUpdateMobile', true)
  2608. return false;
  2609. }
  2610. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf(
  2611. '用户') > -1) {
  2612. console.log('没有昵称')
  2613. this.isShowUpdate = true;
  2614. this.isUpdateInfo = true;
  2615. req.setStorage('isShowUpdateInfo', true)
  2616. return false;
  2617. }
  2618. return true;
  2619. },
  2620. checkUpdate(url) {
  2621. if (!req.isLogins(true)) return false;
  2622. if (this.getUpdate()) this.jumpUrl(url);
  2623. },
  2624. closeUpdate() {
  2625. this.isShowUpdate = false
  2626. this.isUpdateInfo = false;
  2627. this.isUpdateMobile = false;
  2628. },
  2629. updateMobileInfo(e) {
  2630. if (e == 1) { //更新昵称头像
  2631. this.getuserVip();
  2632. this.getUserInfo();
  2633. } else { //绑定手机号
  2634. this.jumpUrl('/open/info/index');
  2635. }
  2636. }
  2637. },
  2638. beforeMount() {
  2639. const systemInfo = uni.getSystemInfoSync();
  2640. console.log('systemInfo==', systemInfo)
  2641. // px转换到rpx的比例
  2642. let pxToRpxScale = 750 / systemInfo.windowWidth;
  2643. this.pxToRpxScale = pxToRpxScale;
  2644. let systems = {
  2645. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  2646. navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
  2647. windowHeight: systemInfo.screenHeight * pxToRpxScale, // 导航栏的高度
  2648. safeBottomHeight: systemInfo.safeAreaInsets.bottom * pxToRpxScale
  2649. };
  2650. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  2651. systems.windowHeights = systems.windowHeight - 115 - systems.safeBottomHeight;
  2652. // this.sheight = (500/pxToRpxScale)/2;
  2653. this.systems = systems;
  2654. console.log('systems==', systems)
  2655. },
  2656. onPageScroll(e) {
  2657. this.clientData.pageY = e.scrollTop;
  2658. if (e.scrollTop > this.sheight) {
  2659. if (this.isPlay == 1) {
  2660. this.isPlay = 2;
  2661. }
  2662. }
  2663. if (this.isSoution || (this.config && this.config.is_hide_searchBox != 1)) {
  2664. let height = this.systems.barHeight / this.pxToRpxScale;
  2665. if (e.scrollTop > height) {
  2666. this.isScroll = true;
  2667. } else {
  2668. this.isScroll = false;
  2669. }
  2670. }
  2671. }
  2672. };
  2673. </script>
  2674. <style>
  2675. page {
  2676. background-color: #fff;
  2677. }
  2678. </style>
  2679. <style scoped>
  2680. @import './index.css';
  2681. </style>