detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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="getTheme.color" :checked="item.switch == 1" />
  39. </view>
  40. <view class="goods-info">
  41. <view class="goods-name t-omit">{{item.name}}</view>
  42. <view class="goods-profit" :style="{'color': getTheme.color, 'border-color': getTheme.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" :style="{'color': getTheme.color}">¥{{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 :style="{'background-color': getTheme.background}" @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 @share="hShareAppMessage" :posterUrl="'/plugins/community/poster/poster?activity_id='+id + '&middleman_id=0'" :hasPosterNav="showShare" v-model="showShare" 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. setting: {}
  100. }
  101. },
  102. components: {
  103. appShareQrCode
  104. },
  105. computed: {
  106. ...mapGetters('mallConfig', {
  107. getTheme: 'getTheme',
  108. }),
  109. ...mapState({
  110. stock: state => state.mallConfig.__wxapp_img.stock,
  111. appSetting: state => state.mallConfig.mall.setting,
  112. appImg: state => state.mallConfig.__wxapp_img.mall,
  113. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  114. })
  115. },
  116. onLoad(options) { this.$commonLoad.onload(options);
  117. let that = this;
  118. that.id = options.id;
  119. that.middleman_id = options.middleman_id;
  120. that.$showLoading({
  121. type: 'global',
  122. text: '加载中...'
  123. });
  124. that.getSetting();
  125. },
  126. onHide() {
  127. clearInterval(this.timeInterval);
  128. },
  129. onUnload() {
  130. clearInterval(this.timeInterval);
  131. },
  132. // #ifdef MP
  133. onShareAppMessage() {
  134. return this.hShareAppMessage();
  135. },
  136. // #endif
  137. methods: {
  138. hShareAppMessage(s = false) {
  139. return this.$shareAppMessage({
  140. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  141. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : this.list[0].cover_pic,
  142. path: "/plugins/community/activity/activity",
  143. params: {
  144. id: this.id
  145. }
  146. }, s);
  147. },
  148. copy() {
  149. let that = this;
  150. let order = '';
  151. let no;
  152. if(that.order.length === 0) {
  153. uni.showToast({
  154. title: '暂无订单,复制接龙文本失败',
  155. duration: 1000,
  156. icon: 'none'
  157. });
  158. return false;
  159. }
  160. for(let i = 0;i < that.order.length;i++) {
  161. no = i + 1
  162. if(no > 1) {
  163. order += '\n\n';
  164. }
  165. if(no < 10) {
  166. order += "【00"+no+"】\n";
  167. }else if(no < 100) {
  168. order += "【0"+no+"】\n";
  169. }else if(no < 1000) {
  170. order += "【"+no+"】\n";
  171. }
  172. order += "用户昵称:"+that.order[i].name+"\n商品名称:";
  173. for(let idx in that.order[i].list) {
  174. if(idx > 0) {
  175. order += "、";
  176. }
  177. order += that.order[i].list[idx].goods + "(";
  178. for(let index in that.order[i].list[idx].attr) {
  179. if(index > 0) {
  180. order += "/";
  181. }
  182. order += that.order[i].list[idx].attr[index].attr_name;
  183. }
  184. order += ") x" + that.order[i].list[idx].num;
  185. }
  186. }
  187. this.$utils.uniCopy({
  188. data: order,
  189. success() {
  190. //#ifndef MP-WEIXIN
  191. uni.showToast({title: '复制成功'});
  192. // #endif
  193. },
  194. });
  195. },
  196. switchGood(item) {
  197. let that = this;
  198. that.$request({
  199. url: that.$api.community.switch,
  200. data: {
  201. activity_id: that.id,
  202. goods_id: item.id
  203. },
  204. method: 'post'
  205. }).then(response=>{
  206. uni.hideLoading();
  207. uni.showToast({
  208. title: response.msg,
  209. icon: 'none',
  210. duration: 1000
  211. });
  212. })
  213. },
  214. toOrder() {
  215. uni.redirectTo({
  216. url: '/plugins/community/order/order?keyword=' + this.activity.title
  217. });
  218. },
  219. toRecord() {
  220. uni.navigateTo({
  221. url: '/plugins/community/record/record?id=' +this.id
  222. });
  223. },
  224. getTime(time) {
  225. if(time > 86399) {
  226. this.d = Math.floor(time / 86400);
  227. time = time - (86400*this.d);
  228. }else {
  229. this.d = 0;
  230. }
  231. if(time > 3599) {
  232. this.h = Math.floor(time / 3600);
  233. time = time - (3600*this.h);
  234. }else {
  235. this.h = 0;
  236. }
  237. if(time > 59) {
  238. this.m = Math.floor(time / 60);
  239. time = time - (60*this.m);
  240. }else {
  241. this.m = 0;
  242. }
  243. },
  244. getSetting() {
  245. let that = this;
  246. that.$request({
  247. url: that.$api.community.setting,
  248. }).then(response=>{
  249. if(response.code === 0) {
  250. that.setting = response.data;
  251. that.getList();
  252. }else {
  253. uni.showToast({
  254. title: response.msg,
  255. icon: 'none',
  256. duration: 1000
  257. });
  258. }
  259. }).catch(() => {
  260. that.$hideLoading();
  261. });
  262. },
  263. getOrder() {
  264. let that = this;
  265. that.$request({
  266. url: that.$api.community.middle_list,
  267. data: {
  268. status: 0,
  269. keyword: that.activity.title,
  270. is_pagination: 2
  271. },
  272. }).then(response=>{
  273. this.order = response.data.list;
  274. })
  275. },
  276. getList() {
  277. let that = this;
  278. that.$request({
  279. url: that.$api.community.activity_detail,
  280. data: {
  281. id: that.id
  282. },
  283. method: 'post'
  284. }).then(response=>{
  285. uni.hideLoading();
  286. that.$hideLoading();
  287. if(response.code === 0) {
  288. that.activity = response.data.activity;
  289. that.list = response.data.list;
  290. for(let i in that.list) {
  291. that.list[i].check = true;
  292. }
  293. if(that.activity.activity_status == 0) {
  294. let time = that.activity.time - 1;
  295. that.timeInterval = setInterval(() =>{
  296. that.getTime(time);
  297. time--;
  298. if(time == 0) {
  299. clearInterval(that.timeInterval);
  300. that.getList();
  301. }
  302. },1000);
  303. }else {
  304. that.status_text = that.activity.end_at.slice(5) + '结束';
  305. that.getOrder();
  306. }
  307. }else {
  308. uni.showToast({
  309. title: response.msg,
  310. icon: 'none',
  311. duration: 1000
  312. });
  313. }
  314. }).catch(() => {
  315. uni.hideLoading();
  316. that.$hideLoading();
  317. });
  318. }
  319. }
  320. }
  321. </script>
  322. <style scoped lang="scss">
  323. .status {
  324. height: 96rpx;
  325. line-height: 96rpx;
  326. background-color: #fff;
  327. padding: 0 24rpx;
  328. font-size: 24rpx;
  329. &.start {
  330. height: 140rpx;
  331. padding-top: 30rpx
  332. }
  333. .status-up,.status-down {
  334. height: 50rpx;
  335. line-height: 50rpx;
  336. font-size: 24rpx;
  337. width: 100%;
  338. view {
  339. height: 50rpx;
  340. line-height: 50rpx;
  341. }
  342. .progress {
  343. width: #{430rpx};
  344. background-color: #f0f0f0;
  345. border-radius: #{10rpx};
  346. height: #{20rpx};
  347. position: relative;
  348. overflow: hidden;
  349. view {
  350. border-radius: #{10rpx};
  351. height: #{20rpx};
  352. position: absolute;
  353. top: 0;
  354. left: 0;
  355. z-index: 2;
  356. }
  357. }
  358. .condition {
  359. font-size: 28rpx;
  360. color: #353535;
  361. }
  362. .status {
  363. font-size: 26rpx;
  364. color: #ff4544;
  365. padding-right: 0;
  366. }
  367. }
  368. }
  369. .goods-list {
  370. padding: 0 24rpx;
  371. .item {
  372. height: 220rpx;
  373. width: 702rpx;
  374. margin-top: 20rpx;
  375. background-color: #fff;
  376. border-radius: 16rpx;
  377. position: relative;
  378. .goods-switch {
  379. position: absolute;
  380. right: 24rpx;
  381. bottom: 24rpx;
  382. transform:scale(0.7)
  383. }
  384. .goods-cover {
  385. flex-shrink: 0;
  386. width: 220rpx;
  387. height: 220rpx;
  388. border-radius: 16rpx;
  389. margin-right: 20rpx;
  390. position: relative;
  391. .out-dialog {
  392. width: #{220rpx};
  393. height: #{220rpx};
  394. border-radius: #{16rpx};
  395. position: absolute;
  396. top: 0;
  397. left: 0;
  398. z-index: 10;
  399. background-color: rgba(0,0,0,.5);
  400. image {
  401. width: #{220rpx};
  402. height: #{220rpx};
  403. border-radius: #{16rpx};
  404. }
  405. }
  406. image {
  407. width: 100%;
  408. height: 100%;
  409. border-radius: 16rpx;
  410. }
  411. }
  412. .goods-info {
  413. padding-top: 20rpx;
  414. font-size: 20rpx;
  415. color: #666;
  416. .goods-name {
  417. font-size: 28rpx;
  418. width: 440rpx;
  419. color: #353535;
  420. }
  421. .goods-profit {
  422. display: inline-block;
  423. padding: 0 4rpx;
  424. border: 2rpx solid;
  425. border-radius: 8rpx;
  426. margin: 12rpx 0 8rpx;
  427. font-size: 22rpx;
  428. height: 30rpx;
  429. line-height: 28rpx;
  430. }
  431. .goods-price {
  432. font-size: 32rpx;
  433. }
  434. }
  435. }
  436. }
  437. .u-bottom-height {
  438. height: 130upx;
  439. }
  440. .bottom-menu {
  441. width: 100%;
  442. height: 110rpx;
  443. font-size: 20rpx;
  444. .menu-btn-area {
  445. width: 50%;
  446. height: 110rpx;
  447. .menu-btn {
  448. height: 110rpx;
  449. color: #999;
  450. border-right: 2rpx solid #e2e2e2;
  451. width: 25%;
  452. &:last-of-type {
  453. border-right: 0;
  454. }
  455. image {
  456. width: 40rpx;
  457. height: 40rpx;
  458. margin-bottom: 5rpx;
  459. }
  460. }
  461. }
  462. .status-btn {
  463. width: 50%;
  464. height: 110rpx;
  465. text-align: center;
  466. line-height: 110rpx;
  467. .lose {
  468. width: 100%;
  469. height: 100%;
  470. background-color: #999999;
  471. color: #fff;
  472. font-size: 28rpx;
  473. }
  474. .share {
  475. width: 100%;
  476. height: 100%;
  477. line-height: 110rpx;
  478. color: #fff;
  479. border-radius: 0;
  480. font-size: 28rpx;
  481. }
  482. }
  483. }
  484. .u-bottom-fixed {
  485. position: fixed;
  486. bottom: 0;
  487. left: 0;
  488. width: 100%;
  489. z-index: 1500;
  490. background-color: #ffffff;
  491. }
  492. </style>