detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <app-layout>
  3. <view class="status" :class="activity.condition > 0 ? 'start':'cross-center'" v-if="activity.activity_status == 1">
  4. <view class="main-between cross-center status-up">
  5. <view v-if="activity.condition == 0" style="color: #999">
  6. {{activity.user_num}}人已抢{{activity.all_sales}}件
  7. </view>
  8. <view v-else class="condition">
  9. <text v-if="activity.num - activity.condition_count > 0">
  10. 还差{{activity.num - activity.condition_count}}{{activity.condition === 1 ? '人':'件'}}
  11. </text>
  12. 拼团成功
  13. </view>
  14. <view class="status">{{status_text}}</view>
  15. </view>
  16. <view v-if="activity.condition > 0" class="main-between cross-center status-down" >
  17. <view class="progress">
  18. <view :style="{'width': `${activity.rate}%`,'backgroundImage':`url(${bonusImg.progress})`}"></view>
  19. </view>
  20. <view style="color: #999">
  21. {{activity.condition_count ? activity.user_num : 0}}人已抢{{activity.all_sales}}件
  22. </view>
  23. </view>
  24. </view>
  25. <view class="status" v-else>
  26. <text v-if="activity.activity_status == 2">本次活动已结束</text>
  27. <text v-if="activity.activity_status == 0">距离本次活动开始还有{{d > 0? d + '天': ''}}{{h > 0? h + '时': ''}}{{m > 0? m + '分': ''}}</text>
  28. </view>
  29. <view class="goods-list">
  30. <view class="dir-left-nowrap item" v-for="item in list" :key="item.id">
  31. <view class="goods-cover">
  32. <view v-if="item.goods_stock == 0" class="out-dialog">
  33. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  34. </view>
  35. <image :src="item.cover_pic"></image>
  36. </view>
  37. <view @click="switchGood(item)" v-if="activity.activity_status < 2" class="goods-switch">
  38. <switch :color="themeColor" :checked="item.switch" />
  39. </view>
  40. <view class="goods-info">
  41. <view class="goods-name t-omit">{{item.name}}</view>
  42. <view class="goods-profit" :class="getTheme + '-m-text ' + getTheme +' '+getTheme+'-m-border'">预计利润
  43. <text v-if="item.use_attr === 1">¥{{item.profit_price.min_price}}-{{item.profit_price.max_price}}</text>
  44. <text v-else>¥{{item.profit_price}}</text>
  45. </view>
  46. <view>库存:{{item.goods_stock}}{{item.goodsWarehouse.unit}}</view>
  47. <view :style="{'color': `${activity.activity_status == 0 ? '#ffffff': '#666'}`}">{{item.sales}}</view>
  48. <view class="goods-price" :class="getTheme + '-m-text ' + getTheme">¥{{item.min_price}}</view>
  49. </view>
  50. </view>
  51. </view>
  52. <!--空格区域-->
  53. <view class="safe-area-inset-bottom">
  54. <view class="u-bottom-height"></view>
  55. </view>
  56. <!--底部按钮-->
  57. <view class="safe-area-inset-bottom u-bottom-fixed">
  58. <view class="bottom-menu dir-left-nowrap">
  59. <view class="menu-btn-area dir-left-nowrap">
  60. <view @click="toOrder" class="menu-btn box-grow-1 dir-top-nowrap main-center cross-center">
  61. <image src="./../image/order.png"></image>
  62. <view>团购订单</view>
  63. </view>
  64. <view @click="toRecord" class="menu-btn box-grow-1 dir-top-nowrap main-center cross-center">
  65. <image src="./../image/data.png"></image>
  66. <view>数据</view>
  67. </view>
  68. <view @click="copy" v-if="activity.activity_status > 0" class="menu-btn box-grow-1 dir-top-nowrap main-center cross-center">
  69. <image src="./../image/long.png"></image>
  70. <view>复制接龙</view>
  71. </view>
  72. </view>
  73. <view class="status-btn">
  74. <button :class="getTheme + '-m-back ' + getTheme" @click="showShare=true" v-if="(activity.activity_status == 2 && activity.is_success == 1) || activity.activity_status == 1 || activity.activity_status == 0" class="share">推广到群聊</button>
  75. <view v-if="activity.activity_status == 2 && activity.is_success == 0" class="lose">活动失败</view>
  76. </view>
  77. </view>
  78. </view>
  79. <app-share-qr-code :posterUrl="'/plugins/community/poster/poster?activity_id='+id + '&middleman_id=0'" hasPosterNav="true" v-model="showShare" :url="poster" title="生成活动海报"></app-share-qr-code>
  80. </app-layout>
  81. </template>
  82. <script>
  83. import {mapGetters, mapState} from 'vuex';
  84. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  85. export default {
  86. data() {
  87. return {
  88. timeInterval: null,
  89. showShare: false,
  90. id: 0,
  91. middleman_id: 0,
  92. list: [],
  93. order: [],
  94. status_text: '',
  95. activity: {},
  96. d: '',
  97. h: '',
  98. m: '',
  99. themeColor: '#ff4544',
  100. setting: {}
  101. }
  102. },
  103. components: {
  104. appShareQrCode
  105. },
  106. computed: {
  107. ...mapGetters('mallConfig', {
  108. getTheme: 'getTheme',
  109. }),
  110. ...mapState({
  111. stock: state => state.mallConfig.__wxapp_img.stock,
  112. appSetting: state => state.mallConfig.mall.setting,
  113. appImg: state => state.mallConfig.__wxapp_img.mall,
  114. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  115. })
  116. },
  117. onLoad: function (options) {
  118. let that = this;
  119. that.id = options.id;
  120. that.middleman_id = options.middleman_id;
  121. that.$showLoading({
  122. type: 'global',
  123. text: '加载中...'
  124. });
  125. that.getSetting();
  126. setTimeout(function(){
  127. switch(that.getTheme) {
  128. case 'b':
  129. that.themeColor = '#fcc600';
  130. break;
  131. case 'c':
  132. that.themeColor = '#ff547b';
  133. break;
  134. case 'd':
  135. that.themeColor = '#ddb766';
  136. break;
  137. case 'e':
  138. that.themeColor = '#7783ea';
  139. break;
  140. case 'g':
  141. that.themeColor = '#63be72';
  142. break;
  143. case 'h':
  144. that.themeColor = '#4a90e2';
  145. break;
  146. case 'i':
  147. that.themeColor = '#333333';
  148. break;
  149. }
  150. },0)
  151. },
  152. onShareAppMessage: function() {
  153. return this.$shareAppMessage({
  154. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  155. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : this.list[0].cover_pic,
  156. path: "/plugins/community/activity/activity",
  157. params: {
  158. id: this.id
  159. }
  160. });
  161. },
  162. onHide() {
  163. clearInterval(this.timeInterval);
  164. },
  165. onUnload() {
  166. clearInterval(this.timeInterval);
  167. },
  168. methods: {
  169. copy() {
  170. let that = this;
  171. let order = '';
  172. let no;
  173. if(that.order.length === 0) {
  174. uni.showToast({
  175. title: '暂无订单,复制接龙文本失败',
  176. duration: 1000,
  177. icon: 'none'
  178. });
  179. return false;
  180. }
  181. for(let i = 0;i < that.order.length;i++) {
  182. no = i + 1
  183. if(no > 1) {
  184. order += '\n\n';
  185. }
  186. if(no < 10) {
  187. order += "【00"+no+"】\n";
  188. }else if(no < 100) {
  189. order += "【0"+no+"】\n";
  190. }else if(no < 1000) {
  191. order += "【"+no+"】\n";
  192. }
  193. order += "用户昵称:"+that.order[i].name+"\n商品名称:";
  194. for(let idx in that.order[i].list) {
  195. if(idx > 0) {
  196. order += "、";
  197. }
  198. order += that.order[i].list[idx].goods + "(";
  199. for(let index in that.order[i].list[idx].attr) {
  200. if(index > 0) {
  201. order += "/";
  202. }
  203. order += that.order[i].list[idx].attr[index].attr_name;
  204. }
  205. order += ") x" + that.order[i].list[idx].num;
  206. }
  207. }
  208. uni.setClipboardData({
  209. data: order,
  210. success() {
  211. uni.hideToast();
  212. uni.getClipboardData({
  213. success() {
  214. uni.showToast({
  215. title: '复制成功',
  216. duration: 1000
  217. });
  218. }
  219. })
  220. }
  221. })
  222. },
  223. switchGood(item) {
  224. let that = this;
  225. that.$request({
  226. url: that.$api.community.switch,
  227. data: {
  228. activity_id: that.id,
  229. goods_id: item.id
  230. },
  231. method: 'post'
  232. }).then(response=>{
  233. uni.hideLoading();
  234. uni.showToast({
  235. title: response.msg,
  236. icon: 'none',
  237. duration: 1000
  238. });
  239. })
  240. },
  241. toOrder() {
  242. uni.redirectTo({
  243. url: '/plugins/community/order/order?keyword=' + this.activity.title
  244. });
  245. },
  246. toRecord() {
  247. uni.navigateTo({
  248. url: '/plugins/community/record/record?id=' +this.id
  249. });
  250. },
  251. getTime(time) {
  252. if(time > 86399) {
  253. this.d = Math.floor(time / 86400);
  254. time = time - (86400*this.d);
  255. }else {
  256. this.d = 0;
  257. }
  258. if(time > 3599) {
  259. this.h = Math.floor(time / 3600);
  260. time = time - (3600*this.h);
  261. }else {
  262. this.h = 0;
  263. }
  264. if(time > 59) {
  265. this.m = Math.floor(time / 60);
  266. time = time - (60*this.m);
  267. }else {
  268. this.m = 0;
  269. }
  270. },
  271. getSetting() {
  272. let that = this;
  273. that.$request({
  274. url: that.$api.community.setting,
  275. }).then(response=>{
  276. if(response.code === 0) {
  277. that.setting = response.data;
  278. that.getList();
  279. }else {
  280. uni.showToast({
  281. title: response.msg,
  282. icon: 'none',
  283. duration: 1000
  284. });
  285. }
  286. }).catch(() => {
  287. that.$hideLoading();
  288. });
  289. },
  290. getOrder() {
  291. let that = this;
  292. that.$request({
  293. url: that.$api.community.middle_list,
  294. data: {
  295. status: 0,
  296. keyword: that.activity.title,
  297. is_pagination: 2
  298. },
  299. }).then(response=>{
  300. this.order = response.data.list;
  301. })
  302. },
  303. getList() {
  304. let that = this;
  305. that.$request({
  306. url: that.$api.community.activity_detail,
  307. data: {
  308. id: that.id
  309. },
  310. method: 'post'
  311. }).then(response=>{
  312. uni.hideLoading();
  313. that.$hideLoading();
  314. if(response.code === 0) {
  315. that.activity = response.data.activity;
  316. that.list = response.data.list;
  317. for(let i in that.list) {
  318. that.list[i].check = true;
  319. }
  320. if(that.activity.activity_status == 0) {
  321. let time = that.activity.time - 1;
  322. that.timeInterval = setInterval(() =>{
  323. that.getTime(time);
  324. time--;
  325. if(time == 0) {
  326. clearInterval(that.timeInterval);
  327. that.getList();
  328. }
  329. },1000);
  330. }else {
  331. that.status_text = that.activity.end_at.slice(5) + '结束';
  332. that.getOrder();
  333. }
  334. }else {
  335. uni.showToast({
  336. title: response.msg,
  337. icon: 'none',
  338. duration: 1000
  339. });
  340. }
  341. }).catch(() => {
  342. uni.hideLoading();
  343. that.$hideLoading();
  344. });
  345. }
  346. }
  347. }
  348. </script>
  349. <style scoped lang="scss">
  350. .status {
  351. height: 96rpx;
  352. line-height: 96rpx;
  353. background-color: #fff;
  354. padding: 0 24rpx;
  355. font-size: 24rpx;
  356. &.start {
  357. height: 140rpx;
  358. padding-top: 30rpx
  359. }
  360. .status-up,.status-down {
  361. height: 50rpx;
  362. line-height: 50rpx;
  363. font-size: 24rpx;
  364. width: 100%;
  365. view {
  366. height: 50rpx;
  367. line-height: 50rpx;
  368. }
  369. .progress {
  370. width: #{430rpx};
  371. background-color: #f0f0f0;
  372. border-radius: #{10rpx};
  373. height: #{20rpx};
  374. position: relative;
  375. overflow: hidden;
  376. view {
  377. border-radius: #{10rpx};
  378. height: #{20rpx};
  379. position: absolute;
  380. top: 0;
  381. left: 0;
  382. z-index: 2;
  383. }
  384. }
  385. .condition {
  386. font-size: 28rpx;
  387. color: #353535;
  388. }
  389. .status {
  390. font-size: 26rpx;
  391. color: #ff4544;
  392. padding-right: 0;
  393. }
  394. }
  395. }
  396. .goods-list {
  397. padding: 0 24rpx;
  398. .item {
  399. height: 220rpx;
  400. width: 702rpx;
  401. margin-top: 20rpx;
  402. background-color: #fff;
  403. border-radius: 16rpx;
  404. position: relative;
  405. .goods-switch {
  406. position: absolute;
  407. right: 24rpx;
  408. bottom: 24rpx;
  409. transform:scale(0.7)
  410. }
  411. .goods-cover {
  412. flex-shrink: 0;
  413. width: 220rpx;
  414. height: 220rpx;
  415. border-radius: 16rpx;
  416. margin-right: 20rpx;
  417. position: relative;
  418. .out-dialog {
  419. width: #{220rpx};
  420. height: #{220rpx};
  421. border-radius: #{16rpx};
  422. position: absolute;
  423. top: 0;
  424. left: 0;
  425. z-index: 10;
  426. background-color: rgba(0,0,0,.5);
  427. image {
  428. width: #{220rpx};
  429. height: #{220rpx};
  430. border-radius: #{16rpx};
  431. }
  432. }
  433. image {
  434. width: 100%;
  435. height: 100%;
  436. border-radius: 16rpx;
  437. }
  438. }
  439. .goods-info {
  440. padding-top: 20rpx;
  441. font-size: 20rpx;
  442. color: #666;
  443. .goods-name {
  444. font-size: 28rpx;
  445. width: 440rpx;
  446. color: #353535;
  447. }
  448. .goods-profit {
  449. display: inline-block;
  450. padding: 0 4rpx;
  451. border: 2rpx solid;
  452. border-radius: 8rpx;
  453. margin: 12rpx 0 8rpx;
  454. font-size: 22rpx;
  455. height: 30rpx;
  456. line-height: 28rpx;
  457. }
  458. .goods-price {
  459. font-size: 32rpx;
  460. }
  461. }
  462. }
  463. }
  464. .u-bottom-height {
  465. height: 130upx;
  466. }
  467. .bottom-menu {
  468. width: 100%;
  469. height: 110rpx;
  470. font-size: 20rpx;
  471. .menu-btn-area {
  472. width: 50%;
  473. height: 110rpx;
  474. .menu-btn {
  475. height: 110rpx;
  476. color: #999;
  477. border-right: 2rpx solid #e2e2e2;
  478. width: 25%;
  479. &:last-of-type {
  480. border-right: 0;
  481. }
  482. image {
  483. width: 40rpx;
  484. height: 40rpx;
  485. margin-bottom: 5rpx;
  486. }
  487. }
  488. }
  489. .status-btn {
  490. width: 50%;
  491. height: 110rpx;
  492. text-align: center;
  493. line-height: 110rpx;
  494. .lose {
  495. width: 100%;
  496. height: 100%;
  497. background-color: #999999;
  498. color: #fff;
  499. font-size: 28rpx;
  500. }
  501. .share {
  502. width: 100%;
  503. height: 100%;
  504. line-height: 110rpx;
  505. color: #fff;
  506. border-radius: 0;
  507. font-size: 28rpx;
  508. }
  509. }
  510. }
  511. .u-bottom-fixed {
  512. position: fixed;
  513. bottom: 0;
  514. left: 0;
  515. width: 100%;
  516. z-index: 1500;
  517. background-color: #ffffff;
  518. }
  519. </style>