detail.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. <template>
  2. <app-layout>
  3. <view class="bg">
  4. <view class="no-content" v-if="!list.status">暂无记录</view>
  5. <view v-if="list && list.status" class="head-bg" :style="{'background-image': 'url(' + lotteryConfig.app_image.bg_pic + ')'}">
  6. <template v-if="list.status === `1` && list.lottery.join_min_num - num > 0">
  7. <view class="dir-left-nowrap detail-head-a main-center">
  8. <icon class="icon-march" type></icon>
  9. <view class="dir-top-nowrap main-center">
  10. <view class="text-success">还差{{ list.lottery.join_min_num - num }}人即可开奖</view>
  11. <view class="text-time">{{ list.time }}</view>
  12. </view>
  13. </view>
  14. <view class="main-center cross-center detail-lucky">您的幸运码为{{ list.lucky_code }}</view>
  15. </template>
  16. <template v-if="list.status === `1` && list.lottery.join_min_num - num <=0">
  17. <view class="dir-left-nowrap detail-head-a main-center">
  18. <icon class="icon-wait" type></icon>
  19. <view class="dir-top-nowrap main-center">
  20. <view class="text-success">参加成功,等待开奖</view>
  21. <view class="text-time">{{ list.time }}</view>
  22. </view>
  23. </view>
  24. <view class="main-center cross-center detail-lucky">您的幸运码为{{ list.lucky_code }}</view>
  25. </template>
  26. <template v-if="list.status===`2` && list.lottery.type !=2">
  27. <view class="dir-left-nowrap detail-head-b main-center">
  28. <icon class="icon-error" type></icon>
  29. <view class="dir-top-nowrap main-center text-winning">很遗憾,您未中奖</view>
  30. </view>
  31. <view @click="prize" class="cross-center main-center dir-left-nowrap detail-lucky">
  32. <view>查看我的幸运码</view>
  33. <icon class="icon-arrow-right-white" type></icon>
  34. </view>
  35. </template>
  36. <template v-if="list.status===`2` && list.lottery.type ==2">
  37. <view class="dir-left-nowrap detail-head-b main-center">
  38. <icon class="icon-people" type></icon>
  39. <view class="dir-top-nowrap main-center text-winning">人数未到,开奖失败</view>
  40. </view>
  41. </template>
  42. <template v-if="list.status===`3` || list.status===`4`">
  43. <view class="dir-left-nowrap detail-head-b main-center">
  44. <icon class="icon-winning" type></icon>
  45. <view class="dir-top-nowrap main-center">
  46. <view class="text-winning">恭喜你,中奖啦!</view>
  47. <view class="text-code">中奖幸运码为 {{ list.lucky_code }}</view>
  48. </view>
  49. </view>
  50. <view @click="prize" class="cross-center main-center dir-left-nowrap detail-lucky">
  51. <view>查看我的幸运码</view>
  52. <icon class="icon-arrow-right-white" type></icon>
  53. </view>
  54. </template>
  55. </view>
  56. <view class="detail-box" v-if="list && list.goods"
  57. :style="{background: 'linear-gradient(' + lotteryConfig.config.bg_color +', '+ ( lotteryConfig.config.bg_color_type === 'gradient' ? lotteryConfig.config.bg_gradient_color: lotteryConfig.config.bg_color) + ')'}">
  58. <view class="detail-center-a">
  59. <view @click="navGoods" class="dir-left-nowrap goods">
  60. <image class="box-grow-0" :src="list.goods.goodsWarehouse.cover_pic" load-lazy></image>
  61. <view class="dir-top-nowrap goods-center">
  62. <view class="t-omit-three goods-name" :class="list.lottery.join_min_num > 0 ? 'limit' : ''"
  63. :data-limit="`${list.lottery.join_min_num}人起抽`">
  64. {{ list.goods.goodsWarehouse.name }}
  65. </view>
  66. <view class="attr-text dir-left-wrap t-omit">
  67. <block v-for="(value, key) in list.attr.attr_list" :key="key">
  68. <text>{{ value.attr_group_name }}:{{ value.attr_name }}</text>
  69. </block>
  70. </view>
  71. <view class="stock">共
  72. <text>{{ list.lottery.stock }}</text>
  73. </view>
  74. <view class="dir-left-nowrap cross-center">
  75. <view class="box-grow-0 price">免费</view>
  76. <view class="box-grow-1 original-price">¥{{ list.goods.price }}</view>
  77. </view>
  78. </view>
  79. </view>
  80. <view v-if="setting.cs_status ===1 && setting.cs_prompt_pic" @click="qrcode" class="lottery-share" >
  81. <image :src="setting.cs_prompt_pic" mode="aspectFit" load-lazy></image>
  82. </view>
  83. <template v-if="list.status == 1">
  84. <view class="dir-left-nowrap cross-center people">
  85. <view class="dir-top-nowrap box-grow-1">
  86. <view class="text">邀请好友参与,增加中奖概率哦!</view>
  87. <view class="ok">已成功邀请
  88. <text>{{list.parent_num}}</text>
  89. 位好友
  90. </view>
  91. </view>
  92. <view @click="prize" class="box-grow-0 dir-left-nowrap cross-center jt">
  93. <view class="text">详情</view>
  94. <icon class="icon-arrow-right" type></icon>
  95. </view>
  96. </view>
  97. <view class="dir-left-nowrap main-center t-small open">
  98. <view class="share">
  99. <view @click="moreLottery" class="more-lottery a">参与更多抽奖</view>
  100. </view>
  101. <app-jump-button open_type="share">
  102. <!-- #ifdef MP -->
  103. <app-button font-size="28" background="#ff4544" color="#ffffff" height="72"
  104. width="300" round>邀请好友参与
  105. </app-button>
  106. <!-- #endif -->
  107. <!-- #ifdef H5 -->
  108. <app-button font-size="28" background="#ff4544" color="#ffffff" height="72"
  109. @click="hShareAppMessage"
  110. width="300" round>邀请好友参与
  111. </app-button>
  112. <!-- #endif -->
  113. </app-jump-button>
  114. </view>
  115. </template>
  116. <template v-else-if="list.status == 2">
  117. <view class="main-center open">
  118. <view @click="moreLottery" class="more-lottery b">参与更多抽奖</view>
  119. </view>
  120. </template>
  121. <template v-else-if="list.status == 3 || list.status == 4">
  122. <view class="dir-left-nowrap main-center t-small open">
  123. <view class="share">
  124. <app-button @click="moreLottery" font-size="28" background="#FFFFFF" color="#ff4544"
  125. height="72"
  126. width="300" round>
  127. 参与更多抽奖
  128. </app-button>
  129. </view>
  130. <app-button font-size="28" v-if="list.status == 3" background="#ff4544"
  131. color="#ffffff" @click="submit" height="72" width="300" round>
  132. 立即兑换
  133. </app-button>
  134. <app-button font-size="28" v-if="list.status == 4" background="#cdcdcd" color="#ffffff"
  135. height="72"
  136. width="300"
  137. round disabled>
  138. 已兑换
  139. </app-button>
  140. </view>
  141. </template>
  142. <view class="user-list" v-if="(list.status==2 && list.lottery.type ==2) || list.status == 1">
  143. <view class="user">已有{{num}}人参与</view>
  144. <view class="flex-wrap">
  145. <block v-for="(v,k) in user_list" :key="k">
  146. <image class="box-grow-0" :src="v.user.userInfo.avatar"></image>
  147. </block>
  148. </view>
  149. <view v-if="num > 30" class="t-medium end">仅显示最近参与30人</view>
  150. </view>
  151. <view class="detail-suc" v-else>
  152. <view class="main-center cross-center people">已有{{num}}人参与 {{list.ok_num}}人中奖</view>
  153. <view class="father">
  154. <view v-for="(v,k) in user_list" :key="k"
  155. class="dir-left-nowrap cross-center user-winning-list">
  156. <image class="box-grow-0" :src="v.user.userInfo.avatar"></image>
  157. <view class="box-grow-1">{{ v.user.nickname }}</view>
  158. <view class="dir-top-nowrap box-grow-0 main-right right">
  159. <view class="main-right text-num">{{ v.lucky_code }}</view>
  160. <view class="main-right text-code">幸运码</view>
  161. </view>
  162. </view>
  163. </view>
  164. <view v-if="list.ok_num>3 && !args" class="load" @click="userload">加载更多</view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </app-layout>
  170. </template>
  171. <script>
  172. import {mapState} from "vuex";
  173. export default {
  174. name: "detail",
  175. data() {
  176. return {
  177. page: 1,
  178. load: false,
  179. args: false,
  180. title: '抽奖',
  181. list: {},
  182. num: '',
  183. user_list: null,
  184. setting: {},
  185. }
  186. },
  187. computed: {
  188. ...mapState({
  189. lotteryConfig: state => state.mallConfig.plugin.lottery,
  190. }),
  191. },
  192. onLoad(options) { this.$commonLoad.onload(options);
  193. const self = this;
  194. self.getSetting();
  195. self.$showLoading();
  196. self.$request({
  197. url: self.$api.lottery.detail,
  198. data: {
  199. id: options.id ? options.id : 0,
  200. lottery_id: options.lottery_id ? options.lottery_id : 0,
  201. },
  202. method: 'POST'
  203. }).then(info => {
  204. self.$hideLoading();
  205. if (info.code === 0) {
  206. [self.list, self.num, self.user_list] = [info.data.list, info.data.num, info.data.user_list];
  207. } else {
  208. uni.showModal({
  209. title: '提示',
  210. content: info.msg,
  211. showCancel: false,
  212. success: function (e) {
  213. if (e.confirm) {
  214. uni.navigateBack({delta: 1});
  215. }
  216. }
  217. });
  218. }
  219. }).catch(e => {
  220. self.$hideLoading();
  221. })
  222. },
  223. // #ifdef MP
  224. onShareAppMessage() {
  225. return this.hShareAppMessage();
  226. },
  227. // #endif
  228. methods: {
  229. hShareAppMessage(s = false) {
  230. return this.$shareAppMessage({
  231. title: this.list.goods.app_share_title ? this.list.goods.app_share_title : this.title,
  232. path: '/plugins/lottery/goods/goods',
  233. imageUrl: this.list.goods.app_share_pic ? this.list.goods.app_share_pic : '',
  234. params: {
  235. lottery_id: this.list.lottery_id,
  236. },
  237. }, s);
  238. },
  239. userload: function () {
  240. const self = this;
  241. if (self.args || self.load)
  242. return;
  243. self.load = true;
  244. let page = self.page + 1;
  245. self.$request({
  246. url: self.$api.lottery.detail,
  247. data: {
  248. page: page,
  249. lottery_id: self.list.lottery_id,
  250. }
  251. }).then(info => {
  252. if (info.code === 0) {
  253. [self.page, self.args, self.user_list] = [page, info.data.user_list.length < 6, self.user_list.concat(info.data.user_list)];
  254. }
  255. self.load = false;
  256. });
  257. },
  258. getSetting: function () {
  259. const self = this;
  260. self.$request({
  261. url: self.$api.lottery.setting,
  262. }).then(info => {
  263. if (info.code === 0) {
  264. self.setting = info.data.setting;
  265. }
  266. });
  267. },
  268. navGoods() {
  269. uni.navigateTo({url: `/plugins/lottery/goods/goods?lottery_id=` + this.list.lottery_id})
  270. },
  271. qrcode() {
  272. uni.navigateTo({url: `/plugins/lottery/qrcode/qrcode`})
  273. },
  274. prize() {
  275. uni.navigateTo({url: `/plugins/lottery/lucky-code/lucky-code?lottery_id=` + this.list.lottery_id});
  276. },
  277. moreLottery() {
  278. uni.redirectTo({url: `/plugins/lottery/index/index`});
  279. },
  280. submit: function () {
  281. const list = this.list;
  282. const mchList = [{
  283. "mch_id": 0,
  284. "lottery_log_id": list.id,
  285. "goods_list": [{
  286. "id": list.goods.id,
  287. "attr": list.attr.attr_list,
  288. "num": 1,
  289. "cart_id": 0,
  290. "goods_attr_id": list.goods.attr_id,
  291. }]
  292. }];
  293. uni.navigateTo({
  294. url: '/pages/order-submit/order-submit?mch_list=' +
  295. JSON.stringify(mchList) +
  296. '&preview_url=' + encodeURIComponent(this.$api.lottery.order_preview) +
  297. '&submit_url=' + encodeURIComponent(this.$api.lottery.order_submit)
  298. });
  299. }
  300. }
  301. }
  302. </script>
  303. <style scoped lang="scss">
  304. .head-bg {
  305. background-size: 100% 100%;
  306. background-repeat: no-repeat;
  307. height: #{242rpx};
  308. width: 100%;
  309. }
  310. .attr-text {
  311. color: #999999;
  312. font-size: #{26rpx};
  313. margin-top: #{14rpx};
  314. max-width: #{335rpx};
  315. text:after {
  316. content: ','
  317. }
  318. text:last-child:after {
  319. content: ''
  320. }
  321. }
  322. .load {
  323. text-align: center;
  324. color: #999;
  325. font-size: #{24rpx};
  326. padding-bottom: #{20rpx};
  327. }
  328. .bg {
  329. min-height: 100vh;
  330. }
  331. .lottery-share {
  332. margin: #{20rpx} 0;
  333. image {
  334. height: #{140rpx};
  335. margin: 0 auto;
  336. width: #{702rpx};
  337. display: block;
  338. }
  339. }
  340. .no-content {
  341. color: #888;
  342. padding: #{100rpx} 0 0 0;
  343. text-align: center;
  344. }
  345. .limit[data-limit]:before {
  346. content: attr(data-limit);
  347. font-size: #{24rpx};
  348. color: #ff4544;
  349. border: 1px solid #ff4544;
  350. padding: 0 #{12rpx};
  351. height: #{40rpx};
  352. text-align: center;
  353. line-height: #{40rpx};
  354. background: #fff;
  355. border-radius: #{20rpx};
  356. margin-right: #{12rpx};
  357. display: inline-block;
  358. }
  359. .detail-head-a {
  360. padding-top: #{64rpx};
  361. color: #FFFFFF;
  362. margin-bottom: #{32rpx};
  363. .icon-march {
  364. margin-right: #{48rpx};
  365. width: #{88rpx};
  366. height: #{88rpx};
  367. background-image: url('./../image/lottery-march.png');
  368. background-repeat: no-repeat;
  369. background-size: 100% 100%;
  370. }
  371. .icon-wait {
  372. margin-right: #{48rpx};
  373. width: #{88rpx};
  374. height: #{88rpx};
  375. background-image: url('./../image/lottery-go.png');
  376. background-repeat: no-repeat;
  377. background-size: 100% 100%;
  378. }
  379. .text-success {
  380. font-size: #{32rpx};
  381. }
  382. .text-time {
  383. margin-top: #{10rpx};
  384. font-size: #{28rpx};
  385. }
  386. }
  387. .detail-lucky {
  388. color: #fff;
  389. font-size: #{28rpx};
  390. padding-bottom: #{16rpx};
  391. .icon-arrow-right-white {
  392. width: #{16rpx};
  393. height: #{30rpx};
  394. margin-left: #{16rpx};
  395. background-image: url('../../../static/image/icon/arrow-right-white.png');
  396. background-repeat: no-repeat;
  397. background-size: 100% 100%;
  398. }
  399. }
  400. .goods {
  401. padding: 0 #{32rpx};
  402. font-size: #{32rpx};
  403. color: #353535;
  404. image {
  405. display: block;
  406. width: #{280rpx};
  407. height: #{280rpx};
  408. }
  409. .stock {
  410. color: #999999;
  411. margin-top: #{30rpx};
  412. margin-bottom: #{30rpx};
  413. font-size: #{28rpx};
  414. text {
  415. font-size: #{36rpx};
  416. color: #ff4544;
  417. font-weight: bold;
  418. padding: 0 #{5rpx};
  419. }
  420. }
  421. .goods-center {
  422. padding-left: #{24rpx};
  423. }
  424. .price {
  425. color: #ff4544;
  426. }
  427. .original-price {
  428. text-decoration: line-through;
  429. padding-left: #{12rpx};
  430. color: #999;
  431. }
  432. }
  433. .open {
  434. padding: 0 #{35rpx};
  435. margin: #{40rpx} 0 #{32rpx} 0;
  436. .share {
  437. padding-right: #{32rpx};
  438. }
  439. .more-lottery {
  440. background: #ffffff;
  441. color: #ff4544;
  442. font-size: #{28rpx};
  443. height: #{72rpx};
  444. border-radius: #{36rpx};
  445. text-align: center;
  446. line-height: #{72rpx};
  447. border: 1px solid #ff4544;
  448. }
  449. .a {
  450. width: #{300rpx};
  451. }
  452. .b {
  453. width: #{500rpx};
  454. }
  455. }
  456. .user-list {
  457. border-top: #{1px} solid #e2e2e2;
  458. padding: 0 #{32rpx};
  459. .user {
  460. font-size: #{28rpx};
  461. margin-top: #{40rpx};
  462. margin-bottom: #{32rpx};
  463. text-align: center;
  464. color: #666;
  465. }
  466. image {
  467. display: block;
  468. width: #{56rpx};
  469. height: #{56rpx};
  470. margin: 0 #{3rpx} #{20rpx} #{4rpx};
  471. }
  472. .end {
  473. color: #999999;
  474. text-align: center;
  475. font-size: #{24rpx};
  476. }
  477. }
  478. .detail-box {
  479. padding-top: #{16rpx};
  480. min-height: calc(100vh - #{242rpx});
  481. }
  482. .detail-center-a {
  483. background: #fff;
  484. border-radius: #{16rpx};
  485. margin: 0 #{24rpx};
  486. padding: #{32rpx} 0;
  487. .people {
  488. background: #fff7e7;
  489. margin-top: #{32rpx};
  490. padding: #{26rpx} #{32rpx};
  491. .text {
  492. color: #666;
  493. font-size: #{24rpx};
  494. }
  495. .ok {
  496. color: #353535;
  497. padding-top: #{10rpx};
  498. font-size: #{28rpx};
  499. text {
  500. font-weight: bold;
  501. color: #FF4544;
  502. padding: 0 #{5rpx};
  503. }
  504. }
  505. .jt {
  506. font-size: #{24rpx};
  507. color: #999999;
  508. .icon-arrow-right {
  509. background-image: url("../../../static/image/icon/arrow-right.png");
  510. background-size: 100% 100%;
  511. background-repeat: no-repeat;
  512. width: #{16rpx};
  513. height: #{30rpx};
  514. margin-left: #{16rpx};
  515. }
  516. }
  517. }
  518. }
  519. .detail-head-b {
  520. padding-top: #{72rpx};
  521. color: #fff;
  522. font-size: #{28rpx};
  523. margin-bottom: #{32rpx};
  524. .icon-winning {
  525. margin-right: #{48rpx};
  526. width: #{88rpx};
  527. height: #{88rpx};
  528. background-image: url('./../image/lottery-success.png');
  529. background-repeat: no-repeat;
  530. background-size: 100% 100%;
  531. }
  532. .icon-error {
  533. margin-right: #{48rpx};
  534. width: #{88rpx};
  535. height: #{88rpx};
  536. background-image: url('./../image/lottery-error.png');
  537. background-repeat: no-repeat;
  538. background-size: 100% 100%;
  539. }
  540. .icon-people {
  541. margin-right: #{48rpx};
  542. width: #{88rpx};
  543. height: #{88rpx};
  544. background-image: url('./../image/lottery-people.png');
  545. background-repeat: no-repeat;
  546. background-size: 100% 100%;
  547. }
  548. .text-winning {
  549. font-size: #{32rpx};
  550. }
  551. .text-code {
  552. margin-top: #{8}rpx;
  553. font-size: #{28rpx};
  554. }
  555. }
  556. .detail-suc {
  557. background: #f7f7f7;
  558. color: #353535;
  559. font-size: #{28rpx};
  560. margin: 0 #{32rpx};
  561. .people {
  562. text-align: center;
  563. height: #{88rpx};
  564. background: #f7f7f7;
  565. border-bottom: 1px solid #e2e2e2;
  566. }
  567. .user-winning-list:first-child {
  568. padding-top: #{32rpx};
  569. }
  570. .user-winning-list {
  571. padding-bottom: #{32rpx};
  572. image {
  573. display: block;
  574. width: #{64rpx};
  575. height: #{64rpx};
  576. margin: 0 #{32rpx} 0 #{40rpx};
  577. border-radius: 50%;
  578. }
  579. .right {
  580. margin-right: #{40rpx};
  581. .text-num {
  582. font-size: #{28rpx};
  583. color: #353535;
  584. }
  585. .text-code {
  586. margin-top: #{5rpx};
  587. font-size: #{22rpx};
  588. color: #999999;
  589. }
  590. }
  591. }
  592. }
  593. </style>