fight-detail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. onShareAppMessage(e) {
  81. const shareData = {
  82. type: 4,
  83. collageId: this.collageData.collageId,
  84. initiatorId: this.userId
  85. }
  86. const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
  87. return {
  88. title: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
  89. path: `/pages/tabBar/index/index?state_str=${state_str}`,
  90. imageUrl: this.collageData.productImage
  91. }
  92. },
  93. methods: {
  94. handleClick(type) {
  95. const clickFunc = {
  96. 1: this.toHome,
  97. 2: this.toShare,
  98. 3: this.toOrder
  99. }
  100. clickFunc[type].apply(this)
  101. },
  102. // 跳转首页
  103. toHome() {
  104. console.log('首页')
  105. uni.switchTab({ url: '/pages/tabBar/index/index' })
  106. },
  107. // 分享
  108. toShare() {
  109. console.log('分享')
  110. },
  111. // 跳转订单
  112. toOrder() {
  113. console.log('订单')
  114. this.$api.navigateTo(`/pages/order/order-detail?orderId=${this.collageData.orderId}`)
  115. },
  116. // 获取拼单详情
  117. fetchOrderDetails() {
  118. console.log('获取拼单详情')
  119. this.FightService.OrderCollageDetails({
  120. collageId: this.collageId,
  121. userId: this.userId
  122. }).then(res => {
  123. console.log(res)
  124. this.collageData = res.data
  125. this.countDown()
  126. this.isRequest = false
  127. })
  128. },
  129. // 倒计时
  130. countDown() {
  131. const diffTime = new Date(this.collageData.endTime).getTime()
  132. const loadTime = new Date().getTime()
  133. this.$util.countDown(diffTime, loadTime, {}, item => {
  134. this.countDownTime = item.conttainer
  135. this.timer = item.t
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. /* scss中可以用mixin来扩展 */
  143. @mixin ellipsis($line: 1) {
  144. overflow: hidden;
  145. text-overflow: ellipsis;
  146. display: -webkit-box;
  147. -webkit-line-clamp: $line;
  148. -webkit-box-orient: vertical;
  149. }
  150. .flex-center-box {
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. .fight-detail {
  156. background: #f7f7f7;
  157. min-height: 100vh;
  158. .row {
  159. background: #fff;
  160. overflow: hidden;
  161. }
  162. .fight-tip {
  163. @extend .flex-center-box;
  164. margin-top: 70rpx;
  165. margin-bottom: 48rpx;
  166. font-size: 30rpx;
  167. font-weight: 400;
  168. color: #333333;
  169. text {
  170. color: #ff457b;
  171. }
  172. .success {
  173. font-size: 34rpx;
  174. color: #333333;
  175. font-weight: bold;
  176. }
  177. }
  178. .fight-control {
  179. display: flex;
  180. justify-content: center;
  181. align-items: center;
  182. flex-direction: column;
  183. margin-top: 48rpx;
  184. margin-bottom: 48rpx;
  185. .success {
  186. margin-bottom: 66rpx;
  187. }
  188. .link {
  189. margin-top: 24rpx;
  190. font-size: 26rpx;
  191. line-height: 38rpx;
  192. color: #999999;
  193. }
  194. .btn {
  195. @extend .flex-center-box;
  196. width: 600rpx;
  197. height: 90rpx;
  198. border-radius: 45rpx;
  199. box-sizing: border-box;
  200. font-size: 30rpx;
  201. &.type1 {
  202. color: #ffffff;
  203. background: linear-gradient(90deg, #fc32b4 0%, #f83c6c 100%);
  204. }
  205. &.type2 {
  206. margin-top: 24rpx;
  207. color: #ff457b;
  208. border: 1px solid #ff457b;
  209. }
  210. }
  211. }
  212. .grid {
  213. margin: 48rpx 0 48rpx;
  214. width: 750rpx;
  215. height: 20rpx;
  216. background: #f7f7f7;
  217. }
  218. .line {
  219. width: 702rpx;
  220. height: 1px;
  221. margin: 48rpx auto 48rpx auto;
  222. background: #e1e1e1;
  223. }
  224. .goods-info {
  225. @extend .flex-center-box;
  226. padding: 0 24rpx 48rpx;
  227. .cover {
  228. width: 80rpx;
  229. height: 80rpx;
  230. background: eee;
  231. border: 1rpx solid #e1e1e1;
  232. border-radius: 8rpx;
  233. border: 50%;
  234. }
  235. .title {
  236. flex: 1;
  237. margin-left: 24rpx;
  238. word-break: break-word;
  239. font-size: 26rpx;
  240. line-height: 1.6;
  241. color: #333333;
  242. text-align: justify;
  243. @include ellipsis(2);
  244. }
  245. }
  246. }
  247. </style>