fight-detail.vue 7.5 KB

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