fight-detail.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="fight-detail">
  3. <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
  4. <view class="row">
  5. <view class="fight-tip">
  6. <view class="success" v-if="success">恭喜您,拼团成功!</view>
  7. <view v-else
  8. >还差<text>{{ collageData.needNum }}</text
  9. >人,赶快邀请好友来拼单吧!</view
  10. >
  11. </view>
  12. <!-- 成功 -->
  13. <template v-if="success">
  14. <user-list :status="success"></user-list>
  15. </template>
  16. <!-- 等待完成 -->
  17. <template v-else>
  18. <!-- 倒计时 -->
  19. <countdown-box :countDownTime="countDownTime"></countdown-box>
  20. </template>
  21. <!-- 操作 -->
  22. <view class="fight-control success" v-if="success">
  23. <view class="btn type1" @click="handleClick(1)">去首页逛逛</view>
  24. <view class="link" @click="handleClick(3)">查看订单详情 ></view>
  25. </view>
  26. <view class="fight-control" v-else>
  27. <button class="btn type1" @click="handleClick(2)" open-type="share">邀请好友拼单</button>
  28. <view class="btn type2" @click="handleClick(1)">去首页逛逛</view>
  29. </view>
  30. <!-- 商品 + 用户信息 -->
  31. <template v-if="!success">
  32. <view class="grid"></view>
  33. <!-- 拼单用户列表 -->
  34. <user-list :status="success"></user-list>
  35. <view class="line"></view>
  36. <view class="goods-info">
  37. <image :src="collageData.productImage" class="cover"></image>
  38. <view class="title" v-text="collageData.productName"></view>
  39. </view>
  40. </template>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import UserList from './components/user-list.vue'
  46. import CountdownBox from './components/countdown-box.vue'
  47. import orderShare from '@/pages/order/mixins/orderShare.js'
  48. import { mapGetters } from 'vuex'
  49. export default {
  50. components: {
  51. UserList,
  52. CountdownBox
  53. },
  54. computed: {
  55. ...mapGetters(['userId', 'hasLogin']),
  56. success() {
  57. return this.collageData.memberNum === this.collageData.existNum
  58. }
  59. },
  60. data() {
  61. return {
  62. isRequest: true,
  63. collageId: '',
  64. initiatorId: '',
  65. collageData: {},
  66. // 自定义标签
  67. tagsList: ['2人拼团价'],
  68. // 倒计时
  69. countDownTime: {},
  70. timer: null,
  71. // 商品数量
  72. count: 1,
  73. countVisible: false
  74. }
  75. },
  76. onLoad(options) {
  77. this.collageId = options.collageId
  78. this.fetchOrderDetails()
  79. },
  80. onShow() {
  81. !isRequest && this.countDown()
  82. },
  83. onShareAppMessage(e) {
  84. const shareData = {
  85. type: 4,
  86. collageId: this.collageData.collageId,
  87. initiatorId: this.userId
  88. }
  89. const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
  90. return {
  91. title: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
  92. path: `/pages/tabBar/index/index?state_str=${state_str}`,
  93. imageUrl: this.collageData.productImage
  94. }
  95. },
  96. methods: {
  97. handleClick(type) {
  98. const clickFunc = {
  99. 1: this.toHome,
  100. 2: this.toShare,
  101. 3: this.toOrder
  102. }
  103. clickFunc[type].apply(this)
  104. },
  105. // 跳转首页
  106. toHome() {
  107. console.log('首页')
  108. uni.switchTab({ url: '/pages/tabBar/index/index' })
  109. },
  110. // 分享
  111. toShare() {
  112. console.log('分享')
  113. },
  114. // 跳转订单
  115. toOrder() {
  116. console.log('订单')
  117. this.$api.navigateTo(`/pages/order/order-detail?orderId=${this.collageData.orderId}`)
  118. },
  119. // 获取拼单详情
  120. fetchOrderDetails() {
  121. console.log('获取拼单详情')
  122. this.FightService.OrderCollageDetails({
  123. collageId: this.collageId,
  124. userId: this.userId
  125. }).then(res => {
  126. console.log(res)
  127. this.collageData = res.data
  128. this.countDown()
  129. this.isRequest = false
  130. })
  131. },
  132. // 倒计时
  133. countDown() {
  134. const diffTime = new Date(this.collageData.endTime).getTime()
  135. const loadTime = new Date().getTime()
  136. this.timer && clearTimeout(this.timer)
  137. this.$util.countDown(diffTime, loadTime, {}, item => {
  138. this.countDownTime = item.conttainer
  139. this.timer = item.t
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. /* scss中可以用mixin来扩展 */
  147. @mixin ellipsis($line: 1) {
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. display: -webkit-box;
  151. -webkit-line-clamp: $line;
  152. -webkit-box-orient: vertical;
  153. }
  154. .flex-center-box {
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. .fight-detail {
  160. background: #f7f7f7;
  161. min-height: 100vh;
  162. .row {
  163. background: #fff;
  164. overflow: hidden;
  165. }
  166. .fight-tip {
  167. @extend .flex-center-box;
  168. margin-top: 70rpx;
  169. margin-bottom: 48rpx;
  170. font-size: 30rpx;
  171. font-weight: 400;
  172. color: #333333;
  173. text {
  174. color: #ff457b;
  175. }
  176. .success {
  177. font-size: 34rpx;
  178. color: #333333;
  179. font-weight: bold;
  180. }
  181. }
  182. .fight-control {
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. flex-direction: column;
  187. margin-top: 48rpx;
  188. margin-bottom: 48rpx;
  189. .success {
  190. margin-bottom: 66rpx;
  191. }
  192. .link {
  193. margin-top: 24rpx;
  194. font-size: 26rpx;
  195. line-height: 38rpx;
  196. color: #999999;
  197. }
  198. .btn {
  199. @extend .flex-center-box;
  200. width: 600rpx;
  201. height: 90rpx;
  202. border-radius: 45rpx;
  203. box-sizing: border-box;
  204. font-size: 30rpx;
  205. &.type1 {
  206. color: #ffffff;
  207. background: linear-gradient(90deg, #fc32b4 0%, #f83c6c 100%);
  208. }
  209. &.type2 {
  210. margin-top: 24rpx;
  211. color: #ff457b;
  212. border: 1px solid #ff457b;
  213. }
  214. }
  215. }
  216. .grid {
  217. margin: 48rpx 0 48rpx;
  218. width: 750rpx;
  219. height: 20rpx;
  220. background: #f7f7f7;
  221. }
  222. .line {
  223. width: 702rpx;
  224. height: 1px;
  225. margin: 48rpx auto 48rpx auto;
  226. background: #e1e1e1;
  227. }
  228. .goods-info {
  229. @extend .flex-center-box;
  230. padding: 0 24rpx 48rpx;
  231. .cover {
  232. width: 80rpx;
  233. height: 80rpx;
  234. background: eee;
  235. border: 1rpx solid #e1e1e1;
  236. border-radius: 8rpx;
  237. border: 50%;
  238. }
  239. .title {
  240. flex: 1;
  241. margin-left: 24rpx;
  242. word-break: break-word;
  243. font-size: 26rpx;
  244. line-height: 1.6;
  245. color: #333333;
  246. text-align: justify;
  247. @include ellipsis(2);
  248. }
  249. }
  250. }
  251. </style>