index.vue 66 KB

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