activity.vue 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998
  1. <template>
  2. <app-layout>
  3. <scroll-view @scrolltolower="getMore" :scroll-top="scrollTop" scroll-y @scroll="scroll" :style="{'height':`${windowHeight}px`}">
  4. <app-head v-if="getTheme" :theme="getTheme"></app-head>
  5. <!-- 团长信息 -->
  6. <view @click="toList" class="middleman dir-top-nowrap main-center">
  7. <view class="location t-omit">{{middleman.location}}</view>
  8. <view v-if="middleman.id > 0" class="middleman-info dir-left-nowrap">
  9. <image class="avatar" :src="middleman.avatar"></image>
  10. <view class="user-info">
  11. <view class="t-omit">{{middleman.name}} {{setting.middleman}} {{middleman.mobile}}</view>
  12. <view>
  13. <image class="icon" src="./../image/address.png"></image>
  14. <text>提货地址:{{middleman.province}}<text v-if="middleman.province != middleman.city">{{middleman.city}}</text>{{middleman.district}}{{middleman.detail}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view v-if="middleman.is_allow_change == 1" class="space">距离最近{{space}}</view>
  19. <image v-if="middleman.is_allow_change == 1" class="arrow-image" src="/static/image/icon/arrow-right-white.png"></image>
  20. </view>
  21. <!-- 团购活动状态 -->
  22. <view v-if="activity.time > 0" class="time dir-left-nowrap cross-center">
  23. <image class="icon" src="./../image/timeline.png"></image>
  24. <view>距离本次团购活动开始还有{{d}}天{{h}}时{{m}}分{{s}}秒</view>
  25. </view>
  26. <view v-if="activity.activity_status == 2" class="time">
  27. <text>团购已结束,下次记得早点来哦</text>
  28. </view>
  29. <view v-if="activity.activity_status == 3" class="time">
  30. <text>本次团购活动已经下架</text>
  31. </view>
  32. <view class="status-area" v-if="activity.activity_status == 1">
  33. <view class="status dir-top-nowrap main-center cross-center">
  34. <view v-if="activity.condition == 0" class="end-time">{{activity.end_at}}结束</view>
  35. <view v-else class="condition main-between">
  36. <view>
  37. <text v-if="activity.num - activity.condition_count > 0">还差<text class="end-time">{{activity.num - activity.condition_count}}</text>{{activity.condition == 1 ? '人':'件商品'}}</text>拼团成功
  38. </view>
  39. <view class="end-time">{{activity.end_at}}结束</view>
  40. </view>
  41. <!-- 进度条 -->
  42. <view class="progress" v-if="activity.condition > 0">
  43. <view :style="{'width': `${activity.rate}%`,'backgroundImage':`url(${bonusImg.progress})`}"></view>
  44. </view>
  45. <!-- 下单人数 -->
  46. <view class="main-center cross-center buy-user">
  47. <view class="user-list dir-right-nowrap">
  48. <image v-for="(item,index) in user_list" :key="index" class="avatar" :src="item.avatar"></image>
  49. </view>
  50. <view class="sales">
  51. <text>{{activity.user_num}}</text>
  52. 人已抢<text>{{activity.all_sales > activity.condition_count ? activity.all_sales : activity.condition_count}}</text>件
  53. </view>
  54. </view>
  55. <!-- 最新下单状态 -->
  56. <view v-if="user_list.length > 0" class="main-center cross-center new-buy">
  57. <image class="avatar" :src="user_list[user_list.length - 1].avatar"></image>
  58. <view>{{end_time}}参与团购</view>
  59. </view>
  60. </view>
  61. </view>
  62. <scroll-view :scroll-into-view="`scroll-${activeIndex}`" scroll-with-animation v-show="activity.id > 0" scroll-x class="app-scroll" :class="activity.time > 0 || activity.activity_status == 2 ? 'no-ing' : ''">
  63. <text class="app-item" v-for="(item, index) in nav_list"
  64. :key="item.id" :id="`scroll-${index}`"
  65. :style="{'color': cat_id == item.id ? getTheme.color : '', 'border-color': cat_id == item.id ? getTheme.border : ''}"
  66. :class="cat_id == item.id ? 'app-active-item' : ''"
  67. @click="changeStatus(item.id, index)"
  68. >{{item.name}}</text>
  69. </scroll-view>
  70. <!-- 商品 -->
  71. <view class="list">
  72. <view @click="toGoods(item)" class="goods dir-left-nowrap" v-for="item in list" :key="item.id">
  73. <view v-if="item.goods_stock === 0" class="out-dialog">
  74. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  75. </view>
  76. <image class="cover" mode='aspectFill' :src="item.cover_pic"></image>
  77. <view class="info">
  78. <view class="name t-omit-two">{{item.name}}</view>
  79. <view class="sale" :style="{'color': getTheme.color, 'border-color': getTheme.border}">
  80. <view style="position: relative">
  81. {{item.sales}}
  82. <view class="sale-bg" :style="{'background-color': getTheme.background}"></view>
  83. </view>
  84. <view class="stock">剩{{item.goods_stock}}{{item.goodsWarehouse.unit}}</view>
  85. </view>
  86. <view class="price" :style="{'color': getTheme.color}">¥{{item.min_price}}</view>
  87. <view :style="{'background-color': item.buy_goods_auth ? getTheme.background : '#9999999'}" class="cart" @click.stop="toBuy(item)" v-if="activity && activity.activity_status == 1 && item.goods_stock > 0">
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 购物车 -->
  93. <view @click="openCart" v-if="showCart && cart.length > 0" class="bg">
  94. <view class="dialog cart-dialog" @click.stop="" style="padding: 0;">
  95. <view v-if="activity.full_price.length > 0" class="cart-discount main-center">
  96. <view :style="{'color': getTheme.color}" v-for="(item,index) in activity.full_price" :key="index"><view class="discount-bg" :style="{'background-color': getTheme.background}"></view><text v-if="index > 0">,</text>满{{item.full_price}}减{{item.reduce_price}}</view>
  97. </view>
  98. <view class="title main-between">
  99. <view>已选商品</view>
  100. <view class="dir-right-nowrap cross-center" @click.stop="clearAll">
  101. <view style="color: #999999">清空购物车</view>
  102. <image src="/static/image/icon/delete.png"></image>
  103. </view>
  104. </view>
  105. <view class="goods-list">
  106. <view v-if="item.num > 0 || item.num == ''" class="goods dir-left-nowrap" v-for="(item,index) in cart" :key="item.id">
  107. <image class="cover" mode='aspectFill' :src="item.pic_url"></image>
  108. <view class="info">
  109. <view class="name t-omit-two" :style="{'color': item.is_exist == 1 ? '#353535': '#999999'}">{{item.name}}</view>
  110. <view class="attr">
  111. <text class="attr-group" v-for="(attr,idx) in item.attr_list" :key="idx">
  112. {{attr.attr_group_name}}:{{attr.attr_name}}
  113. </text>
  114. </view>
  115. <view style="height: 60rpx"></view>
  116. <view class="price" v-if="item.is_exist == 1" :style="{'color': getTheme.color}">¥{{item.price}}</view>
  117. <view class="price" v-else style="color: #353535">商品已失效</view>
  118. <view class="app-add-subtract dir-left-nowrap cross-center">
  119. <image class="app-icon" @click.stop="_calcValue(index,'minus')"
  120. :src="item.is_exist == 0 ? '/static/image/cart/unreducible.png' : '/static/image/icon/subtract.png'"
  121. ></image>
  122. <view class="app-value">
  123. <input v-model="item.num" v-if="item.is_exist == 1" @blur.stop="_onBlur(index)" type="number">
  124. <view v-else>{{item.num}}</view>
  125. </view>
  126. <image class="app-icon" v-show="is_loading" @load="imgLoad" @click.stop="_calcValue(index,'plus')"
  127. :src="item.num >= 99 || item.is_exist == 0 ? '/static/image/cart/can-add.png' : '/static/image/icon/add-but.png'"
  128. :style="{'background-color': getTheme.background}"></image>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <view v-if="is_exist" class="discount main-center" style="background-color: #f0f0f0;color: #999999;">
  134. <view>{{is_exist}}件商品已失效</view>
  135. </view>
  136. <view class="cart-placeholder cart-list-placeholder" :class="{'again-placeholder': is_exist}"></view>
  137. </view>
  138. </view>
  139. <!-- 买家信息 -->
  140. <view id="input" v-if="cart.length > 0 && activity.activity_status == 1" class="input-info">
  141. <view class="input-item">
  142. <view class="input-label">手机号</view>
  143. <view class="input">
  144. <input placeholder-style="color:#999999" type="number" placeholder="请输入手机号" v-model="mobile">
  145. </view>
  146. </view>
  147. <view class="input-item" @click="inputRemark = false">
  148. <view class="input-label">备注</view>
  149. <view class="input" v-if="inputRemark" :style="{'color': remark ? '#353535': '#999999'}">{{remark ? remark : '请输入备注'}}</view>
  150. <view class="input" v-else>
  151. <input placeholder-style="color:#999999" :focus="!inputRemark" @blur="inputRemark = true" maxlength="50" v-model="remark" placeholder="请输入备注">
  152. </view>
  153. </view>
  154. </view>
  155. <!-- 结算栏 -->
  156. <view v-if="cart.length > 0 && activity.activity_status == 1 && activity.full_price.length > 0" class="discount main-center">
  157. <view :style="{'color': getTheme.color}" v-for="(item,index) in activity.full_price" :key="index"><view class="discount-bg" :style="{'background-color': getTheme.background}"></view><text v-if="index > 0">,</text>满{{item.full_price}}减{{item.reduce_price}}</view>
  158. </view>
  159. <view v-if="cart.length > 0 && activity.activity_status == 1" class="cart-placeholder" :class="{'more-placeholder': is_middleman}"></view>
  160. <view v-if="cart.length > 0 && activity.activity_status == 1" class="cart-item main-between cross-center">
  161. <view @click="openCart" class="cart-left dir-left-nowrap">
  162. <view class="cart-icon">
  163. <image src="./../image/cart.png" class="cart"></image>
  164. <view :style="{'background-color': getTheme.background}">{{cartLength > 99 ? '99+':cartLength}}</view>
  165. </view>
  166. <view class="price-info main-center dir-top-nowrap">
  167. <view class="total-price t-omit">总计<text :style="{'color': getTheme.color}">¥{{total < 0 ? '0.00':total}}</text></view>
  168. <view class="minus-price t-omit">已减<text :style="{'color': getTheme.color}">¥{{minus}}</text></view>
  169. </view>
  170. </view>
  171. <view @click="toSubmit" class="cart-right" :style="{'background-color': getTheme.background}">确认下单</view>
  172. </view>
  173. <!-- 悬浮按钮 -->
  174. <view class="dialog-btn">
  175. <view v-if="is_middleman" @click="toIndex">
  176. <image src="./../image/user-index.png"></image>
  177. </view>
  178. <view @click="toOrder">
  179. <image src="./../image/user-order.png"></image>
  180. </view>
  181. <view @click="toUser">
  182. <image src="./../image/user-center.png"></image>
  183. </view>
  184. <view @click="showHiddenClick">
  185. <image src="./../image/user-share.png"></image>
  186. </view>
  187. </view>
  188. <u-attr
  189. v-if="goods"
  190. v-model="attrShow"
  191. :theme="getTheme"
  192. :goods="goods"
  193. :checked="selectAttr"
  194. @check="attr"
  195. :is_show_left="false"
  196. :is_show_right="false"
  197. >
  198. <template slot="right">
  199. <!-- 购物车信息 -->
  200. <view class="attr-bottom dir-left-nowrap">
  201. <view class="box-grow-1 dir-left-nowrap cross-center">
  202. <view class="total-price">总计<text :style="{'color': getTheme.color}">¥{{selectAttr ? attr_price : goods.price}}</text></view>
  203. </view>
  204. <view class="box-grow-1 u-add-btn main-center cross-center"
  205. :style="{'background': getTheme.background_gradient_btn}" @click="add">加入购物车
  206. </view>
  207. </view>
  208. </template>
  209. </u-attr>
  210. <!-- 推荐 -->
  211. <view v-if="recommendDialog" @click="recommendDialog=!recommendDialog" class="bg">
  212. <view class="dialog" @click.stop="" :animation="animationData">
  213. <view v-show="showOther" @click="recommendDialog=!recommendDialog" class="end-close main-center cross-center">
  214. <image src="/static/image/icon/icon-close.png"></image>
  215. </view>
  216. <view class="end-title">当前团购已结束</view>
  217. <view class="end-recommend main-center cross-center">
  218. <view class="end-line"></view>
  219. <view>为您推荐</view>
  220. <view class="end-line"></view>
  221. </view>
  222. <view class="end-sec-title">以下{{recommend.count}}个商品正在团购</view>
  223. <view class="main-center recommend-goods">
  224. <image v-if="index < 3" v-for="(item,index) in recommend.goods_list" :key="index" :src="item.cover_pic"></image>
  225. </view>
  226. <view v-show="showOther" class="to-activity" :style="{'background-color': getTheme.background}" @click="toActivity">去看看</view>
  227. </view>
  228. </view>
  229. <!-- 分享 -->
  230. <view>
  231. <app-share-qr-code @share="hShareAppMessage"
  232. :posterUrl="'/plugins/community/poster/poster?activity_id='+id + '&middleman_id='+middleman.user_id"
  233. :hasPosterNav="showShare" v-model="showShare" :url="poster"
  234. title="生成活动海报"></app-share-qr-code>
  235. </view>
  236. </scroll-view>
  237. <app-close v-if="showClose" :toBack="true" @update="getMall"></app-close>
  238. </app-layout>
  239. </template>
  240. <script>
  241. import {mapGetters, mapState} from 'vuex';
  242. import appHead from '../components/app-head.vue';
  243. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  244. import uAttr from '../../../components/page-component/goods/u-attr.vue';
  245. import AppClose from '../../../components/basic-component/app-close/app-close.vue';
  246. export default {
  247. data() {
  248. return {
  249. activeIndex: 0,
  250. nav_list: [],
  251. cat_id: -1,
  252. id: null,
  253. showCart: false,
  254. is_loading: false,
  255. submitLock: false,
  256. recommendDialog: false,
  257. showShare: false,
  258. stopLoad: false,
  259. showOther: false,
  260. more: false,
  261. is_middleman: false,
  262. share: false,
  263. default: false,
  264. inputRemark: true,
  265. cartLength: 0,
  266. windowHeight: 0,
  267. is_exist: 0,
  268. page: 1,
  269. poster: '',
  270. mobile: '',
  271. remark: '',
  272. d: '',
  273. h: '',
  274. m: '',
  275. s: '',
  276. selectAttr: {},
  277. animationData: {},
  278. animation: {},
  279. attr_price: '0.00',
  280. number: 1,
  281. space: '0m',
  282. display: 'none',
  283. // attrShow: 0,
  284. attrShow: false,
  285. scrollTop: 0,
  286. scrollHeight: 0,
  287. goods: null,
  288. timeInterval: null,
  289. buyBool: true,
  290. longitude: '',
  291. latitude: '',
  292. activity: {
  293. rate: 0
  294. },
  295. middleman: {},
  296. setting: {},
  297. recommend: {},
  298. list: [],
  299. cart: [],
  300. user_list: [],
  301. template_message_list: [],
  302. end_time: '1小时前',
  303. title: '',
  304. total: '0.00',
  305. minus: '0.00',
  306. middleman_id: 0,
  307. first: true,
  308. showClose: false,
  309. is_open: false,
  310. disable: 'disable'
  311. }
  312. },
  313. components: {
  314. appShareQrCode,
  315. appHead,
  316. uAttr,
  317. AppClose
  318. },
  319. computed: {
  320. ...mapGetters('mallConfig', {
  321. getTheme: 'getTheme'
  322. }),
  323. ...mapState({
  324. community: state => state.mallConfig.__wxapp_img.community,
  325. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  326. appImg: state => state.mallConfig.__wxapp_img.mall,
  327. appSetting: state => state.mallConfig.mall.setting,
  328. userInfo: state => state.user.info
  329. }),
  330. },
  331. onLoad(options) { this.$commonLoad.onload(options);
  332. let that = this;
  333. if(options.activity_id) {
  334. this.id = options.activity_id;
  335. }
  336. if(options.id) {
  337. this.id = options.id;
  338. }
  339. this.title = options.title;
  340. uni.setNavigationBarTitle({
  341. title: options.title,
  342. });
  343. uni.getSystemInfo({
  344. success: function (res) {
  345. that.windowHeight = res.windowHeight;
  346. }
  347. });
  348. // #ifndef H5
  349. uni.getLocation({
  350. success: (e) => {
  351. uni.hideLoading();
  352. that.longitude = e.longitude;
  353. that.latitude = e.latitude;
  354. if(this.$storage.getStorageSync('middleman_info')) {
  355. let middleman = this.$storage.getStorageSync('middleman_info');
  356. if(middleman.id > 0) {
  357. if(options.middleman_id) {
  358. that.middleman_id = options.middleman_id;
  359. that.share = true;
  360. }else {
  361. that.middleman_id = middleman.user_id
  362. }
  363. }
  364. }else {
  365. if(options.middleman_id) {
  366. that.middleman_id = options.middleman_id;
  367. that.share = true;
  368. }
  369. }
  370. that.$showLoading({
  371. type: 'global',
  372. text: '加载中...'
  373. });
  374. that.getSetting();
  375. },
  376. fail: () => {
  377. uni.hideLoading();
  378. uni.showModal({
  379. title: '提示',
  380. content: '获取位置信息失败,需要授权获取您的位置信息',
  381. showCancel: false,
  382. confirmText: '打开授权',
  383. success(e) {
  384. if (e.confirm) {
  385. uni.openSetting({});
  386. }
  387. }
  388. });
  389. },
  390. });
  391. // #endif
  392. // #ifdef H5
  393. if (that.$jwx.isWechat()) {
  394. that.$jwx.getLocation({
  395. success(res) {
  396. that.longitude = e.longitude;
  397. that.latitude = e.latitude;
  398. if(this.$storage.getStorageSync('middleman_info')) {
  399. let middleman = this.$storage.getStorageSync('middleman_info');
  400. if(middleman.id > 0) {
  401. if(options.middleman_id) {
  402. that.middleman_id = options.middleman_id;
  403. that.share = true;
  404. }else {
  405. that.middleman_id = middleman.user_id
  406. }
  407. }
  408. }else {
  409. if(options.middleman_id) {
  410. that.middleman_id = options.middleman_id;
  411. that.share = true;
  412. }
  413. }
  414. that.$showLoading({
  415. type: 'global',
  416. text: '加载中...'
  417. });
  418. that.getSetting();
  419. },
  420. fail: function () {
  421. uni.showToast({
  422. title: '请开启手机位置权限',
  423. icon: 'none',
  424. duration: 1000
  425. });
  426. },
  427. })
  428. }else {
  429. // uni.getLocation({
  430. // success: (e) => {
  431. // uni.hideLoading();
  432. that.longitude = 11;
  433. that.latitude = 22;
  434. if(this.$storage.getStorageSync('middleman_info')) {
  435. let middleman = this.$storage.getStorageSync('middleman_info');
  436. if(middleman.id > 0) {
  437. if(options.middleman_id) {
  438. that.middleman_id = options.middleman_id;
  439. that.share = true;
  440. }else {
  441. that.middleman_id = middleman.user_id
  442. }
  443. }
  444. }else {
  445. if(options.middleman_id) {
  446. that.middleman_id = options.middleman_id;
  447. that.share = true;
  448. }
  449. }
  450. that.$showLoading({
  451. type: 'global',
  452. text: '加载中...'
  453. });
  454. that.getSetting();
  455. // },
  456. // fail: (e) => {
  457. // uni.showToast({
  458. // title: '请开启手机位置权限',
  459. // icon: 'none',
  460. // duration: 1000
  461. // });
  462. // },
  463. // });
  464. }
  465. that.$jwx.getLocation({
  466. success: (e) => {
  467. uni.hideLoading();
  468. that.longitude = e.longitude;
  469. that.latitude = e.latitude;
  470. if(this.$storage.getStorageSync('middleman_info')) {
  471. let middleman = this.$storage.getStorageSync('middleman_info');
  472. if(middleman.id > 0) {
  473. if(options.middleman_id) {
  474. that.middleman_id = options.middleman_id;
  475. that.share = true;
  476. }else {
  477. that.middleman_id = middleman.user_id
  478. }
  479. }
  480. }else {
  481. if(options.middleman_id) {
  482. that.middleman_id = options.middleman_id;
  483. that.share = true;
  484. }
  485. }
  486. that.$showLoading({
  487. type: 'global',
  488. text: '加载中...'
  489. });
  490. that.getSetting();
  491. },
  492. fail: function () {
  493. uni.showToast({
  494. title: '请开启手机位置权限',
  495. icon: 'none',
  496. duration: 1000
  497. });
  498. },
  499. })
  500. // #endif
  501. // #ifdef MP-WEIXIN
  502. wx.showShareMenu({
  503. menus: ['shareAppMessage', 'shareTimeline']
  504. });
  505. // #endif
  506. },
  507. onUnload() {
  508. this.stopLoad = true;
  509. clearInterval(this.timeInterval);
  510. },
  511. onHide() {
  512. this.stopLoad = true;
  513. clearInterval(this.timeInterval);
  514. },
  515. onShow() {
  516. let that = this;
  517. if(this.stopLoad) {
  518. this.stopLoad = false;
  519. if(this.$storage.getStorageSync('bind')) {
  520. let bindInfo = this.$storage.getStorageSync('bind');
  521. if(bindInfo > 0) {
  522. that.$showLoading({
  523. type: 'global',
  524. text: '加载中...'
  525. });
  526. that.middleman = {};
  527. that.middleman_id = 0;
  528. if(this.$storage.getStorageSync('middleman_info')) {
  529. let middleman = this.$storage.getStorageSync('middleman_info');
  530. if(middleman.id > 0) {
  531. that.middleman_id = middleman.user_id;
  532. }
  533. that.getActivity('reload');
  534. }else {
  535. that.getActivity('reload');
  536. }
  537. this.$storage.removeStorageSync('bind');
  538. }else {
  539. that.getActivity('reload');
  540. }
  541. }else {
  542. if(that.id > 0) {
  543. that.getActivity();
  544. }
  545. }
  546. }
  547. },
  548. // #ifdef MP
  549. onShareAppMessage() {
  550. return this.hShareAppMessage();
  551. },
  552. // #endif
  553. methods: {
  554. hShareAppMessage(s = false) {
  555. return this.$shareAppMessage({
  556. title: this.setting.app_share_title ? this.setting.app_share_title : this.title,
  557. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : this.list[0].cover_pic,
  558. path: "/plugins/community/activity/activity",
  559. params: {
  560. id: this.id,
  561. user_id: this.userInfo.options.user_id,
  562. middleman_id: this.middleman.user_id
  563. }
  564. }, s);
  565. },
  566. changeStatus(id, index) {
  567. this.cat_id = id;
  568. this.page = 1;
  569. if (index < 2) {
  570. this.activeIndex = 0
  571. } else {
  572. this.activeIndex = index - 2
  573. }
  574. uni.showLoading({
  575. mask: true,
  576. title: '加载中'
  577. });
  578. this.getList(this.middleman.user_id);
  579. },
  580. requestCats(middleman_id) {
  581. this.$request({
  582. url: this.$api.community.cats,
  583. data: {
  584. id: this.id,
  585. middleman_id: middleman_id ? middleman_id : this.middleman.user_id
  586. }
  587. }).then(res => {
  588. if (res.code === 0) {
  589. this.nav_list = res.data.list;
  590. this.getList(middleman_id);
  591. }
  592. });
  593. },
  594. toSubmit() {
  595. this.showClose = false;
  596. setTimeout(()=>{
  597. this.showClose = true;
  598. })
  599. },
  600. getMall(e) {
  601. this.is_open = e.is_open == 1 ? true : false;
  602. if(this.is_open) {
  603. this.allBuy();
  604. }
  605. },
  606. scroll(e) {
  607. this.scrollHeight = e.detail.scrollTop;
  608. },
  609. getMore() {
  610. if(this.more) {
  611. this.page++;
  612. uni.showLoading({
  613. mask: true,
  614. title: '加载更多'
  615. });
  616. this.getOther();
  617. this.more = false;
  618. }
  619. },
  620. getOther() {
  621. let that = this;
  622. let para = {
  623. id: that.id,
  624. middleman_id: that.middleman.user_id,
  625. page: that.page,
  626. }
  627. if(that.cat_id > 0) {
  628. para.cat_id = that.cat_id
  629. }
  630. that.$request({
  631. url: that.$api.community.activity_goods,
  632. data: para
  633. }).then(response=>{
  634. uni.hideLoading();
  635. that.$hideLoading();
  636. if(response.code === 0) {
  637. if(response.data.list.length === 20) {
  638. that.more = true;
  639. }
  640. that.list = that.list.concat(response.data.list);
  641. }
  642. })
  643. },
  644. openCart() {
  645. this.showCart = !this.showCart;
  646. this.stopLoad = true;
  647. if(this.showCart == false) {
  648. this.stopLoad = false;
  649. this.getActivity();
  650. }
  651. },
  652. toList() {
  653. if(this.middleman.is_allow_change === '0') {
  654. return false;
  655. }
  656. uni.navigateTo({
  657. url: '/plugins/community/captain/captain?longitude=' + this.longitude + '&latitude='+ this.latitude
  658. });
  659. },
  660. showHiddenClick() {
  661. this.showShare = !this.showShare;
  662. },
  663. toGoods(item) {
  664. this.stopLoad = true;
  665. uni.navigateTo({
  666. url: '/plugins/community/goods/goods?goods_id=' + item.id + '&middleman_id=' + this.middleman.user_id
  667. });
  668. },
  669. toIndex() {
  670. this.stopLoad = true;
  671. uni.navigateTo({
  672. url: '/plugins/community/index/index'
  673. });
  674. },
  675. toOrder() {
  676. this.stopLoad = true;
  677. uni.navigateTo({
  678. url: '/plugins/community/order/order?is_user=1'
  679. });
  680. },
  681. toUser() {
  682. this.stopLoad = true;
  683. uni.navigateTo({
  684. url: '/pages/user-center/user-center'
  685. });
  686. },
  687. toActivity() {
  688. this.stopLoad = true;
  689. uni.redirectTo({
  690. url: '/plugins/community/activity/activity?id=' + this.recommend.activity_id
  691. });
  692. },
  693. attr(e) {
  694. this.selectAttr = e.item;
  695. this.number = e.number;
  696. this.attr_price = (+this.selectAttr.price * +this.number).toFixed(2);
  697. },
  698. imgLoad() {
  699. this.is_loading = true;
  700. },
  701. allBuy() {
  702. if(this.submitLock) {
  703. return false;
  704. }
  705. this.showCart = false;
  706. this.scrollTop = this.scrollHeight
  707. if(this.default) {
  708. this.$nextTick().then(() => {
  709. this.scrollTop = 9999999;
  710. this.default = false;
  711. })
  712. uni.showToast({
  713. title: '请确认手机号',
  714. icon: 'none',
  715. duration: 1000
  716. });
  717. return false;
  718. }
  719. if(this.mobile.length == 11 && (/0?(1)[0-9]{10}/.test(this.mobile))) {
  720. this.$subscribe(this.template_message_list).then(res => {
  721. this.submit();
  722. }).catch(() => {
  723. this.submit();
  724. });
  725. }else {
  726. this.$nextTick().then(() => {
  727. this.scrollTop = 9999999;
  728. })
  729. this.stopLoad = false;
  730. this.getActivity();
  731. uni.showToast({
  732. title: '请输入正确的手机号码',
  733. icon: 'none',
  734. duration: 1000
  735. });
  736. }
  737. },
  738. submit() {
  739. uni.showLoading({
  740. mask: true,
  741. title: '提交订单...'
  742. });
  743. this.stopLoad = true;
  744. this.submitLock = true;
  745. let goods_list = [];
  746. for(let i in this.cart) {
  747. if(this.cart[i].is_exist == 1) {
  748. let para = {};
  749. para.id = this.cart[i].goods_id;
  750. para.goods_attr_id = this.cart[i].goods_attr_id;
  751. para.num = this.cart[i].num;
  752. para.cart_id = this.cart[i].id;
  753. para.attr = this.cart[i].attr_list;
  754. para.cat_id = 0;
  755. para.form_data = [];
  756. goods_list.push(para);
  757. }
  758. }
  759. if(goods_list.length === 0) {
  760. uni.showToast({
  761. title: '请添加有效商品',
  762. icon: 'none',
  763. duration: 1000
  764. });
  765. return false
  766. }
  767. let mch_list = [{
  768. mch_id: 0,
  769. activity_id: this.id,
  770. middleman_id: this.middleman.user_id,
  771. goods_list: goods_list,
  772. distance: 0,
  773. remark: this.remark,
  774. order_form: [],
  775. use_integral: 0,
  776. user_coupon_id: 0
  777. }];
  778. let form = {};
  779. form.list = mch_list;
  780. form.address_id = 0;
  781. form.address = {
  782. name: this.userInfo.nickname,
  783. mobile: this.mobile
  784. };
  785. this.$request({
  786. url: this.$api.community.order_submit,
  787. data: {
  788. form_data: JSON.stringify(form)
  789. },
  790. method: 'post'
  791. }).then(response => {
  792. if (response.code === 0) {
  793. this.getPayOrderId(response.data.queue_id, response.data.token);
  794. } else {
  795. this.submitLock = false;
  796. this.stopLoad = false;
  797. uni.hideLoading();
  798. uni.showModal({
  799. title: '提示',
  800. content: response.msg,
  801. showCancel: false,
  802. });
  803. }
  804. }).catch(e => {
  805. this.submitLock = false;
  806. this.stopLoad = false;
  807. uni.hideLoading();
  808. uni.showModal({
  809. title: '提示',
  810. content: e.errMsg,
  811. showCancel: false,
  812. });
  813. });
  814. },
  815. getPayOrderId(queue_id, token) {
  816. this.$request({
  817. url: this.$api.order.pay_data,
  818. method: 'post',
  819. data: {
  820. queue_id: queue_id,
  821. token: token,
  822. },
  823. }).then(response => {
  824. if (response.code === 0) {
  825. if (response.data.retry && response.data.retry === 1) {
  826. this.getPayDataTimer = setTimeout(() => {
  827. this.getPayOrderId(queue_id, token);
  828. }, 1000);
  829. } else {
  830. uni.hideLoading();
  831. this.cart = [];
  832. this.pay(response.data);
  833. }
  834. } else {
  835. this.submitLock = false;
  836. uni.hideLoading();
  837. uni.showModal({
  838. title: '提示',
  839. content: response.msg,
  840. showCancel: false,
  841. });
  842. }
  843. }).catch(e => {
  844. this.submitLock = false;
  845. uni.hideLoading();
  846. uni.showModal({
  847. title: '提示',
  848. content: e.errMsg,
  849. showCancel: false,
  850. });
  851. });
  852. },
  853. pay(data) {
  854. this.$storage.removeStorageSync('middleman_info');
  855. this.$payment.pay(data.id).then(() => {
  856. this.submitLock = false;
  857. let url = '/plugins/community/order/order';
  858. uni.navigateTo({
  859. url: `/pages/order-submit/pay-result?payment_order_union_id=${data.id}&order_page_url=${url}`
  860. });
  861. }).catch(() => {
  862. this.submitLock = false;
  863. this.toOrder();
  864. });
  865. },
  866. _calcValue(index,type) {
  867. if(type === 'minus') {
  868. this.cart[index].num--;
  869. }else if(type === 'plus') {
  870. this.cart[index].num++;
  871. }
  872. this._onBlur(index);
  873. },
  874. _onBlur(index) {
  875. this.total = 0;
  876. this.cartLength = 0;
  877. for(let i in this.cart) {
  878. this.total = (+this.total + (+this.cart[i].price*this.cart[i].num));
  879. this.cartLength += +this.cart[i].num;
  880. }
  881. let minus = 0;
  882. for(let i in this.activity.full_price) {
  883. if(+this.activity.full_price[i].full_price < +this.total || +this.activity.full_price[i].full_price == +this.total) {
  884. if(this.activity.full_price[i].reduce_price > minus) {
  885. minus = +this.activity.full_price[i].reduce_price;
  886. }
  887. }
  888. }
  889. this.total = (+this.total - minus).toFixed(2);
  890. this.minus = minus.toFixed(2);
  891. if(this.cart[index].num == 0) {
  892. this.delCart(index)
  893. }else {
  894. this.$request({
  895. url: this.$api.community.cart_edit,
  896. data: {
  897. list: JSON.stringify(this.cart)
  898. },
  899. });
  900. }
  901. },
  902. clearAll() {
  903. let cart = [];
  904. for(let i in this.cart) {
  905. cart.push(this.cart[i].id)
  906. }
  907. this.cart = [];
  908. this.showCart = false;
  909. this.$request({
  910. url: this.$api.community.cart_delete,
  911. data: {
  912. cart_id_list: JSON.stringify(cart),
  913. },
  914. }).then(() => {
  915. this.stopLoad = false;
  916. this.getActivity();
  917. })
  918. },
  919. delCart(index) {
  920. let list = [];
  921. list.push(this.cart[index].id)
  922. this.cart.splice(index,1);
  923. this.total = 0;
  924. this.cartLength = 0;
  925. for(let i in this.cart) {
  926. this.total = (+this.total + (+this.cart[i].price*this.cart[i].num));
  927. this.cartLength += +this.cart[i].num
  928. }
  929. let minus = 0;
  930. for(let i in this.activity.full_price) {
  931. if(+this.activity.full_price[i].full_price < +this.total || +this.activity.full_price[i].full_price == +this.total) {
  932. if(this.activity.full_price[i].reduce_price > minus) {
  933. minus = +this.activity.full_price[i].reduce_price
  934. }
  935. }
  936. }
  937. this.total = (+this.total - minus).toFixed(2);
  938. this.minus = minus.toFixed(2);
  939. if(this.cart.length === 0) {
  940. this.showCart = false
  941. }
  942. this.$request({
  943. url: this.$api.community.cart_delete,
  944. data: {
  945. cart_id_list: list,
  946. },
  947. }).then(() => {
  948. this.stopLoad = false;
  949. this.getActivity();
  950. }).catch(() => {
  951. this.attrShow = false;
  952. uni.hideLoading();
  953. });
  954. },
  955. add() {
  956. uni.showLoading({
  957. mask: true,
  958. title: '加入购物车'
  959. });
  960. let para = {
  961. activity_id: this.id,
  962. goods_id: this.selectAttr.goods_id,
  963. goods_attr_id: this.selectAttr.id,
  964. num: this.number
  965. }
  966. this.$request({
  967. url: this.$api.community.cart_add,
  968. data: para,
  969. method: 'post'
  970. }).then(response => {
  971. if(response.code === 0) {
  972. this.addResult(response.data.queue_id, response.data.token);
  973. } else {
  974. uni.hideLoading();
  975. this.attrShow = false;
  976. uni.showToast({
  977. title: response.msg,
  978. icon: 'none',
  979. duration: 1000
  980. });
  981. }
  982. }).catch(() => {
  983. this.attrShow = false;
  984. uni.hideLoading();
  985. });
  986. },
  987. addResult(queue_id, token) {
  988. this.$request({
  989. url: this.$api.community.cart_result,
  990. method: 'post',
  991. data: {
  992. queue_id: queue_id,
  993. token: token,
  994. },
  995. }).then(response => {
  996. if (response.code === 0) {
  997. if (response.data && response.data.retry === 1) {
  998. this.getResult = setTimeout(() => {
  999. this.addResult(queue_id, token);
  1000. }, 1000);
  1001. } else {
  1002. this.attrShow = false;
  1003. let index = -1;
  1004. for(let i in this.cart) {
  1005. if(this.cart[i].goods_id == this.selectAttr.goods_id && this.cart[i].goods_attr_id == this.selectAttr.id) {
  1006. index = i;
  1007. }
  1008. }
  1009. if(index > -1) {
  1010. this.cart[index].num += +this.number;
  1011. } else {
  1012. let para = {
  1013. activity_id: this.id,
  1014. community_goods_id: this.goods.id,
  1015. goods_id: this.selectAttr.goods_id,
  1016. goods_attr_id: this.selectAttr.id,
  1017. num: this.number,
  1018. name: this.goods.name,
  1019. attr_list: this.selectAttr.attr_list,
  1020. pic_url: this.selectAttr.pic_url,
  1021. id: 0,
  1022. price: this.selectAttr.price,
  1023. is_exist: 1
  1024. }
  1025. this.cart.push(para);
  1026. }
  1027. this.total = 0;
  1028. this.cartLength = 0;
  1029. for(let item of this.cart) {
  1030. this.total = (+this.total + (+item.price*item.num));
  1031. this.cartLength += +item.num;
  1032. }
  1033. let minus = 0;
  1034. for(let i in this.activity.full_price) {
  1035. if(+this.activity.full_price[i].full_price < +this.total || +this.activity.full_price[i].full_price == +this.total) {
  1036. if(this.activity.full_price[i].reduce_price > minus) {
  1037. minus = +this.activity.full_price[i].reduce_price;
  1038. }
  1039. }
  1040. }
  1041. this.total = (+this.total - minus).toFixed(2);
  1042. this.minus = minus.toFixed(2);
  1043. uni.hideLoading();
  1044. setTimeout(()=>{
  1045. this.goods = null
  1046. })
  1047. }
  1048. } else {
  1049. uni.hideLoading();
  1050. uni.showModal({
  1051. title: '提示',
  1052. content: response.msg,
  1053. showCancel: false
  1054. });
  1055. }
  1056. }).catch(e => {
  1057. this.attrShow = false;
  1058. uni.hideLoading();
  1059. uni.showModal({
  1060. title: '提示',
  1061. content: e.errMsg,
  1062. showCancel: false
  1063. });
  1064. });
  1065. },
  1066. toBuy(item) {
  1067. if (!item.buy_goods_auth) {
  1068. this.$tips.showToast({
  1069. title: '您暂无权限购买该商品',
  1070. icon: 'none'
  1071. });
  1072. return;
  1073. }
  1074. this.selectAttr = null;
  1075. this.goods = item;
  1076. this.attrShow = true;
  1077. },
  1078. getCart() {
  1079. let that = this;
  1080. if(that.stopLoad) {
  1081. return false;
  1082. }
  1083. that.$request({
  1084. url: that.$api.community.cart,
  1085. data: {
  1086. middleman_id: that.middleman.user_id,
  1087. activity_id: that.activity.id,
  1088. }
  1089. }).then(response=>{
  1090. if(that.stopLoad) {
  1091. return false;
  1092. }
  1093. if(response.code === 0) {
  1094. that.total = 0;
  1095. that.cartLength = 0;
  1096. that.cart = response.data.list;
  1097. that.is_exist = 0;
  1098. for(let i in that.cart) {
  1099. if(that.cart[i].is_exist == 0) {
  1100. that.is_exist++;
  1101. }
  1102. that.total = (+that.total + (+that.cart[i].price*that.cart[i].num));
  1103. that.cartLength += +that.cart[i].num;
  1104. }
  1105. let minus = 0;
  1106. for(let i in that.activity.full_price) {
  1107. if(+that.activity.full_price[i].full_price < +that.total || +that.activity.full_price[i].full_price == +that.total) {
  1108. if(that.activity.full_price[i].reduce_price > minus) {
  1109. minus = +that.activity.full_price[i].reduce_price;
  1110. }
  1111. }
  1112. }
  1113. that.total = (+that.total - minus).toFixed(2);
  1114. that.minus = minus.toFixed(2);
  1115. }else {
  1116. that.stopLoad = true;
  1117. uni.showToast({
  1118. title: response.msg,
  1119. icon: 'none',
  1120. duration: 1000
  1121. });
  1122. if(response.msg === '所选活动已下架') {
  1123. setTimeout(()=>{
  1124. uni.navigateBack({});
  1125. },1000);
  1126. }
  1127. }
  1128. }).catch(() => {
  1129. that.$hideLoading();
  1130. });
  1131. },
  1132. getTime(time) {
  1133. if(time > 86399) {
  1134. this.d = Math.floor(time / 86400);
  1135. time = time - (86400*this.d);
  1136. }else {
  1137. this.d = 0;
  1138. }
  1139. if(time > 3599) {
  1140. this.h = Math.floor(time / 3600);
  1141. if(this.h < 10) {
  1142. this.h = '0' + this.h;
  1143. }
  1144. time = time - (3600*this.h);
  1145. }else {
  1146. this.h = '00'
  1147. }
  1148. if(time > 59) {
  1149. this.m = Math.floor(time / 60);
  1150. if(this.m < 10) {
  1151. this.m = '0' + this.m;
  1152. }
  1153. time = time - (60*this.m);
  1154. }else {
  1155. this.m = '00';
  1156. }
  1157. if(time < 60) {
  1158. this.s = time;
  1159. if(this.s < 10) {
  1160. this.s = '0' + this.s;
  1161. }
  1162. }
  1163. },
  1164. getSetting() {
  1165. let that = this;
  1166. that.$request({
  1167. url: that.$api.community.setting,
  1168. }).then(response=>{
  1169. if(response.code === 0) {
  1170. that.head = that.community.a;
  1171. switch(that.getTheme.key) {
  1172. case 'b':
  1173. that.head = that.community.b;
  1174. break;
  1175. case 'c':
  1176. that.head = that.community.c;
  1177. break;
  1178. case 'd':
  1179. that.head = that.community.d;
  1180. break;
  1181. case 'e':
  1182. that.head = that.community.e;
  1183. break;
  1184. case 'g':
  1185. that.head = that.community.g;
  1186. break;
  1187. case 'h':
  1188. that.head = that.community.h;
  1189. break;
  1190. case 'i':
  1191. that.head = that.community.i;
  1192. break;
  1193. }
  1194. that.setting = response.data;
  1195. that.getActivity();
  1196. }else {
  1197. that.$hideLoading();
  1198. uni.showToast({
  1199. title: response.msg,
  1200. icon: 'none',
  1201. duration: 1000
  1202. });
  1203. }
  1204. }).catch(() => {
  1205. that.$hideLoading();
  1206. });
  1207. },
  1208. getList(middleman_id) {
  1209. let that = this;
  1210. let para = {
  1211. type: 1,
  1212. id: that.id,
  1213. }
  1214. para.middleman_id = middleman_id ? middleman_id: that.middleman.user_id
  1215. if(that.cat_id > 0) {
  1216. para.cat_id = that.cat_id
  1217. }
  1218. that.$request({
  1219. url: that.$api.community.activity_goods,
  1220. data: para
  1221. }).then(response=>{
  1222. uni.hideLoading();
  1223. that.$hideLoading();
  1224. if(response.data.list.length === 0) {
  1225. that.page = 1;
  1226. that.stopLoad = true;
  1227. uni.showToast({
  1228. title: '活动商品异常,正在返回活动主页',
  1229. icon: 'none',
  1230. duration: 1000
  1231. });
  1232. setTimeout(()=>{
  1233. uni.redirectTo({
  1234. url: '/plugins/community/list/list'
  1235. });
  1236. },1000);
  1237. return false;
  1238. }
  1239. that.list = response.data.list;
  1240. response.data.list.length < 20 ? that.more = false : that.more = true;
  1241. })
  1242. },
  1243. getActivity(string) {
  1244. let that = this;
  1245. let para = {
  1246. id: that.id,
  1247. longitude: that.longitude,
  1248. latitude: that.latitude
  1249. }
  1250. if(that.middleman_id > 0) {
  1251. para.middleman_id = that.middleman_id
  1252. }
  1253. that.$request({
  1254. url: that.$api.community.user_activity,
  1255. data: para
  1256. }).then(response=>{
  1257. if(response.code === 0) {
  1258. if(that.nav_list.length == 0 || string == 'reload') {
  1259. that.requestCats(response.data.middleman_info.user_id);
  1260. }
  1261. if(!that.mobile && response.data.last_mobile) {
  1262. that.mobile = response.data.last_mobile;
  1263. that.default = true;
  1264. }
  1265. that.activity = response.data.activity;
  1266. that.is_middleman = response.data.is_middleman;
  1267. that.middleman = response.data.middleman_info;
  1268. if(that.middleman_id == 0) {
  1269. if(this.$storage.getStorageSync('middleman_info')) {
  1270. let middleman = this.$storage.getStorageSync('middleman_info');
  1271. if(middleman.id > 0) {
  1272. that.middleman = middleman;
  1273. }
  1274. }
  1275. }
  1276. that.space = ~~that.middleman.distance +'m';
  1277. if(that.middleman.distance > 1000) {
  1278. that.space = (that.middleman.distance / 1000).toFixed(1) + 'km';
  1279. }
  1280. if(that.share) {
  1281. this.$storage.setStorageSync('middleman_info',that.middleman);
  1282. }
  1283. that.user_list = response.data.user_list;
  1284. if(that.user_list.length > that.activity.user_num){
  1285. that.user_list = that.user_list.slice(0,that.activity.user_num);
  1286. }
  1287. that.template_message_list = response.data.template_message_list;
  1288. if(that.activity.activity_status == 1) {
  1289. if(!that.stopLoad) {
  1290. setTimeout(function(){
  1291. that.getActivity();
  1292. },8000)
  1293. }
  1294. that.getCart();
  1295. let end_time = Math.floor(that.user_list[that.user_list.length - 1].time / 60);
  1296. if(end_time > 60) {
  1297. that.end_time = '1小时前';
  1298. }else if(end_time == 0) {
  1299. that.end_time = '刚刚';
  1300. }else {
  1301. that.end_time = end_time+ '分钟前';
  1302. }
  1303. }
  1304. if(that.activity.activity_status == 2 && response.data.recommend_activity.activity_id > 0) {
  1305. setTimeout(function(){
  1306. that.recommend = response.data.recommend_activity;
  1307. that.recommendDialog = true;
  1308. var animation = uni.createAnimation({
  1309. duration: 1000,
  1310. timingFunction: 'ease',
  1311. })
  1312. that.animation = animation;
  1313. setTimeout(function(){
  1314. animation.bottom(0).step();
  1315. that.animationData = animation.export();
  1316. setTimeout(function(){
  1317. that.showOther = true;
  1318. },1500);
  1319. },200);
  1320. },800);
  1321. }
  1322. if(that.activity.time > 0) {
  1323. let time = that.activity.time;
  1324. that.timeInterval = setInterval(() =>{
  1325. that.getTime(time);
  1326. time--;
  1327. if(time == 0) {
  1328. clearInterval(that.timeInterval);
  1329. that.getActivity();
  1330. }
  1331. },1000);
  1332. }
  1333. }else {
  1334. that.stopLoad = true;
  1335. if(response.msg === '周边没有活动可参加') {
  1336. uni.showToast({
  1337. title: '周边没有活动可参加,正在返回活动主页',
  1338. icon: 'none',
  1339. duration: 1000
  1340. });
  1341. setTimeout(()=>{
  1342. uni.redirectTo({
  1343. url: '/plugins/community/list/list'
  1344. });
  1345. },1000);
  1346. }else {
  1347. uni.showToast({
  1348. title: response.msg,
  1349. icon: 'none',
  1350. duration: 1000
  1351. });
  1352. }
  1353. }
  1354. }).catch(() => {
  1355. uni.hideLoading();
  1356. that.$hideLoading();
  1357. });
  1358. },
  1359. },
  1360. // #ifdef MP-WEIXIN
  1361. onShareTimeline: function() {
  1362. return this.$shareTimeline({
  1363. title: this.share_title ? this.share_title : this.title,
  1364. query: {
  1365. id: this.id,
  1366. user_id: this.userInfo.options.user_id,
  1367. middleman_id: this.middleman.user_id
  1368. }
  1369. });
  1370. }
  1371. // #endif
  1372. }
  1373. </script>
  1374. <style scoped lang="scss">
  1375. .app-scroll {
  1376. height: 80rpx;
  1377. background-color: #fff;
  1378. position: relative;
  1379. width: 702rpx;
  1380. margin: 0 24rpx 24rpx;
  1381. border-radius: 16rpx;
  1382. white-space: nowrap;
  1383. font-size: 26rpx;
  1384. padding-top: 20rpx;
  1385. &.no-ing {
  1386. border-top-left-radius: 0;
  1387. border-top-right-radius: 0;
  1388. }
  1389. .app-item {
  1390. display: inline-block;
  1391. padding-bottom: 10rpx;
  1392. padding-right: 5rpx;
  1393. margin-left: 40rpx;
  1394. margin-right: 15rpx;
  1395. &.app-active-item {
  1396. border-bottom: 2rpx solid;
  1397. }
  1398. }
  1399. }
  1400. .middleman {
  1401. margin-top: -360rpx;
  1402. height: 190rpx;
  1403. color: #ffffff;
  1404. padding: 0 35rpx;
  1405. position: relative;
  1406. .space {
  1407. color: #fff;
  1408. font-size: 22rpx;
  1409. position: absolute;
  1410. top: 45rpx;
  1411. right: 30rpx;
  1412. }
  1413. .arrow-image {
  1414. margin-left: 36rpx;
  1415. width: #{12rpx};
  1416. height: #{24rpx};
  1417. position: absolute;
  1418. top: 50%;
  1419. right: 30rpx;
  1420. margin-top: -12rpx;
  1421. }
  1422. .location {
  1423. font-size: 40rpx;
  1424. width: 70%;
  1425. margin-bottom: 15rpx;
  1426. margin-top: -10rpx;
  1427. }
  1428. .middleman-info {
  1429. font-size: 26rpx;
  1430. .avatar {
  1431. width: 58rpx;
  1432. height: 58rpx;
  1433. border-radius: 50%;
  1434. margin-right: 20rpx;
  1435. flex-shrink: 0;
  1436. }
  1437. .user-info {
  1438. .icon {
  1439. height: 25rpx;
  1440. width: 25rpx;
  1441. margin-right: 6rpx;
  1442. color: #ff4544;
  1443. }
  1444. }
  1445. }
  1446. }
  1447. .time {
  1448. padding: 0 36rpx;
  1449. color: #ff4544;
  1450. height: 90rpx;
  1451. line-height: 90rpx;
  1452. margin: 0 24rpx;
  1453. width: 702rpx;
  1454. border-top-left-radius: 16rpx;
  1455. border-top-right-radius: 16rpx;
  1456. background-color: #F2F2F2;
  1457. position: relative;
  1458. z-index: 2;
  1459. font-size: 24rpx;
  1460. .icon {
  1461. color: #ff4544;
  1462. width: 24rpx;
  1463. height: 24rpx;
  1464. margin-right: 10rpx;
  1465. }
  1466. }
  1467. .status-area {
  1468. width: 702rpx;
  1469. margin: 0 24rpx;
  1470. padding-bottom: 24rpx;
  1471. border-radius: 16rpx;
  1472. background-color: #f7f7f7;
  1473. position: relative;
  1474. z-index: 2;
  1475. .status {
  1476. background-color: #fff;
  1477. border-radius: 16rpx;
  1478. padding: 24rpx;
  1479. .end-time {
  1480. color: #ff4544;
  1481. text-align: center;
  1482. font-size: 24rpx;
  1483. }
  1484. .condition {
  1485. color: #353535;
  1486. font-size: 24rpx;
  1487. width: 100%;
  1488. .end-time {
  1489. color: #ff4544;
  1490. }
  1491. }
  1492. .progress {
  1493. width: #{654rpx};
  1494. background-color: #f0f0f0;
  1495. border-radius: #{10rpx};
  1496. height: #{20rpx};
  1497. position: relative;
  1498. margin: 15rpx 0;
  1499. overflow: hidden;
  1500. view {
  1501. border-radius: #{10rpx};
  1502. height: #{20rpx};
  1503. position: absolute;
  1504. top: 0;
  1505. left: 0;
  1506. z-index: 2;
  1507. }
  1508. }
  1509. .buy-user {
  1510. height: 58rpx;
  1511. .user-list {
  1512. image {
  1513. width: 58rpx;
  1514. height: 58rpx;
  1515. margin-left: -14rpx;
  1516. border-radius: 50%;
  1517. border: 2rpx solid #ffffff;
  1518. }
  1519. }
  1520. .sales {
  1521. font-size: 24rpx;
  1522. line-height: 58rpx;
  1523. height: 58rpx;
  1524. margin-left: 14rpx;
  1525. text {
  1526. color: #ff4544;
  1527. }
  1528. }
  1529. }
  1530. .new-buy {
  1531. margin-top: 20rpx;
  1532. color: #999999;
  1533. font-size: 24rpx;
  1534. image {
  1535. width: 60rpx;
  1536. height: 60rpx;
  1537. border-radius: 50%;
  1538. display: block;
  1539. margin-right: 20rpx;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. .list {
  1545. margin: 0 24rpx;
  1546. width: 702rpx;
  1547. .goods {
  1548. background-color: #fff;
  1549. border-radius: 16rpx;
  1550. width: 702rpx;
  1551. height: 220rpx;
  1552. margin-bottom: 20rpx;
  1553. position: relative;
  1554. z-index: 2;
  1555. .out-dialog {
  1556. width: #{220rpx};
  1557. height: #{220rpx};
  1558. border-radius: #{16rpx};
  1559. position: absolute;
  1560. top: 0;
  1561. left: 0;
  1562. z-index: 10;
  1563. background-color: rgba(0,0,0,.5);
  1564. image {
  1565. width: #{220rpx};
  1566. height: #{220rpx};
  1567. border-radius: #{16rpx};
  1568. }
  1569. }
  1570. .cover {
  1571. height: 220rpx;
  1572. width: 220rpx;
  1573. border-radius: 16rpx;
  1574. margin-right: 15rpx;
  1575. }
  1576. .info {
  1577. padding: 20rpx 0;
  1578. position: relative;
  1579. .name {
  1580. width: 445rpx;
  1581. // #ifndef MP-ALIPAY
  1582. height: 72rpx;
  1583. // #endif
  1584. // #ifdef MP-ALIPAY
  1585. height: 66rpx;
  1586. // #endif
  1587. font-size: 28rpx;
  1588. }
  1589. .sale {
  1590. height: 30rpx;
  1591. line-height: 28rpx;
  1592. font-size: 22rpx;
  1593. margin-top: 18rpx;
  1594. display: inline-block;
  1595. position: relative;
  1596. >view {
  1597. padding: 0 10rpx;
  1598. border: 2rpx solid;
  1599. display: inline-block;
  1600. }
  1601. .sale-bg {
  1602. padding: 0;
  1603. position: absolute;
  1604. top: 0;
  1605. left: 0;
  1606. opacity: 0.1;
  1607. border-top-left-radius: 15rpx;
  1608. border-bottom-left-radius: 15rpx;
  1609. border: 0;
  1610. height: 100%;
  1611. width: 100%;
  1612. }
  1613. view:first-of-type {
  1614. border-right: 0;
  1615. border-top-left-radius: 15rpx;
  1616. border-bottom-left-radius: 15rpx;
  1617. }
  1618. .stock {
  1619. border-top-right-radius: 15rpx;
  1620. border-bottom-right-radius: 15rpx;
  1621. border-left: 0;
  1622. background-color: #fff;
  1623. }
  1624. }
  1625. .price {
  1626. font-size: 32rpx;
  1627. position: absolute;
  1628. bottom: 20rpx;
  1629. left: 0;
  1630. }
  1631. .cart {
  1632. background-repeat: no-repeat;
  1633. background-size: 100% 100%;
  1634. background-image:url("../../../static/image/icon/cats.png");
  1635. border: 0;
  1636. border-radius: 50%;
  1637. position: absolute;
  1638. bottom: 20rpx;
  1639. right: 0;
  1640. width: 80rpx;
  1641. height: 80rpx;
  1642. z-index: 2;
  1643. }
  1644. }
  1645. }
  1646. }
  1647. .cart-placeholder {
  1648. height: 450rpx;
  1649. &.cart-list-placeholder {
  1650. height: 150rpx;
  1651. &.again-placeholder {
  1652. height: 210rpx;
  1653. }
  1654. }
  1655. &.more-placeholder {
  1656. height: 540rpx;
  1657. }
  1658. }
  1659. .total-price {
  1660. width: 350rpx;
  1661. text {
  1662. font-size: 32rpx;
  1663. }
  1664. }
  1665. .minus-price {
  1666. width: 350rpx;
  1667. }
  1668. .discount {
  1669. position: fixed;
  1670. bottom: 145rpx;
  1671. left: 0;
  1672. height: 60rpx;
  1673. line-height: 60rpx;
  1674. width: 100%;
  1675. font-size: 24rpx;
  1676. z-index: 10;
  1677. background-color: #fff;
  1678. .discount-bg {
  1679. position: fixed;
  1680. bottom: 145rpx;
  1681. left: 0;
  1682. height: 60rpx;
  1683. line-height: 60rpx;
  1684. width: 100%;
  1685. opacity: 0.1;
  1686. z-index: 10;
  1687. }
  1688. text {
  1689. margin-right: 10rpx;
  1690. }
  1691. }
  1692. .cart-item {
  1693. position: fixed;
  1694. bottom: 0;
  1695. left: 0;
  1696. height: 145rpx;
  1697. width: 100%;
  1698. padding: 0 16rpx 24rpx;
  1699. background-color: #fff;
  1700. z-index: 20;
  1701. box-shadow: 0 0 #{10rpx} rgba(0,0,0,.3);
  1702. .cart-left {
  1703. font-size: 24rpx;
  1704. color: #353535;
  1705. height: 74rpx;
  1706. line-height: 74rpx;
  1707. .cart-icon {
  1708. position: relative;
  1709. margin-right: 45rpx;
  1710. image {
  1711. width: 74rpx;
  1712. height: 74rpx;
  1713. border-radius: 50%;
  1714. }
  1715. view {
  1716. position: absolute;
  1717. top: -5rpx;
  1718. left: 52rpx;
  1719. height: #{34rpx};
  1720. line-height: #{34rpx};
  1721. border-radius: #{17rpx};
  1722. color: #fff;
  1723. padding: 0 #{10rpx};
  1724. }
  1725. }
  1726. .price-info {
  1727. height: 74rpx;
  1728. >view {
  1729. height: 37rpx;
  1730. line-height: 37rpx;
  1731. }
  1732. }
  1733. }
  1734. .cart-right {
  1735. font-size: 28rpx;
  1736. color: #fff;
  1737. height: 78rpx;
  1738. line-height: 78rpx;
  1739. border-radius: 39rpx;
  1740. padding: 0 50rpx;
  1741. }
  1742. }
  1743. .dialog-btn {
  1744. position: fixed;
  1745. bottom: 175rpx;
  1746. left: 30rpx;
  1747. z-index: 10;
  1748. >view {
  1749. margin-top: 10rpx;
  1750. width: 80rpx;
  1751. height: 80rpx;
  1752. image {
  1753. width: 80rpx;
  1754. height: 80rpx;
  1755. }
  1756. }
  1757. }
  1758. .bg {
  1759. position: fixed;
  1760. top: 0;
  1761. left: 0;
  1762. width: 100%;
  1763. height: 100%;
  1764. background-color: rgba(0,0,0,.3);
  1765. z-index: 18;
  1766. .dialog {
  1767. background-color: #fff;
  1768. border-top-left-radius: 16rpx;
  1769. border-top-right-radius: 16rpx;
  1770. position: fixed;
  1771. bottom: -600rpx;
  1772. left: 0;
  1773. width: 100%;
  1774. z-index: 19;
  1775. padding: 0 24rpx;
  1776. &.cart-dialog {
  1777. bottom: 0
  1778. }
  1779. .cart-discount {
  1780. height: 60rpx;
  1781. line-height: 60rpx;
  1782. width: 100%;
  1783. font-size: 24rpx;
  1784. z-index: 10;
  1785. border-top-left-radius: 16rpx;
  1786. border-top-right-radius: 16rpx;
  1787. position: relative;
  1788. .discount-bg {
  1789. position: absolute;
  1790. top: 0;
  1791. left: 0;
  1792. width: 100%;
  1793. height: 100%;
  1794. opacity: 0.1;
  1795. }
  1796. text {
  1797. margin-right: 10rpx;
  1798. }
  1799. }
  1800. .title {
  1801. height: 84rpx;
  1802. line-height: 84rpx;
  1803. font-size: 26rpx;
  1804. padding: 0 24rpx;
  1805. color: #353535;
  1806. image {
  1807. display: block;
  1808. width: 40rpx;
  1809. height: 40rpx;
  1810. margin-right: 12rpx;
  1811. }
  1812. }
  1813. .goods-list {
  1814. padding: 0 24rpx;
  1815. max-height: 510rpx;
  1816. overflow: auto;
  1817. }
  1818. .goods {
  1819. background-color: #fff;
  1820. border-radius: 8rpx;
  1821. width: 702rpx;
  1822. margin-bottom: 20rpx;
  1823. padding-top: 20rpx;
  1824. border-top: 2rpx solid #e2e2e2;
  1825. position: relative;
  1826. z-index: 22;
  1827. &:first-of-type {
  1828. border-top: 0;
  1829. padding-top: 0;
  1830. }
  1831. .cover {
  1832. height: 180rpx;
  1833. width: 180rpx;
  1834. border-radius: 8rpx;
  1835. margin-right: 25rpx;
  1836. }
  1837. .info {
  1838. position: relative;
  1839. width: 492rpx;
  1840. .name {
  1841. width: 445rpx;
  1842. max-height: 72rpx;
  1843. font-size: 28rpx;
  1844. margin-bottom: 20rpx;
  1845. }
  1846. .attr {
  1847. font-size: 24rpx;
  1848. color: #999999;
  1849. .attr-group {
  1850. margin-left: 10rpx;
  1851. &:first-of-type {
  1852. margin-left: 0;
  1853. }
  1854. }
  1855. }
  1856. .price {
  1857. font-size: 30rpx;
  1858. position: absolute;
  1859. bottom: 0;
  1860. left: 0;
  1861. }
  1862. .app-add-subtract {
  1863. height: #{60rpx};
  1864. position: absolute;
  1865. bottom: 0;
  1866. right: 0;
  1867. .app-icon {
  1868. height: #{44rpx};
  1869. width: #{44rpx};
  1870. background-size: 100% 100%;
  1871. background-repeat: no-repeat;
  1872. }
  1873. .app-value {
  1874. height: #{60rpx};
  1875. width: #{88rpx};
  1876. input,view {
  1877. height: #{60rpx};
  1878. width: #{88rpx};
  1879. font-size: #{26rpx};
  1880. color: #353535;
  1881. background-color: #ffffff;
  1882. text-align: center;
  1883. }
  1884. view {
  1885. line-height: #{60rpx};
  1886. color: #999999;
  1887. }
  1888. }
  1889. }
  1890. }
  1891. }
  1892. .end-close {
  1893. position: fixed;
  1894. bottom: 488rpx;
  1895. right: 0;
  1896. z-index: 20;
  1897. width: 80rpx;
  1898. height: 80rpx;
  1899. padding: 25rpx;
  1900. image {
  1901. width: 30rpx;
  1902. height: 30rpx;
  1903. }
  1904. }
  1905. .end-title {
  1906. margin-top: 40rpx;
  1907. font-size: 32rpx;
  1908. color: #353535;
  1909. text-align: center;
  1910. }
  1911. .end-recommend {
  1912. font-size: 24rpx;
  1913. color: #999999;
  1914. height: 70rpx;
  1915. .end-line {
  1916. width: 40rpx;
  1917. height: 2rpx;
  1918. background-color: #999999;
  1919. margin: 0 15rpx;
  1920. }
  1921. }
  1922. .end-sec-title {
  1923. font-size: 28rpx;
  1924. color: #353535;
  1925. text-align: center;
  1926. }
  1927. .recommend-goods {
  1928. margin-top: 25rpx;
  1929. margin-bottom: 135rpx;
  1930. image {
  1931. width: 220rpx;
  1932. height: 220rpx;
  1933. border-radius: 8rpx;
  1934. display: block;
  1935. margin: 0 33rpx;
  1936. }
  1937. }
  1938. .to-activity {
  1939. position: fixed;
  1940. bottom: 0;
  1941. left: 0;
  1942. height: 100rpx;
  1943. width: 100%;
  1944. text-align: center;
  1945. line-height: 100rpx;
  1946. color: #fff;
  1947. font-size: 30rpx;
  1948. }
  1949. }
  1950. }
  1951. .attr-bottom {
  1952. position: fixed;
  1953. z-index: 1666;
  1954. bottom: 0;
  1955. left: 0;
  1956. height: #{110rpx};
  1957. width: 100%;
  1958. padding: 20upx 24upx;
  1959. font-size: $uni-font-size-general-one;
  1960. .total-price {
  1961. margin-left: 25rpx;
  1962. }
  1963. }
  1964. .input-info {
  1965. margin: 0 24rpx;
  1966. background-color: #fff;
  1967. border-radius: 16rpx;
  1968. width: 702rpx;
  1969. .input-item {
  1970. font-size: 26rpx;
  1971. padding: 30rpx;
  1972. padding-bottom: 15rpx;
  1973. border-top: 2rpx solid #e2e2e2;
  1974. view.input {
  1975. line-height: 52rpx;
  1976. word-break: break-all;
  1977. }
  1978. &:first-of-type {
  1979. border-top: 0;
  1980. }
  1981. .input-label {
  1982. color: #666;
  1983. margin-bottom: 10rpx;
  1984. }
  1985. }
  1986. }
  1987. .u-add-btn {
  1988. color: #ffffff;
  1989. border-radius: 35upx;
  1990. }
  1991. </style>