1
0

detail.vue 21 KB

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