金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4509 lines
149 KiB

  1. <template>
  2. <view style="position: relative;">
  3. <view class="top-tap mx-1px-bottom" v-show="!detailData.data.shop_hidden_more_info">
  4. <view class="item">
  5. <view class="name active" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="activeName == 'shop'" data-type="shop" @tap="jumpScroll">
  6. 商品
  7. </view>
  8. <view class="name" v-else data-type="shop" @tap="jumpScroll">
  9. 商品
  10. </view>
  11. </view>
  12. <view class="item">
  13. <view class="name active" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="activeName == 'comment'" data-type="comment" @tap="jumpScroll">
  14. 评价
  15. </view>
  16. <view class="name" v-else data-type="comment" @tap="jumpScroll">
  17. 评价
  18. </view>
  19. </view>
  20. <view class="item">
  21. <view class="name active" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="activeName == 'details'" data-type="details" @tap="jumpScroll">
  22. 详情
  23. </view>
  24. <view class="name" v-else data-type="details" @tap="jumpScroll">
  25. 详情
  26. </view>
  27. </view>
  28. <!-- <view class="item ">
  29. <view class="name active" style="color: {{config.mainColor}}; border-color: {{config.mainColor}}" v-if="{{activeName == 'recommend'}}" data-type="recommend" @tap="jumpScroll">
  30. 推荐
  31. </view>
  32. <view class="name" v-else data-type="recommend" @tap="jumpScroll">
  33. 推荐
  34. </view>
  35. </view> -->
  36. <!-- #ifdef MP-WEIXIN -->
  37. <view class="share" @tap="changeShare">
  38. <i class="iconfont icon--fenxiang"></i>
  39. </view>
  40. <!-- #endif -->
  41. <!-- #ifdef H5 -->
  42. <!-- <view class="share" @tap="togglePopup('middle-img')">
  43. <i class="iconfont icon--fenxiang"></i>
  44. </view> -->
  45. <view class="share" @tap="toggleShare">
  46. <i class="iconfont icon--fenxiang"></i>
  47. </view>
  48. <!-- #endif -->
  49. </view>
  50. <!-- #ifdef H5 -->
  51. <view >
  52. <uni-popup :show="type === 'middle-img'" position="top" mode="fixed" @hidePopup="togglePopup('')">
  53. <view class="uni-center center-box">
  54. <image style="position: absolute; top: 0;right:0" @tap="togglePopup('')" class="image" src="/static/ico-share-wechat.png" />
  55. </view>
  56. </uni-popup>
  57. </view>
  58. <!-- #endif -->
  59. <view class="content" :class="detailData.data.shop_hidden_more_info == 1 ? 'no-top' : ''">
  60. <view class="js__top">
  61. <view class="top-image">
  62. <swiper indicator-dots="true" autoplay="flase" circular="true">
  63. <swiper-item v-for="(item, index) in detailData.data.photos" :key="index" >
  64. <image :src="item.url" :data-url="item.url" class="slide-image" @tap="bigImg"></image>
  65. </swiper-item>
  66. </swiper>
  67. <view class="small-txt" v-if="detailData.data.is_first_order_free">
  68. 收货全额返
  69. </view>
  70. <view class="call" v-if="freeInfo">
  71. <span v-if="(!is_login && freeInfo.status != 2) || (freeInfo.status == 1 && freeInfo.task.status != 1)" @tap="call">集Call免费领</span>
  72. <span v-if="freeInfo.status == 2 && freeInfo.task.status != 1" class="over">集Call已领完</span>
  73. <span v-if="freeInfo.task.status == 1" @tap="call" class="success">集Call已完成</span>
  74. </view>
  75. <!--秒杀-->
  76. <view class="marketing-box" :style="'background: ' + config.mainColor" v-if="detailData.meta.seckill">
  77. <seckill :end="detailData.meta.seckill?detailData.meta.seckill.ends_at:''"
  78. :starts="detailData.meta.seckill?detailData.meta.seckill.starts_at:''"
  79. :server="detailData.meta.seckill?detailData.meta.seckill.server_time:''" @starts="isStarts" @end="isEnd"></seckill>
  80. </view>
  81. <!--拼团-->
  82. <view class="marketing-box" :style="'background: ' + config.mainColor" v-if="detailData.meta.multiGroupon">
  83. <seckill v-if="commodity.multi_groupon_init_status == 1 || commodity.multi_groupon_init_status == 2" :end="commodity.multi_groupon_ends_at" :starts="commodity.multi_groupon_starts_at" :server="detailData.data.server_time" typename="拼团" @starts="isStarts" @end="isEnd"></seckill>
  84. <view v-if="commodity.multi_groupon_init_status == 0" class="over">
  85. 此次拼团失败可以参加其他人的拼团购买
  86. </view>
  87. </view>
  88. </view>
  89. <view class="basic-information">
  90. <!-- <view class="seckill-box mx-1px-bottom {{detailData.meta.seckill.init_status == 1 ? 'active' : ''}}" v-if="{{detailData.meta.seckill}}">
  91. <view class="seckill-time-box">
  92. <view class="seckill seckill-item" v-if="{{active}}">
  93. <i class="iconfont icon-shijian"></i>
  94. <view class="text">距离秒杀结束还剩余</view>
  95. <view class="tiem"><span> <p v-if="{{endTime.hour < 10}}">0</p>{{endTime.hour}}</span> : <span><p v-if="{{endTime.minute < 10}}">0</p>{{endTime.minute}}</span> : <span><p v-if="{{endTime.second < 10}}">0</p>{{endTime.second}}</span></view>
  96. </view>
  97. <view class="seckill-item" v-else>
  98. <view v-if="{{type == 0}}">
  99. <view class="no-starts">
  100. 未开始
  101. </view>
  102. <view class="time-text">
  103. {{message}}
  104. </view>
  105. </view>
  106. <view v-if="{{type == 1}}">
  107. <i class="iconfont icon-shijian"></i>
  108. <view class="text">距离秒杀开始还剩余</view>
  109. <view class="tiem"><span> <p v-if="{{startsTime.hour < 10}}">0</p>{{startsTime.hour}}</span> : <span> <p v-if="{{startsTime.minute < 10}}">0</p>{{startsTime.minute}}</span> : <span> <p v-if="{{startsTime.second < 10}}">0</p>{{startsTime.second}}</span></view>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="money-box">
  114. <span class="old">{{detailData.data.market_price}}</span>
  115. <span class="new">{{price}}</span>
  116. </view>
  117. </view> -->
  118. <view class="basic-top">
  119. <view class="price-box">
  120. {{detailData.data.name}}
  121. </view>
  122. <!-- <view class="recommend" @tap="changeShare">
  123. 我要推荐 >
  124. </view> -->
  125. </view>
  126. <!-- 商品描述-->
  127. <view class="basic-center">{{detailData.data.extend_description}}</view>
  128. <view class="basic-vip-box">
  129. <view class="group-num" v-if="detailData.meta.multiGroupon">
  130. {{detailData.meta.multiGroupon.number}} 人团
  131. </view>
  132. <view class="basic">
  133. <view class="basic-bottom" v-if="is_init">
  134. <view class="price-box">
  135. <block v-if="detailData.data.negotiable == 1">
  136. <view style="font-size: 20px">
  137. 价格面议
  138. </view>
  139. </block>
  140. <block v-else>
  141. <text class="price" v-if="!cart_status.group">{{price}}</text>
  142. <text class="price" v-else>{{detailData.meta.multiGroupon.price}}</text>
  143. <!-- <text v-if="{{!detailData.meta.multiGroupon}}">{{detailData.data.price_txt_sell}}</text>
  144. <span class="group-num" v-else>{{detailData.meta.multiGroupon.number}}人拼团价</span> -->
  145. </block>
  146. </view>
  147. <!-- <view class="recommend" v-if="{{detailData.data.can_share}}" @tap="changeShare">
  148. 我要推荐 >
  149. </view> -->
  150. </view>
  151. <view class="market-price">
  152. <view class="price">
  153. <view :hidden="detailData.data.shop_hidden_more_info">
  154. <block v-if="detailData.data.negotiable != 1">
  155. {{detailData.data.market_price}}
  156. </block>
  157. </view>
  158. </view>
  159. <view>
  160. <block v-if="detailData.data.shop_show_sell_nums">
  161. 月销: {{detailData.data.sale}}
  162. </block>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. <!--限购信息-->
  168. <view class="purchaseInfo mx-1px-top" v-if="detailData.data.user_limit">
  169. <view class="title">
  170. 限购
  171. </view>
  172. <view>
  173. 本商品每人限购{{detailData.data.user_limit}}
  174. </view>
  175. </view>
  176. <!--拼团信息-->
  177. <!-- <view class="groups-info mx-1px-top" v-if="{{detailData.meta.groupon}}">
  178. <view>
  179. 运费免运费
  180. </view>
  181. <view>
  182. 剩余人数{{detailData.meta.groupon.number - detailData.meta.groupon.sale_number}}
  183. </view>
  184. <view>
  185. 已参加人数{{detailData.meta.groupon.sale_number}}
  186. </view>
  187. </view> -->
  188. <!--快捷sku-->
  189. <!-- <view class="select-sku-box mx-1px-top" @tap="showSelect">
  190. <view class="title">选择</view>
  191. <view class="sku-info">
  192. {{select_product.color}}
  193. <block v-if="{{select_product.color}}">
  194. ,
  195. </block>
  196. {{select_product.size}}
  197. </view>
  198. <view class="iconfont icon--xiangyoujiantou">
  199. </view>
  200. </view>
  201. <view class="new-addbox mx-1px-top">
  202. <image mode="widthFix" src="https://cdn.ibrand.cc/%E7%BC%96%E7%BB%84%207@2x.png"></image>
  203. </view> -->
  204. <!--优惠券信息-->
  205. <view class="coupons-tags mx-1px-top" v-if="coupons.length" @tap="showCoupons">
  206. <view class="tags-title">
  207. 领券
  208. </view>
  209. <view class="coupon-box">
  210. <view class="tags-item" :style="'background: ' + config.mainColor" v-for="(item, index) in coupons" :key="index" v-if="index <= 2 && item.is_open == 1" >
  211. {{item.label}}
  212. <view class="dot-wrap">
  213. <view class="dot-left">
  214. <view class="dot-item dot-item-left"></view>
  215. <view class="dot-item dot-item-left"></view>
  216. <view class="dot-item dot-item-left"></view>
  217. </view>
  218. <view class="dot-right">
  219. <view class="dot-item dot-item-right"></view>
  220. <view class="dot-item dot-item-right"></view>
  221. <view class="dot-item dot-item-right"></view>
  222. </view>
  223. </view>
  224. </view>
  225. </view>
  226. </view>
  227. <!--折扣信息-->
  228. <view class="discounts-tags mx-1px-top" v-if="discounts.length" @tap="showDiscounts">
  229. <view class="tags-title">
  230. 促销
  231. </view>
  232. <view class="discounts-box">
  233. <view class="disconts-item" v-for="(item, index) in discounts" :key="index" >
  234. <view class="discounts-tags-title" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor">
  235. {{item.tags}}
  236. </view>
  237. <view class="tags-item">
  238. {{item.label}}
  239. </view>
  240. </view>
  241. </view>
  242. </view>
  243. <!-- <view class="old-box mx-1px-top">;
  244. 价格 {{detailData.data.market_price}}
  245. </view> -->
  246. </view>
  247. <!-- 新提出来的模块-->
  248. <view class="new-module">
  249. <!--快捷sku-->
  250. <view class="select-sku-box mx-1px-top" @tap="showSelect" v-if="select_product">
  251. <view class="title">选择</view>
  252. <view class="sku-info">
  253. {{select_product.color || ''}}
  254. <block v-if="select_product.color">
  255. ,
  256. </block>
  257. {{select_product.size || ''}}
  258. </view>
  259. <view class="iconfont icon--xiangyoujiantou">
  260. </view>
  261. </view>
  262. <!-- 品牌直供 正品保障-->
  263. <view class="new-addbox mx-1px-top">
  264. <image mode="widthFix" src="https://cdn.ibrand.cc/%E7%BC%96%E7%BB%84%207@2x.png"></image>
  265. </view>
  266. </view>
  267. <!--可自提门店-->
  268. <view class="seif-info" @tap="changeMoreShop" v-if="shopInfo && shopInfo.length">
  269. <view class="title">
  270. 可自提门店
  271. </view>
  272. <view class="name-info">
  273. <view class="name">
  274. {{shopInfo[0].name}}
  275. </view>
  276. <view class="iconfont icon--xiangyoujiantou">
  277. </view>
  278. </view>
  279. </view>
  280. <!--新人免单-->
  281. <view class="new-free" v-if="freeGoodsInfo && freeGoodsInfo.item && freeGoodsInfo.item.length">
  282. <view class="seif-info mx-1px-bottom">
  283. <view class="title">
  284. {{freeGoodsInfo.name}}
  285. </view>
  286. <view class="name-info">
  287. <view class="iconfont icon--xiangyoujiantou">
  288. </view>
  289. </view>
  290. </view>
  291. <view class="free-goods-info">
  292. <view class="item" :data-link="item.link" v-for="(item, index) in freeGoodsInfo.item" :key="index" @tap="jumpFreeLink">
  293. <image :src="item.image">
  294. <view class="free-tag">
  295. 收货全额返
  296. </view>
  297. </image>
  298. <view class="name">
  299. {{item.name}}
  300. </view>
  301. <view class="price">
  302. {{item.goods_sell_price}}
  303. </view>
  304. </view>
  305. </view>
  306. </view>
  307. <!--拼团信息和规则-->
  308. <view class="groups-rule" v-if="detailData && detailData.meta && detailData.meta.multiGroupon">
  309. <view class="rule-title" @tap="sharRules">
  310. <view class="info-one">拼团</view>
  311. <view class="info-two">{{detailData.meta.multiGroupon.number}} 人团人数未达到自动退款</view>
  312. <view class="info-three">玩法详情 <view class="iconfont icon--xiangyoujiantou"></view></view>
  313. </view>
  314. <view class="rule-avatar" v-if="groupon_userlist && groupon_userlist.userList && groupon_userlist.userList.length">
  315. <view class="avatar-item" v-for="(item,index) in groupon_userlist.userList" :style="{left:-3*index + 'px',zIndex:groupon_userlist.userList.length - index}" >
  316. <image :src="item.meta.avatar" v-if="item.meta.avatar"></image>
  317. <view class="iconfont icon-yonghu" v-else></view>
  318. <span class="colonel" v-if="item.is_leader">团长</span>
  319. </view>
  320. </view>
  321. <view class="rule-text" v-if="groupon_userlist && groupon_userlist.userList&&groupon_userlist.userList.length">
  322. 欢迎来到 <view class="usename">{{groupon_userlist.userList[0].meta.nick_name}}</view> 的拼团
  323. <block v-if="commodity&&commodity.multi_groupon_item_complete_status == 0">还需<view class="num">{{groupon_userlist.gap_number}}</view>人即可成团</block>
  324. <block v-if="commodity&&commodity.multi_groupon_item_complete_status == 1">已成团</block>
  325. <block v-if="commodity&&commodity.multi_groupon_item_complete_status == 2">成团失败</block>
  326. </view>
  327. <view class="rule-progress">
  328. <progress :percent='emjstatus.percent' stroke-width="4" activeColor="#EA4448" backgroundColor="#DBDBDB"></progress>
  329. <view class="launch" :class="emjstatus.lauch ? 'active-emj' :''" style="left: 10%">
  330. <view class="iconfont icon-faqipintuan"></view>
  331. <view class="text">发起拼团</view>
  332. </view>
  333. <view class="invite" :class="emjstatus.half ? 'active-emj' :''" style="left:40%">
  334. <view class="iconfont icon-yaoqinghaoyou"></view>
  335. <view class="text">邀请好友参团</view>
  336. </view>
  337. <view class="success" :class="emjstatus.end ? 'active-emj' :''" style="left: 80%">
  338. <view class="iconfont icon-pintuanchenggong"></view>
  339. <view class="text">拼团<block v-if="commodity && commodity.multi_groupon_item_complete_status != 2">成功</block><block v-if="commodity.multi_groupon_item_complete_status == 2">失败</block></view>
  340. </view>
  341. </view>
  342. <view class="virtual-box mx-1px-top" v-if="!detailData.meta.has_multiGroup && detailData.meta.is_agent">
  343. <view class="title">
  344. 开团
  345. </view>
  346. <view class="text">
  347. 您可虚拟开团该商品
  348. </view>
  349. <view class="virtual-btn" @tap="jumpVirtual">
  350. 虚拟开团
  351. </view>
  352. </view>
  353. </view>
  354. <!--他们也在拼-->
  355. <view class="they-groups" v-if="detailData.meta.multiGroupon && groupon_itemList[0] && groupon_itemList[0].length">
  356. <view class="they-title">
  357. <view class="num">
  358. {{meta.pagination.total}}个拼团正在进行中
  359. </view>
  360. <view class="they-more" @tap="seeMore">查看更多拼团 <view class="iconfont icon--xiangyoujiantou"></view></view>
  361. </view>
  362. <view class="they-detail">
  363. <view class="use-info">
  364. <image :src="groupon_itemList[0][0].leader.meta.avatar"></image>
  365. <view class="nick-name">{{groupon_itemList[0][0].leader.meta.nick_name}}</view>
  366. </view>
  367. <view class="offered-info">
  368. <view class="box">
  369. <view class="info-num">还差<span>{{groupon_itemList[0][0].gap_number}}</span>成团</view>
  370. <view class="groups-time-box">
  371. <span>剩余: </span>
  372. <group :end="groupon_itemList[0][0].ends_at" :starts="groupon_itemList[0][0].starts_at" :server="detailData.data.server_time" mold="list"></group>
  373. </view>
  374. </view>
  375. <view class="info-btn" @tap="multiAddToCart" :data-id="groupon_itemList[0][0].id" :data-join="groupon_itemList[0][0].has_joined" :data-no="groupon_itemList[0][0].multi_groupon_order_no">
  376. <span v-if="groupon_itemList[0][0].has_joined == 1">已参团</span>
  377. <span v-else>去参团</span>
  378. </view>
  379. </view>
  380. </view>
  381. <view class="they-detail" v-if="groupon_itemList[0][1]">
  382. <view class="use-info">
  383. <image :src="groupon_itemList[0][1].leader.meta.avatar"></image>
  384. <view class="nick-name">{{groupon_itemList[0][1].leader.meta.nick_name}}</view>
  385. </view>
  386. <view class="offered-info">
  387. <view class="box">
  388. <view class="info-num">还差<span>{{groupon_itemList[0][1].gap_number}}</span>成团</view>
  389. <view class="groups-time-box">
  390. <span>剩余: </span>
  391. <group :end="groupon_itemList[0][1].ends_at" :starts="groupon_itemList[0][1].starts_at" :server="detailData.data.server_time" mold="list"></group>
  392. </view>
  393. </view>
  394. <view class="info-btn" @tap="multiAddToCart" :data-id="groupon_itemList[0][1].id" :data-join="groupon_itemList[0][1].has_joined" :data-no="groupon_itemList[0][1].multi_groupon_order_no">
  395. <span v-if="groupon_itemList[0][1].has_joined == 1">已参团</span>
  396. <span v-else>去参团</span>
  397. </view>
  398. </view>
  399. </view>
  400. </view>
  401. <!--同款信息-->
  402. <view class="same" @tap="showSame" v-if="detailData.data.subsection == 1">
  403. <view>
  404. <span>商场同款</span> 线下商场同步销售
  405. </view>
  406. <view>
  407. ...
  408. </view>
  409. </view>
  410. <!--我要推荐-->
  411. <view class="recommended" v-if="detailData.data.can_share && !detailData.meta.multiGroupon" @tap="changeShare">
  412. <view class="title">推荐</view>
  413. <view class="goodness"><block v-if="detailData.data.show_commission">推荐可获得佣金 <span>{{detailData.data.commission}}</span></block> </view>
  414. <!-- #ifdef MP-WEIXIN -->
  415. <view class="btn">我要推荐 ></view>
  416. <!-- #endif -->
  417. </view>
  418. <!--第三方供货说明-->
  419. <view class="third-party" @tap="changeThird" v-if="detailData.data.supplier && detailData.data.supplier.code != 'self'">
  420. <view class="title">说明 :</view>
  421. <view class="detail-list">
  422. <view class="item pa-bottom">
  423. <span class="iconfont icon-Group92"></span>
  424. <view class="txt">本商品为第三方供应提供</view>
  425. </view>
  426. <view class="item">
  427. <span class="iconfont icon-Group92"></span>
  428. <view class="txt"> {{detailData.data.supplier?detailData.data.supplier.company_name:''}} 发货并提供售后</view>
  429. </view>
  430. </view>
  431. <view class="more-see">
  432. <span class="iconfont icon--xiangyoujiantou"></span>
  433. </view>
  434. </view>
  435. </view>
  436. <view class="detail-item-box">
  437. <!--商品评论-->
  438. <view class="js__comment" @tap="viewComment" v-if="!detailData.data.shop_hidden_more_info">
  439. <view class="title mx-1px-bottom">
  440. <view class="title_content">
  441. 商品评论{{detailData.meta.comments || 0}}
  442. </view>
  443. <view class="praise-of" v-if="detailData.data.comment_rate">好评度 {{detailData.data.comment_rate}}% <span class="iconfont icon--xiangyoujiantou"></span></view>
  444. </view>
  445. <!-- 标签列表-->
  446. <view class="tags-content">
  447. <view class="item" v-for="(item, index) in detailData.data.tags" :key="index" >{{item}}</view>
  448. </view>
  449. <view class="content" v-if="detailData.data.oneComment && detailData.data.oneComment.length">
  450. <view class="comment_list" v-for="(item, index) in detailData.data.oneComment" :key="index" >
  451. <view class="comment_user">
  452. <view class="img-box">
  453. <image :src="item.user.avatar"></image>
  454. <view class="user_name">{{item.user.nick_name}}</view>
  455. </view>
  456. <view class="rater">
  457. <!-- <template is="rater" data="{{ ...$vlc.rater.store }}"/> -->
  458. <uni-rate size="18" :disabled="rateDisabled" active-color="red" :value="item.point"></uni-rate>
  459. </view>
  460. </view>
  461. <view class="comment_time">
  462. <view class="time">
  463. {{item.updated_at}}
  464. </view>
  465. <view class="model">
  466. {{item.item_meta.specs_text}}
  467. </view>
  468. </view>
  469. <view class="comment_content">
  470. {{item.contents}}
  471. </view>
  472. <view class="comment-img">
  473. <image :src="item" mode="widthFix" alt v-for="(item, index) in item.pic_list" :key="index" ></image>
  474. </view>
  475. <view class="all-comment mx-1px-top">
  476. <view class="text">
  477. 更多热评
  478. <span class="iconfont icon--xiangyoujiantou"></span>
  479. </view>
  480. </view>
  481. </view>
  482. </view>
  483. </view>
  484. <!--商品参数-->
  485. <view v-if="attributesList.top.length">
  486. <view class="title mx-1px-bottom" :data-type="parameter" @tap="change">
  487. <view class="title-text">
  488. 商品参数
  489. </view>
  490. <view :class="expands.parameter ? 'arrow-up' : 'arrow-down'">
  491. </view>
  492. </view>
  493. <view class="content" v-if="expands.parameter">
  494. <view class="argument-box">
  495. <view class="argument-top">
  496. <span v-for="(top,index) in attributesList.top" :key="index">
  497. {{top.name}} : {{top.attribute_value}}
  498. </span>
  499. </view>
  500. <view class="argument-bottom" v-if="attributesList.bottom.length">
  501. <view class="argument-item" v-for="(bottom,idx) in attributesList.bottom" :key="idx">
  502. <view class="index-title">{{bottom.name}} </view>
  503. <view class="index-box">
  504. <view>
  505. <view :class="bottom.attribute_value_id == list.id ? 'red-dot' : ''" v-for="(list,index) in bottom.values" >
  506. {{list.name}}
  507. </view>
  508. </view>
  509. </view>
  510. </view>
  511. </view>
  512. </view>
  513. </view>
  514. </view>
  515. <!--套餐详情-->
  516. <view v-if="detailData.meta.suit && detailData.meta.suit.length!=0">
  517. <view class="title mx-1px-bottom" data-type="meal" @tap="change">
  518. <view class="title-text">
  519. 搭配套餐
  520. </view>
  521. <view>
  522. </view>
  523. </view>
  524. <view class="content meals" v-if="!expands.meal">
  525. <view class="commodity_description" v-for="(item, index) in detailData.meta.suit" :key="index" v-for-item="detail">
  526. <view class="meal_list">
  527. <view class="store_list" v-for="(item, index) in detail.items" :key="index" >
  528. <view @tap="jumpToDetail" :data-id="item.goods.id">
  529. <image class="slider-image" :src="item.goods.img"></image>
  530. <view class="description">{{item.goods.name}}</view>
  531. <!-- <view>1</view>
  532. <p class="price"><span style="color: red">{{i.package_price}}</span>/<span>{{i.origin_price}}</span></p> -->
  533. </view>
  534. </view>
  535. </view>
  536. <view class="all_count" :data-suitid="detail.id" @tap="jumpMeal">
  537. 搭配套餐价=<span style="color: red">{{detail.total}}</span>/<span style="text-decoration: line-through">{{detail.origin_total}}</span>
  538. </view>
  539. <!-- {{{commodity.content}}} -->
  540. </view>
  541. </view>
  542. </view>
  543. <!--商品详情-->
  544. <view>
  545. <view class="title mx-1px-bottom" data-type="commodity" @tap="change">
  546. <view class="title-text">
  547. 商品详情
  548. </view>
  549. <view>
  550. </view>
  551. </view>
  552. <view class="content" v-if="expands.commodity">
  553. <u-parse :content="detailData.data.content" v-if="detailData.data.content" />
  554. </view>
  555. </view>
  556. </view>
  557. <!-- <view class="to-top" hidden="{{!showToTop}}" @tap="goTop">
  558. <i class="iconfont icon-xiangshang"></i>
  559. </view> -->
  560. <!-- <view class="tabbar mx-1px-top">
  561. <view class="tabbar-item item_0 mx-1px-right" data-type="shop" @tap="jump">
  562. <i class="iconfont icon-shangcheng"></i>
  563. <text>商城</text>
  564. </view>
  565. <view class="tabbar-item item_1 mx-1px-right" v-if="{{service_info && service_info.online_service_status == 1}}" @tap="changeAttention">
  566. <i class="iconfont icon-service"></i>
  567. <text>客服</text>
  568. <button open-type="contact" v-if="{{service_info.online_service_type !== 'self'}}" />
  569. </view>
  570. &lt;!&ndash; <view class="tabbar-item item_2 {{is_Fav ? 'favorite' : ''}}" @tap="changeStatus">
  571. <i class="iconfont icon-favor"></i>
  572. <span>{{is_Fav ? '已收藏' : '收藏'}}</span>
  573. </view>&ndash;&gt;
  574. <view class="tabbar-item item_1 mx-1px-left-right" data-type="cart" @tap="jump">
  575. <i class="iconfont icon-gouwuche"></i>
  576. <text>购物车</text>
  577. </view>
  578. <view class="tabbar-item item_3 alone" @tap="aloneAddToCart" v-if="{{detailData.meta.multiGroupon && detailData.data.multi_groupon_init_status == 1}}" style="background: {{config.secColor}}">
  579. <view class="price">{{commodity.sell_price}}</view>
  580. 单独购买
  581. </view>
  582. <block v-if="{{!detailData.meta.seckill && !detailData.meta.multiGroupon && cart_status.status && !is_fives}}">
  583. <view class="tabbar-item item_3 btn_1" style="background: {{config.secColor}}" @tap="showSelect" v-if="{{detailData.meta.vip_plan && initInfoData.vip_plan_status == 1 && detailData.meta.vip_plan.level != 0}}">
  584. {{cart_status.message}}
  585. </view>
  586. <block v-else>
  587. <view class="tabbar-item item_3 btn_1" v-if="{{cart_status.status || cart_status.seckill || cart_status.group}}" style="background: {{config.secColor}}" @tap="showSelect">
  588. {{cart_status.message}}
  589. </view>
  590. <view class="tabbar-item item_3 btn_1 no-seckill" v-else @tap="showSelect">
  591. {{cart_status.message}}
  592. </view>
  593. </block>
  594. </block>
  595. &lt;!&ndash;立即购买&ndash;&gt;
  596. <view class="tabbar-item item_3 btn_1 svip-btn" data-status="true" @tap="showSelect" v-if="{{detailData.meta.vip_plan && initInfoData.vip_plan_status == 1 && detailData.meta.vip_plan.level != 0}}">
  597. {{immediately_text.message}}
  598. </view>
  599. <block v-else>
  600. <view class="tabbar-item item_3 btn_2 seckill" data-status="true" v-if="{{cart_status.status || cart_status.seckill || cart_status.group}}" style="background: {{config.mainColor}}" @tap="showSelect">
  601. {{immediately_text.message}}
  602. </view>
  603. <view class="tabbar-item item_3 btn_1 no-seckill" data-status="true" v-else @tap="showSelect">
  604. {{immediately_text.message}}
  605. </view>
  606. </block>
  607. &lt;!&ndash;<view class="tabbar-item item_3 btn_2" style="background: {{config.mainColor}}" @tap="immediately" v-if="{{show_immediately}}">
  608. </view>&ndash;&gt;
  609. </view> -->
  610. <view class="tabbar mx-1px-top new-tabbar" v-if="is_show_tabbar">
  611. <view class="tabbar-item item_0" data-type="shop" @tap="jump">
  612. <i class="iconfont icon--shouye"></i>
  613. <text>首页</text>
  614. </view>
  615. <view data-type="cart" @tap="jump" class="tabbar-item item_0 cart-item-box">
  616. <i class="iconfont icon-gouwuche"></i>
  617. <text>购物车</text>
  618. </view>
  619. <view class="tabbar-item item_1 server-item" v-if="service_info && service_info.online_service_status == 1" @tap="changeAttention">
  620. <i class="iconfont icon-service"></i>
  621. <text>客服</text>
  622. <button open-type="contact" v-if="service_info.online_service_type !== 'self'" />
  623. </view>
  624. <view class="tabbar-item item_3 alone" @tap="aloneAddToCart" v-if="detailData.meta.multiGroupon && detailData.data.multi_groupon_init_status == 1" :style="{background: config.secColor}">
  625. 原价购买
  626. <view class="price">{{commodity.sell_price}}</view>
  627. </view>
  628. <!-- 加入购物车 -->
  629. <block v-if="!detailData.meta.seckill && !detailData.meta.multiGroupon && cart_status.status && !is_fives">
  630. <view class="tabbar-item item_3 btn_1" :style="{background: config.secColor}" @tap="showSelect" v-if="detailData.meta.vip_plan && initInfoData.vip_plan_status == 1 && detailData.meta.vip_plan.level != 0">
  631. {{cart_status.message}}
  632. </view>
  633. <block v-else>
  634. <!-- 普通 -->
  635. <view class="tabbar-item item_3 btn_1" v-if="cart_status.status || cart_status.seckill || cart_status.group" :style="{background: config.secColor}" @tap="showSelect">
  636. {{cart_status.message}}
  637. </view>
  638. <view class="tabbar-item item_3 btn_1 no-seckill" v-else @tap="showSelect">
  639. {{cart_status.message}}
  640. </view>
  641. </block>
  642. </block>
  643. <view class="tabbar-item item_3 btn_1 svip-btn right_btn" data-status="true" @tap="showSelect" v-if="detailData.meta.vip_plan && initInfoData.vip_plan_status == 1 && detailData.meta.vip_plan.level != 0">
  644. {{immediately_text.message}}
  645. </view>
  646. <block v-else>
  647. <!--购买按钮普通拼团秒杀-->
  648. <view class="tabbar-item item_3 btn_2 seckill right_btn" :class="[detailData.meta.multiGroupon ? 'multiGroupon' : '',cart_status.seckill ? 'seckill-btn-box' : '']" data-status="true" v-if="cart_status.status || cart_status.seckill || cart_status.group" @tap="showSelect">
  649. {{immediately_text.message}}
  650. </view>
  651. <view class="tabbar-item item_3 btn_1 no-seckill right_btn" data-status="true" v-else @tap="showSelect" >
  652. {{immediately_text.message}}
  653. </view>
  654. </block>
  655. <!-- <view class="tabbar-item item_1 server-item" v-if="service_info && service_info.online_service_status == 1" @tap="changeAttention">
  656. <i class="iconfont icon-service"></i>
  657. <text>客服</text>
  658. <button open-type="contact" v-if="service_info.online_service_type !== 'self'" />
  659. </view> -->
  660. </view>
  661. </view>
  662. <view class="maks" :class="!show_select ? 'cur' : ''" @tap="closeSelect">
  663. </view>
  664. <view class="detail-popup" :class="!show_select ? 'detail-active' : ''" :hidden="show_select" :animation="show.animation">
  665. <view class="select_goods_container">
  666. <!--关闭按钮-->
  667. <view class="select_goods_cloese" @tap="closeSelect"></view>
  668. <view class="select_goods_header">
  669. <view class="img_box">
  670. <image v-if="select_product && select_product.img" :src="select_product.img" :alt="select_product.sku"></image>
  671. <image v-else :src="commodity.img + ' '" alt></image>
  672. </view>
  673. <!-- <view class="img_box" style="background-color: {{select_product.bac}};width: 78px;height: 78px;" v-if="{{!select_product.img && !!select_product.color}}"></view> -->
  674. <view class="price_item">
  675. <span v-if="select_product">
  676. <text v-if="!cart_status.group || is_alone">{{price}}</text>
  677. <text v-if="cart_status.group && !is_alone">{{detailData.meta.multiGroupon.price}}</text>
  678. </span>
  679. <span style="font-weight:bold;color:#ee2b1d;" v-else>
  680. {{price_interval}}
  681. </span>
  682. <!-- <text v-else>{{price}}</text>
  683. <text v-else>{{detailData.meta.groupon.groupon_price}}</text> -->
  684. <text v-if="detailData.data.shop_show_store == 1">库存{{store_count}}</text>
  685. </view>
  686. </view>
  687. <view class="select_spec">
  688. <view class="spec_line" v-for="(spec, index) in specs" :key="index">
  689. <view class="spec_title">{{spec.label}}</view>
  690. <view class="spec_value">
  691. <view class="spec_block" :class=" !!item.disabled ? 'disabled' : '' " v-for="(item, index) in spec.values" :key="index" :data-key="index"
  692. :data-index="item.index" :data-disabled="item.disabled ? 1 : 0" :data-id="item.id" :data-active="item.active ? 1 : 0" @tap="selectSpec">
  693. <!-- <view class="spec_icon spec_text" v-if="item.spec_img">
  694. <image :src="item.spec_img" data-alt="item.alias || item.value"></image>
  695. </view>
  696. <text class="spec_icon" :style=" 'background-color:'+ item.color" v-if="!item.spec_img && item.color"></text> -->
  697. <view class="spec_text" v-if="(item.alias || item.value) && item.spec_img !== ''">
  698. {{item.alias || item.value}}
  699. <view v-if="!!item.active" :style="'border-color: ' + config.mainColor" class="border-color">
  700. </view>
  701. </view>
  702. <view class="spec_text" v-if="!item.spec_img && !item.color">
  703. {{item.alias || item.value}}
  704. <view v-if="!!item.active" :style="'border-color: ' + config.mainColor" class="border-color">
  705. </view>
  706. </view>
  707. </view>
  708. <!-- <view class="spec_list" v-if="{{spec.id != 2}}">尺码表</view> -->
  709. </view>
  710. </view>
  711. <view class="spec_line">
  712. <view class="num_title">数量</view>
  713. <view class="num_value">
  714. <text @tap="changeCount" data-index="0">-</text>
  715. <view class="none_border">
  716. <input @input="modifyCount" :value="select_count" type="number" confirm-type="done"></input>
  717. </view>
  718. <text @tap="changeCount" data-index="1">+</text>
  719. </view>
  720. <view class="purchase" v-if="detailData.data.user_limit">
  721. 本商品每人限购{{detailData.data.user_limit}}
  722. </view>
  723. </view>
  724. <button class="button" v-if="!canBuy" :style="'background: ' + config.mainColor" type="primary" :loading="loading" @tap="confirmF">确定</button>
  725. <button class="button disabled" v-else type="primary" :loading="loading" @tap="confirmF">确定</button>
  726. <!-- <view class="button {{ canBuy ? 'disabled' : '' }}" @tap="confirm">
  727. <submit-button v-ref:button bindsubmit="confirm" :status="disallow_cart ? 'disabled' : 'normal'">确定</submit-button>
  728. </view> -->
  729. </view>
  730. </view>
  731. </view>
  732. <!--弹出客服-->
  733. <view class="maks" :class="show_attention ? 'cur' : ''" @tap="changeAttention">
  734. </view>
  735. <view class="attention-WeChat" :class="show_attention ? 'cur' : ''">
  736. <view class="service-box">
  737. <view class="code item" @tap="previewImage">
  738. <image mode="widthFix" :src="service_info?service_info.online_service_self.qr_code:''" alt></image>
  739. <view class="text">
  740. 保存二维码用微信识别添加
  741. </view>
  742. </view>
  743. <view class="item phone" @tap="callPhone">
  744. <view class="phone-text">
  745. <image mode="widthFix" :src="service_info?service_info.online_service_self.qr_code:''" alt></image>
  746. <view class="phone-warp">
  747. <i class="iconfont icon-dianhua"></i>
  748. <view class="phone-num">{{service_info?service_info.online_service_self.phone:''}}</view>
  749. <view>点击电话咨询客服</view>
  750. </view>
  751. </view>
  752. <view>
  753. {{service_info?service_info.online_service_self.time:''}}
  754. </view>
  755. </view>
  756. </view>
  757. </view>
  758. <!--网络繁忙弹窗-->
  759. <ten :show="show_ten" @endTen="HideTen"></ten>
  760. <!--用户拒绝下载图片授权弹出-->
  761. <alert :is_refused="is_refused" @close="closeAlert"></alert>
  762. <!--选择优惠券部分-->
  763. <view class="maks" :class="show_coupons ? 'cur' : ''" @tap="showCoupons">
  764. </view>
  765. <view class="select-coupon-box" :class="show_coupons ? 'cur' : ''">
  766. <view class="select-coupon">
  767. <view class="select-coupon-top">
  768. <view class="title">
  769. 优惠券
  770. <view class="close" @tap="showCoupons">
  771. X
  772. </view>
  773. </view>
  774. </view>
  775. <view class="select-coupon-bottom">
  776. <view class="title">
  777. 可领优惠券
  778. </view>
  779. <view class="coupon-box">
  780. <view class="coupon-item" v-for="(item, index) in coupons" :key="index" v-if="item.is_open">
  781. <view class="coupon">
  782. <view class="coupon-left" :style="'background: ' + config.mainColor">
  783. <view class="text-wrap">
  784. <view class="text-box">
  785. <view class="text">
  786. <span class="money" v-if="item.action_type.type == 'cash'"></span>
  787. <span class="num">{{ item.action_type.value }}</span>
  788. <span class="money" v-if="item.action_type.type == 'discount'"></span>
  789. </view>
  790. <span class="label text">{{ item.label }}</span>
  791. </view>
  792. </view>
  793. <view class="dot-wrap">
  794. <view class="dot-item">
  795. </view>
  796. <view class="dot-item">
  797. </view>
  798. <view class="dot-item">
  799. </view>
  800. <view class="dot-item">
  801. </view>
  802. <view class="dot-item">
  803. </view>
  804. </view>
  805. </view>
  806. <view class="coupon-right">
  807. <view class="top">
  808. <span>
  809. <span class="type" v-if="item.channel == 'ec'">商店</span>
  810. <span class="type" v-if="item.channel == 'shop'">门店</span>
  811. </span>
  812. <span class="info">{{item.title}}</span>
  813. </view>
  814. <view class="bottom">
  815. <view class="bottom-use">
  816. <view class="tiem-box">
  817. <text>{{item.use_start_time}}{{item.use_end_time}}</text>
  818. </view>
  819. <view class="btn use" :style="'background: ' + config.mainColor + '; border-color: ' + config.mainColor" :data-code="item.code" :data-index="index" v-if="!coupons[index].has_get" @tap="getCoupon">
  820. 点击领取
  821. </view>
  822. <view class="btn already" v-else>
  823. 已领取
  824. </view>
  825. </view>
  826. </view>
  827. </view>
  828. </view>
  829. </view>
  830. </view>
  831. </view>
  832. </view>
  833. </view>
  834. <!--查看促销部分-->
  835. <view class="maks" :class="show_discounts ? 'cur' : ''" @tap="showDiscounts">
  836. </view>
  837. <view class="see-discounts-box" :class="show_discounts ? 'cur' : ''">
  838. <view class="select-discounts">
  839. <view class="select-discounts-top">
  840. <view class="title">
  841. 促销
  842. <view class="close" @tap="showDiscounts">
  843. X
  844. </view>
  845. </view>
  846. </view>
  847. <view class="select-discounts-bottom">
  848. <view class="discounts-box">
  849. <view class="disconts-item mx-1px-bottom" v-for="(item, index) in discounts" :key="index" >
  850. <view class="discounts-tags-title" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor">
  851. {{item.tags}}
  852. </view>
  853. <view class="tags-item">
  854. {{item.label}}
  855. </view>
  856. </view>
  857. </view>
  858. </view>
  859. </view>
  860. </view>
  861. <!--弹出第三方供货详情-->
  862. <view class="maks" :class="show_third ? 'cur' : ''">
  863. </view>
  864. <view class="third-box" :class="show_third ? 'cur' : ''">
  865. <view class="title mx-1px-bottom">
  866. <view class="txt">说明</view>
  867. <view class="iconfont icon-close" @tap="changeThird"></view>
  868. </view>
  869. <view class="content">
  870. <view class="item pad-bottom">
  871. <span class="iconfont icon-Group92"></span>
  872. <view class="txt">本商品为第三方供应提供</view>
  873. </view>
  874. <view class="item pad-bottom">
  875. <span class="iconfont icon-Group92"></span>
  876. <view class="txt"> {{detailData.data.supplier?detailData.data.supplier.company_name:''}} 发货并提供售后</view>
  877. </view>
  878. <view class="item">
  879. <span class="iconfont icon-Group92"></span>
  880. <view class="txt">
  881. <view class="topic pad-bottom">企业信息</view>
  882. <view class="info">企业名称{{detailData.data.supplier?detailData.data.supplier.company_name:''}} </view>
  883. <view class="info">企业执照注册号{{detailData.data.supplier?detailData.data.supplier.company_number:''}} </view>
  884. <view class="info">企业地址{{detailData.data.supplier?detailData.data.supplier.company_address:''}}</view>
  885. <view class="info">企业电话{{detailData.data.supplier?detailData.data.supplier.company_phone:''}}</view>
  886. <view class="info">营业期限{{detailData.data.supplier?detailData.data.supplier.company_limit:''}} </view>
  887. <view class="info mar-bottom">经营范围{{detailData.data.supplier?detailData.data.supplier.company_scope:''}}</view>
  888. </view>
  889. </view>
  890. </view>
  891. </view>
  892. <!--弹出拼团规则部分-->
  893. <view class="maks" :class="show_rule ? 'cur' : ''">
  894. </view>
  895. <view class="rule-box" :class="show_rule ? 'cur' :''">
  896. <view class="rules-title">
  897. <view class="text">拼团规则</view>
  898. <view class="iconfont icon-close" @tap="closeRule"></view>
  899. </view>
  900. <view class="rules-content">
  901. <view class="rules-item">
  902. <view class="info-title">团长</view>
  903. <view class="infomation">是指该团第一位支付的人</view>
  904. </view>
  905. <view class="rules-item">
  906. <view class="info-title">开团</view>
  907. <view class="infomation">团长购买拼团商品并完成支付该团即正式开启无论该团成功与否每次活动每人仅可发起一个拼团</view>
  908. </view>
  909. <view class="rules-item">
  910. <view class="info-title">参团</view>
  911. <view class="infomation"> 从团长分享的商品链接进入购买该商品即可成为该团团员也可将该团链接分享给更多新团员参加使该团尽快成功并发货</view>
  912. </view>
  913. <view class="rules-item">
  914. <view class="info-title">拼团成功</view>
  915. <view class="infomation">开团后24小时内该团达到规定的人数且商品库存充足则拼团成功因活动商品紧俏越快邀请到好友成团购买到活动商品的可能性越大</view>
  916. </view>
  917. <view class="rules-item">
  918. <view class="info-title">拼团失败</view>
  919. <view class="infomation">开团后24小时内未达到规定人数库存不足活动提前结束活动时间到期等原因将引起拼团失败拼团失败后将自动取消订单活动结束后立即退款</view>
  920. </view>
  921. <view class="rules-item">
  922. <view class="info-title">其他说明</view>
  923. <view class="infomation">拼团活动不可使用优惠券其他促销折扣积分</view>
  924. </view>
  925. </view>
  926. </view>
  927. <!--弹出更多门店-->
  928. <view class="maks" :class="show_more_shop ? 'cur' : ''">
  929. </view>
  930. <view class="more-shop-box" :class="show_more_shop ? 'cur' :''">
  931. <view class="title iconfont icon-close" @tap="changeMoreShop">
  932. </view>
  933. <view class="content">
  934. <view class="title-text mx-1px-bottom">
  935. 可自提门店
  936. </view>
  937. <view class="shop-list">
  938. <view class="item mx-1px-bottom" v-for="(item, index) in shopInfo" :key="index">
  939. <view class="name">
  940. {{item.name}}
  941. </view>
  942. <view class="address">
  943. 地址{{item.address}}
  944. </view>
  945. <view class="time">
  946. 营业时间{{item.business_hours}}
  947. </view>
  948. <!--<view class="phone">
  949. 联系电话{{item.phone}}
  950. </view>-->
  951. </view>
  952. </view>
  953. </view>
  954. </view>
  955. <!--弹出更多拼团-->
  956. <view class="maks" :class="show_more ? 'cur' : ''" @tap="closeMore">
  957. </view>
  958. <view class="more-box" :class="show_more ? 'cur' : ''">
  959. <view class="more-title">TA们也在拼</view>
  960. <scroll-view scroll-y bindscrolltolower="scrollBottom">
  961. <view class="more-content">
  962. <view v-for="(items, idx) in groupon_itemList" :key="idx" >
  963. <view class="more-item" v-for="(item, index) in groupon_itemList[idx]" :key="index">
  964. <view class="use-info">
  965. <image :src="item.leader.meta.avatar"></image>
  966. <view class="nick-name">{{item.leader.meta.nick_name}}</view>
  967. </view>
  968. <view class="offered-info">
  969. <view class="box">
  970. <view class="info-num">还差<span>{{groupon_itemList[0][0].gap_number}}</span>成团</view>
  971. <view class="groups-time-box">
  972. <span>剩余: </span>
  973. <group :end="groupon_itemList[0][0].ends_at" :starts="groupon_itemList[0][0].starts_at" :server="detailData.data.server_time" mold="list">
  974. 我已经进来了
  975. </group>
  976. </view>
  977. </view>
  978. <view class="info-btn" @tap="multiAddToCart" :data-id="item.id" :data-join="item.has_joined" :data-no="item.multi_groupon_order_no">
  979. <span v-if="item.has_joined == 1">已参团</span>
  980. <span v-else>去参团</span>
  981. </view>
  982. </view>
  983. </view>
  984. </view>
  985. </view>
  986. </scroll-view>
  987. </view>
  988. <!--弹出分享部分-->
  989. <view class="maks share" :class="show_share ? 'cur' : ''" @tap="changeShare">
  990. </view>
  991. <view class="share-box" :class="show_share ? 'cur' : ''">
  992. <!-- #ifdef MP-WEIXIN -->
  993. <button class="shaer-item" open-type="share">
  994. 分享给好友
  995. </button>
  996. <!-- #endif -->
  997. <!-- #ifdef APP-PLUS -->
  998. <button class="shaer-item" @click="shareapp">
  999. 分享给好友
  1000. </button>
  1001. <!-- #endif -->
  1002. <view class="shaer-item mx-1px-top" @tap="getShearImg">
  1003. 生成海报
  1004. </view>
  1005. <view class="shaer-item clear" @tap="changeShare">
  1006. 取消
  1007. </view>
  1008. </view>
  1009. <!--固定的分享盒子-->
  1010. <!-- #ifdef MP-WEIXIN || APP-PLUS-->
  1011. <view class="share-fixed" @tap="changeShare">
  1012. <view class="iconfont icon--fenxiang"></view>
  1013. <view class="txt">分享</view>
  1014. </view>
  1015. <!-- #endif -->
  1016. <!--同款部分-->
  1017. <view class="maks" :class="show_same ? 'cur' : ''">
  1018. </view>
  1019. <view class="see-discounts-box" :class="show_same ? 'cur' : ''">
  1020. <view class="select-discounts">
  1021. <view class="select-discounts-top">
  1022. <view class="title">
  1023. 促销
  1024. <view class="close" @tap="showSame">
  1025. X
  1026. </view>
  1027. </view>
  1028. </view>
  1029. <view class="show-same">
  1030. 该商品线上商城和线下商场同步销售欢迎到线下商场体验购买
  1031. </view>
  1032. </view>
  1033. </view>
  1034. <!--分享到朋友圈弹出-->
  1035. <view class="share-img-box" :class="share_img ? 'cur' : ''">
  1036. <view class="imgs-box">
  1037. <view class="img">
  1038. <image mode="widthFix" :src="shareImg"></image>
  1039. </view>
  1040. <!-- #ifdef MP-WEIXIN || APP-PLUS-->
  1041. <view class="text">
  1042. 保存图片后可分享到朋友圈
  1043. </view>
  1044. <view class="save" :style="'background: ' + config.mainColor" @tap="downImg">
  1045. 保存图片
  1046. </view>
  1047. <!-- #endif -->
  1048. <!-- #ifdef H5 -->
  1049. <view class="text">
  1050. 长按图片,下载保存分享到朋友圈
  1051. </view>
  1052. <!-- #endif -->
  1053. <i class="iconfont icon-delete" @tap="changeImg"></i>
  1054. </view>
  1055. </view>
  1056. <!--加入购物车弹出-->
  1057. <view class="cart-box" catchtouchmove="move" :hidden="!show_cart">
  1058. <view class="cart-mask">
  1059. </view>
  1060. <view class="cart-dialog">
  1061. <view class="title mx-1px-bottom">
  1062. 商品成功加入购物车
  1063. </view>
  1064. <view class="buttons">
  1065. <view class="button" :style="'background: ' + config.mainColor" @tap="goCart">
  1066. 进入购物车
  1067. </view>
  1068. <view class="button agin" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" @tap="changeCart">
  1069. 继续购物
  1070. </view>
  1071. </view>
  1072. </view>
  1073. </view>
  1074. <!-- H5的分享样式-->
  1075. <view class="maks" :class="is_toggle_share ? 'cur' : ''" @tap="toggleShare">
  1076. </view>
  1077. <view class="new-share-box" :class="is_toggle_share ? 'cur' : ''">
  1078. <view class="paney-body">
  1079. <view class="title">
  1080. 分享到
  1081. </view>
  1082. <view class="btn-box mx-1px-bottom">
  1083. <view class="graphic-btn item" @tap="shareGraphic">
  1084. <image src="https://cdn.guojiang.club/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200428143540.png"></image>
  1085. <view class="txts">
  1086. 图文分享
  1087. </view>
  1088. </view>
  1089. <view class="weiixn-btn item" @tap="togglePopup('middle-img')">
  1090. <image src="https://cdn.guojiang.club/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200428143536.png"></image>
  1091. <view class="txts">微信分享</view>
  1092. </view>
  1093. </view>
  1094. <view class="cancel-btn" @tap.stop="toggleShare">
  1095. 取消
  1096. </view>
  1097. </view>
  1098. </view>
  1099. <!-- 点击图文弹出 -->
  1100. <view class="graphic-show-box" :class="share_gaphic ? 'cur' : ''" @tap="closeShareGraphic">
  1101. <image :src="qr_code_image" mode="widthFix" @tap="preImage"></image>
  1102. <view class="texts">
  1103. 长按图片保存到本地
  1104. </view>
  1105. </view>
  1106. </view>
  1107. </template>
  1108. <script>
  1109. var app = getApp();
  1110. import {pageLogin, getUrl,config,is,GetUrl,
  1111. // #ifdef MP-WEIXIN
  1112. autoLogin
  1113. // #endif
  1114. } from '@/common/js/utils.js';
  1115. import Animation from '@/common/js/animation.js';
  1116. // 引入安卓权限
  1117. import permision from "@/common/js/permission.js"
  1118. import uParse from '@/components/gaoyia-parse/parse.vue';
  1119. import ten from "@/components/ten/ten";
  1120. import group from "@/components/group/group";
  1121. import seckill from "@/components/seckill/seckill";
  1122. import alert from "@/components/alert/alert";
  1123. import uniRate from "@/components/score/uni-rate/uni-rate.vue";
  1124. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  1125. export default {
  1126. data() {
  1127. return {
  1128. cart_status: {
  1129. status: false,
  1130. message: '商品已下架'
  1131. },
  1132. immediately_text: {
  1133. status: false,
  1134. message: '商品已下架'
  1135. },
  1136. id: '',
  1137. skuTable: {},
  1138. price: 0,
  1139. commodity: {},
  1140. detailData: {data:'',meta:''},
  1141. specs: [],
  1142. detail: '',
  1143. attributesList: {
  1144. top: [],
  1145. bottom: []
  1146. },
  1147. expands: {
  1148. parameter: true,
  1149. //商品参数
  1150. recommend: true,
  1151. //推荐搭配
  1152. commodity: true,
  1153. //商品详情
  1154. story: true,
  1155. //产品故事
  1156. interest: true,
  1157. //TA们也感兴趣
  1158. like: true,
  1159. //猜你喜欢
  1160. history: true //历史浏览
  1161. },
  1162. showToTop: false,
  1163. show_select: true,
  1164. //选尺寸
  1165. select_product: {},
  1166. //当前选中商品
  1167. store_count: 0,
  1168. store_num: 0,
  1169. select_count: 1,
  1170. is_login: true,
  1171. is_show_tabbar: false,
  1172. show_attention: false,
  1173. canBuy: false,
  1174. query: {},
  1175. animationSelect: {},
  1176. loading: false,
  1177. coupons: [],
  1178. // 可领取的优惠券信息
  1179. discounts: [],
  1180. // 可享受的优惠折扣信息
  1181. show_coupons: false,
  1182. // 领取优惠券
  1183. show_discounts: false,
  1184. // 查看促销活动
  1185. show_cart: false,
  1186. // 加入购物车弹窗
  1187. show_share: false,
  1188. // 弹出分享
  1189. message: '',
  1190. purchaseInfo: {
  1191. status: false,
  1192. num: 0
  1193. },
  1194. // 限购
  1195. active: false,
  1196. type: 0,
  1197. endTime: {
  1198. interval: '',
  1199. day: 0,
  1200. hour: 0,
  1201. minute: 0,
  1202. second: 0,
  1203. count: 0
  1204. },
  1205. startsTime: {
  1206. interval: '',
  1207. day: 0,
  1208. hour: 0,
  1209. minute: 0,
  1210. second: 0,
  1211. count: 0
  1212. },
  1213. show_ten: false,
  1214. // 网络繁忙弹窗
  1215. freeInfo: '',
  1216. domInfo: {
  1217. shop: '',
  1218. like: 0
  1219. },
  1220. activeName: 'shop',
  1221. lock: false,
  1222. author: '',
  1223. brand: config.BRAND.name,
  1224. share_img: false,
  1225. shareImg: "",
  1226. show_same: false,
  1227. show_rule: false,
  1228. show_more: false,
  1229. groupon_item_id: '',
  1230. //子参团id
  1231. url_groupon_item_id: '',
  1232. //url上面自带的子参团id 通过分享进来的
  1233. groupon_userlist: {
  1234. userList: ''
  1235. },
  1236. // 拼团用户信息数据
  1237. groupon_itemList: [],
  1238. // 他们也在拼数据
  1239. meta: '',
  1240. // 他们也在拼页面数据
  1241. init: false,
  1242. //是否加载过
  1243. more: true,
  1244. //是否还可以加载
  1245. page: 1,
  1246. //当前请求第几页的数据
  1247. emjstatus: {
  1248. percent: 0,
  1249. //进度条百分比
  1250. lauch: false,
  1251. //第一个icon控制
  1252. half: false,
  1253. //第二个icon控制
  1254. end: false //第三个icon控制
  1255. },
  1256. show_third: false,
  1257. //弹出第三方供货
  1258. config: '',
  1259. gbConfig: '',
  1260. price_interval: '',
  1261. initInfoData: '',
  1262. is_immediately: false,
  1263. is_refused: false,
  1264. is_fives: false,
  1265. show_more_shop: false,
  1266. freeGoodsInfo: '',
  1267. shopInfo: '',
  1268. animation:'',
  1269. show:'',
  1270. service_info:'',
  1271. is_alone: false,
  1272. rateDisabled: true,
  1273. is_init:false,
  1274. is_toggle_share:false,
  1275. share_gaphic:false,
  1276. qr_code_image:'',
  1277. open_id:'',
  1278. // #ifdef H5
  1279. env:{
  1280. isIPad: /ipad/i.test(window.navigator.userAgent),
  1281. isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
  1282. isWechat: /MicroMessenger/i.test(window.navigator.userAgent)
  1283. },
  1284. // #endif
  1285. is_no_specification:false
  1286. };
  1287. },
  1288. components: {
  1289. ten,
  1290. group,
  1291. seckill,
  1292. alert,
  1293. uParse,
  1294. uniRate,
  1295. uniPopup
  1296. },
  1297. onLoad(e) {
  1298. // 第三方平台配置颜色
  1299. var gbConfig = this.$cookieStorage.get('globalConfig') || '';
  1300. var init = this.$cookieStorage.get('init');
  1301. // this.setData({
  1302. // config: gbConfig,
  1303. //
  1304. // author: init && init.other_technical_support ? init.other_technical_support : ''
  1305. // });
  1306. //
  1307. this.config=gbConfig;
  1308. this.author=init && init.other_technical_support ? init.other_technical_support : '';
  1309. if (!gbConfig) {
  1310. let extConfig = {};
  1311. if (extConfig) {
  1312. // this.setData({
  1313. // config: extConfig
  1314. // });
  1315. //
  1316. this.config=extConfig;
  1317. }
  1318. }
  1319. wx.showLoading({
  1320. title: "加载中",
  1321. mask: true
  1322. }); // 显示页面转发按钮
  1323. //#ifdef MP-WEIXIN
  1324. wx.showShareMenu({
  1325. withShareTicket: true
  1326. });
  1327. //#endif
  1328. var id = '';
  1329. var groupon_item_id = '';
  1330. var user_id = '';
  1331. if (e.id) {
  1332. id = e.id;
  1333. }
  1334. if (e.user_id) {
  1335. user_id = e.user_id;
  1336. }
  1337. if (e.groupon_item_id) {
  1338. groupon_item_id = e.groupon_item_id;
  1339. this.setData({
  1340. url_groupon_item_id: e.groupon_item_id
  1341. });
  1342. }
  1343. if (e.scene) {
  1344. var scene = decodeURIComponent(e.scene);
  1345. var sceneArr = scene.split(',');
  1346. if (sceneArr.length > 1) {
  1347. groupon_item_id = sceneArr[2] ? sceneArr[2] : '';
  1348. this.setData({
  1349. url_groupon_item_id: sceneArr[2] ? sceneArr[2] : ''
  1350. });
  1351. }
  1352. id = sceneArr[0];
  1353. /* if (sceneArr[3]) {
  1354. user_id = sceneArr[3];
  1355. this.beSharePoint(id, sceneArr[3]);
  1356. } */
  1357. }
  1358. if (!id) {
  1359. wx.redirectTo({
  1360. url: '/pages/store/list/list'
  1361. });
  1362. return;
  1363. }
  1364. /* if (e.is_share && e.user_id) {
  1365. // #ifdef MP-WEIXIN
  1366. this.beSharePoint(id, user_id);
  1367. // #endif
  1368. }
  1369. */
  1370. var is_login = this.$cookieStorage.get('user_token');
  1371. this.id=id;
  1372. this.query=e;
  1373. this.is_login=is_login;
  1374. this.groupon_item_id=groupon_item_id;
  1375. this.user_id=user_id;
  1376. // this.queryDiscounts(e.id);
  1377. this.initfun(e);
  1378. /*
  1379. 分销相关 S
  1380. */
  1381. /*
  1382. 分销相关 E
  1383. */
  1384. // 用户登录后请求限购接口
  1385. if (this.is_login) {
  1386. this.goodsPurchase(this.id);
  1387. }
  1388. // H5自动登陆
  1389. // #ifdef H5
  1390. if(e.openid){
  1391. this.open_id = e.openid;
  1392. this.$cookieStorage.set('openid',e.openid)
  1393. let agent_code = e.agent_code;
  1394. this.postNewQuickLogin(this.open_id,agent_code);
  1395. }
  1396. // #endif
  1397. },
  1398. onShareAppMessage(res) {
  1399. if(res.from === 'menu'){
  1400. this.setData({
  1401. show_share:false
  1402. })
  1403. } else {
  1404. this.changeShare();
  1405. }
  1406. var codeTitle = '';
  1407. if (this.commodity.user) {
  1408. codeTitle = this.commodity.user.nick_name + '向您推荐' + this.commodity.name;
  1409. }
  1410. var priceTitle = '¥ ' + this.commodity.sell_price + ' | ' + this.commodity.name;
  1411. var id = this.commodity.user ? this.commodity.user.id : '';
  1412. let pages = getCurrentPages();
  1413. let currPage = null;
  1414. // console.log(pages) 的到一个数组
  1415. if (pages.length) {
  1416. // 获取当前页面的对象(上边所获得的数组中最后一项就是当前页面的对象)
  1417. currPage = pages[pages.length - 1];
  1418. }
  1419. // 获取当前页面的路由
  1420. let route = currPage.route;
  1421. return {
  1422. title: priceTitle,
  1423. // path: '/' + this.router + '?id=' + this.id,
  1424. path: `/${route}?id=${this.id}&agent_code=${this.detailData.data.agent_code}&user_id=${id}&is_share=true`,
  1425. imageUrl: this.commodity.img
  1426. };
  1427. },
  1428. methods: {
  1429. preImage(){
  1430. uni.previewImage({
  1431. current:this.qr_code_image,
  1432. urls:[this.qr_code_image]
  1433. })
  1434. },
  1435. //封装H5的登陆
  1436. wechatLogin(){
  1437. let env = {
  1438. isIPad: /ipad/i.test(window.navigator.userAgent),
  1439. isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
  1440. isWechat: /MicroMessenger/i.test(window.navigator.userAgent)
  1441. }
  1442. let agent_code = this.$cookieStorage.get("agent_code");
  1443. if(env.isWechat){
  1444. if(this.open_id){
  1445. this.$cookieStorage.set('openid',this.open_id)
  1446. }
  1447. var openid = this.$cookieStorage.get('openid') || this.open_id;
  1448. if(openid){
  1449. this.postNewQuickLogin(openid,agent_code);
  1450. } else{
  1451. let origin = window.location.origin;
  1452. let id = this.commodity.user ? this.commodity.user.id : '';
  1453. let url = origin+'/pages/store/detail/detail?id='+this.id+'&agent_code='+agent_code+'&user_id='+id+'&is_share=true';
  1454. window.location.href = this.$config.GLOBAL.baseUrl+'oauth/wxOauth?redirect_url='+encodeURIComponent(url);
  1455. }
  1456. } else{
  1457. let url = getUrl();
  1458. wx.navigateTo({
  1459. url:'/pages/user/loginType/loginType?url='+url
  1460. })
  1461. }
  1462. },
  1463. // 分享给app的好友
  1464. shareapp(){
  1465. this.changeShare();
  1466. var user_id = this.commodity.user ? this.commodity.user.id : '';
  1467. var imageUrl = this.commodity.img;
  1468. var id = this.id;
  1469. var agent_code = this.detailData.data.agent_code || '';
  1470. var priceTitle = '¥ ' + this.commodity.sell_price + ' | ' + this.commodity.name;
  1471. var url = `pages/store/detail/detail?id=${id}&agent_code=${agent_code}&user_id=${user_id}&is_share=true`;
  1472. uni.getProvider({
  1473. service:'share',
  1474. success:function(res){
  1475. uni.share({
  1476. provider: "weixin",
  1477. scene: "WXSceneSession",
  1478. type: 5,
  1479. title:priceTitle,
  1480. imageUrl:imageUrl,
  1481. miniProgram:{
  1482. id:'gh_72e65196278a',
  1483. path:`pages/store/detail/detail?id=${id}&agent_code=${agent_code}&user_id=${user_id}&is_share=true`,
  1484. type:0,
  1485. webUrl: 'https://guojiang.club'
  1486. },
  1487. success: function (res) {
  1488. console.log("success:" + JSON.stringify(res));
  1489. },
  1490. fail: function (err) {
  1491. console.log("fail:" + JSON.stringify(err));
  1492. }
  1493. });
  1494. }
  1495. })
  1496. },
  1497. jumpRecharge() {
  1498. var token = this.$cookieStorage.get('user_token');
  1499. if (token) {
  1500. wx.navigateTo({
  1501. url: '/pages/recharge/index/index'
  1502. });
  1503. } else {
  1504. // #ifdef H5
  1505. var url = getUrl()+ '?id='+this.id;
  1506. // #endif
  1507. // #ifdef APP-PLUS || MP-WEIXIN
  1508. var url = getUrl();
  1509. // #endif
  1510. wx.showModal({
  1511. content: '请先登录',
  1512. success: res => {
  1513. if (res.confirm) {
  1514. // #ifdef APP-PLUS || MP-WEIXIN
  1515. wx.navigateTo({
  1516. url: '/pages/user/register/register?url=' + url
  1517. });
  1518. // #endif
  1519. // #ifdef H5
  1520. this.wechatLogin();
  1521. // #endif
  1522. }
  1523. }
  1524. });
  1525. }
  1526. },
  1527. jumpSvip() {
  1528. if (this.detailData.meta.vip_plan) {
  1529. var link = this.detailData.meta.vip_plan.vip_plan_equity_link;
  1530. wx.navigateTo({
  1531. url: '/pages/other/links/links?url=' + link
  1532. });
  1533. }
  1534. },
  1535. closeAlert() {
  1536. this.setData({
  1537. is_refused: false
  1538. });
  1539. },
  1540. callPhone() {
  1541. wx.makePhoneCall({
  1542. phoneNumber: this.service_info.online_service_self.phone
  1543. });
  1544. },
  1545. setCode(e) {
  1546. var agent_code = '';
  1547. if (e.agent_code) {
  1548. agent_code = e.agent_code;
  1549. }
  1550. if (e.scene) {
  1551. var scene = decodeURIComponent(e.scene);
  1552. var sceneArr = scene.split(',');
  1553. if (sceneArr.length > 0) {
  1554. agent_code = sceneArr[1];
  1555. }
  1556. } // 获取agent_code存缓存里
  1557. if (agent_code) {
  1558. // 如果有agent_code并且有coupon_agent_code就将coupon_agent_code清除,保证agent_code为第一位
  1559. if (this.$cookieStorage.get('coupon_agent_code')) {
  1560. this.$cookieStorage.clear('coupon_agent_code');
  1561. }
  1562. const timeMap = {
  1563. y: 31536000000,
  1564. m: 2592000000,
  1565. d: 86400000,
  1566. h: 3600000,
  1567. n: 60000,
  1568. s: 1000
  1569. }; // 默认有效期为7天
  1570. var valid_time = "";
  1571. if (!this.$cookieStorage.get('distribution_valid_time')) {
  1572. valid_time = 10080;
  1573. } else {
  1574. valid_time = this.$cookieStorage.get('distribution_valid_time');
  1575. }
  1576. let timeStamp = new Date().getTime();
  1577. timeStamp += timeMap.n * valid_time;
  1578. // 如果有agent_code就讲这次进入的时间缓存
  1579. this.$cookieStorage.set('agent_code_time', timeStamp, valid_time + 'n'); // 如果缓存中没有agent_code
  1580. if (!this.$cookieStorage.get('agent_code')) {
  1581. var data = [];
  1582. data.push({
  1583. id: this.id,
  1584. time: timeStamp
  1585. });
  1586. this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n');
  1587. this.$cookieStorage.set('agent_goods_id', data);
  1588. } else {
  1589. // 判断缓存的code和从url的code相等
  1590. if (agent_code == this.$cookieStorage.get('agent_code')) {
  1591. var data = this.$cookieStorage.get('agent_goods_id') ? this.$cookieStorage.get('agent_goods_id') : [];
  1592. var flag = false;
  1593. for (var i = 0; i < data.length; i++) {
  1594. if (data[i].id == this.id) {
  1595. flag = true;
  1596. data[i].time = timeStamp;
  1597. break;
  1598. }
  1599. }
  1600. if (!flag) {
  1601. data.push({
  1602. id: this.id,
  1603. time: timeStamp
  1604. });
  1605. }
  1606. this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n');
  1607. this.$cookieStorage.set('agent_goods_id', data);
  1608. } else {
  1609. var data = [];
  1610. ;
  1611. data.push({
  1612. id: this.id,
  1613. time: timeStamp
  1614. });
  1615. this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n');
  1616. this.$cookieStorage.set('agent_goods_id', data); // this.$cookieStorage.set('agent_scan', 0, valid_time + 'n');
  1617. }
  1618. }
  1619. }
  1620. },
  1621. // 初始化数据
  1622. initfun(e) {
  1623. var token = this.$cookieStorage.get('user_token');
  1624. var agent_code = '';
  1625. if (e.agent_code) {
  1626. agent_code = e.agent_code;
  1627. }
  1628. if (e.scene) {
  1629. var scene = decodeURIComponent(e.scene);
  1630. var sceneArr = scene.split(',');
  1631. if (sceneArr.length > 0) {
  1632. agent_code = sceneArr[1];
  1633. }
  1634. }
  1635. this.$http.get({
  1636. api: 'api/system/init'
  1637. }).then(res => {
  1638. res = res.data;
  1639. if (res.status) {
  1640. this.$cookieStorage.set('init_info', res.data.h5_share);
  1641. this.$cookieStorage.set('service_info', res.data.online_service_data);
  1642. this.$cookieStorage.set('distribution_valid_time', res.data.distribution_valid_time);
  1643. this.$cookieStorage.set('init', res.data);
  1644. var shareTicketInfo = this.$cookieStorage.get('shareTicketInfo');
  1645. var init = this.$cookieStorage.get('init');
  1646. var service_info = this.$cookieStorage.get('service_info');
  1647. // this.setData({
  1648. // service_info: service_info,
  1649. // initInfoData: res.data
  1650. // });
  1651. this.service_info=service_info;
  1652. this.initInfoData=res.data;
  1653. /* if (shareTicketInfo && init && init.get_gid == 1) {
  1654. this.getGid(shareTicketInfo);
  1655. } else {
  1656. } */
  1657. this.getStoreDetail();
  1658. this.setCode(e);
  1659. // #ifdef MP-WEIXIN
  1660. if (agent_code && res.data.mini_program_login_type == 'default' && token == '') {
  1661. wx.showLoading({
  1662. title: '正在自动登录',
  1663. mask: true
  1664. });
  1665. wx.login({
  1666. success: res => {
  1667. if (res.code) {
  1668. autoLogin(res.code, agent_code).then(res => {
  1669. if (res.status) {
  1670. if (res.data.access_token) {
  1671. var access_token = res.data.token_type + ' ' + res.data.access_token;
  1672. this.setData({
  1673. is_login: access_token
  1674. });
  1675. }
  1676. if (res.data.open_id) {
  1677. wx.reLaunch({
  1678. url: '/pages/user/agentlogin/agentlogin?agent_code=' + agent_code + '&open_id=' + res.data.open_id + '&url=' + getUrl()
  1679. });
  1680. }
  1681. }
  1682. wx.hideLoading();
  1683. }, err => {
  1684. wx.hideLoading();
  1685. });
  1686. } else {
  1687. wx.showToast({
  1688. title: '获取code失败',
  1689. icon: 'none'
  1690. });
  1691. }
  1692. }
  1693. });
  1694. }
  1695. // #endif
  1696. // #ifdef H5
  1697. if(agent_code && token == ''){
  1698. var env = {
  1699. isIPad: /ipad/i.test(window.navigator.userAgent),
  1700. isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
  1701. isWechat: /MicroMessenger/i.test(window.navigator.userAgent)
  1702. }
  1703. if(env.isWechat){
  1704. if(e.openid){
  1705. this.$cookieStorage.set('openid',e.openid)
  1706. }
  1707. var openid = this.$cookieStorage.get('openid') || e.openid;
  1708. if(openid){
  1709. this.postNewQuickLogin(openid,agent_code);
  1710. } else{
  1711. let origin = window.location.origin;
  1712. var id = this.commodity.user ? this.commodity.user.id : '';
  1713. var url = origin+'/pages/store/detail/detail?id='+this.id+'&agent_code='+agent_code+'&user_id='+id+'&is_share=true';
  1714. window.location.href = this.$config.GLOBAL.baseUrl+'oauth/wxOauth?redirect_url='+encodeURIComponent(url);
  1715. }
  1716. } else{
  1717. var url = getUrl()+ '?id='+this.id;
  1718. wx.navigateTo({
  1719. url:'/pages/user/loginType/loginType?url='+url
  1720. })
  1721. }
  1722. }
  1723. // #endif
  1724. } else {
  1725. this.getStoreDetail();
  1726. }
  1727. this.setCode(e);
  1728. }).catch(err => {
  1729. this.setCode(e);
  1730. });
  1731. },
  1732. postNewQuickLogin(open_id,agent_code){
  1733. wx.showLoading({
  1734. title: '正在登录',
  1735. mask: true
  1736. });
  1737. this.$http.post({
  1738. api:'api/oauth/newQuickLogin',
  1739. data:{
  1740. open_id:open_id,
  1741. agent_code:agent_code
  1742. }
  1743. }).then(res=>{
  1744. res = res.data;
  1745. if(res.status){
  1746. if(res.data.access_token){
  1747. var access_token = res.data.token_type + ' ' + res.data.access_token;
  1748. var expires_in = res.data.expires_in || 315360000;
  1749. this.$cookieStorage.set("user_token", access_token, expires_in);
  1750. //如果用户没有绑定手机号
  1751. /* if(res.data.has_bind_mobile == 0){
  1752. wx.reLaunch({
  1753. url:'/pages/user/bindingphone/bindingphone'
  1754. })
  1755. } else{
  1756. } */
  1757. this.is_login = this.$cookieStorage.get('user_token');
  1758. } else{
  1759. wx.showModal({
  1760. content: res.message || '请求失败,请重试',
  1761. showCancel: false
  1762. });
  1763. }
  1764. } else{
  1765. wx.showModal({
  1766. content: res.message || '请求失败,请重试',
  1767. showCancel: false
  1768. });
  1769. }
  1770. wx.hideLoading()
  1771. }).catch(rej=>{
  1772. wx.showModal({
  1773. content: rej.message || '请求失败,请重试',
  1774. showCancel: false
  1775. });
  1776. wx.hideLoading()
  1777. })
  1778. },
  1779. // 请求商品详情页面数据
  1780. getStoreDetail(wechat_group_id) {
  1781. var token = this.$cookieStorage.get('user_token') || '';
  1782. var wechat_group_id = wechat_group_id || this.$cookieStorage.get('openGId') || '';
  1783. this.getGoodsDetail({
  1784. api: `api/store/detail/${this.id}`,
  1785. header: {
  1786. Authorization: token
  1787. },
  1788. data: {
  1789. include: 'photos,oneComment,guessYouLike,point,user',
  1790. multi_groupon_item_id: this.groupon_item_id,
  1791. wechat_group_id: wechat_group_id
  1792. }
  1793. }).then(() => {
  1794. if (this.detailData.data.shop_hidden_more_info == 0) {
  1795. this.getDomInfo('.js__top', 'shop'); // this.getDomInfo('.js__like', 'like');
  1796. this.getDomInfo('.js__comment', 'comment');
  1797. }
  1798. // this.attributesList(this.detailData.meta);
  1799. wx.setNavigationBarTitle({
  1800. title: this.detailData.data.name
  1801. });
  1802. var price_interval = '¥' + this.detailData.data.min_price + ' - ' + '¥' + this.detailData.data.max_price;
  1803. if (this.detailData.data.min_price == this.detailData.data.max_price) {// price_interval = '¥' + this.detailData.data.min_price
  1804. }
  1805. this.setData({
  1806. price_interval: price_interval,
  1807. is_show_tabbar: true,
  1808. is_init:true
  1809. }); // 新增
  1810. // 设置价格
  1811. this.setData({
  1812. price: Number(this.commodity.sell_price).toFixed(2),
  1813. store_count: this.commodity.store_nums
  1814. });
  1815. this.changeText();
  1816. this.immediatelyText();
  1817. this.disallow_cart();
  1818. this.queryCommodityStore(this.id);
  1819. // #ifdef H5
  1820. if (this.$wechat && this.$wechat.isWechat()) {
  1821. var desc=this.detailData.data.name;
  1822. var img=this.detailData.data.img;
  1823. var priceTitle = '¥ ' + this.commodity.sell_price + ' | ' + this.commodity.name;
  1824. var id = this.commodity.user ? this.commodity.user.id : '';
  1825. var origin = window.location.origin;
  1826. var pathname = window.location.pathname;
  1827. var path = origin+'/pages/store/detail/detail?id='+this.id+'&agent_code='+this.detailData.data.agent_code+'&user_id='+id+'&is_share=true';
  1828. this.$wechat.share({
  1829. title:priceTitle,
  1830. img:img,
  1831. desc:'果酱小店'
  1832. },path);
  1833. }
  1834. // #endif
  1835. });
  1836. },
  1837. changeStatus() {
  1838. var token = this.$cookieStorage.get('user_token');
  1839. if (token) {
  1840. this.changeFavorite(this.id, 'goods');
  1841. } else {
  1842. // #ifdef H5
  1843. var url = getUrl()+ '?id='+this.id;
  1844. // #endif
  1845. // #ifdef APP-PLUS || MP-WEIXIN
  1846. var url = getUrl();
  1847. // #endif
  1848. wx.showModal({
  1849. content: '请先登录',
  1850. success: res => {
  1851. if (res.confirm) {
  1852. // #ifdef APP-PLUS || MP-WEIXIN
  1853. wx.navigateTo({
  1854. url: '/pages/user/register/register?url=' + url
  1855. });
  1856. // #endif
  1857. // #ifdef H5
  1858. this.wechatLogin();
  1859. // #endif
  1860. }
  1861. }
  1862. });
  1863. }
  1864. },
  1865. // 监听页面滚动
  1866. onPageScroll(e) {
  1867. if (this.detailData.data.shop_hidden_more_info) {
  1868. return;
  1869. }
  1870. var shop = this.domInfo.shop;
  1871. var like = 0;
  1872. var comment = this.domInfo.comment;
  1873. if (!this.lock) {
  1874. if (e.scrollTop < shop) {
  1875. this.setData({
  1876. activeName: 'shop'
  1877. });
  1878. } else if (e.scrollTop > shop + like && e.scrollTop < shop + like + comment) {
  1879. this.setData({
  1880. activeName: 'comment'
  1881. });
  1882. } else {
  1883. this.setData({
  1884. activeName: 'details'
  1885. });
  1886. }
  1887. }
  1888. this.setData({
  1889. lock: false
  1890. });
  1891. },
  1892. // 网络繁忙倒计时
  1893. HideTen() {
  1894. this.setData({
  1895. show_ten: false
  1896. });
  1897. },
  1898. // 弹出客服
  1899. showServer() {
  1900. var srcList = ['https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/QQ20180517-0.jpg'];
  1901. wx.previewImage({
  1902. urls: srcList
  1903. });
  1904. /*this.setData({
  1905. showServer: !this.showServer
  1906. })*/
  1907. },
  1908. // 弹出分享
  1909. changeShare() {
  1910. this.setData({
  1911. show_share: !this.show_share
  1912. });
  1913. },
  1914. //弹出规则
  1915. sharRules() {
  1916. this.setData({
  1917. show_rule: !this.show_rule
  1918. });
  1919. },
  1920. //弹出第三方供货详情
  1921. changeThird() {
  1922. this.setData({
  1923. show_third: !this.show_third
  1924. });
  1925. },
  1926. //弹出更多拼团
  1927. seeMore() {
  1928. this.setData({
  1929. show_more: !this.show_more
  1930. });
  1931. },
  1932. //点击幕布关闭更多拼团
  1933. closeMore() {
  1934. this.setData({
  1935. show_more: false
  1936. });
  1937. },
  1938. //关闭规则
  1939. closeRule() {
  1940. this.setData({
  1941. show_rule: false
  1942. });
  1943. },
  1944. //请求h5的图片接口
  1945. getCreateShareImg(){
  1946. wx.showLoading({
  1947. title:"生成中",
  1948. mask:true
  1949. })
  1950. let origin = window.location.origin;
  1951. let share_url = origin+'/pages/store/detail/detail';
  1952. this.$http.get({
  1953. api:'api/distribution/createH5ShareImg',
  1954. data:{
  1955. goods_id:this.id,
  1956. share_url:share_url
  1957. }
  1958. }).then(res=>{
  1959. res = res.data;
  1960. if(res.status){
  1961. this.qr_code_image = res.data.image;
  1962. if(this.qr_code_image){
  1963. this.share_gaphic =!this.share_gaphic; this.is_toggle_share = false;
  1964. }
  1965. } else{
  1966. wx.showModal({
  1967. content: res.message || '请求失败,请重试',
  1968. showCancel: false
  1969. });
  1970. }
  1971. wx.hideLoading()
  1972. }).catch(rej=>{
  1973. wx.hideLoading()
  1974. wx.showModal({
  1975. content: rej.message || '内部错误,请重试',
  1976. showCancel: false
  1977. });
  1978. })
  1979. },
  1980. // 弹出图片
  1981. changeImg() {
  1982. // this.setData({
  1983. // share_img: !this.share_img
  1984. // });
  1985. this.share_img=!this.share_img;
  1986. },
  1987. jumpAuthor() {
  1988. wx.navigateTo({
  1989. url: '/pages/index/author/author'
  1990. });
  1991. },
  1992. jumpFreeLink(e) {
  1993. let link = e.currentTarget.dataset.link;
  1994. wx.navigateTo({
  1995. url: link,
  1996. fail: () => {
  1997. wx.switchTab({
  1998. url: link
  1999. });
  2000. }
  2001. });
  2002. },
  2003. // 获取分享图片
  2004. getShearImg() {
  2005. wx.showLoading({
  2006. title: "生成中",
  2007. mask: true
  2008. });
  2009. var token = this.$cookieStorage.get('user_token') || '';
  2010. this.$http.get({
  2011. api: 'api/distribution/createMiniShareImg',
  2012. header: {
  2013. Authorization: token
  2014. },
  2015. data: {
  2016. goods_id: this.id
  2017. }
  2018. }).then(res => {
  2019. if (res.statusCode == 200) {
  2020. res = res.data;
  2021. if (res.status) {
  2022. this.setData({
  2023. shareImg: res.data.image
  2024. });
  2025. setTimeout(() => {
  2026. this.changeImg();
  2027. }, 100)
  2028. } else {
  2029. wx.showModal({
  2030. content: res.message || '请求失败',
  2031. showCancel: false
  2032. });
  2033. }
  2034. } else {
  2035. wx.showModal({
  2036. content: '请求失败',
  2037. showCancel: false
  2038. });
  2039. }
  2040. wx.hideLoading();
  2041. this.changeShare();
  2042. }).catch(rej => {
  2043. wx.showModal({
  2044. content: '内部错误',
  2045. showCancel: false
  2046. });
  2047. wx.hideLoading();
  2048. this.changeShare();
  2049. });
  2050. },
  2051. toggleShare(){
  2052. this.is_toggle_share = !this.is_toggle_share;
  2053. },
  2054. // 下载图片
  2055. downImg() {
  2056. if (this.shareImg) {
  2057. wx.showLoading({
  2058. title: '正在下载',
  2059. mask: true
  2060. });
  2061. this.$http.dowloadFile({
  2062. api: this.shareImg
  2063. }).then(res => {
  2064. if (res.statusCode == 200) {
  2065. // #ifdef MP-WEIXIN
  2066. wx.getSetting({
  2067. success: ret => {
  2068. // 如果之前没有授权
  2069. if (!ret.authSetting['scope.writePhotosAlbum']) {
  2070. wx.authorize({
  2071. scope: 'scope.writePhotosAlbum',
  2072. success: rej => {
  2073. this.saveImg(res.tempFilePath);
  2074. },
  2075. // 用户拒绝授权
  2076. fail: ret => {
  2077. this.setData({
  2078. is_refused: true
  2079. });
  2080. wx.hideLoading();
  2081. }
  2082. });
  2083. } else {
  2084. this.saveImg(res.tempFilePath);
  2085. }
  2086. }
  2087. });
  2088. // #endif
  2089. // #ifdef APP-PLUS
  2090. var that = this;
  2091. uni.getSystemInfo({
  2092. success(result) {
  2093. if(result.platform == 'android'){
  2094. that.requestAndroidPermission(res.tempFilePath);
  2095. } else if(result.platform == 'ios'){
  2096. that.requestIosPermission(res.tempFilePath)
  2097. }
  2098. }
  2099. })
  2100. // #endif
  2101. } else {
  2102. wx.hideLoading();
  2103. wx.showToast({
  2104. title: '下载图片失败',
  2105. icon: 'none'
  2106. });
  2107. }
  2108. }, err => {});
  2109. }
  2110. },
  2111. //ios app授权
  2112. requestIosPermission(url){
  2113. var result = permision.judgeIosPermission('photoLibrary');
  2114. if(result){
  2115. this.saveImg(url);
  2116. }else{
  2117. //打开授权,iOS上如果没有调用过的权限,不会出现在权限设置界面。
  2118. permision.gotoAppPermissionSetting()
  2119. }
  2120. },
  2121. //安卓app授权
  2122. async requestAndroidPermission(url) {
  2123. var result = await permision.requestAndroidPermission("android.permission.WRITE_EXTERNAL_STORAGE")
  2124. var strStatus
  2125. if (result == 1) {
  2126. strStatus = "已获得授权";
  2127. this.saveImg(url);
  2128. } else if (result == 0) {
  2129. strStatus = "未获得授权";
  2130. void permision.gotoAppPermissionSetting()
  2131. } else {
  2132. strStatus = "被永久拒绝权限"
  2133. void permision.gotoAppPermissionSetting()
  2134. }
  2135. },
  2136. // 保存图片
  2137. saveImg(path) {
  2138. wx.saveImageToPhotosAlbum({
  2139. filePath: path,
  2140. success: res => {
  2141. wx.hideLoading();
  2142. wx.showToast({
  2143. title: '保存图片成功',
  2144. icon: 'success'
  2145. });
  2146. },
  2147. fail: rej => {
  2148. wx.hideLoading();
  2149. wx.showToast({
  2150. title: '保存图片失败',
  2151. icon: 'none'
  2152. });
  2153. }
  2154. });
  2155. },
  2156. // 获取节点信息
  2157. getDomInfo(name, type) {
  2158. var query = uni.createSelectorQuery().in(this);
  2159. query.select(name).boundingClientRect(res => {
  2160. this.setData({
  2161. [`domInfo.${type}`]: res.height
  2162. });
  2163. }).exec();
  2164. },
  2165. jumpScroll(e) {
  2166. var type = e.target.dataset.type;
  2167. if (type == 'shop') {
  2168. wx.pageScrollTo({
  2169. scrollTop: 0,
  2170. duration: 0
  2171. });
  2172. } else if (type == 'comment') {
  2173. wx.pageScrollTo({
  2174. scrollTop: this.domInfo.shop + this.domInfo.like + 10,
  2175. duration: 0
  2176. });
  2177. } else if (type == 'details') {
  2178. wx.pageScrollTo({
  2179. scrollTop: this.domInfo.shop + this.domInfo.like + this.domInfo.comment,
  2180. duration: 0
  2181. });
  2182. } else {
  2183. wx.pageScrollTo({
  2184. scrollTop: this.domInfo.shop,
  2185. duration: 0
  2186. });
  2187. }
  2188. this.setData({
  2189. activeName: type,
  2190. lock: true
  2191. });
  2192. },
  2193. viewComment() {
  2194. wx.navigateTo({
  2195. url: '/pages/store/comment/comment?id=' + this.id
  2196. });
  2197. },
  2198. immediatelyText() {
  2199. var ret;
  2200. var commodity = this.commodity;
  2201. var seckill = this.detailData.meta.seckill;
  2202. var group = this.detailData.meta.multiGroupon;
  2203. if (!commodity) {
  2204. return;
  2205. }
  2206. if (commodity.is_del != 0 || commodity.is_largess != 0) {
  2207. ret = {
  2208. status: false,
  2209. message: '商品已下架'
  2210. };
  2211. } else if (commodity.store_nums <= 0) {
  2212. ret = {
  2213. status: false,
  2214. message: '商品缺货中'
  2215. };
  2216. } else {
  2217. ret = {
  2218. status: true,
  2219. message: '立即购买'
  2220. };
  2221. }
  2222. if (seckill && seckill.init_status == 2) {
  2223. ret = {
  2224. seckill: false,
  2225. message: '原价购买'
  2226. };
  2227. } else if (seckill && seckill.init_status == 1) {
  2228. ret = {
  2229. seckill: true,
  2230. message: '立即抢购'
  2231. };
  2232. }
  2233. if (group && commodity.multi_groupon_init_status == 2) {
  2234. ret = {
  2235. group: false,
  2236. message: '原价购买'
  2237. };
  2238. } else if (group && commodity.multi_groupon_init_status == 1) {
  2239. if (this.detailData.data.multi_groupon_join_status == 1) {
  2240. ret = {
  2241. group: true,
  2242. message: '已参团'
  2243. };
  2244. } else if (this.groupon_item_id) {
  2245. ret = {
  2246. group: true,
  2247. message: '一键参团'
  2248. };
  2249. } else {
  2250. ret = {
  2251. group: true,
  2252. message: '一键开团'
  2253. };
  2254. }
  2255. }
  2256. this.setData({
  2257. immediately_text: ret
  2258. });
  2259. },
  2260. changeMoreShop() {
  2261. this.setData({
  2262. show_more_shop: !this.show_more_shop
  2263. });
  2264. },
  2265. changeText() {
  2266. var ret;
  2267. var commodity = this.commodity;
  2268. var seckill = this.detailData.meta.seckill;
  2269. var group = this.detailData.meta.multiGroupon;
  2270. if (!commodity) {
  2271. return;
  2272. }
  2273. if (commodity.is_del != 0 || commodity.is_largess != 0) {
  2274. ret = {
  2275. status: false,
  2276. message: '商品已下架'
  2277. };
  2278. } else if (commodity.store_nums <= 0) {
  2279. ret = {
  2280. status: false,
  2281. message: '商品缺货中'
  2282. };
  2283. } else {
  2284. ret = {
  2285. status: true,
  2286. message: '加入购物车'
  2287. };
  2288. }
  2289. if (seckill && seckill.init_status == 2) {
  2290. ret = {
  2291. status: true,
  2292. seckill: false,
  2293. message: '原价购买'
  2294. };
  2295. } else if (seckill && seckill.init_status == 1) {
  2296. ret = {
  2297. status: true,
  2298. seckill: true,
  2299. message: '立即抢购'
  2300. };
  2301. }
  2302. if (group && commodity.multi_groupon_init_status == 2) {
  2303. ret = {
  2304. status: true,
  2305. group: false,
  2306. message: '原价购买'
  2307. };
  2308. } else if (group && commodity.multi_groupon_init_status == 1) {
  2309. if (this.detailData.data.multi_groupon_join_status == 1) {
  2310. ret = {
  2311. status: true,
  2312. group: true,
  2313. message: '已参团'
  2314. };
  2315. } else if (this.groupon_item_id) {
  2316. ret = {
  2317. status: true,
  2318. group: true,
  2319. message: '一键参团'
  2320. };
  2321. } else {
  2322. ret = {
  2323. status: true,
  2324. group: true,
  2325. message: '一键开团'
  2326. };
  2327. }
  2328. }
  2329. this.setData({
  2330. cart_status: ret
  2331. });
  2332. },
  2333. // 活动开始的倒计时
  2334. countTime() {
  2335. var d = 86400000,
  2336. h = 3600000,
  2337. n = 60000,
  2338. end = this.detailData.meta.seckill.ends_at,
  2339. server = this.detailData.meta.seckill.server_time,
  2340. arr = String(end).split(/\D/),
  2341. newArr = String(server).split(/\D/);
  2342. newArr = newArr.map(Number);
  2343. arr = arr.map(Number);
  2344. var serverTime = new Date(newArr[0], newArr[1] - 1, newArr[2], newArr[3], newArr[4], newArr[5]).getTime(); // var nowTime = new Date().getTime();
  2345. var endTime = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5]).getTime(); // 组件才秒杀列表页使用时,没有重新请求列表,服务器时间应该加上未开始倒计时的时间
  2346. if (this.mold == 'list') {
  2347. serverTime = serverTime + this.startsTime.count;
  2348. } // 计算开始时间跟结束时间的差值
  2349. var timeDiff = endTime - serverTime; // 在本地计算倒计时
  2350. var allTime = this.endTime.count + 1000;
  2351. this.setData({
  2352. 'endTime.count': allTime
  2353. }); // this.endTime.count += 1000;
  2354. var interval = timeDiff - this.endTime.count;
  2355. if (interval < 0) {
  2356. // 活动结束
  2357. this.isEnd(); // this.$emit('end',this.index)
  2358. } else {
  2359. var day = Math.floor(interval / d);
  2360. Math.floor(interval -= day * d);
  2361. var hour = Math.floor(interval / h);
  2362. Math.floor(interval -= hour * h);
  2363. var minute = Math.floor(interval / n);
  2364. var second = Math.floor(interval % n / 1000);
  2365. this.setData({
  2366. 'endTime.day': day,
  2367. 'endTime.hour': hour,
  2368. 'endTime.minute': minute,
  2369. 'endTime.second': second
  2370. }); // this.endTime.day = day;
  2371. // this.endTime.hour = hour;
  2372. // this.endTime.minute = minute;
  2373. // this.endTime.second = second;
  2374. }
  2375. },
  2376. // 活动未开始的倒计时
  2377. countStartsTime() {
  2378. var d = 86400000,
  2379. h = 3600000,
  2380. n = 60000,
  2381. sta = this.detailData.meta.seckill.starts_at,
  2382. server = this.detailData.meta.seckill.server_time,
  2383. arr = String(sta).split(/\D/),
  2384. newArr = String(server).split(/\D/);
  2385. newArr = newArr.map(Number);
  2386. arr = arr.map(Number);
  2387. var serverTime = new Date(newArr[0], newArr[1] - 1, newArr[2], newArr[3], newArr[4], newArr[5]).getTime();
  2388. var staTime = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5]).getTime();
  2389. var timeDiff = staTime - serverTime;
  2390. var allTime = this.startsTime.count + 1000;
  2391. this.setData({
  2392. 'startsTime.count': allTime
  2393. }); // this.startsTime.count += 1000;
  2394. var interval = timeDiff - this.startsTime.count; // var interval = staTime - nowTime;
  2395. // 时间差小于一天
  2396. if (interval < d) {
  2397. this.setData({
  2398. type: 1
  2399. });
  2400. if (interval < 0) {
  2401. // 代表活动已经开始了,需要执行活动开始倒计时
  2402. var interval = setInterval(this.countTime, 1000);
  2403. this.setData({
  2404. active: true,
  2405. 'endTime.interval': interval
  2406. });
  2407. this.isStarts(); // this.active = true;
  2408. // this.startsTime.count = -(this.startsTime.count - 1000)
  2409. // this.$emit('starts',this.index);
  2410. // this. = setInterval(this.countTime,1000);
  2411. // 清除掉倒计时,以免重复分发事件
  2412. clearInterval(this.startsTime.interval);
  2413. } else {
  2414. var day = Math.floor(interval / d);
  2415. Math.floor(interval -= day * d);
  2416. var hour = Math.floor(interval / h);
  2417. Math.floor(interval -= hour * h);
  2418. var minute = Math.floor(interval / n);
  2419. var second = Math.floor(interval % n / 1000);
  2420. this.setData({
  2421. 'startsTime.day': day,
  2422. 'startsTime.hour': hour,
  2423. 'startsTime.minute': minute,
  2424. 'startsTime.second': second
  2425. }); // this.startsTime.day = day;
  2426. // this.startsTime.hour = hour;
  2427. // this.startsTime.minute = minute;
  2428. // this.startsTime.second = second;
  2429. }
  2430. } else {
  2431. this.setData({
  2432. message: `${arr[1]}${arr[2]} 日,${arr[3]} : ${arr[4]} 开始`
  2433. }); // this.message = `${arr[1] - 1} 月 ${arr[2]} 日,${arr[3]} : ${arr[4]} 开始`
  2434. }
  2435. },
  2436. // 秒杀结束执行
  2437. isEnd() {
  2438. if (this.detailData.meta.seckill || this.detailData.meta.groupon) {
  2439. var id = this.id;
  2440. var token = this.$cookieStorage.get('user_token') || '';
  2441. this.getGoodsDetail({
  2442. api: `api/store/detail/${id}`,
  2443. header: {
  2444. Authorization: token
  2445. },
  2446. data: {
  2447. include: 'photos,products,oneComment,guessYouLike,whoLike,point,user'
  2448. }
  2449. });
  2450. this.queryCommodityStore(id);
  2451. }
  2452. },
  2453. isStarts() {
  2454. if (this.detailData.meta.seckill && this.detailData.meta.seckill.init_status == 2 || this.detailData.meta.groupon && this.commodity.multi_groupon_init_status == 2) {
  2455. var token = this.$cookieStorage.get('user_token') || '';
  2456. var id = this.id;
  2457. this.getGoodsDetail({
  2458. api: `api/store/detail/${id}`,
  2459. header: {
  2460. Authorization: token
  2461. },
  2462. data: {
  2463. include: 'photos,products,oneComment,guessYouLike,whoLike,point,user'
  2464. }
  2465. });
  2466. this.queryCommodityStore(id);
  2467. }
  2468. },
  2469. // onStateChange(nextState){
  2470. // console.log(nextState)
  2471. // if (!app.isEmptyObject(nextState.detailData)) {
  2472. // Wxparse.wxParse('detailI', 'html', nextState.detailData.data.content, this, 0);
  2473. // this.attributesList(nextState.detailData.meta);
  2474. // wx.setNavigationBarTitle({
  2475. // title: nextState.detailData.data.name
  2476. // })
  2477. // this.setData({
  2478. // detailData: nextState.detailData,
  2479. // commodity: nextState.detailData.data
  2480. // })
  2481. // wx.hideLoading()
  2482. // }
  2483. //
  2484. // // if (nextState.commoditySpec.length > 0 ) {
  2485. // //
  2486. // // this.setData({
  2487. // // specs:nextState.commoditySpec
  2488. // // })
  2489. // // }
  2490. // //
  2491. // // if (!app.isEmptyObject(nextState.resultStore)) {
  2492. // // this.specStore(nextState.resultStore,nextState.resultStore.key)
  2493. // //
  2494. //
  2495. // // }
  2496. //
  2497. // },
  2498. change(e) {
  2499. var expands = this.expands[e.currentTarget.dataset.type];
  2500. this.setData({
  2501. [`expands.${e.currentTarget.dataset.type}`]: !expands
  2502. });
  2503. },
  2504. jumpCollage() {
  2505. var multi_groupon_item_id = this.groupon_userlist.multi_groupon_item_id;
  2506. wx.navigateTo({
  2507. url: `/pages/store/collage/collage?multi_groupon_item_id=${multi_groupon_item_id}`
  2508. });
  2509. },
  2510. showSelect(e) {
  2511. /*if (this.id == 1) {
  2512. this.call();
  2513. return
  2514. }*/
  2515. var id = e.target.dataset.id;
  2516. var group = this.detailData.meta.multiGroupon;
  2517. var multi_groupon_item_id = this.groupon_userlist.multi_groupon_item_id;
  2518. if (group && this.commodity.multi_groupon_init_status == 1 && this.detailData.data.multi_groupon_join_status == 1) {
  2519. if (this.detailData.data.multi_groupon_order_no) {
  2520. wx.showModal({
  2521. content: '您的参团订单未支付,点击确定继续支付',
  2522. success: res => {
  2523. if (res.confirm) {
  2524. wx.navigateTo({
  2525. url: '/pages/store/payment/payment?order_no=' + this.detailData.data.multi_groupon_order_no
  2526. });
  2527. }
  2528. }
  2529. });
  2530. } else {
  2531. wx.navigateTo({
  2532. url: `/pages/store/collage/collage?multi_groupon_item_id=${multi_groupon_item_id}`
  2533. });
  2534. }
  2535. } else {
  2536. //直接进来,URL上面没有子参团id,想要从他们也在拼的去参团买
  2537. if (id) {
  2538. this.setData({
  2539. show_more: false,
  2540. groupon_item_id: id
  2541. });
  2542. } else if (this.url_groupon_item_id) {
  2543. //通过分享进来的
  2544. this.setData({
  2545. groupon_item_id: this.url_groupon_item_id
  2546. });
  2547. } else {
  2548. this.setData({
  2549. groupon_item_id: ''
  2550. });
  2551. }
  2552. if (e.target.dataset.status && (this.immediately_text.message == '立即购买' || this.immediately_text.message == '原价购买')) {
  2553. this.setData({
  2554. is_immediately: true
  2555. });
  2556. } else {
  2557. this.setData({
  2558. is_immediately: false
  2559. });
  2560. }
  2561. // this.setData({
  2562. // is_alone: false,
  2563. // show_select: false
  2564. // });
  2565. this.is_alone=false;
  2566. this.show_select=false;
  2567. // #ifdef MP-WEIXIN
  2568. var animation = new Animation('show');
  2569. animation.positionInit();
  2570. // #endif
  2571. }
  2572. },
  2573. // 子团点击
  2574. multiAddToCart(e) {
  2575. var id = e.currentTarget.dataset.id;
  2576. var status = e.currentTarget.dataset.join;
  2577. var order_no = e.currentTarget.dataset.order_no;
  2578. if (status == 1) {
  2579. // 当订单未付款时跳转到付款页面
  2580. if (order_no) {
  2581. wx.showModal({
  2582. content: '您的参团订单未支付,点击确定继续支付',
  2583. success: res => {
  2584. if (res.confirm) {
  2585. wx.navigateTo({
  2586. url: '/pages/store/payment/payment?order_no=' + order_no
  2587. });
  2588. }
  2589. }
  2590. });
  2591. } else {
  2592. wx.navigateTo({
  2593. url: `/pages/store/collage/collage?multi_groupon_item_id=${id}`
  2594. });
  2595. }
  2596. return;
  2597. }
  2598. if (id) {
  2599. this.setData({
  2600. show_more: false,
  2601. groupon_item_id: id
  2602. });
  2603. } else if (this.url_groupon_item_id) {
  2604. this.setData({
  2605. groupon_item_id: this.url_groupon_item_id
  2606. });
  2607. } else {
  2608. this.setData({
  2609. groupon_item_id: ''
  2610. });
  2611. }
  2612. this.setData({
  2613. show_select: false,
  2614. is_alone: false
  2615. });
  2616. // #ifdef MP-WEIXIN
  2617. var animation = new Animation('show');
  2618. animation.positionInit();
  2619. // #endif
  2620. },
  2621. // 单独购买
  2622. aloneAddToCart() {
  2623. this.setData({
  2624. is_alone: true,
  2625. show_select: false
  2626. });
  2627. // #ifdef MP-WEIXIN
  2628. var animation = new Animation('show');
  2629. animation.positionInit();
  2630. // #endif
  2631. },
  2632. // 立即购买
  2633. immediately() {
  2634. this.setData({
  2635. is_immediately: true,
  2636. show_select: false
  2637. });
  2638. // #ifdef MP-WEIXIN
  2639. var animation = new Animation('show');
  2640. animation.positionInit();
  2641. // #endif
  2642. },
  2643. closeSelect() {
  2644. // #ifdef MP-WEIXIN
  2645. var animation = new Animation('show');
  2646. animation.up().then(() => {
  2647. this.setData({
  2648. show_select: true
  2649. });
  2650. });
  2651. // #endif
  2652. // #ifdef H5 || APP-PLUS
  2653. this.show_select=true;
  2654. // #endif
  2655. },
  2656. changeCount(e) {
  2657. var select_count = parseInt(this.select_count);
  2658. var index = e.target.dataset.index;
  2659. var val = select_count + (parseInt(index) ? 1 : -1);
  2660. if (val > 0 && val <= parseInt(this.store_count)) {
  2661. this.setData({
  2662. select_count: val
  2663. }); // 用户登录并且开启了限购
  2664. if (this.purchaseInfo.status && this.is_login) {
  2665. if (this.select_count > this.purchaseInfo.num) {
  2666. this.setData({
  2667. select_count: this.select_count - 1
  2668. });
  2669. wx.showToast({
  2670. title: '超过限购数量',
  2671. image: '../../../static/error.png'
  2672. });
  2673. }
  2674. }
  2675. } else if (val <= 0) {
  2676. wx.showToast({
  2677. title: '小于最小库存',
  2678. image: '../../../static/error.png'
  2679. });
  2680. } else if (val > parseInt(this.store_count)) {
  2681. wx.showToast({
  2682. title: '超出最大库存',
  2683. image: '../../../static/error.png'
  2684. });
  2685. }
  2686. },
  2687. modifyCount(e) {
  2688. var val = parseInt(e.detail.value);
  2689. if (!val) {
  2690. val = 1;
  2691. } else if (!/^[1-9]\d*$/.test(val)) {
  2692. val = val.replace(/[^\d].*$/, '');
  2693. val = parseInt(val) || 1;
  2694. }
  2695. if (this.purchaseInfo.status && this.is_login) {
  2696. if (val < 0) {
  2697. val = 1;
  2698. } else if (val > this.purchaseInfo.num) {
  2699. val = this.purchaseInfo.num || 1;
  2700. wx.showToast({
  2701. title: '超过限购数量',
  2702. image: '../../../static/error.png'
  2703. });
  2704. }
  2705. } else {
  2706. if (val < 0) {
  2707. val = 1;
  2708. } else if (val > this.store_count) {
  2709. wx.showToast({
  2710. title: '超过最大库存',
  2711. image: '../../../static/error.png'
  2712. });
  2713. val = parseInt(this.store_count);
  2714. }
  2715. }
  2716. this.setData({
  2717. select_count: val
  2718. });
  2719. },
  2720. showCoupons() {
  2721. this.setData({
  2722. show_coupons: !this.show_coupons
  2723. });
  2724. },
  2725. changeAttention() {
  2726. if (this.service_info.online_service_type !== 'self') return;
  2727. this.setData({
  2728. show_attention: !this.show_attention
  2729. });
  2730. },
  2731. showDiscounts() {
  2732. this.setData({
  2733. show_discounts: !this.show_discounts
  2734. });
  2735. },
  2736. showSame() {
  2737. this.setData({
  2738. show_same: !this.show_same
  2739. });
  2740. },
  2741. getCoupon(e) {
  2742. var is_login = this.$cookieStorage.get('user_token');
  2743. var code = e.currentTarget.dataset.code;
  2744. var index = e.currentTarget.dataset.index;
  2745. if (is_login) {
  2746. this.goodsConvertCoupon(code, index);
  2747. } else {
  2748. // #ifdef APP-PLUS || MP-WEIXIN
  2749. var url = getUrl()+ '?id='+this.id;
  2750. // #endif
  2751. // #ifdef H5
  2752. var url = getUrl();
  2753. // #endif
  2754. wx.showModal({
  2755. content: '请先登录',
  2756. success: res => {
  2757. if (res.confirm) {
  2758. // #ifdef APP-PLUS || MP-WEIXIN
  2759. wx.navigateTo({
  2760. url: '/pages/user/register/register?url=' + url
  2761. });
  2762. // #endif
  2763. // #ifdef H5
  2764. this.wechatLogin()
  2765. // #endif
  2766. }
  2767. }
  2768. });
  2769. }
  2770. },
  2771. selectSpec(e) {
  2772. var spec = {
  2773. key: e.currentTarget.dataset.key,
  2774. index: e.currentTarget.dataset.index,
  2775. disabled: Number(e.currentTarget.dataset.disabled),
  2776. active: Number(e.currentTarget.dataset.active),
  2777. id: Number(e.currentTarget.dataset.id)
  2778. };
  2779. if (spec.disabled) return;
  2780. var specs = this.specs;
  2781. if (!spec.active) {
  2782. for (let item of specs[spec.index].values) {
  2783. if (item.active) {
  2784. item.active = false;
  2785. break;
  2786. }
  2787. }
  2788. }
  2789. specs[spec.index].values[spec.key].active = !specs[spec.index].values[spec.key].active;
  2790. spec.active = !spec.active;
  2791. specs[spec.index].select = spec.active ? spec.id : '';
  2792. this.setData({
  2793. specs: specs
  2794. });
  2795. var canBuy = this.disallow_cart();
  2796. this.setData({
  2797. canBuy: canBuy
  2798. }); // this.queryCommodityStore(id, spec.index);
  2799. this.specStore(this.result, spec.index);
  2800. },
  2801. specStore(result, key) {
  2802. var query = this.query;
  2803. var data = result.data;
  2804. var specs = this.specs;
  2805. if (key === undefined) {
  2806. specs.forEach(spec => {
  2807. for (let v of spec.values) {
  2808. v.disabled = !data[v.id] || data[v.id].count == 0;
  2809. }
  2810. });
  2811. this.setData({
  2812. specs: specs,
  2813. skuTable: result.table
  2814. });
  2815. specs = this.specs;
  2816. var canBuy = this.disallow_cart();
  2817. this.setData({
  2818. canBuy: canBuy
  2819. });
  2820. specs.forEach(spec => {
  2821. let name = 'spec[' + spec.id + ']';
  2822. if (query[name]) {
  2823. let id = query[name];
  2824. for (let v of spec.values) {
  2825. if (v.id == id && !v.disabled && data[v.id] && data[v.id].count) {
  2826. v.active = true;
  2827. spec.select = v.id;
  2828. this.setData({
  2829. specs: specs
  2830. });
  2831. specs = this.specs;
  2832. var canBuy = this.disallow_cart();
  2833. this.setData({
  2834. canBuy: canBuy
  2835. });
  2836. this.specStore(result, v.index);
  2837. return;
  2838. }
  2839. }
  2840. }
  2841. if (!spec.select) {
  2842. for (let v of spec.values) {
  2843. if (!v.disabled && data[v.id] && data[v.id].count) {
  2844. v.active = true;
  2845. spec.select = v.id;
  2846. this.setData({
  2847. specs: specs
  2848. });
  2849. specs = this.specs;
  2850. var canBuy = this.disallow_cart();
  2851. this.setData({
  2852. canBuy: canBuy
  2853. }); // this.$emit('specStore', result, v.index);
  2854. this.specStore(result, v.index);
  2855. return;
  2856. }
  2857. }
  2858. return;
  2859. }
  2860. this.setData({
  2861. specs: specs
  2862. });
  2863. });
  2864. return;
  2865. }
  2866. var spec = specs[key];
  2867. if (spec.select) {
  2868. this.setData({
  2869. store_count: data[spec.select].count
  2870. });
  2871. for (let i = 0; i < specs.length; i++) {
  2872. if (i == key) continue;
  2873. specs[i].values.forEach(v => {
  2874. v.disabled = !data[spec.select].specs[v.id].count;
  2875. });
  2876. if (specs[i].select) {
  2877. this.setData({
  2878. store_count: data[spec.select].specs[specs[i].select].count
  2879. });
  2880. }
  2881. this.setData({
  2882. specs: specs
  2883. });
  2884. }
  2885. } else {
  2886. this.setData({
  2887. store_count: this.commodity.store
  2888. });
  2889. for (let i = 0; i < specs.length; i++) {
  2890. if (i == key) continue;
  2891. specs[i].values.forEach(v => {
  2892. v.disabled = !data[v.id] || !data[v.id].count;
  2893. });
  2894. if (specs[i].select) {
  2895. this.setData({
  2896. store_count: data[specs[i].select].count
  2897. });
  2898. }
  2899. this.setData({
  2900. specs: specs
  2901. });
  2902. }
  2903. }
  2904. if (parseInt(this.select_count) > this.store_count) {
  2905. this.setData({
  2906. select_count: String(this.store_count)
  2907. });
  2908. } else if (parseInt(this.select_count) == 0) {
  2909. this.setData({
  2910. select_count: '1'
  2911. });
  2912. }
  2913. this.setData({
  2914. specs: specs
  2915. });
  2916. var canBuy = this.disallow_cart();
  2917. // this.setData({
  2918. // canBuy: canBuy
  2919. // });
  2920. //
  2921. this.canBuy=canBuy;
  2922. },
  2923. confirmF() {
  2924. if (this.loading) return;
  2925. if (this.disallow_cart()) return;
  2926. this.setData({
  2927. loading: true
  2928. });
  2929. var select_product = this.select_product;
  2930. var select_count = Number(this.select_count);
  2931. var data = this.specs.length ? {
  2932. id: select_product.id,
  2933. name: this.commodity.name,
  2934. qty: select_count,
  2935. store_count: this.store_count,
  2936. price: select_product.price,
  2937. market_price: this.commodity.market_price,
  2938. attributes: {
  2939. img: select_product.img || this.detailData.data.photos[0].url,
  2940. size: select_product.size,
  2941. color: select_product.color,
  2942. com_id: this.commodity.id,
  2943. }
  2944. } : {
  2945. id: this.commodity.id,
  2946. name: this.commodity.name,
  2947. qty: select_count,
  2948. store_count: this.store_count,
  2949. price: this.commodity.sell_price,
  2950. market_price: this.commodity.market_price,
  2951. attributes: {
  2952. img: this.commodity.img || this.detailData.data.photos[0].url,
  2953. com_id: this.commodity.id,
  2954. }
  2955. }; // if (this.channel) data.attributes.channel = 'employee';
  2956. if (select_product.sku) data.attributes.sku = select_product.sku; // 秒杀开始添加信息
  2957. if (this.detailData.meta.seckill && this.detailData.meta.seckill.init_status == 1) {
  2958. var newData = {};
  2959. newData.attributes = {};
  2960. newData.id = data.id;
  2961. newData.img = data.attributes.img || this.detailData.data.photos[0].url;
  2962. newData.name = data.name;
  2963. if(this.is_no_specification){
  2964. newData.price = this.price;
  2965. } else{
  2966. newData.price = data.price;
  2967. }
  2968. newData.qty = data.qty;
  2969. newData.total = data.qty * newData.price;
  2970. newData.seckill_goods_id = this.detailData.meta.seckill.item_id;
  2971. newData.seckill_item_id = this.detailData.meta.seckill.id;
  2972. if (this.specs.length) {
  2973. newData.attributes['dynamic_sku'] = {};
  2974. newData.attributes['dynamic_sku'].id = data.id;
  2975. newData.attributes['dynamic_sku'].size = data.attributes.size;
  2976. newData.attributes['dynamic_sku'].color = data.attributes.color;
  2977. }
  2978. }
  2979. // 拼团开始添加信息
  2980. if (this.detailData.meta.multiGroupon && this.commodity.multi_groupon_init_status == 1) {
  2981. /* var grouponData = data; */
  2982. var grouponData = JSON.parse(JSON.stringify(data));
  2983. grouponData.multi_groupon_id = this.detailData.meta.multiGroupon.id;
  2984. grouponData.price = this.detailData.meta.multiGroupon.price;
  2985. grouponData.multi_groupon_item_id = this.groupon_item_id;
  2986. } // 添加511特殊需求信息
  2987. if (this.is_immediately) {
  2988. var immdeData = JSON.parse(JSON.stringify(data));
  2989. immdeData.product_id = data.id;
  2990. } // 判断是否登录
  2991. // var is_login = !!Cache.get(cache_keys.token);
  2992. // 判断是否参与秒杀并且秒杀开始
  2993. if (this.detailData.meta.seckill && this.detailData.meta.seckill.init_status == 1) {
  2994. if (!this.is_login) {
  2995. var url = getUrl()+ '?id='+this.id;
  2996. wx.showModal({
  2997. content: '请先登录',
  2998. success: res => {
  2999. if (res.confirm) {
  3000. // #ifdef APP-PLUS || MP-WEIXIN
  3001. wx.navigateTo({
  3002. url: '/pages/user/register/register?url=' + url
  3003. });
  3004. // #endif
  3005. // #ifdef H5
  3006. this.wechatLogin()
  3007. // #endif
  3008. }
  3009. }
  3010. });
  3011. } else {
  3012. this.checkoutSeckillOrder(newData);
  3013. }
  3014. } else if (this.detailData.meta.multiGroupon && this.commodity.multi_groupon_init_status == 1 && !this.is_alone) {
  3015. if (!this.is_login) {
  3016. // #ifdef H5
  3017. var url = getUrl()+ '?id='+this.id;
  3018. // #endif
  3019. // #ifdef APP-PLUS || MP-WEIXIN
  3020. var url = getUrl();
  3021. // #endif
  3022. wx.showModal({
  3023. content: '请先登录',
  3024. success: res => {
  3025. if (res.confirm) {
  3026. // #ifdef APP-PLUS || MP-WEIXIN
  3027. wx.navigateTo({
  3028. url: '/pages/user/register/register?url=' + url
  3029. });
  3030. // #endif
  3031. // #ifdef H5
  3032. this.wechatLogin()
  3033. // #endif
  3034. }
  3035. }
  3036. });
  3037. } else {
  3038. this.checkoutGroupOrder(grouponData);
  3039. }
  3040. } else if (this.is_immediately) {
  3041. if (!this.is_login) {
  3042. // #ifdef APP-PLUS || MP-WEIXIN
  3043. var url = getUrl()
  3044. // #endif
  3045. // #ifdef H5
  3046. var url = getUrl()+ '?id='+this.id;
  3047. // #endif
  3048. wx.showModal({
  3049. content: '请先登录',
  3050. success: res => {
  3051. if (res.confirm) {
  3052. // #ifdef APP-PLUS || MP-WEIXIN
  3053. wx.navigateTo({
  3054. url: '/pages/user/register/register?url=' + url
  3055. });
  3056. // #endif
  3057. // #ifdef H5
  3058. this.wechatLogin()
  3059. // #endif
  3060. this.loading = false
  3061. }
  3062. }
  3063. });
  3064. } else {
  3065. // 是否立即购买
  3066. this.checkoutImmdeOrder(immdeData);
  3067. }
  3068. } else {
  3069. if (this.is_login) {
  3070. this.appendToCart(data);
  3071. this.addStoreNum();
  3072. } else {
  3073. data.local = true;
  3074. data.total = Number(data.qty) * Number(data.price);
  3075. data.color = data.attributes.color;
  3076. data.size = data.attributes.size;
  3077. data.img = data.attributes.img;
  3078. var locals = this.$cookieStorage.get('cart') || [];
  3079. locals.unshift(data);
  3080. var skus = {};
  3081. var save = [];
  3082. locals.forEach(v => {
  3083. let sku, index;
  3084. if (v.attributes && v.attributes.sku) {
  3085. sku = v.attributes.sku;
  3086. } else {
  3087. sku = v.id;
  3088. }
  3089. if (skus[sku] === undefined) {
  3090. index = save.length;
  3091. v.index = index;
  3092. v.checked = true;
  3093. save.push(v);
  3094. skus[sku] = index;
  3095. } else {
  3096. let i = skus[sku];
  3097. save[i].qty += v.qty;
  3098. save[i].total += v.total;
  3099. save[i].store_count = this.store_count;
  3100. }
  3101. }); // console.log(skus, save)
  3102. this.$cookieStorage.set('cart', save);
  3103. this.setData({
  3104. store_num: 0
  3105. });
  3106. this.addStoreNum();
  3107. this.addCart(true);
  3108. }
  3109. }
  3110. },
  3111. addStoreNum() {
  3112. // 判断是否登录
  3113. // var is_login = !!Cache.get(cache_keys.token);
  3114. // var cache_store_num = Cache.get(cache_keys.cart);
  3115. var cache_store_num = this.$cookieStorage.get('cart');
  3116. if (this.is_login) {
  3117. this.queryShoppingCount();
  3118. } else {
  3119. if (cache_store_num && cache_store_num.length) {
  3120. var store_num = this.store_num;
  3121. cache_store_num.forEach(v => {
  3122. store_num += v.qty;
  3123. });
  3124. this.setData({
  3125. store_num: store_num
  3126. });
  3127. }
  3128. }
  3129. },
  3130. disallow_cart() {
  3131. if (!this.specs.length) {
  3132. return !this.store_count;
  3133. }
  3134. var ids = [],
  3135. select_product = {},
  3136. specs = this.specs; // console.log(this.commodity.sell_price)
  3137. //设置价格
  3138. this.setData({
  3139. price: Number(this.commodity.sell_price).toFixed(2)
  3140. });
  3141. for (let spec of specs) {
  3142. if (!spec.select) {
  3143. this.setData({
  3144. price: Number(this.commodity.sell_price).toFixed(2),
  3145. select_product: null
  3146. });
  3147. return true;
  3148. }
  3149. ids.push(spec.select);
  3150. for (let v of spec.values) {
  3151. if (v.id == spec.select) {
  3152. switch (spec.label_key) {
  3153. case 'color':
  3154. select_product.img = v.spec_img;
  3155. select_product.color = v.alias || v.value;
  3156. select_product.bac = v.color;
  3157. break;
  3158. default:
  3159. select_product.size = v.alias || v.value;
  3160. }
  3161. break;
  3162. }
  3163. }
  3164. }
  3165. if (this.skuTable) {
  3166. ids = ids[0] > ids[1] ? [ids[1], ids[0]] : ids;
  3167. ids = ids.join('-');
  3168. select_product = Object.assign(select_product, this.skuTable[ids]);
  3169. }
  3170. //设置价格
  3171. this.setData({
  3172. price: Number(select_product.price).toFixed(2),
  3173. select_product: select_product
  3174. });
  3175. return false;
  3176. },
  3177. jump(e) {
  3178. if (e.currentTarget.dataset.type == 'shop') {
  3179. wx.switchTab({
  3180. url: '/pages/index/index/index'
  3181. });
  3182. } else if (e.currentTarget.dataset.type == 'cart') {
  3183. wx.switchTab({
  3184. url: '/pages/store/cart/cart'
  3185. });
  3186. } else {
  3187. wx.navigateTo({
  3188. url: '/pages/store/detail/detail?id=' + e.currentTarget.dataset.id
  3189. });
  3190. }
  3191. },
  3192. jumpToDetail(e) {
  3193. var id = e.currentTarget.dataset.id;
  3194. wx.navigateTo({
  3195. url: `/pages/store/detail/detail?id=${id}`
  3196. });
  3197. },
  3198. jumpMeal(e) {
  3199. var id = e.currentTarget.dataset.suitid;
  3200. wx.navigateTo({
  3201. url: `/pages/store/meal/meal?id=${id}`
  3202. });
  3203. },
  3204. bigImg(e) {
  3205. var srcList = [];
  3206. var src = e.currentTarget.dataset.url;
  3207. this.detailData.data.photos.forEach(i => {
  3208. srcList.push(i.url);
  3209. });
  3210. if (src && srcList.length) {
  3211. wx.previewImage({
  3212. current: src,
  3213. urls: srcList
  3214. });
  3215. }
  3216. },
  3217. previewImage() {
  3218. wx.previewImage({
  3219. current: this.service_info.online_service_self.qr_code,
  3220. urls: [this.service_info.online_service_self.qr_code]
  3221. });
  3222. },
  3223. goCart() {
  3224. wx.switchTab({
  3225. url: '/pages/store/cart/cart'
  3226. });
  3227. this.changeCart();
  3228. },
  3229. changeCart() {
  3230. this.setData({
  3231. show_cart: !this.show_cart
  3232. });
  3233. },
  3234. call(e) {
  3235. var token = this.$cookieStorage.get('user_token');
  3236. var id = this.freeInfo.id;
  3237. var CallUrl = '/pages/store/call/call?id=' + id;
  3238. if (!token) {
  3239. // #ifdef H5
  3240. var url = getUrl()+ '?id='+this.id;
  3241. // #endif
  3242. // #ifdef APP-PLUS || MP-WEIXIN
  3243. var url = getUrl();
  3244. // #endif
  3245. // #ifdef APP-PLUS || MP-WEIXIN
  3246. wx.navigateTo({
  3247. url: '/pages/user/register/register?url=' + url
  3248. });
  3249. // #endif
  3250. // #ifdef H5
  3251. this.wechatLogin()
  3252. // #endif
  3253. return;
  3254. }
  3255. wx.navigateTo({
  3256. url: CallUrl
  3257. });
  3258. },
  3259. // 请求sku
  3260. queryCommodityStore(id, key) {
  3261. var that = this;
  3262. this.$http.get({
  3263. api: `api/store/detail/${id}/stock`
  3264. }).then(res => {
  3265. wx.hideLoading();
  3266. res = res.data;
  3267. if (!res.status || !res.data || !res.data.specs) return;
  3268. //是无规格商品并且是秒杀商品
  3269. if((res.data.specs && res.data.specs.length == 0) && (res.data.stores && res.data.stores.length == 0)){
  3270. if(this.detailData.meta.seckill){
  3271. this.is_no_specification = true;
  3272. this.price = this.commodity.seckill_price;
  3273. }
  3274. }
  3275. if (res.data.specs && typeof key === 'undefined') {
  3276. let specs = [];
  3277. Object.keys(res.data.specs).forEach((key, index) => {
  3278. let value = res.data.specs[key];
  3279. value.select = '';
  3280. value.values = value.list.map(v => {
  3281. return Object.assign({
  3282. index: index,
  3283. active: false,
  3284. disabled: false
  3285. }, v);
  3286. });
  3287. delete value.list;
  3288. specs.push(value);
  3289. });
  3290. that.setData({
  3291. specs: specs
  3292. }); // console.log(specs)
  3293. var canBuy = this.disallow_cart();
  3294. this.setData({
  3295. canBuy: canBuy
  3296. });
  3297. }
  3298. if (res.data.stores) {
  3299. let data = {};
  3300. Object.keys(res.data.stores).forEach(key => {
  3301. let value = res.data.stores[key];
  3302. value.ids.forEach(id => {
  3303. data[id] = data[id] || {
  3304. count: 0,
  3305. specs: {}
  3306. };
  3307. data[id].count += Number(value.store);
  3308. value.ids.forEach(i => {
  3309. if (i == id) return;
  3310. data[id].specs[i] = {
  3311. count: Number(value.store)
  3312. };
  3313. });
  3314. });
  3315. }); // console.log(data);
  3316. var result = {
  3317. data,
  3318. table: res.data.stores
  3319. };
  3320. // this.setData({
  3321. // result: result
  3322. // });
  3323. this.result=result;
  3324. that.specStore(result, key); // this.$emit('specStore', result, key);
  3325. }
  3326. }).catch(err => {
  3327. console.log('paojinlai zheli')
  3328. });
  3329. },
  3330. queryShoppingCount() {
  3331. var oauth = this.is_login;
  3332. this.$http.get({
  3333. api: `api/shopping/cart/count`,
  3334. header: {
  3335. Authorization: oauth
  3336. }
  3337. }).then(res => {}).catch(rej => {});
  3338. },
  3339. appendToCart(data) {
  3340. if (!Array.isArray(data)) {
  3341. data = [data];
  3342. }
  3343. var oauth = this.is_login;
  3344. var json = {};
  3345. data.forEach((v, i) => json[i] = v);
  3346. data = json;
  3347. var that = this;
  3348. this.$http.post({
  3349. api: 'api/shopping/cart',
  3350. header: {
  3351. Authorization: oauth
  3352. },
  3353. data: data
  3354. }).then(res => {
  3355. res = res.data;
  3356. if (res.status) {
  3357. that.addCart(true);
  3358. } else {
  3359. that.addCart(false, res.message);
  3360. }
  3361. }).catch(rej => {
  3362. that.addCart(false);
  3363. });
  3364. },
  3365. addCart(success, message) {
  3366. this.setData({
  3367. loading: false
  3368. });
  3369. if (success) {
  3370. this.closeSelect();
  3371. this.changeCart();
  3372. } else {
  3373. if (message) {
  3374. wx.showToast({
  3375. title: message,
  3376. icon: 'none'
  3377. });
  3378. } else {
  3379. wx.showToast({
  3380. title: '添加到购物车失败,请重试',
  3381. icon: 'none'
  3382. });
  3383. }
  3384. }
  3385. },
  3386. // 请求商品详情页面数据
  3387. getGoodsDetail(obj) {
  3388. var that = this;
  3389. return new Promise((resolve, reject) => {
  3390. this.$http.get(obj).then(res => {
  3391. // console.log(res)
  3392. if (res.statusCode == 200) {
  3393. res = res.data;
  3394. if (res.status) {
  3395. that.setData({
  3396. detailData: res,
  3397. commodity: res.data
  3398. });
  3399. /*if (res.meta.seckill) {
  3400. var interval = setInterval(this.countStartsTime, 1000);
  3401. that.setData({
  3402. 'startsTime.interval': interval
  3403. })
  3404. }*/
  3405. if (res.meta.discounts) {
  3406. res.meta.discounts.coupons.forEach(v => v.receive = false);
  3407. that.setData({
  3408. coupons: res.meta.discounts.coupons,
  3409. discounts: res.meta.discounts.discounts
  3410. });
  3411. }
  3412. if (res.meta.multiGroupon) {
  3413. //当有拼团,并且拼团正在进行中
  3414. var id = this.id; // 商品id
  3415. var multi_groupon_item_id = this.groupon_item_id; // 子参团id
  3416. this.getGrouponUserList(id, multi_groupon_item_id);
  3417. this.getGrouponItems(res.meta.multiGroupon.id, 1, multi_groupon_item_id);
  3418. this.controlProgress();
  3419. }
  3420. resolve();
  3421. } else {
  3422. wx.showModal({
  3423. content: res.message || '请求失败',
  3424. showCancel: false
  3425. });
  3426. wx.hideLoading();
  3427. reject();
  3428. }
  3429. } else {
  3430. wx.showModal({
  3431. content: res.message || '请求失败',
  3432. showCancel: false
  3433. });
  3434. wx.hideLoading();
  3435. reject();
  3436. }
  3437. }).catch(err => {
  3438. wx.showModal({
  3439. content: res.message || '请求失败',
  3440. showCancel: false
  3441. });
  3442. wx.hideLoading(); // console.log(err);
  3443. reject();
  3444. });
  3445. });
  3446. },
  3447. // 查询商品详情页优惠折扣信息
  3448. // queryDiscounts(id) {
  3449. // wx.request({
  3450. // url: config.GLOBAL.baseUrl + 'api/store/detail/' + id + '/discount',
  3451. // success: res => {
  3452. // if (res.statusCode == 200) {
  3453. // res = res.data;
  3454. // if (res.status) {
  3455. // res.data.coupons.forEach(v => v.receive = false);
  3456. // this.setData({
  3457. // coupons: res.data.coupons,
  3458. // discounts: res.data.discounts
  3459. // })
  3460. // }
  3461. // }
  3462. // }
  3463. // })
  3464. // },
  3465. // 领取优惠券
  3466. goodsConvertCoupon(code, index) {
  3467. var token = this.$cookieStorage.get('user_token');
  3468. this.$http.post({
  3469. api: 'api/coupon/convert',
  3470. header: {
  3471. Authorization: token
  3472. },
  3473. data: {
  3474. coupon_code: code
  3475. }
  3476. }).then(res => {
  3477. res = res.data;
  3478. if (res.status) {
  3479. this.coupons[index].has_get = true;
  3480. this.$set(this.coupons,index,this.coupons[index]);
  3481. wx.showToast({
  3482. title: '领取成功'
  3483. });
  3484. } else {
  3485. wx.showToast({
  3486. title: res.message,
  3487. image: '../../../static/error.png'
  3488. });
  3489. }
  3490. });
  3491. },
  3492. // 秒杀结算
  3493. checkoutSeckillOrder(data) {
  3494. var token = this.$cookieStorage.get('user_token');
  3495. this.$http.post({
  3496. api: 'api/shopping/order/checkout?seckill_item_id=' + data.seckill_item_id,
  3497. header: {
  3498. Authorization: token
  3499. },
  3500. data: data
  3501. }).then(res => {
  3502. if (res.statusCode == 200) {
  3503. res = res.data;
  3504. if (res.status) {
  3505. this.$cookieStorage.set('local_order', res.data);
  3506. this.setData({
  3507. loading: false
  3508. });
  3509. wx.navigateTo({
  3510. url: '/pages/store/order/order?type=seckill'
  3511. });
  3512. } else {
  3513. if (res.data && res.data.server_busy) {
  3514. this.setData({
  3515. show_ten: true
  3516. });
  3517. } else if (res.message == 'User unbind mobile') {
  3518. wx.showModal({
  3519. content: '请先绑定手机号',
  3520. showCancel: false,
  3521. success: res => {
  3522. if (res.confirm || !res.cancel && !res.confirm) {
  3523. wx.navigateTo({
  3524. url: '/pages/user/phone/phone?url=' + getUrl()
  3525. });
  3526. }
  3527. }
  3528. });
  3529. } else {
  3530. wx.showModal({
  3531. content: res.message || '请求失败',
  3532. showCancel: false
  3533. });
  3534. }
  3535. this.setData({
  3536. loading: false
  3537. });
  3538. }
  3539. }
  3540. });
  3541. },
  3542. // 拼团结算
  3543. checkoutGroupOrder(data) {
  3544. var token = this.$cookieStorage.get('user_token');
  3545. this.$http.post({
  3546. api: 'api/shopping/order/checkout',
  3547. header: {
  3548. Authorization: token
  3549. },
  3550. data: data
  3551. }).then(res => {
  3552. if (res.statusCode == 200) {
  3553. res = res.data;
  3554. if (res.status) {
  3555. var info = {
  3556. multi_groupon_id: data.multi_groupon_id,
  3557. multi_groupon_item_id: data.multi_groupon_item_id
  3558. };
  3559. this.$cookieStorage.set('group_info', info);
  3560. this.$cookieStorage.set('local_order', res.data);
  3561. this.setData({
  3562. loading: false
  3563. });
  3564. wx.navigateTo({
  3565. url: '/pages/store/order/order?type=groupon'
  3566. });
  3567. } else {
  3568. if (res.data && res.data.server_busy) {
  3569. this.setData({
  3570. show_ten: true
  3571. });
  3572. } else if (res.message == 'User unbind mobile') {
  3573. wx.showModal({
  3574. content: '请先绑定手机号',
  3575. showCancel: false,
  3576. success: res => {
  3577. if (res.confirm || !res.cancel && !res.confirm) {
  3578. wx.navigateTo({
  3579. url: '/pages/user/phone/phone?url=' + getUrl()
  3580. });
  3581. }
  3582. }
  3583. });
  3584. } else {
  3585. wx.showModal({
  3586. content: res.message || '请求失败',
  3587. showCancel: false
  3588. });
  3589. }
  3590. this.setData({
  3591. loading: false
  3592. });
  3593. }
  3594. }
  3595. });
  3596. },
  3597. // 虚拟参团
  3598. jumpVirtual() {
  3599. wx.navigateTo({
  3600. url: '/pages/store/virtual/virtual?id=' + this.id + '&multi_groupon_id=' + this.detailData.meta.multiGroupon.id
  3601. });
  3602. },
  3603. // 立即购买
  3604. checkoutImmdeOrder(data) {
  3605. var token = this.$cookieStorage.get('user_token');
  3606. this.$http.post({
  3607. api: 'api/shopping/order/checkout?product_id=' + data.id,
  3608. header: {
  3609. Authorization: token
  3610. },
  3611. data: data
  3612. }).then(res => {
  3613. if (res.statusCode == 200) {
  3614. res = res.data;
  3615. if (res.status) {
  3616. this.$cookieStorage.set('local_order', res.data);
  3617. this.setData({
  3618. loading: false
  3619. });
  3620. wx.navigateTo({
  3621. url: '/pages/store/order/order'
  3622. });
  3623. } else {
  3624. if (res.data && res.data.server_busy) {
  3625. this.setData({
  3626. show_ten: true
  3627. });
  3628. } else if (res.message == 'User unbind mobile') {
  3629. wx.showModal({
  3630. content: '请先绑定手机号',
  3631. showCancel: false,
  3632. success: res => {
  3633. if (res.confirm || !res.cancel && !res.confirm) {
  3634. wx.navigateTo({
  3635. url: '/pages/user/phone/phone?url=' + getUrl()
  3636. });
  3637. }
  3638. }
  3639. });
  3640. } else {
  3641. wx.showModal({
  3642. content: res.message || '请求失败',
  3643. showCancel: false
  3644. });
  3645. }
  3646. this.setData({
  3647. loading: false
  3648. });
  3649. }
  3650. }
  3651. });
  3652. },
  3653. // 商品限购
  3654. goodsPurchase(id) {
  3655. var token = this.$cookieStorage.get('user_token');
  3656. this.$http.get({
  3657. api: 'api/store/goods/purchase/' + id,
  3658. header: {
  3659. Authorization: token
  3660. }
  3661. }).then(res => {
  3662. if (res.statusCode == 200) {
  3663. res = res.data;
  3664. if (res.status) {
  3665. if (res.data) {
  3666. this.setData({
  3667. 'purchaseInfo.status': true,
  3668. 'purchaseInfo.num': res.data.user_limit
  3669. });
  3670. }
  3671. } else {
  3672. wx.showModal({
  3673. content: res.message || '接口错误',
  3674. showCancel: false
  3675. });
  3676. }
  3677. } else {
  3678. wx.showModal({
  3679. content: '请求失败',
  3680. showCancel: false
  3681. });
  3682. }
  3683. });
  3684. },
  3685. //请求拼团数据
  3686. getGrouponUserList(id, multi_groupon_item_id) {
  3687. var token = this.$cookieStorage.get('user_token') || '';
  3688. this.$http.get({
  3689. api: 'api/multiGroupon/getGrouponUserList',
  3690. header: {
  3691. Authorization: token
  3692. },
  3693. data: {
  3694. goods_id: id,
  3695. multi_groupon_item_id: multi_groupon_item_id
  3696. }
  3697. }).then(res => {
  3698. if (res.statusCode == 200) {
  3699. res = res.data;
  3700. if (res.status) {
  3701. this.setData({
  3702. groupon_userlist: res.data
  3703. });
  3704. } else {
  3705. wx.showModal({
  3706. content: res.message || '拼团信息请求失败',
  3707. showCancel: false
  3708. });
  3709. }
  3710. } else {
  3711. wx.showModal({
  3712. content: '拼团信息请求失败',
  3713. showCancel: false
  3714. });
  3715. }
  3716. });
  3717. },
  3718. //scroll-view 滚动刷新
  3719. scrollBottom() {
  3720. var hasMore = this.meta.pagination.total_pages > this.meta.pagination.current_page;
  3721. var multi_groupon_id = this.detailData.meta.multiGroupon.id;
  3722. if (hasMore) {
  3723. this.setData({
  3724. more: true
  3725. });
  3726. var page = this.meta.pagination.current_page + 1;
  3727. var multi_groupon_item_id = this.multi_groupon_item_id;
  3728. this.getGrouponItems(multi_groupon_id, page, multi_groupon_item_id);
  3729. } else {
  3730. wx.showToast({
  3731. image: '../../../static/error.png',
  3732. title: '再拉也没有啦'
  3733. });
  3734. }
  3735. },
  3736. //他们也在拼请求数据
  3737. getGrouponItems(multi_groupon_id, page, multi_groupon_item_id) {
  3738. wx.showLoading({
  3739. title: "加载中",
  3740. mask: true
  3741. });
  3742. var token = this.$cookieStorage.get('user_token') || '';
  3743. this.$http.get({
  3744. api: 'api/multiGroupon/getGrouponItems',
  3745. header: {
  3746. Authorization: token
  3747. },
  3748. data: {
  3749. multi_groupon_id: multi_groupon_id,
  3750. page: page,
  3751. multi_groupon_item_id: multi_groupon_item_id
  3752. }
  3753. }).then(res => {
  3754. if (res.statusCode == 200) {
  3755. res = res.data;
  3756. if (res.status) {
  3757. this.setData({
  3758. //[`groupon_itemList[${page - 1}]`]: res.data,
  3759. meta: res.meta,
  3760. init: true
  3761. });
  3762. this.$set(this.groupon_itemList, page -1, res.data);
  3763. } else {
  3764. wx.showModal({
  3765. content: res.message || '请求他们也在拼数据失败',
  3766. showCancel: false
  3767. });
  3768. }
  3769. } else {
  3770. wx.showModal({
  3771. content: '请求他们也在拼数据失败',
  3772. showCancel: false
  3773. });
  3774. }
  3775. this.setData({
  3776. more: false
  3777. });
  3778. wx.hideLoading();
  3779. }).catch(rej => {
  3780. wx.hideLoading();
  3781. wx.showModal({
  3782. content: res.message || '请求失败',
  3783. showCancel: false
  3784. });
  3785. });
  3786. },
  3787. //进度条控制3种状态
  3788. controlProgress() {
  3789. // todo
  3790. if (this.commodity.multi_groupon_init_status == 1) {
  3791. if (this.detailData.data.multi_groupon_join_status || this.groupon_item_id) {
  3792. //只要你是满团,就是显示全红
  3793. if (this.detailData.data.multi_groupon_item_complete_status != 0) {
  3794. this.setData({
  3795. emjstatus: {
  3796. percent: 100,
  3797. //进度条百分比
  3798. lauch: true,
  3799. //第一个icon控制
  3800. half: true,
  3801. //第二个icon控制
  3802. end: true //第三个icon控制
  3803. }
  3804. });
  3805. } else {
  3806. this.setData({
  3807. emjstatus: {
  3808. percent: 50,
  3809. //进度条百分比
  3810. lauch: true,
  3811. //第一个icon控制
  3812. half: true,
  3813. //第二个icon控制
  3814. end: false //第三个icon控制
  3815. }
  3816. });
  3817. }
  3818. }
  3819. }
  3820. },
  3821. /* beSharePoint(goods_id, user_id) {
  3822. wx.login({
  3823. success: res => {
  3824. if (res.code) {
  3825. this.sharePoint(res.code, goods_id, user_id);
  3826. }
  3827. }
  3828. });
  3829. }, */
  3830. togglePopup(type) {
  3831. this.type = type;
  3832. if(this.type == "middle-img"){
  3833. this.is_toggle_share = false
  3834. }
  3835. },
  3836. shareGraphic(){
  3837. this.getCreateShareImg();
  3838. },
  3839. closeShareGraphic(){
  3840. this.share_gaphic =!this.share_gaphic;
  3841. },
  3842. ShearUser(){
  3843. this.togglePopup('middle-img')
  3844. },
  3845. async shareFc() {
  3846. try {
  3847. console.log('准备生成:' + new Date())
  3848. const d = await getSharePoster({
  3849. _this: this, //若在组件中使用 必传
  3850. type: 'testShareType',
  3851. formData: {
  3852. //访问接口获取背景图携带自定义数据
  3853. },
  3854. posterCanvasId: this.canvasId, //canvasId
  3855. delayTimeScale: 20, //延时系数
  3856. /* background: {
  3857. width: 1080,
  3858. height: 1920,
  3859. backgroundColor: '#666'
  3860. }, */
  3861. drawArray: ({
  3862. bgObj,
  3863. type,
  3864. bgScale
  3865. }) => {
  3866. const dx = bgObj.width * 0.3;
  3867. const fontSize = bgObj.width * 0.045;
  3868. const lineHeight = bgObj.height * 0.04;
  3869. //可直接return数组,也可以return一个promise对象, 但最终resolve一个数组, 这样就可以方便实现后台可控绘制海报
  3870. return new Promise((rs, rj) => {
  3871. rs([{
  3872. type: 'custom',
  3873. setDraw(Context) {
  3874. Context.setFillStyle('black');
  3875. Context.setGlobalAlpha(0.3);
  3876. Context.fillRect(0, bgObj.height - bgObj.height * 0.2, bgObj.width, bgObj.height * 0.2);
  3877. Context.setGlobalAlpha(1);
  3878. }
  3879. },
  3880. {
  3881. type: 'image',
  3882. url: '/static/3.jpg',
  3883. alpha: .3,
  3884. dx,
  3885. dy: bgObj.height - bgObj.width * 0.25,
  3886. infoCallBack(imageInfo) {
  3887. let scale = bgObj.width * 0.2 / imageInfo.height;
  3888. return {
  3889. circleSet: {
  3890. x: imageInfo.width * scale / 2,
  3891. y: bgObj.width * 0.2 / 2,
  3892. r: bgObj.width * 0.2 / 2
  3893. }, // 圆形图片 , 若circleSet与roundRectSet一同设置 优先circleSet设置
  3894. dWidth: imageInfo.width * scale, // 因为设置了圆形图片 所以要乘以2
  3895. dHeight: bgObj.width * 0.2,
  3896. /* roundRectSet: { // 圆角矩形
  3897. r: imageInfo.width * .1
  3898. } */
  3899. }
  3900. }
  3901. },
  3902. {
  3903. type: 'text',
  3904. fontStyle: 'italic',
  3905. text: '取舍',
  3906. size: fontSize,
  3907. color: 'white',
  3908. alpha: .5,
  3909. textAlign: 'left',
  3910. textBaseline: 'middle',
  3911. infoCallBack(textLength) {
  3912. _app.log('index页面的text的infocallback ,textlength:' + textLength);
  3913. return {
  3914. dx: bgObj.width - textLength - fontSize,
  3915. dy: bgObj.height - lineHeight * 3
  3916. }
  3917. },
  3918. serialNum: 0,
  3919. id: 'tag1' //自定义标识
  3920. },
  3921. {
  3922. type: 'text',
  3923. text: '取舍',
  3924. fontWeight: 'bold',
  3925. size: fontSize,
  3926. color: 'white',
  3927. alpha: .75,
  3928. textAlign: 'left',
  3929. textBaseline: 'middle',
  3930. serialNum: 1,
  3931. allInfoCallback({ //v3.0.1 更新 可以获取drawArray中全部数据
  3932. drawArray
  3933. } = {}) {
  3934. const obj = drawArray.find(item => item.id === 'tag1');
  3935. /* return {
  3936. dx: obj.dx,
  3937. dy: obj.dy + lineHeight
  3938. } */
  3939. //也可以return promise对象
  3940. return new Promise((rs, rj) => {
  3941. setTimeout(() => {
  3942. rs({
  3943. dx: obj.dx,
  3944. dy: obj.dy + lineHeight
  3945. });
  3946. }, 1);
  3947. });
  3948. }
  3949. },
  3950. {
  3951. type: 'text',
  3952. text: '取舍',
  3953. size: fontSize,
  3954. color: 'white',
  3955. alpha: 1,
  3956. textAlign: 'left',
  3957. textBaseline: 'middle',
  3958. infoCallBack(textLength) {
  3959. return {
  3960. dx: bgObj.width - textLength - fontSize,
  3961. dy: bgObj.height - lineHeight
  3962. }
  3963. }
  3964. },
  3965. {
  3966. type: 'qrcode',
  3967. text: '你好,我是取舍',
  3968. // size: bgObj.width * 0.2,
  3969. size: 80,
  3970. dx: bgObj.width * 0.05,
  3971. // dy: bgObj.height - bgObj.width * 0.25
  3972. dy: 380
  3973. }
  3974. ]);
  3975. })
  3976. },
  3977. setCanvasWH: ({
  3978. bgObj,
  3979. type,
  3980. bgScale
  3981. }) => { // 为动态设置画布宽高的方法,
  3982. this.poster = bgObj;
  3983. }
  3984. });
  3985. console.log('海报生成成功, 时间:' + new Date() + ', 临时路径: ' + d.poster.tempFilePath)
  3986. this.poster.finalPath = d.poster.tempFilePath;
  3987. this.qrShow = true;
  3988. } catch (e) {
  3989. _app.hideLoading();
  3990. _app.showToast(JSON.stringify(e));
  3991. console.log(JSON.stringify(e));
  3992. }
  3993. },
  3994. setData: function (obj) {
  3995. let that = this;
  3996. let keys = [];
  3997. let val, data;
  3998. Object.keys(obj).forEach(function (key) {
  3999. keys = key.split('.');
  4000. val = obj[key];
  4001. data = that.$data;
  4002. keys.forEach(function (key2, index) {
  4003. if (index + 1 == keys.length) {
  4004. that.$set(data, key2, val);
  4005. } else {
  4006. if (!data[key2]) {
  4007. that.$set(data, key2, {});
  4008. }
  4009. }
  4010. data = data[key2];
  4011. });
  4012. });
  4013. }
  4014. },
  4015. computed: {},
  4016. watch: {}
  4017. };
  4018. </script>
  4019. <style rel="stylesheet/less" lang="less">
  4020. @import "detail";
  4021. </style>