challenge.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="challenge-vs-container">
  3. <view class="challenage-vs-users">
  4. <view class="user-fixed challenge-user">
  5. <view class="user-top">
  6. <view class="user-body">
  7. <view class="user-title">挑战者</view>
  8. <view
  9. class="user-avatar"
  10. :style="{ backgroundImage: `url(${pkInfo.challenge_avatar})` }"
  11. />
  12. </view>
  13. </view>
  14. <view class="user-bottom">{{ pkInfo.challenge_nickname | getName }}</view>
  15. </view>
  16. <view class="user-fixed accept-user">
  17. <view class="user-top" @click="choose">
  18. <view class="user-body">
  19. <view
  20. class="user-avatar"
  21. :class="pkInfo.accept_avatar ? '' : 'no-user'"
  22. :style="{ backgroundImage: `url(${pkInfo.accept_avatar || ''})` }"
  23. />
  24. <view class="user-title">应战者</view>
  25. </view>
  26. </view>
  27. <view class="user-bottom">{{ pkInfo.accept_nickname | getName }}</view>
  28. </view>
  29. </view>
  30. <view class="challenage-vs-main">
  31. <view class="title">挑战期限</view>
  32. <view class="count-time">{{ chooseLong }}天</view>
  33. <view class="accept-time">
  34. <template v-if="false">
  35. <view class="accept-time-text">应战倒计时:</view>
  36. <view class="accept-time-value">24:00:00</view>
  37. </template>
  38. </view>
  39. <view class="control-btns">
  40. <!-- <view class="btn">确定</view> -->
  41. <view v-if="type == 2" class="btn refuse" @click="reject">拒绝</view>
  42. <view v-if="type == 0 || type == 2" class="btn" @click="submit">{{ type == 0 ? '确定' : '应战' }}</view>
  43. <!-- <view class="btn">放弃挑战</view> -->
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { api_initiate_challenge, api_accept_challenge } from '@/api.js'
  50. export default {
  51. data() {
  52. return {
  53. pageTitle: '发起挑战',
  54. chooseLong: Math.abs(Number(this.$store.state.userServerInfo.day)),
  55. type: 0,
  56. pkInfo: {
  57. challenge_id: this.$store.state.userServerInfo.id,
  58. challenge_avatar: this.$store.state.userServerInfo.avatar,
  59. challenge_nickname: this.$store.state.userServerInfo.name,
  60. }
  61. }
  62. },
  63. filters: {
  64. getName(name) {
  65. if (name) {
  66. return name.length > 8 ? name.slice(0, 8) + '...' : name
  67. }
  68. return '选择应战人'
  69. },
  70. },
  71. onShow() {
  72. if (uni.pkInfo) {
  73. this.pkInfo = { ...this.pkInfo, ...uni.pkInfo }
  74. uni.pkInfo = null
  75. }
  76. },
  77. onLoad({ type }) {
  78. uni.hideLoading()
  79. if (type == 1) { // 我的挑战
  80. this.pageTitle = '我的挑战'
  81. this.type = 1
  82. }
  83. if (type == 2) { // 接受挑战
  84. this.pageTitle = '接受挑战'
  85. this.type = 2
  86. }
  87. },
  88. methods: {
  89. choose() { // 点击选择用户
  90. if (this.pageTitle === '发起挑战') {
  91. uni.navigateTo({ url: '../challengeChoose/challengeChoose' })
  92. }
  93. },
  94. reject() { // 拒绝挑战
  95. uni.showModal({ title: '提示', content: `确定拒绝${this.pkInfo.challenge_nickname}的挑战?` }).then(([, { confirm }]) => {
  96. if (confirm) {
  97. uni.loading()
  98. this.$ajax.get(`${api_accept_challenge}?id=${this.pkInfo.id}&type=1`).then(([, { data: { code, msg }}]) => {
  99. uni.hideLoading()
  100. if (code == 200) {
  101. uni.navigateBack()
  102. uni.$emit('RejectPK', this.pkInfo.id)
  103. } else {
  104. uni.showModal({ title: '提示', showCancel: false, content: msg })
  105. }
  106. })
  107. }
  108. })
  109. },
  110. submit() { // 提交挑战
  111. if (!this.pkInfo.accept_id) {
  112. // this.$refs.toast.hover('请选择挑战人', 3456, 'center')
  113. uni.showToast({ title: '请选择挑战人', duration: 2000, icon:"none"})
  114. return
  115. }
  116. if (!this.chooseLong) {
  117. // this.$refs.toast.hover('请选择挑战时长', 3456, 'center')
  118. uni.showToast({ title: '请选择挑战时长', duration: 2000, icon:"none"})
  119. return
  120. }
  121. if (this.type == 0) {
  122. uni.showModal({ title: '提示', content: `确定向${this.pkInfo.accept_nickname}发起挑战,期限${this.chooseLong}天?` }).then(([, { confirm }]) => {
  123. if (confirm) {
  124. uni.loading()
  125. this.$ajax.get(`${api_initiate_challenge}?id=${this.pkInfo.accept_id}`).then(([, { data: { code, msg }}]) => {
  126. uni.hideLoading()
  127. if (code == 200) {
  128. uni.navigateBack()
  129. uni.$emit('REDRESH')
  130. } else {
  131. uni.showModal({ title: '提示', showCancel: false, content: msg })
  132. }
  133. })
  134. }
  135. })
  136. } else if (this.type == 1) {
  137. console.log('放弃挑战')
  138. } else if (this.type == 2) {
  139. uni.showModal({ title: '提示', content: `确定接受${this.pkInfo.challenge_nickname}的挑战?` }).then(([, { confirm }]) => {
  140. if (confirm) {
  141. uni.loading()
  142. this.$ajax.get(`${api_accept_challenge}?id=${this.pkInfo.id}&type=0`).then(([, { data: { code, msg }}]) => {
  143. uni.hideLoading()
  144. if (code == 200) {
  145. uni.navigateBack()
  146. uni.$emit('AcceptPK', this.pkInfo.id)
  147. } else {
  148. uni.showModal({ title: '提示', showCancel: false, content: msg })
  149. uni.navigateBack()
  150. uni.$emit('REDRESH')
  151. }
  152. })
  153. }
  154. })
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. page {
  162. display: flex;
  163. flex-direction: column;
  164. .challenge-vs-container {
  165. flex: 1;
  166. overflow: hidden;
  167. background: url(../../static/new_challenge/bg.jpg) no-repeat top;
  168. background-size: 100%;
  169. .challenage-vs-users {
  170. width: 100%;
  171. height: 524rpx;
  172. position: relative;
  173. margin: 50rpx 0 28rpx 0;
  174. .user-fixed {
  175. position: absolute;
  176. .user-top {
  177. width: 259rpx;
  178. height: 122rpx;
  179. box-sizing: border-box;
  180. display: flex;
  181. align-items: center;
  182. margin-bottom: 20rpx;
  183. .user-body {
  184. width: 250rpx;
  185. height: 110rpx;
  186. display: flex;
  187. align-items: center;
  188. padding: 0 8rpx;
  189. box-sizing: border-box;
  190. .user-avatar {
  191. width: 90rpx;
  192. height: 90rpx;
  193. background-position: center;
  194. background-repeat: no-repeat;
  195. background-size: 100%;
  196. background-color: #FFFFFF;
  197. border-radius: 50%;
  198. overflow: hidden;
  199. &.no-user {
  200. position: relative;
  201. &::after, &::before {
  202. content: "";
  203. display: block;
  204. width: 56rpx;
  205. height: 6rpx;
  206. border-radius: 56rpx;
  207. position: absolute;
  208. top: 50%;
  209. left: 50%;
  210. background-color: #35B7FD;
  211. transform: translate(-50%, -50%);
  212. }
  213. &::after {
  214. transform: translate(-50%, -50%) rotate(90deg) !important;
  215. }
  216. }
  217. }
  218. .user-title {
  219. flex: 1;
  220. overflow: hidden;
  221. text-align: center;
  222. color: #FFFFFF;
  223. font-size: 32rpx;
  224. }
  225. }
  226. }
  227. .user-bottom {
  228. width: 260rpx;
  229. color: #FFFFFF;
  230. font-size: 28rpx;
  231. line-height: 40rpx;
  232. text-overflow: ellipsis;
  233. padding: 0 30rpx;
  234. box-sizing: border-box;
  235. }
  236. &.challenge-user {
  237. top: 0px;
  238. left: -1px;
  239. .user-top {
  240. border: 1px solid #FEC200;
  241. border-left: none;
  242. border-top-right-radius: 120rpx;
  243. border-bottom-right-radius: 120rpx;
  244. .user-body {
  245. background: linear-gradient(80deg, #FFC401 0%, #FE0000 100%);
  246. border-top-right-radius: 110rpx;
  247. border-bottom-right-radius: 110rpx;
  248. justify-content: flex-end;
  249. }
  250. }
  251. .user-bottom {
  252. text-align: left;
  253. }
  254. }
  255. &.accept-user {
  256. bottom: 0rpx;
  257. right: -1px;
  258. .user-top {
  259. border: 1px solid #71C6FB;
  260. border-right: none;
  261. border-top-left-radius: 120rpx;
  262. border-bottom-left-radius: 120rpx;
  263. justify-content: flex-end;
  264. .user-body {
  265. background: linear-gradient(112deg, #13AEFE 0%, #7BC9FB 100%);
  266. border-top-left-radius: 110rpx;
  267. border-bottom-left-radius: 110rpx;
  268. }
  269. }
  270. .user-bottom {
  271. text-align: right;
  272. }
  273. }
  274. }
  275. }
  276. .challenage-vs-main {
  277. display: flex;
  278. flex-direction: column;
  279. align-items: center;
  280. .title {
  281. color: #FFFFFF;
  282. font-size: 36rpx;
  283. line-height: 50rpx;
  284. margin-bottom: 46rpx;
  285. }
  286. .count-time {
  287. width: 304rpx;
  288. height: 90rpx;
  289. border-radius: 6rpx;
  290. background-color: #353235;
  291. color: #FFFFFF;
  292. font-size: 60rpx;
  293. line-height: 90rpx;
  294. text-align: center;
  295. margin-bottom: 90rpx;
  296. }
  297. .accept-time {
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. margin-bottom: 98rpx;
  302. .accept-time-text {
  303. color: #FFFFFF;
  304. font-size: 32rpx;
  305. line-height: 44rpx;
  306. }
  307. .accept-time-value {
  308. width: 222rpx;
  309. height: 62rpx;
  310. background-color: #F2DF42;
  311. color: #EA4A41;
  312. font-size: 36rpx;
  313. line-height: 62rpx;
  314. text-align: center;
  315. }
  316. }
  317. .control-btns {
  318. width: calc(100% - 250rpx);
  319. margin: 0 auto;
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. .btn {
  324. flex: 1;
  325. overflow: hidden;
  326. height: 96rpx;
  327. line-height: 96rpx;
  328. text-align: center;
  329. border-radius: 96rpx;
  330. background: linear-gradient(180deg, #FEEB71 0%, #F89018 100%);
  331. color: #984100;
  332. font-size: 32rpx;
  333. font-weight: bold;
  334. &:nth-last-of-type(1) {
  335. margin-left: 36rpx;
  336. }
  337. &.refuse {
  338. color: #333333 !important;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .new {
  346. @include page();
  347. .content {
  348. position: relative;
  349. .bg {
  350. width: 100%;
  351. height: calc(100% + 90rpx);
  352. margin-top: -90rpx ;
  353. }
  354. .person1, .person2 {
  355. left: 0;
  356. top: 201rpx;
  357. width:240rpx;
  358. height:120rpx;
  359. @include flex();
  360. position: absolute;
  361. justify-content: flex-start;
  362. border-radius:0rpx 57rpx 57rpx 0rpx;
  363. border:1rpx solid rgba(239,115,42,1);
  364. &.person2 {
  365. right: 0;
  366. left: auto;
  367. border-color: #C55AAE;
  368. justify-content: flex-end;
  369. border-radius:57rpx 0rpx 0rpx 57rpx;
  370. }
  371. .con {
  372. width:235rpx;
  373. height:110rpx;
  374. @include flex();
  375. background:rgba(239,115,42,1);
  376. border-radius:0rpx 55rpx 55rpx 0rpx;
  377. &.right {
  378. background:#C55AAE;
  379. border-radius:55rpx 0rpx 0rpx 55rpx;
  380. }
  381. .title {
  382. flex: 1;
  383. height: 100%;
  384. @include flex();
  385. color: #FFFFFF;
  386. font-size: 36rpx;
  387. }
  388. .avatar {
  389. margin: 6rpx;
  390. width: 100rpx;
  391. height: 100rpx;
  392. border-radius: 50%;
  393. }
  394. }
  395. }
  396. .person1Name, .person2Name {
  397. top: 331rpx;
  398. position: absolute;
  399. font-size: 32rpx;
  400. &.person1Name {
  401. left: 31rpx;
  402. color: #EF732A;
  403. }
  404. &.person2Name {
  405. right: 31rpx;
  406. color: #C55AAE;
  407. }
  408. }
  409. .centerTitle {
  410. bottom: 725rpx;
  411. left: 300rpx;
  412. font-size:36rpx;
  413. position: absolute;
  414. color: rgba(239,115,42,1);
  415. text-shadow: 0rpx 1rpx 0rpx rgba(173,74,16,0.75);
  416. }
  417. .timecountdown {
  418. bottom: 450rpx !important;
  419. width: 540rpx !important;
  420. font-size: 36rpx !important;
  421. letter-spacing: 10rpx;
  422. left: 50% !important;
  423. margin-left: -260rpx !important;
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. color: #EF732A !important;
  428. .black {
  429. background: #333333;
  430. padding: 2rpx 4rpx;
  431. }
  432. }
  433. .long {
  434. left: 256rpx;
  435. opacity: 0.5;
  436. width: 240rpx;
  437. height: 98rpx;
  438. bottom: 590rpx;
  439. font-size: 54rpx;
  440. font-weight:bold;
  441. position: absolute;
  442. color:rgba(239,115,42,1);
  443. text-shadow:0rpx 1rpx 0rpx rgba(173,74,16,0.75);
  444. background: rgba(254,234,177,1);
  445. box-shadow:0px 15px 20px 0px rgba(230, 41, 126, 0.35), 3px 4px 0px 0px rgba(255,255,255,0.5), -3px -4px 0px 0px rgba(212,152,0,0.5);
  446. &.nopicker {
  447. @include flex();
  448. }
  449. .num {
  450. width: 100%;
  451. height: 98rpx;
  452. @include flex();
  453. }
  454. }
  455. .submit {
  456. bottom: 135rpx;
  457. left: 195rpx;
  458. width:360rpx;
  459. height:98rpx;
  460. @include flex();
  461. font-size:36rpx;
  462. position: absolute;
  463. border-radius:49rpx;
  464. color:rgba(239,115,42,1);
  465. text-shadow:0rpx 1rpx 0rpx rgba(173,74,16,0.75);
  466. background: rgba(254,234,177,1);
  467. box-shadow:0rpx 15rpx 20rpx 0rpx rgba(230, 41, 126, 0.35), 3rpx 4rpx 0rpx 0rpx rgba(255,255,255,0.5), -3rpx -4rpx 0rpx 0rpx rgba(212,152,0,0.5);
  468. &.reject {
  469. bottom: 280rpx;
  470. color:rgba(102,102,102,1);
  471. text-shadow:0px 1px 0px rgba(173,74,16,0.75);
  472. }
  473. }
  474. }
  475. }
  476. </style>