detail.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. <template>
  2. <view v-if="allShow">
  3. <!--group/detail/detail.wxml-->
  4. <view class="banner">
  5. <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
  6. duration="1000">
  7. <block v-for="(item, index) in bannerUrls" :key="index">
  8. <swiper-item autoplay="true">
  9. <image :src="item + '?x-oss-process=style/w750-auto'" mode="aspectFit"></image>
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. <view class="dots dflex">
  14. <block v-for="(item, index) in bannerUrls" :key="index">
  15. <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
  16. @tap="dotEvent"></view>
  17. </block>
  18. </view>
  19. </view>
  20. <!-- <view class="notification_bar" wx:if="{{isNotice}}">
  21. <swiper class="swiper_container" vertical="true" autoplay="true" circular="false" duration="1000" interval="5000" easing-function="easeInOutCubic" class="bar_box dflex">
  22. <swiper-item class="bar_con dflex" wx:for="{{contentList}}" wx:key="item">
  23. <view class="bar dflex">
  24. <image class="bar_left" src="{{item.pic}}" />
  25. <text class="bar_text">最新订单来自</text>
  26. <text class="bar_text">{{item.name}},</text>
  27. <text class="bar_text">{{item.time}}</text>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. </view> -->
  32. <view class="group">
  33. <image :src="picUrlss+'ptbg.png'" class="ptbg" v-if="act.start"></image>
  34. <image :src="picUrlss+'msyybg.png'" class="ptbg" v-else></image>
  35. <view class="groups dflex">
  36. <view class="left">
  37. <view class="price">拼团价¥<text>{{act.money}}</text></view>
  38. <view class="pin"><text class="origin" v-if="act.marketPrice<act.money&&act.marketPrice!=0">原价
  39. {{act.marketPrice}}</text>
  40. <block v-if="act.marketPrice<act.money&&act.marketPrice!=0"> | </block>{{count? count:0}}人已拼
  41. {{act.activityMainEntity.numberPeople}}人团
  42. </view>
  43. </view>
  44. <view class="right">
  45. <image src="/static/pages/images/tuan.png" class="tuan"></image>
  46. <view class="endtime dflex">
  47. <view>{{isStates==0?'距开始':isStates==1?'距结束':'已结束'}}</view>
  48. <block v-if="timer.length==4">
  49. <block v-if="timer[0] !=0"><text>{{timer[0]}}</text>天</block>
  50. <text>{{timer[1]}}</text>:
  51. <text>{{timer[2]}}</text>:
  52. <text>{{timer[3]}}</text>
  53. </block>
  54. <block v-else>
  55. <text>{{timer[0]}}</text>:
  56. <text>{{timer[1]}}</text>:
  57. <text>{{timer[2]}}</text>
  58. </block>
  59. <!-- <block wx:if="{{timer&&timer.length>0}}">
  60. <text>{{timer[0]}}</text>天</block>
  61. <text>{{timer[1]}}</text>:
  62. <text>{{timer[2]}}</text>:
  63. <text>{{timer[3]}}</text> -->
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="text">
  69. {{product.brandName ? product.brandName : ''}} {{product.brief ? product.brief : ''}}
  70. </view>
  71. <view class="info bgfff">
  72. <view class="infos dflex">
  73. <view class="title flex">{{pro.title?pro.title:'0'}}</view>
  74. <view class="share" @tap="showShare">
  75. <image src="/static/pages/images/fxico.png"></image>分享
  76. </view>
  77. </view>
  78. <view class="guarantee dflex" v-if="guarantee.length>0">
  79. <view class="cont dflex">
  80. <view v-for="(item, index) in guarantee" :key="index" class="dflex li">
  81. <image src="/activity/static/activity/images/guarantee.png"></image>{{item}}
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="detinfo mt20 bgfff">
  87. <!-- isOtc 0 默认 1 处方药 2 非处方药 3 医疗器械 4 食品类 5 海外购 -->
  88. <block v-if="act.isOtc!=5">
  89. <block v-if="is_open_shop == 1 && ascription">
  90. <view class="xiaodian dflex malr20" v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0) || act.serviceShopRate">
  91. <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
  92. <view class="shouyi flex" v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
  93. <text>分销收益</text>
  94. <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
  95. <view v-else><text>¥</text>{{act.twoCommission}}</view>
  96. </view>
  97. <view class="shouyi flex" v-if="act.serviceShopRate">
  98. <text>小店服务费</text>
  99. <view><text>¥</text>{{act.serviceShopRate}}</view>
  100. </view>
  101. <view class="dflex" v-if="act.isJoinShop">
  102. <view class="fenxiang" @tap="showShare">分享推广</view>
  103. <navigator :url="url" hover-class="none" class="goShop">去小店</navigator>
  104. </view>
  105. <view class="addshop" @tap="addShop" v-else>添加到小店</view>
  106. </view>
  107. </block>
  108. <block v-else>
  109. <view class="xiaodian dflex malr20" v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
  110. <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
  111. <view class="shouyi flex">
  112. <text>分销收益</text>
  113. <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
  114. <view v-else><text>¥</text>{{act.twoCommission}}</view>
  115. </view>
  116. <navigator url="/promote/apply/apply" hover-class="none" class="fenxiang" v-if="isDistriUser != 2">我要推广</navigator>
  117. <view class="fenxiang" @tap="showShare" v-else>分享推广</view>
  118. </view>
  119. </block>
  120. </block>
  121. <!-- <view class="item dflex">
  122. <label>优惠券</label>
  123. <view class="quan flex dflex">
  124. <view class="flex dflex">
  125. <text>满500减50</text>
  126. <text>满200减10</text>
  127. </view>
  128. <view class="ling dflex">领券<image src="/pages/images/more3.png"></image>
  129. </view>
  130. </view>
  131. </view> -->
  132. <view class="item pro-sel dflex" v-if="pro.propertiesList && pro.propertiesList.length > 0"
  133. @click="pro.stock > 0 ? atOnceBuy() : ''">
  134. <label>已选</label>
  135. <view class="flex">{{pro.properties}}</view>
  136. <image src="/static/pages/images/more.png" class="mrico"></image>
  137. </view>
  138. <view class="item dflex">
  139. <label>配送至</label>
  140. <view class="flex" @tap="toAddress">
  141. <view class="address">{{address.address?address.address:''}}{{address.house?address.house:''}}
  142. </view>
  143. <view class="huo" v-if="pro.isTimely == 1"><text>现货</text>,现在下单,预计2小时后送达</view>
  144. </view>
  145. <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
  146. </view>
  147. <view class="item dflex">
  148. <label>门店</label>
  149. <view class="flex" @tap="toMerchant">
  150. <view class="address">{{merchant.title}}</view>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- 参团情况 -->
  155. <!-- <view class="cantuan bgfff mt20">
  156. <view class="can-info">{{act.activityMainEntity.numberPeople}}人团,还差<text>{{act.activityMainEntity.numberPeople-(act.activityPurchaseRecordEntitys?act.activityPurchaseRecordEntitys.length:0)}}人</text></view>
  157. <view class="can-infos dflex" wx:for="{{act.activityPurchaseRecordEntitys}}">
  158. <view class="li">
  159. <image src="/pages/images/bar.png" mode="aspectFit"></image>
  160. <text>团长</text>
  161. </view>
  162. <view class="li">
  163. <image src="/pages/images/bar.png" mode="aspectFit"></image>
  164. </view>
  165. <view class="li">
  166. <image src="/pages/images/cha.png"></image>
  167. </view>
  168. <view class="li">
  169. <image src="/pages/images/cha.png"></image>
  170. </view>
  171. </view>
  172. <view class="can-btn mbglinear">我要参团</view>
  173. </view> -->
  174. <!-- 组团情况 -->
  175. <view class="zutuan bgfff mt20">
  176. <view
  177. v-if="(activityPurchaseRecordListDTO&&activityPurchaseRecordListDTO.length>0)||(act.activityPurchaseRecordListDTO.length>0&&act.activityPurchaseRecordListDTO)"
  178. class="zu-tit dflex">
  179. {{act.activityPurchaseRecordListDTO.length}}人正在组团,可直接参与<icon class="icon iconfont icon-bottom"
  180. @tap="activityPurchaseRecordListDTO.length>1&&activityDot.length>0?clickmore():''">
  181. </icon>
  182. </view>
  183. <view class="zu-list">
  184. <view v-for="(item, index) in activityPurchaseRecordListDTO" :key="index" class="li dflex">
  185. <image :src="item.groupMainP.uavatar" mode="aspectFit"></image>
  186. <view class="zu-name flex">{{item.groupMainP.unickName}}</view>
  187. <view class="zu-ren">
  188. <view class="cha"
  189. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  190. {{act.activityMainEntity.numberPeople}}人成团,还差<text>{{(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0?(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0)):0}}人</text>
  191. </view>
  192. <view class="zu-time"
  193. v-if="item.isGroup&&(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  194. 剩余<text>{{item.times}}</text></view>
  195. <block v-else>
  196. <view
  197. v-if="!item.isGroup&&(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  198. 拼团失败</view>
  199. <view
  200. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))<=0">
  201. <text>{{item.groupMainP.state==1?'拼团完成':'拼团待支付'}}</text>
  202. </view>
  203. </block>
  204. </view>
  205. <view class="zu-btn mbglinear" :data-index="index" @tap="toGoGroup"
  206. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">去参团
  207. </view>
  208. <view class="zu-btn mbglinear" :data-index="index" @tap="toGoGroup" v-else>查看详情</view>
  209. </view>
  210. </view>
  211. </view>
  212. <!-- 拼团玩法 -->
  213. <view class="wanfa bgfff mt20">
  214. <view class="wan-tit">拼团玩法</view>
  215. <view class="wan-info dflex">
  216. <view class="li dflex">
  217. <icon class="icon iconfont icon-zhifu"></icon>
  218. <view class="flex">支付开团<text>或参团</text></view>
  219. </view>
  220. <icon class="icon iconfont icon-right"></icon>
  221. <view class="li dflex">
  222. <icon class="icon iconfont icon-haoyou"></icon>
  223. <view class="flex">邀请好友<text>拼团</text></view>
  224. </view>
  225. <icon class="icon iconfont icon-right"></icon>
  226. <view class="li dflex">
  227. <icon class="icon iconfont icon-dingdan"></icon>
  228. <view class="flex">达到人数拼团成功<text>人数不足拼团失败</text></view>
  229. </view>
  230. </view>
  231. </view>
  232. <!-- 商品详情等页面 -->
  233. <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="pro.id" v-if="pro.id" :form="form"
  234. @showTab="showTab" @scoreTab="scoreTab" @freshen="freshenFun"></product-footer>
  235. <v-share :hide-toast="hideShare" :product="pro" :code-url="codeUrl" :a-type="'3'" @onFather="click"></v-share>
  236. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
  237. <view class="bot fixed bgfff dflex" :style="'padding-bottom: ' + (bottomBlankHeight + 20) + 'rpx'">
  238. <button open-type="contact" class="botbtn">
  239. <image src="/static/pages/images/kfico.png"></image>在线客服
  240. </button>
  241. <!-- <navigator class="botbtn" open-type="switchTab" url="/pages/cart/cart" hover-class="none">
  242. <image src="/pages/images/gwc.png"></image>购物车<text class="message" wx:if="{{pro.count > 0}}">{{pro.count}}</text>
  243. </navigator> -->
  244. <!-- <view class="botbtn" bindtap="clickCollect">
  245. <image src="/pages/images/shoucang_h.png" wx:if="{{pro.isCollect}}"></image>
  246. <image src="/pages/images/shoucang.png" wx:else></image>收藏
  247. </view> -->
  248. <!-- <view class="addcart">加入购物车</view> -->
  249. <block v-if="isStates!=0">
  250. <view class="gmbtn" @tap="atOnceBuy">¥{{salePrice}} 单独购买</view>
  251. <!-- <view class="ctbtn mbglinear">我要参团</view>官方组团按钮 -->
  252. <!-- 自由组团按钮 -->
  253. <view class="ctbtn mbglinear" @tap="createGroup" v-if="isStates==1&&myActData.state!=1&&!activityEnd">
  254. ¥{{ act.money}}发起拼团</view>
  255. <view class="ctbtn mbglinear" @tap="createGroup" v-if="myActData.state==1">查看拼团</view>
  256. <view class="ctbtn end" v-if="(isStates==2&&myActData.state!=1)||activityEnd">活动已结束</view>
  257. </block>
  258. <block v-if="isStates==0">
  259. <view class="cancel-yy dflex" @tap="cancelActivityRemind" v-if="isRemind">
  260. <icon class="icon iconfont icon-yugao"></icon>取消提醒
  261. </view>
  262. <view class="yybtn mbggreen dflex" @tap="addActivityRemind" v-else>
  263. <icon class="icon iconfont icon-yugao"></icon>预约提醒
  264. </view>
  265. </block>
  266. </view>
  267. <!-- 商品规格 -->
  268. <block v-if="isShow">
  269. <product-popup :product="popup" :activityId="act.id" :is-cart="isCart" order-type="4" @hidePopup="hidePopup"
  270. @addCartSuccess="addCartSuccess" :order-type="orderType" :merchant="merchant"
  271. :merchant-id="query.merchantId" :shop-id="query.shopId"></product-popup>
  272. </block>
  273. <view class="contact_index" @tap="goTop">
  274. <image src="/static/pages/images/backtop.png"></image>顶部
  275. </view>
  276. <!-- 查看更多 -->
  277. <view class="mask" @tap="eliminate" v-if="show" catchtouchmove="true"></view>
  278. <view class="page" :style="'margin:-' + (windowHeight/2) + 'px 0 0 -' + (windowWidth/2) + 'px'">
  279. <view class="ptuanmode" catchtouchmove="true" v-if="show">
  280. <view class="zu-list">
  281. <view class="pttop">正在拼团</view>
  282. <scroll-view scroll-y="true" style="max-height: 550rpx;">
  283. <view v-for="(item, index) in activityDot" :key="index" class="li dflex">
  284. <image :src="item.groupMainP.uavatar" mode="aspectFit"></image>
  285. <view class="zu-name flex">{{item.groupMainP.unickName}}</view>
  286. <view class="zu-ren">
  287. <view class="cha"
  288. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  289. {{act.activityMainEntity.numberPeople}}人成团,还差<text>{{(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0?(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0)):0}}人</text>
  290. </view>
  291. <view class="zu-time"
  292. v-if="item.isGroup&&(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  293. 剩余<text>{{item.times}}</text></view>
  294. <block v-else>
  295. <view
  296. v-if="!item.isGroup&&(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  297. 拼团失败</view>
  298. <view
  299. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))<=0">
  300. <text>{{item.groupMainP.state==1?'拼团完成':'拼团待支付'}}</text>
  301. </view>
  302. </block>
  303. </view>
  304. <view class="zu-btn mbglinear" :data-index="index" data-type="1" @tap="toGoGroup"
  305. v-if="(act.activityMainEntity.numberPeople-(item.groupList?item.groupList.length:0))>0">
  306. 去参团</view>
  307. <view class="zu-btn mbglinear" :data-index="index" @tap="toGoGroup" :data-type="1" v-else>
  308. 查看详情</view>
  309. </view>
  310. </scroll-view>
  311. <view class="tole" v-if="activityDot.length==21">--仅显示20个正在拼团的人--</view>
  312. </view>
  313. </view>
  314. </view>
  315. <!-- 添加到小店成功 -->
  316. <view class="mask" :hidden="isHide" @tap="hidePop"></view>
  317. <view class="suc" :hidden="isHide">
  318. <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
  319. <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
  320. <text>快去我的小店看看吧</text>
  321. <view class="shopcc dflex">
  322. <view class="shop" @tap="showShare">分享推广</view>
  323. <navigator :url="url" hover-class="none" class="shop" >我的小店</navigator>
  324. </view>
  325. <!-- <view class="share-btn dflex">
  326. <button class="wxfriend dflex" open-type="share">
  327. <image src="/static/pages/images/wechat.png"></image>
  328. 微信好友
  329. </button>
  330. <view class="wxposter dflex" @tap="generatePoster">
  331. <image src="/static/pages/images/poster.png"></image>
  332. 生成海报
  333. </view>
  334. </view> -->
  335. <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
  336. </view>
  337. <block v-if="isPopupLogin">
  338. <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
  339. </block>
  340. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate"></update-userinfo>
  341. <privacy :is-update="true" @getLocations="initLocation"></privacy>
  342. <!-- #ifdef H5 -->
  343. <wx-share ref="wxshare" />
  344. <!-- #endif -->
  345. </view>
  346. </template>
  347. <script>
  348. const app = getApp();
  349. const req = require("../../../utils/request.js");
  350. const utils = require("../../../utils/util.js");
  351. var QQMapWX = require("../../../utils/qqmap.js");
  352. const requsetmessage = require("../../../utils/requestmessage.js");
  353. const route = require("../../../utils/route");
  354. const api = require("../../../utils/api.js");
  355. import productPopup from "../../../components/product-popup/index";
  356. import vShare from "../../../components/share/share";
  357. import productLogin from "../../../components/product-login/index";
  358. export default {
  359. data() {
  360. return {
  361. picUrlss: req.public.picUrls,
  362. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  363. swiperCurrent: 0,
  364. bannerUrls: [],
  365. isShow: false,
  366. pro: {},
  367. timer: [],
  368. isRemind: false,
  369. hideShare: true,
  370. codeUrl: '',
  371. start: false,
  372. activityPurchaseRecordListDTO: [],
  373. activityDot: [],
  374. act: {},
  375. isGroup: true,
  376. hideShop: true,
  377. //隐藏添加到小店
  378. isHide: true,
  379. //添加小店成功弹窗
  380. contentList: [{
  381. pic: "/static/pages/images/bar.png",
  382. name: '好风依旧',
  383. time: '4秒前'
  384. }, {
  385. pic: "/static/pages/images/bar.png",
  386. name: '杨鑫',
  387. time: '20秒前'
  388. }, {
  389. pic: "/static/pages/images/bar.png",
  390. name: '杨鑫',
  391. time: '5秒前'
  392. }],
  393. isNotice: false,
  394. form: {
  395. page: 1,
  396. limit: 10
  397. },
  398. freshen: true //是否更新页面
  399. ,
  400. current: "",
  401. query: "",
  402. merchant: "",
  403. merchantId: "",
  404. shopId: "",
  405. imgs: "",
  406. nodes: "",
  407. salePrice: "",
  408. activityEnd: false,
  409. isStates: 0,
  410. address: {},
  411. popup: "",
  412. myActData: "",
  413. count: "",
  414. show: false,
  415. tabIndex: "",
  416. guarantee: "",
  417. is_open_comments: "",
  418. switch: true,
  419. about: {},
  420. allShow: false,
  421. url:'',
  422. is_open_shop: '',//商户是否开启分销
  423. ascription: false,//是否开启小店
  424. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  425. isPopupLogin: false,
  426. isShowUpdate: false,//是否显示更新信息弹窗
  427. isUpdateInfo: false,//更新用户信息
  428. isUpdateMobile: false,//绑定手机号
  429. };
  430. },
  431. components: {
  432. productPopup,
  433. vShare,
  434. productLogin
  435. },
  436. props: {},
  437. onLoad: async function(options) {
  438. // console.log(options);
  439. if(options.appId) req.setStorage('appId',options.appId);
  440. this.query = options;
  441. this.setData({
  442. query: options
  443. });
  444. if (options.scene) {
  445. this.scene = options.scene;
  446. }
  447. if (options.isShare) {
  448. this.query.id = options.id;
  449. this.query.acid = options.acid;
  450. req.setStorage('pidCode', options.userId);
  451. req.setStorage('pidCode', options.userId);
  452. let params = {
  453. userId: options.userId,
  454. merchantId: options.merchantId ? options.merchantId : '',
  455. }
  456. await this.bindUser(params);
  457. }else{
  458. await req.silenceLogin();
  459. }
  460. if (options.hideShop) {
  461. this.setData({
  462. hideShop: this.query.hideShop
  463. });
  464. } else {
  465. this.setData({
  466. hideShop: 'true'
  467. });
  468. } // this.isShop()
  469. setInterval(() => {
  470. this.setData({
  471. isNotice: true
  472. });
  473. }, 10000);
  474. // this.getuserInfo()
  475. },
  476. onShow: async function() {
  477. let that = this
  478. if (this.freshen) {
  479. await this.loadCodeParams();
  480. if(that.scene){
  481. await that.bindUser(that.query);
  482. }
  483. // this.loadDefaultAddress();
  484. this.groupCount();
  485. this.getGuarantee().then(data => {
  486. if (this.switch) {
  487. that.getMerchant();
  488. }
  489. })
  490. await this.browsRecound(this.query.id); // let merchant = req.getStorage('defaultMerchant');
  491. // this.setData({ merchant: merchant });
  492. // this.getMerchant();
  493. }
  494. },
  495. onUnload() {
  496. if (this.timer) clearInterval(this.timer);
  497. this.clearAllTimer();
  498. },
  499. onShareAppMessage: function() {
  500. return this.onShareMessage();
  501. // return {
  502. // title: this.data.pro.title,
  503. // imageUrl: this.data.pro.pic,
  504. // path: 'activity/group/detail/detail?acid=' + this.query.acid + "&id=" + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id + '&merchantId=' + this.data.query.merchantId
  505. // // path: '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id
  506. // }
  507. },
  508. onReachBottom() {
  509. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  510. this.form.page++;
  511. this.setData({
  512. ['form.page']: this.form.page
  513. });
  514. // this.selectComponent("#list").loadScore(this.current);
  515. this.$refs.list.loadScore(this.current);
  516. }
  517. },
  518. onHide() {
  519. this.clearAllTimer();
  520. },
  521. onReady() {
  522. // #ifdef H5
  523. var that = this;
  524. //初始化分享内容
  525. setTimeout(function() {
  526. var shareContent = that.onShareMessage();
  527. if (shareContent) {
  528. shareContent.path = window.location.origin + shareContent.path;
  529. }
  530. console.log('分享内容》》》》》', shareContent);
  531. that.$refs.wxshare.init(shareContent);
  532. }, 4 * 1000);
  533. // #endif
  534. },
  535. methods: {
  536. initLocation(){
  537. this.getMerchant();
  538. },
  539. onShareMessage(){
  540. let merchantId = '';
  541. let path = '';
  542. let isSolution = '';
  543. // #ifndef H5
  544. isSolution = req.env[req.env.NODE_ENV].isSolution;
  545. // #endif
  546. // #ifdef H5
  547. isSolution = false;
  548. // #endif
  549. let userInfo = req.getStorage('userInfo');
  550. let shopId = '';
  551. if(isSolution){
  552. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  553. }else{
  554. path = '/activity/group/detail/detail?id=' + this.query.id + '&acid=' + this.query.acid + '&isShare=' +true+ '&appId=' + req.getStorage('appId');
  555. // console.log(!req.getStorage('userInfo').id);
  556. if (!userInfo.id) {} else {
  557. path += '&userId=' + userInfo.id;
  558. }
  559. // console.log(this.query.merchantId);
  560. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  561. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  562. merchantId = req.getStorage('MERCHANT').id;
  563. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  564. path += '&shopId=' + req.getStorage('smallShop').id;
  565. shopId = req.getStorage('smallShop').id;
  566. merchantId = req.getStorage('smallShop').merchantDTO.id;
  567. }
  568. }
  569. }
  570. // console.log(path)
  571. route.share(1, userInfo.id, path, merchantId, shopId, 7, this.query.acid + '_' + this.query.id);
  572. return {
  573. title: this.pro.title,
  574. imageUrl: this.pro.pic,
  575. path: path
  576. };
  577. },
  578. getMerchant(){
  579. let that = this;
  580. api.getMerchant(this.query, req, data => {
  581. that.loadDefaultAddress();
  582. if (data == 1) {
  583. if(that.about.Many_Store == 1) api.locationShow()
  584. else{
  585. that.getuserInfos(data);
  586. if(req.getStorage('defaultMerchant')) {
  587. that.merchant = req.getStorage('defaultMerchant');
  588. that.query.merchantId = that.merchant.id
  589. }else{
  590. api.defaultMerchant(req, that.query, defaultRes=>{
  591. that.merchant = defaultRes;
  592. that.query.merchantId = defaultRes.id
  593. });
  594. }
  595. that.loadProudct(that.query);
  596. }
  597. } else {
  598. that.getuserInfos(data);
  599. if (data.type == 5) {
  600. that.query.merchantId = data.merchantDTO.id
  601. that.query.shopId = data.id
  602. } else {
  603. that.query.merchantId = data.id
  604. }
  605. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  606. this.loadProudct();
  607. let pages = getCurrentPages();
  608. var prevPage = pages[pages.length - 2];
  609. if (prevPage) {
  610. prevPage.$vm.setData({
  611. freshen: true
  612. });
  613. }
  614. } else {
  615. this.loadProudct();
  616. }
  617. that.merchant = data
  618. }
  619. })
  620. },
  621. bindUser(par){
  622. let userInfo = req.getStorage('userInfo');
  623. if(!userInfo){
  624. // uni.login({
  625. // success(res) {
  626. // let params = {
  627. // code: res.code,
  628. // parentId: par.userId,
  629. // merchantId: par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
  630. // }
  631. // return new Promise((resolve,reject)=>{
  632. // req.postRequest('/api/v2/login', params, data => {
  633. // resolve();
  634. // });
  635. // })
  636. // }
  637. // });
  638. // this.isPopupLogin = true;
  639. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  640. }
  641. },
  642. // 获取用户信息
  643. getuserInfo() {
  644. let userInfo = req.getStorage('userInfo');
  645. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  646. 0) {
  647. if (userInfo.listShopBase[0].merchant_id) {
  648. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' +
  649. userInfo.listShopBase[
  650. 0].id;
  651. this.setData({
  652. url: url
  653. });
  654. }
  655. console.log(this.url)
  656. }
  657. },
  658. click(e) {
  659. // console.log(e)
  660. this.hideShare = e
  661. },
  662. showShare() {
  663. // #ifndef H5
  664. req.isLogin().then(success => {
  665. if (success) {
  666. this.setData({
  667. hideShare: false
  668. });
  669. this.getCodeUrl()
  670. }
  671. });
  672. // #endif
  673. },
  674. /**
  675. * 轮播切换
  676. */
  677. swiperChange({
  678. detail
  679. }) {
  680. if (this.current == 0 && this.swiperCurrent > 1) {
  681. //卡死时,重置current为正确索引
  682. this.setData({
  683. current: this.swiperCurrent
  684. });
  685. } else {
  686. //正常轮转时,记录正确页码索引
  687. this.setData({
  688. swiperCurrent: detail.current
  689. });
  690. }
  691. },
  692. dotEvent(e) {
  693. this.setData({
  694. current: e.currentTarget.dataset.current
  695. });
  696. },
  697. browsRecound(id) {
  698. let from = {
  699. bindId: id,
  700. type: 7,
  701. page: '/activity/group/detail/detail?id=' + this.query.id + '&acid=' + this.query.acid
  702. };
  703. if (this.query.isShare) {
  704. from.shareType = 1;
  705. from.page = '/activity/group/detail/detail?id=' + this.query.id + '&acid=' + this.query.acid +
  706. '&isShare=' + true;
  707. if (!this.query.userId) {} else {
  708. from.page += '&userId=' + this.query.userId;
  709. }
  710. if (!this.query.merchantId) {} else {
  711. from.merchantId = this.query.merchantId;
  712. }
  713. if (!this.query.shopId) {} else {
  714. from.shopId = this.query.shopId;
  715. }
  716. if (!this.query.userId) {} else {
  717. from.uid = this.query.userId;
  718. }
  719. }
  720. if (this.query.isShareTimeline) {
  721. from.shareType = 2;
  722. from.page = '/activity/group/detail/detail?id=' + this.query.id + '&acid=' + this.query.acid +
  723. '&isShareTimeline=' +
  724. true;
  725. if (!this.query.userId) {} else {
  726. from.page += '&userId=' + this.query.userId;
  727. }
  728. if (!this.query.merchantId) {} else {
  729. from.merchantId = this.query.merchantId;
  730. }
  731. if (!this.query.shopId) {} else {
  732. from.shopId = this.query.shopId;
  733. }
  734. if (!this.query.userId) {} else {
  735. from.uid = this.query.userId;
  736. }
  737. }
  738. return new Promise((reject,resolve)=>{
  739. req.postRequest('/api/browse', from, data => {resolve()});
  740. })
  741. },
  742. loadCodeParams() {
  743. let _ts = this;
  744. return new Promise((resolve, reject) => {
  745. if (!_ts.scene) {
  746. resolve();
  747. return false;
  748. }
  749. req.getRequest('/api/code/params', {
  750. scene: _ts.scene
  751. }, data => {
  752. let res = data.scene.split('_');
  753. this.query.id = res[0];
  754. this.query.acid = res[1];
  755. this.query.merchantId = res[2];
  756. this.query.shopId = res[3];
  757. this.query.userId = data.userId;
  758. req.setStorage('pidCode', data.userId);
  759. req.setStorage('appId',res[res.length-1]);
  760. resolve();
  761. });
  762. });
  763. },
  764. getCodeUrl() {
  765. let that = this; //获取小程序码
  766. const query = this.query;
  767. let scene = that.pro.id + '_' + query.acid;
  768. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  769. scene += '_' + req.getStorage('MERCHANT').id;
  770. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  771. scene += '_' + req.getStorage('smallShop').id;
  772. }
  773. }
  774. if(req.getStorage('appId')) scene += '_'+ req.getStorage('appId');
  775. // console.log(scene); //获取小程序码
  776. const params = {
  777. page: 'activity/group/detail/detail',
  778. scene: scene
  779. };
  780. req.getRequest('/api/program/codev', params, url => {
  781. that.setData({
  782. codeUrl: url
  783. });
  784. });
  785. },
  786. async loadProudct() {
  787. let that = this;
  788. await that.loadActivity();
  789. const query = that.query;
  790. let isShowLoading = false;
  791. if (!isShowLoading) {
  792. req.loadIng('加载中');
  793. isShowLoading = true;
  794. }
  795. req.getRequest('/api/product/detail', {
  796. id: query.id
  797. }, data => {
  798. //富文本图片放大
  799. var nodes = data.detail;
  800. // if (nodes) {
  801. // if (nodes.indexOf("src") >= 0) {
  802. // //正则匹配所有图片路径
  803. // var imgs = [];
  804. // nodes = nodes.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function(match, capture) {
  805. // imgs.push(capture);
  806. // that.setData({
  807. // imgs: imgs
  808. // });
  809. // return '';
  810. // });
  811. // }
  812. // }
  813. let propertiesList = []
  814. if (data.propertiesList && data.propertiesList.length > 0) {
  815. data.propertiesList.map(it => {
  816. propertiesList.push(it.value);
  817. })
  818. }
  819. data.properties = propertiesList.join(' / ')
  820. that.setData({
  821. bannerUrls: data.images,
  822. pro: data,
  823. nodes: nodes,
  824. // 'pro.stock': this.act.quantity,
  825. 'pro.stock': this.act.quantity - this.act.payQuantity,
  826. salePrice: data.salePrice,
  827. 'pro.payQuantity': this.act.payQuantity,
  828. 'pro.maxBuy': this.act.maxBuy,
  829. 'pro.salePrice': this.act.money,
  830. allShow: true
  831. });
  832. if (isShowLoading) {
  833. uni.hideLoading();
  834. isShowLoading = false;
  835. }
  836. // console.log(this.pro);
  837. // that.getCodeUrl();
  838. });
  839. },
  840. loadActivity() {
  841. const query = this.query;
  842. return new Promise((resolve, reject) => {
  843. let from = {
  844. id: query.acid,
  845. type: 3
  846. }
  847. if (!this.query.merchantId) {} else {
  848. from.merchantId = this.query.merchantId
  849. }
  850. let userInfo = req.getStorage('userInfo');
  851. if(userInfo.listShopBase && userInfo.listShopBase.length >0 ){
  852. from.shopId = userInfo.listShopBase[0].id;
  853. }
  854. req.getRequest('/api/activity/detailNew', from, data => {
  855. /**
  856. * 判断活动是否结束,结束,2秒后为用户跳转至该商品的详情页面
  857. */
  858. // if (data.end) {
  859. // this.setData({ start: data.end })
  860. // console.log(this.data.start)
  861. // wx.showToast({
  862. // title: '活动已结束,两秒后将为您跳转至该商品页面',
  863. // icon: 'none',
  864. // success: function () {
  865. // setTimeout(function () {
  866. // wx.redirectTo({ url: '/product/detail/detail?id=' + data.productId })
  867. // }, 2000);
  868. // }
  869. // })
  870. // }
  871. // data.activityPurchaseRecordListDTO.content(data.activityPurchaseRecordListDTO)
  872. // let arr=data.activityPurchaseRecordListDTO.filter(ele=>console.log(ele))
  873. this.getMy();
  874. if (!data || data == 2001) {
  875. this.setData({
  876. activityEnd: true
  877. });
  878. return false;
  879. } else {
  880. let activityPurchaseRecordListDTO;
  881. let arr;
  882. if (data.activityPurchaseRecordListDTO) {
  883. activityPurchaseRecordListDTO = data.activityPurchaseRecordListDTO.slice(0,
  884. 2);
  885. arr = data.activityPurchaseRecordListDTO.slice(0, 21);
  886. // console.log(arr,"789");
  887. }
  888. // console.log(data.activityPurchaseRecordListDTO);
  889. this.setData({
  890. act: data,
  891. isRemind: data.remindId
  892. });
  893. this.setData({
  894. activityPurchaseRecordListDTO: activityPurchaseRecordListDTO,
  895. activityDot: arr
  896. });
  897. // console.log(this.activityPurchaseRecordListDTO, this
  898. // .activityPurchaseRecordListDTO);
  899. this.checkMyIsGroup();
  900. this.initTimer(data);
  901. this.groupItemTimer(1);
  902. this.groupItemTimer();
  903. }
  904. resolve();
  905. });
  906. });
  907. },
  908. // 获取用户信息
  909. getuserInfos(data) {
  910. let userInfo = req.getStorage('userInfo');
  911. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  912. 0) {
  913. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  914. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' + userInfo.listShopBase[0].id;
  915. this.url = url;
  916. this.ascription = true;
  917. }
  918. }
  919. },
  920. getMy() {
  921. let that = this;
  922. let userInfo = req.getStorage('userInfo');
  923. if(!userInfo || userInfo == null) return false;
  924. req.getRequest('/api/user/my', {}, data => {
  925. that.isDistriUser = data.isDistriUser;
  926. });
  927. },
  928. //组团倒计时
  929. groupItemTimer(type) {
  930. // this.clearAllTimer();
  931. //社区拼图定时器
  932. let _ts = this;
  933. let group;
  934. if (type == 1) {
  935. group = this.activityPurchaseRecordListDTO;
  936. } else {
  937. group = this.activityDot;
  938. }
  939. if (group && group.length > 0) {
  940. let pageList = group;
  941. for (let i = 0, len = pageList.length; i < len; i++) {
  942. let group = pageList[i]; // let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  943. let nowTime = new Date(this.act.nowTime.replace(/-/g, '/')).getTime();
  944. let endTime = new Date(group.endDate.replace(/-/g, '/'))
  945. .getTime(); // let actend=new Date(this.data.act.endTime.replace(/-/g, '/')).getTime();
  946. // if (!group.start) endTime = startTime;
  947. // let times
  948. // if(actend-endTime>0){
  949. // times = parseInt((endTime - nowTime) / 1000);
  950. // }else{
  951. // times = parseInt((actend - nowTime) / 1000);
  952. // }
  953. let times = parseInt((endTime - nowTime) / 1000);
  954. let timer = setInterval(() => {
  955. times--;
  956. let data = {};
  957. if (times < 0) {
  958. if (type == 1) {
  959. data['activityPurchaseRecordListDTO[' + i + '].isGroup'] = false;
  960. } else {
  961. data['activityDot[' + i + '].isGroup'] = false;
  962. } // this.setData({isGroup:false})
  963. } else if (times === 0) {
  964. //重新加载列表
  965. clearInterval(timer);
  966. } else {
  967. let n = utils.formatDayTimes(times);
  968. if (type == 1) {
  969. data['activityPurchaseRecordListDTO[' + i + '].times'] = n;
  970. data['activityPurchaseRecordListDTO[' + i + '].isGroup'] = true;
  971. } else {
  972. data['activityDot[' + i + '].times'] = n;
  973. data['activityDot[' + i + '].isGroup'] = true;
  974. }
  975. }
  976. _ts.setData(data);
  977. }, 1000);
  978. let fs = [];
  979. if (type == 1) {
  980. fs['activityPurchaseRecordListDTO[' + i + '].timer'] = timer;
  981. } else {
  982. fs['activityDot[' + i + '].timer'] = timer;
  983. }
  984. _ts.setData(fs);
  985. }
  986. }
  987. },
  988. clearAllTimer() {
  989. if (this.activityPurchaseRecordListDTO) {
  990. this.activityPurchaseRecordListDTO.forEach(it => {
  991. // console.log(it);
  992. clearInterval(it.timer);
  993. clearInterval(it.times);
  994. });
  995. }
  996. if (this.activityDot) {
  997. this.activityDot.forEach(it => {
  998. // console.log(it);
  999. clearInterval(it.timer);
  1000. clearInterval(it.times);
  1001. });
  1002. }
  1003. },
  1004. initTimer(group) {
  1005. //计时器
  1006. let _ts = this;
  1007. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  1008. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  1009. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  1010. if (!group.start) endTime = startTime;
  1011. let times = parseInt((endTime - nowTime) / 1000);
  1012. let data = {}; //判断是否已开始
  1013. if (nowTime - startTime > 0) {
  1014. //开始了
  1015. _ts.setData({
  1016. isStates: 1
  1017. });
  1018. } else {
  1019. //未开始
  1020. _ts.setData({
  1021. isStates: 0
  1022. });
  1023. }
  1024. _ts.setData(data);
  1025. if (times > 0) {
  1026. this.timer = setInterval(() => {
  1027. times--;
  1028. if (times === 0) {
  1029. //重新加载列表
  1030. _ts.setData({
  1031. 'act.end': true
  1032. });
  1033. return false;
  1034. }
  1035. let n = utils.formatDayTimes(times);
  1036. _ts.setData({
  1037. timer: n.split(/:|天/g)
  1038. });
  1039. }, 1000);
  1040. } else {
  1041. _ts.setData({
  1042. isStates: 2
  1043. });
  1044. }
  1045. },
  1046. loadDefaultAddress() {
  1047. if (req.isAuth()) {
  1048. req.g('/api/address/default', data => {
  1049. if (data) this.setData({
  1050. address: data
  1051. });
  1052. else if(this.about.Many_Store == 1) this.pointLocation();
  1053. }, true);
  1054. } else {
  1055. if(this.about.Many_Store == 1) this.pointLocation();
  1056. }
  1057. },
  1058. toAddress() {
  1059. app.globalData.openPage('mine/address/address');
  1060. },
  1061. toMerchant() {
  1062. if (this.about.User_Limit_Store == 1) {
  1063. } else {
  1064. app.globalData.openPage('merchant/nearby/nearby?isChoose=true');
  1065. }
  1066. },
  1067. pointLocation() {
  1068. //定位当前位置
  1069. let _ts = this;
  1070. QQMapWX.initMap(req.public.mapLBSKEY);
  1071. req.getLocation(res => {
  1072. QQMapWX.reverseGeocoder(res, data => {
  1073. _ts.setData({
  1074. ['address.address']: data.address
  1075. });
  1076. });
  1077. });
  1078. },
  1079. atOnceBuy() {
  1080. //立即购买
  1081. // console.log("立即购买"); // if (this.data.isStates == 0) return req.msg('活动还未开始');
  1082. // if (this.data.isStates == 2) return req.msg('活动已结束');
  1083. // if (this.data.start) return req.msg('活动已结束');
  1084. if(!this.getUpdate()) return false;
  1085. let popup = this.pro;
  1086. popup.salePrice = this.salePrice;
  1087. popup.stock = this.pro.stock;
  1088. this.setData({
  1089. isShow: true,
  1090. popup: popup
  1091. });
  1092. },
  1093. //创建拼团
  1094. createGroup() {
  1095. req.isLogin().then(success => {});
  1096. if (!req.getStorage('userInfo')) return false;
  1097. // console.log(this.start);
  1098. if (this.start) return req.msg('活动已结束'); //state 1存在记录,2不存在,id创建团时存在则为已创建过团记录id,未创建则为-1 参与团id返回为传入的superiorId
  1099. if(!this.getUpdate()) return false;
  1100. if (this.myActData.state == 1) {
  1101. //存在拼团记录
  1102. this.jumpGoGroup(this.myActData.id);
  1103. } else {
  1104. //不存在,去创建
  1105. req.postRequest('/api/activity/carterActivityPurchaseRecords', {
  1106. acpId: this.act.id,
  1107. type: 3
  1108. }, res => {
  1109. // this.jumpGoGroup(res);
  1110. // this.atOnceBuy(res)
  1111. this.createGroupOrder(res);
  1112. });
  1113. }
  1114. },
  1115. createGroupOrder(aprId) {
  1116. const params = {
  1117. skuId: this.act.skuId,
  1118. quantity: 1,
  1119. productId: this.act.productId,
  1120. aprId: aprId
  1121. };
  1122. if (this.merchant && this.merchant.type != 5) {
  1123. params.merchantId = this.merchant.id;
  1124. }
  1125. if (this.merchant && this.merchant.type == 5) {
  1126. params.merchantId = this.merchant.merchantDTO.id
  1127. params.shopId = this.merchant.id;
  1128. }
  1129. if (this.act.id) params.activityId = this.act.id;
  1130. req.postRequest('/api/purchase/direct/buy', params, res => {
  1131. let redirect = '/product/subOrder/subOrder?ids=' + res;
  1132. redirect += '&orderType=' + 4;
  1133. redirect += '&aprId=' + aprId;
  1134. redirect += '&activityId=' + this.act.id;
  1135. if (params.merchantId) {
  1136. redirect += '&merchantId=' + params.merchantId;
  1137. }
  1138. if (params.shopId) {
  1139. redirect += '&shopId=' + params.shopId;
  1140. }
  1141. uni.navigateTo({
  1142. url: redirect
  1143. });
  1144. });
  1145. },
  1146. //校验是否开团
  1147. checkMyIsGroup() {
  1148. req.getRequest('/api/activity/participationActivity', {
  1149. acpId: this.act.id,
  1150. actId: this.act.actId,
  1151. productId: this.act.productId,
  1152. type: 3,
  1153. initOrPart: 1
  1154. }, res => {
  1155. this.setData({
  1156. myActData: res
  1157. });
  1158. });
  1159. },
  1160. toGoGroup(event) {
  1161. // req.isLogin().then(success => {
  1162. // })
  1163. if(!this.getUpdate()) return false;
  1164. const index = event.currentTarget.dataset.index;
  1165. const type = event.currentTarget.dataset.type;
  1166. let activityPurchaseRecord;
  1167. if (type == 1) {
  1168. activityPurchaseRecord = this.activityDot[index];
  1169. } else {
  1170. activityPurchaseRecord = this.activityPurchaseRecordListDTO[index];
  1171. }
  1172. // console.log(index, activityPurchaseRecord, type);
  1173. this.jumpGoGroup(activityPurchaseRecord.id);
  1174. },
  1175. //跳入到平团详情
  1176. jumpGoGroup(groupId) {
  1177. app.globalData.openPage('activity/group/ptDetail/ptDetail?acid=' + this.act.id + "&id=" + groupId +
  1178. "&merchantId=" +
  1179. this.query.merchantId);
  1180. },
  1181. addActivityRemind() {
  1182. req.postRequest('/api/activity/remind', {
  1183. activityId: this.act.id
  1184. }, res => {
  1185. requsetmessage.remind();
  1186. req.msg('订阅提醒成功');
  1187. this.setData({
  1188. isRemind: true
  1189. });
  1190. });
  1191. },
  1192. cancelActivityRemind(event) {
  1193. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  1194. } else {
  1195. req.postRequest('/api/activity/cancel/remind', {
  1196. id: this.act.id
  1197. }, res => {
  1198. req.msg('取消提醒成功');
  1199. this.setData({
  1200. isRemind: false
  1201. });
  1202. });
  1203. }
  1204. },
  1205. hidePopup() {
  1206. this.setData({
  1207. isShow: false
  1208. });
  1209. },
  1210. hidePopupLogin(data) {
  1211. this.isPopupLogin = false;
  1212. },
  1213. clickCollect() {
  1214. let _ts = this;
  1215. req.postRequest('/api/collect', {
  1216. bindId: this.pro.id,
  1217. type: 1
  1218. }, data => {
  1219. _ts.setData({
  1220. 'pro.isCollect': !_ts.pro.isCollect
  1221. });
  1222. });
  1223. },
  1224. goTop: function(e) {
  1225. // 一键回到顶部
  1226. if (uni.pageScrollTo) {
  1227. uni.pageScrollTo({
  1228. scrollTop: 0
  1229. });
  1230. } else {
  1231. uni.showModal({
  1232. title: '提示',
  1233. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  1234. });
  1235. }
  1236. },
  1237. onShareTimeline() {
  1238. let merchantId = '';
  1239. let path = 'id=' + this.query.id + '&acid=' + this.query.acid + '&isShareTimeline=' + true+'&appId='+req.getStorage('appId');
  1240. if (!req.getStorage('userInfo').id) {} else {
  1241. path += '&userId=' + req.getStorage('userInfo').id;
  1242. }
  1243. let shopId = '';
  1244. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  1245. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  1246. merchantId = req.getStorage('MERCHANT').id;
  1247. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  1248. path += '&shopId=' + req.getStorage('smallShop').id;
  1249. shopId = req.getStorage('smallShop').id;
  1250. merchantId = req.getStorage('smallShop').merchantDTO.id;
  1251. }
  1252. }
  1253. let url = '/activity/group/detail/detail?' + path;
  1254. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 7, this.query.acid + '_' + this
  1255. .query.id);
  1256. return {
  1257. title: (req.getStorage("userInfo").nickName ? req.getStorage("userInfo").nickName : '') + '邀请您参加拼团:' +
  1258. this.pro.title,
  1259. query: path,
  1260. imageUrl: this.pro.pic
  1261. }; // return {
  1262. // title: this.data.pro.title,
  1263. // imageUrl: this.data.pro.pic
  1264. // }
  1265. },
  1266. // 获取参团活动总人数
  1267. groupCount() {
  1268. let param = {
  1269. aprId: this.query.acid
  1270. };
  1271. req.getRequest('/api/activity/groupCount', param, data => {
  1272. this.setData({
  1273. count: data
  1274. });
  1275. });
  1276. },
  1277. // 是否开启小店
  1278. isShop() {
  1279. if (req.getStorage('distribution')) {
  1280. dist = req.getStorage('distribution')
  1281. this.setData({
  1282. distr: dist
  1283. })
  1284. console.log(dist)
  1285. if (dist.distributionSmallShopOpen == 1) {
  1286. req.postRequest('/api/shopBase/isOpenShop', {}, data => {
  1287. this.setData({
  1288. isshop: data
  1289. })
  1290. console.log(data)
  1291. })
  1292. }
  1293. }
  1294. },
  1295. addShop() { //添加到小店
  1296. req.postRequest('/api/shopProduct/save', {
  1297. productId: this.act.id,
  1298. type: 4
  1299. }, data => {
  1300. this.act.isJoinShop = true;
  1301. this.isHide = false;
  1302. })
  1303. },
  1304. hidePop() { //添加到小店
  1305. this.setData({
  1306. isHide: true
  1307. })
  1308. },
  1309. clickmore() {
  1310. // let arrayShow = [];
  1311. // let index = 0;
  1312. // for (let i = index; i < index + 5; i++) {
  1313. // if (this.data.activityPurchaseRecordListDTO[i]) {
  1314. // arrayShow.push(this.data.activityPurchaseRecordListDTO[i]);
  1315. // index = i;
  1316. // }
  1317. // }
  1318. // index = index + 1;
  1319. // if(arrayShow.length>=20){
  1320. // return req.msg("仅显示20个正在拼团的人")
  1321. // }
  1322. // this.setData({arrayShow:arrayShow})
  1323. // this.groupItemTimer()
  1324. // console.log("123",this.activityDot)
  1325. this.getPage();
  1326. this.setData({
  1327. show: true
  1328. });
  1329. },
  1330. eliminate() {
  1331. this.setData({
  1332. show: false
  1333. });
  1334. },
  1335. getPage() {
  1336. //获取系统信息:获取当前屏幕可见区域的宽和高
  1337. let that = this;
  1338. uni.getSystemInfo({
  1339. success: function(res) {
  1340. that.setData({
  1341. "windowWidth": res.windowWidth,
  1342. //可使用窗口宽度,单位px
  1343. "windowHeight": res.windowHeight //可使用窗口高度,单位px
  1344. });
  1345. // console.log(res.windowWidth, that.windowWidth);
  1346. // console.log(res.windowHeight, that.windowHeight);
  1347. }
  1348. });
  1349. },
  1350. showTab: function(e) {
  1351. this.setData({
  1352. tabIndex: e.detail
  1353. });
  1354. },
  1355. scoreTab: function(e) {
  1356. this.form.page = 0;
  1357. this.setData({
  1358. current: e.detail,
  1359. ['form.page']: 1
  1360. });
  1361. },
  1362. freshenFun: function(e) {
  1363. this.setData({
  1364. freshen: e.detail
  1365. });
  1366. },
  1367. // 获取品种保证
  1368. getGuarantee() {
  1369. return new Promise((data, rej) => {
  1370. req.getRequest('/api/config', {}, res => {
  1371. req.setStorage("configRes", JSON.stringify(res))
  1372. this.about = res
  1373. data(res)
  1374. if (this.merchant && this.merchant.isDefault == 1 || this.query.acid) {
  1375. // 切割;拿到数组,然后在过滤掉空值
  1376. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  1377. this.setData({
  1378. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  1379. return it = it && it.trim();
  1380. })
  1381. });
  1382. }
  1383. } else {
  1384. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  1385. this.setData({
  1386. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  1387. return it = it && it.trim();
  1388. })
  1389. });
  1390. }
  1391. } // if(res.Is_Store_Price_Stock){
  1392. // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
  1393. // }
  1394. if (res.is_open_shop) {
  1395. this.is_open_shop = res.is_open_shop;
  1396. }
  1397. if (res.is_open_comments) {
  1398. this.setData({
  1399. is_open_comments: res.is_open_comments
  1400. });
  1401. } // this.setData({ show_membership_price: res.show_membership_price, Is_Store_Price_Stock: res.Is_Store_Price_Stock, is_open_shop: res.is_open_shop })
  1402. });
  1403. })
  1404. },
  1405. getUpdate() {
  1406. let userInfos = req.getStorage('userInfo');
  1407. if(!userInfos.mobile){
  1408. console.log('没有手机号')
  1409. this.isShowUpdate = true;
  1410. this.isUpdateMobile = true;
  1411. req.setStorage('isShowUpdateMobile',true)
  1412. return false;
  1413. }
  1414. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf('用户') > -1 ) {
  1415. console.log('没有昵称')
  1416. this.isShowUpdate = true;
  1417. this.isUpdateInfo = true;
  1418. req.setStorage('isShowUpdateInfo',true)
  1419. return false;
  1420. }
  1421. return true;
  1422. },
  1423. closeUpdate(){
  1424. this.isShowUpdate = false
  1425. this.isUpdateInfo = false;
  1426. this.isUpdateMobile = false;
  1427. },
  1428. }
  1429. };
  1430. </script>
  1431. <style>
  1432. @import "./detail.css";
  1433. </style>