index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <view class="wrap">
  3. <u-navbar :autoBack="true" title="答题" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <view class="logo" @click="onStart">
  5. <image :src="topImage || 'https://huli-app.wenlvti.net/app_static/minnanhun/image/lb_3.jpg'" mode="widthFix"></image>
  6. </view>
  7. <!-- <view class="main" v-if="hasLoad"> -->
  8. <view class="main">
  9. <view>
  10. <u-popup :show="show" :round="10" mode="center" bgColor="#fdfff3" @close="close" @open="open">
  11. <view>
  12. <text class="b-content">{{ examineData.rule_content }}</text>
  13. </view>
  14. </u-popup>
  15. </view>
  16. <view class="user-info">
  17. <!-- 名次头像 -->
  18. <view style="display: flex; justify-content: space-between; align-items: center">
  19. <view v-if="selfData.ranking < 100" style="display: flex; justify-content: space-between; align-items: center; margin-right: 10rpx">
  20. <view class="s-tit1">第</view>
  21. <view class="s-num" style="color: #da5650; font-size: 40rpx; font-weight: 700">{{ selfData.ranking }}</view>
  22. <view class="s-tit2">名</view>
  23. </view>
  24. <view v-else style="color: #da5650; font-size: 30rpx; font-weight: 700">未上榜</view>
  25. <view class="b-avatar">
  26. <image :src="selfData.avatar_url || 'https://huli-app.wenlvti.net/app_static/minnanhun/image/lb_3.jpg'" mode="aspectFill"></image>
  27. </view>
  28. <!-- 分数 -->
  29. <view class="b-score" v-if="examineData.max_sid > 0" @click="onGoLast('max', examineData.max_sid)">
  30. <!-- 暂时注释显示undefind -->
  31. <text class="s-score">{{ selfData.match_score ? selfData.match_score : selfData.max_score }}分</text>
  32. <!-- 暂时注释 -->
  33. <!-- <text class="s-tit">{{ costTime(selfData.cost_time) }}</text> -->
  34. </view>
  35. </view>
  36. <!-- 名次头像end -->
  37. <!--
  38. <view class="b-info">
  39. <view class="s-name">{{ selfData.name }}</view>
  40. </view> -->
  41. <view style="display: flex; flex-direction: column">
  42. <u-button customStyle="width:136rpx" open-type="share" @click="shareBtn" shape="circle" size="small" text="分享" color="#da5650"></u-button>
  43. </view>
  44. </view>
  45. <view class="examine">
  46. <view class="b-chance">
  47. <view class="s-tit" style="margin-left: 30rpx">答题机会</view>
  48. <view class="s-flag">×</view>
  49. <view class="s-num">{{ examineData.challenge_chance }}</view>
  50. <button @click="show = true" size="mini" style="font-size: 28upx; color: #da5650; margin-left: 250rpx">答题规则</button>
  51. </view>
  52. <view class="b-start disable" v-if="examineData.activity_status == 0">答题未开始</view>
  53. <template v-else-if="examineData.activity_status == 1">
  54. <view class="b-start" :class="{ disable: disable.submit }" @click="onContinue" v-if="examineData.session_data && examineData.session_data.status == 1">
  55. 继续答题
  56. </view>
  57. <view class="b-start" :class="{ disable: disable.submit }" @click="onStart" v-else-if="examineData.challenge_chance > 0">
  58. {{ examineData.last_sid > 0 ? '重新答题' : '开始答题' }}
  59. </view>
  60. <view class="b-start disable" v-else>完成答题</view>
  61. </template>
  62. <view class="b-start disable" v-else-if="examineData.activity_status == 2">答题已结束</view>
  63. <view class="b-start f-finish" style="color: #da5650" v-if="examineData.last_sid > 0" @click="onGoLast('last', examineData.last_sid)">上次成绩</view>
  64. </view>
  65. <view class="top-data">
  66. <view class="b-tit" style="font-size: 30rpx; color: #ff0000; margin-left: 20rpx">排 行 榜</view>
  67. <view style="height: 20rpx"></view>
  68. <scroll-view class="top-scroll" scroll-y scroll-with-animation :lower-threshold="100" @scrolltolower="onScrollToLower" :style="{ height: scrollHeight + 'px' }">
  69. <!-- 数据列表排行榜 -->
  70. <view class="user-list">
  71. <view class="b-item" v-for="(item, index) in userData.ranking_list" :key="index">
  72. <view class="b-sort">
  73. <image
  74. :src="'https://huli-app.wenlvti.net/app_static/wuyuan/static/static/imgs/top_' + item.ranking + '.png'"
  75. mode="aspectFit"
  76. v-if="item.ranking < 4"
  77. ></image>
  78. <text v-else>{{ item.ranking }}</text>
  79. </view>
  80. <view class="b-avatar">
  81. <image :src="item.avatar_url || 'https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/bm_top.png'" mode="aspectFill"></image>
  82. </view>
  83. <view class="b-user">
  84. <view class="s-name">{{ item.name }}</view>
  85. </view>
  86. <view class="b-data">
  87. <!-- 暂时注释显示undefind -->
  88. <view class="s-score">{{ item.match_score ? item.match_score : item.max_score }}分</view>
  89. <!-- 暂时注释显示 -->
  90. <!-- <view class="s-time">{{ costTime(item.cost_time) }}</view> -->
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 加载中 -->
  95. <load-more :loadingsType="loadingsType" :loadingsText="loadingsText"></load-more>
  96. </scroll-view>
  97. </view>
  98. <!-- <view style="height: 100rpx"></view> -->
  99. <!-- <view class="rules">
  100. <view class="b-tit">答题规则</view>
  101. <text class="b-content">{{examineData.rule_content}}</text>
  102. </view> -->
  103. </view>
  104. <!-- </view> -->
  105. <view class="bottom_show" v-if="shareUserData.user_id">
  106. <view v-if="shareUserData.ranking < 100" style="display: flex; justify-content: space-between; align-items: center; margin-right: 30rpx">
  107. <view class="s-tit1">第</view>
  108. <view class="s-num" style="color: #da5650; font-size: 40rpx; font-weight: 700">{{ shareUserData.ranking }}</view>
  109. <view class="s-tit2">名</view>
  110. </view>
  111. <view v-else style="color: #da5650; font-size: 30rpx; font-weight: 700; margin-right: 30rpx">未上榜</view>
  112. <view class="b-avatar" style="width: 100upx; height: 100upx">
  113. <image
  114. style="width: 100upx; height: 100upx; border-radius: 50%"
  115. :src="shareUserData.avatar_url || 'https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/bm_top.png'"
  116. mode="aspectFill"
  117. ></image>
  118. </view>
  119. <view style="margin-right: 50rpx; margin-left: 30rpx">{{ shareUserData.name }}</view>
  120. <view class="">
  121. <view class="">
  122. <text class="" style="color: #da5650">{{ shareUserData.match_score ? shareUserData.match_score : shareUserData.max_score }}分</text>
  123. <view class=""></view>
  124. </view>
  125. </view>
  126. <view class="gui-margin">
  127. <button type="default" class="gui-button gui-gtbg-red gui-noborder button" style="width: 100rpx" @click="toLike">
  128. <text class="gui-color-white gui-button-text gui-icons button-text">&#xe6ea;点赞</text>
  129. </button>
  130. </view>
  131. </view>
  132. <!-- 加载中 -->
  133. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  134. <!-- 上传头像 -->
  135. <upload-avatar :show="display.avatarChange" :image="userInfo.avatar_url" @bindClose="onAvatarClose" @bindChange="onAvatarChange"></upload-avatar>
  136. </view>
  137. </template>
  138. <script>
  139. import { getHomeData } from '@/service/api/page.js';
  140. import { startChallenge, getRankingList, getNew, userShare } from '@/service/api/examine.js';
  141. // 暂时注释可以正常显示页面
  142. // import mixinsCommon from '@/mixins/common.js';
  143. // import mixinsAuth from '../../mixins/auth.js';
  144. import Util from '../../common/util';
  145. export default {
  146. // mixins: [mixinsCommon, mixinsAuth],
  147. data() {
  148. return {
  149. SharerId: '' /* 分享人的id */,
  150. userInfo: {},
  151. show: false,
  152. topData: {},
  153. examineData: {},
  154. hasLoad: false,
  155. loadingType: 1,
  156. loadingText: '',
  157. disable: {
  158. submit: false
  159. },
  160. display: {
  161. avatarChange: false
  162. },
  163. loadingsType: 1,
  164. loadingsText: '',
  165. userData: {
  166. ranking_list: []
  167. },
  168. selfData: {},
  169. shareUserData: {},
  170. refreshTime: 0,
  171. scrollHeight: 100,
  172. from_userid: 0
  173. };
  174. },
  175. onLoad(e) {
  176. console.log(e, 989898989);
  177. this.SharerId = e.SharerId;
  178. this.initScrollHeight();
  179. this.refreshTime = Util.getTimestamp();
  180. // 暂时注释3月12
  181. this.loadRankingList(e.from_userid);
  182. this.loadHomeData();
  183. if (e.from_userid) {
  184. this.from_userid = e.from_userid;
  185. }
  186. },
  187. computed: {
  188. topImage() {
  189. return this.$store.getters.globalConfig.home_top_img;
  190. }
  191. },
  192. methods: {
  193. /* 测试分享功能 */
  194. shareBtn() {
  195. // console.log(this.SharerId, '33333333');
  196. uni.share({
  197. provider: 'weixin',
  198. type: 0,
  199. scene: 'WXSceneSession',
  200. title: '分享标题',
  201. summary: '分享摘要',
  202. id: this.SharerId,
  203. href: 'http://example.com',
  204. imageUrl: 'https://huli-app.wenlvti.net//uploads/20230424/e3a3e0dccdc71d5ad6aab5a42fcfd1d1.jpg',
  205. success: function () {
  206. console.log('分享成功');
  207. },
  208. fail: function (err) {
  209. console.log('分享失败:' + err.errMsg);
  210. }
  211. });
  212. },
  213. open() {
  214. // console.log('open');
  215. },
  216. close() {
  217. this.show = false;
  218. // console.log('close');
  219. },
  220. loadHomeData() {
  221. getHomeData().then(([err, res]) => {
  222. console.log('getHomeData', err, res);
  223. if (!err) {
  224. this.hasLoad = true;
  225. this.loadingType = -1;
  226. this.userInfo = res.userInfo;
  227. this.topData = res.topData;
  228. this.examineData = res.examineData;
  229. if (!this.userInfo.avatar_url) {
  230. if (!this.$store.getters['user/uploadAvatarTip']) {
  231. this.$store.commit('user/setUploadAvatarTip', true);
  232. this.display.avatarChange = true;
  233. }
  234. }
  235. } else {
  236. if (!this.hasLoad) {
  237. this.loadingType = 3;
  238. this.loadingText = err.data.msg || '加载失败';
  239. }
  240. }
  241. });
  242. },
  243. loadRankingList(share_user_id) {
  244. // if (refresh) {
  245. // this.page = 1;
  246. // this.userData.ranking_list = [];
  247. // } else {
  248. // this.page++;
  249. // }
  250. this.loadingsType = 1;
  251. this.loadingsText = '';
  252. getRankingList(share_user_id).then(([err, res]) => {
  253. console.log('getRankingList66', err, res);
  254. this.loadingsType = -1;
  255. this.hasLoad = true;
  256. this.userData.ranking_list = res.ranking_list;
  257. console.log(this.userData.ranking_list, '成绩列表');
  258. this.selfData = res.self;
  259. console.log(this.selfData, '分数');
  260. this.shareUserData = res.share_user;
  261. //刷新重复出现,数据太少的原因?
  262. // if (!err) {
  263. // if (res.ranking_list.length > 0) {
  264. // this.userData.ranking_list = [...this.userData.ranking_list, ...res.ranking_list]
  265. // } else {
  266. // this.loadingsType = 2
  267. // if (this.page == 1) {
  268. // this.loadingsText = '暂无数据'
  269. // }
  270. // this.page-- // 重置分页
  271. // }
  272. // } else {
  273. // this.loadingsType = 3
  274. // }
  275. });
  276. },
  277. toLike() {
  278. let param = {
  279. share_user_id: 0
  280. };
  281. if (this.from_userid > 0) {
  282. param.share_user_id = this.from_userid;
  283. }
  284. userShare(param.share_user_id).then(([err, res]) => {
  285. console.log('userShare', err, res);
  286. });
  287. },
  288. onStart() {
  289. uni.navigateTo({
  290. url: '/answer_pages/examine/summary'
  291. });
  292. // 暂时注释3月12
  293. if (this.disable.submit) {
  294. return;
  295. }
  296. this.disable.submit = true;
  297. startChallenge().then(([err, res]) => {
  298. console.log('startChallenge', err, res);
  299. this.disable.submit = false;
  300. if (!err) {
  301. if (res.state === 'new' || res.state === 'exist') {
  302. uni.navigateTo({
  303. url: '/answer_pages/examine/answer?session_id=' + res.session_id + '&activity_type=' + this.examineData.activity_type
  304. });
  305. } else if (res.state === 'end') {
  306. uni.navigateTo({
  307. url: '/answer_pages/examine/summary?session_id=' + res.session_id + '&activity_type=' + this.examineData.activity_type
  308. });
  309. }
  310. }
  311. });
  312. },
  313. onContinue() {
  314. uni.navigateTo({
  315. url: '/answer_pages/examine/answer?session_id=' + this.examineData.session_data.session_id + '&activity_type=' + this.examineData.activity_type
  316. });
  317. },
  318. onGoTop(groupId) {
  319. this.$store.commit('examine/setTopGroupId', groupId);
  320. uni.navigateTo({
  321. url: '/answer_pages/examine/top'
  322. });
  323. },
  324. onGoLast(from, sessionId) {
  325. if (!sessionId) {
  326. return;
  327. }
  328. uni.navigateTo({
  329. url: '/answer_pages/examine/summary?from=' + from + '&session_id=' + sessionId
  330. });
  331. },
  332. onAvatarClose() {
  333. this.display.avatarChange = false;
  334. },
  335. onAvatarChange(avatarUrl) {
  336. this.userInfo.avatar_url = avatarUrl;
  337. },
  338. onFilter(e) {
  339. this.loadRankingList(true);
  340. },
  341. initScrollHeight() {
  342. const systemInfo = uni.getSystemInfoSync();
  343. const windowHeight = systemInfo.windowHeight;
  344. const searchBarHeight = this.$logic.rpx2px(360);
  345. this.scrollHeight = windowHeight - searchBarHeight;
  346. },
  347. onScrollToLower(e) {
  348. this.loadRankingList(false);
  349. }
  350. }
  351. };
  352. </script>
  353. <style>
  354. .logo image {
  355. width: 100%;
  356. height: 460upx;
  357. }
  358. .wrap {
  359. width: 100%;
  360. padding-bottom: 50rpx;
  361. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xy_bgt.png');
  362. background-size: 100% 100%;
  363. background-attachment: fixed;
  364. background-repeat: repeat-y;
  365. height: auto;
  366. }
  367. .main {
  368. padding: 40upx;
  369. }
  370. .user-info {
  371. padding: 0 30upx 0 20upx;
  372. display: flex;
  373. align-items: center;
  374. background: #ffffff;
  375. border-radius: 20upx;
  376. justify-content: space-between;
  377. }
  378. .user-info .b-avatar {
  379. width: 100upx;
  380. height: 100upx;
  381. }
  382. .user-info .b-avatar image {
  383. width: 100upx;
  384. height: 100upx;
  385. border-radius: 50%;
  386. }
  387. .user-info .b-info {
  388. margin-left: 10upx;
  389. flex: 1;
  390. display: flex;
  391. flex-direction: column;
  392. }
  393. .user-info .b-info .s-name {
  394. font-size: 28upx;
  395. }
  396. .user-info .b-info .s-org {
  397. margin-top: 10upx;
  398. padding: 0 20upx;
  399. width: fit-content;
  400. background: #da5650;
  401. border-radius: 10upx;
  402. color: #fff;
  403. line-height: 20px;
  404. height: 20px;
  405. font-size: 24upx;
  406. text-align: center;
  407. }
  408. .user-info .b-score {
  409. margin-left: 15upx;
  410. margin-right: 10upx;
  411. display: flex;
  412. align-items: center;
  413. text-align: center;
  414. color: #ffc300;
  415. }
  416. .user-info .b-score .s-score {
  417. font-size: 32upx;
  418. font-weight: bold;
  419. }
  420. .user-info .b-score .s-tit {
  421. margin-top: 10upx;
  422. font-size: 24upx;
  423. color: #999;
  424. }
  425. .examine {
  426. margin-top: 40upx;
  427. }
  428. .examine .b-chance {
  429. display: flex;
  430. align-items: center;
  431. justify-content: center;
  432. }
  433. .examine .b-chance .s-tit {
  434. font-size: 26upx;
  435. color: #808080;
  436. }
  437. .examine .b-chance .s-flag {
  438. margin: 0 10upx;
  439. font-size: 26upx;
  440. color: #808080;
  441. }
  442. .examine .b-chance .s-num {
  443. font-size: 36upx;
  444. color: #da5650;
  445. font-weight: bold;
  446. }
  447. .examine .b-start {
  448. margin-top: 20upx;
  449. height: 100upx;
  450. line-height: 100upx;
  451. text-align: center;
  452. color: #fff;
  453. font-size: 32upx;
  454. background: #da5650;
  455. border-radius: 50upx;
  456. letter-spacing: 10upx;
  457. }
  458. .examine .b-start.disable {
  459. background: rgba(218, 86, 80, 0.8);
  460. }
  461. .examine .b-start.f-finish {
  462. font-size: 28upx;
  463. background: #ffffff;
  464. color: #da5650;
  465. }
  466. .top-data {
  467. margin-top: 40upx;
  468. }
  469. .top-data .b-tit {
  470. font-size: 28upx;
  471. font-weight: bold;
  472. }
  473. .top-data .b-main {
  474. display: flex;
  475. align-items: center;
  476. justify-content: space-between;
  477. flex-wrap: wrap;
  478. }
  479. .top-data .b-main .b-item {
  480. margin-top: 20upx;
  481. padding: 30upx;
  482. width: 260upx;
  483. background: #ffffff;
  484. border-radius: 20upx;
  485. display: flex;
  486. align-items: center;
  487. }
  488. .top-data .b-main .b-item .b-top {
  489. flex: 1;
  490. display: flex;
  491. align-items: center;
  492. }
  493. .top-data .b-main .b-item .b-top .s-tit1,
  494. .top-data .b-main .b-item .b-top .s-tit2 {
  495. font-size: 26upx;
  496. color: #808080;
  497. }
  498. .top-data .b-main .b-item .b-top .s-num {
  499. margin: 0 20upx;
  500. font-size: 32upx;
  501. color: #da5650;
  502. }
  503. .top-data .b-main .b-item .b-more .iconfont {
  504. font-size: 30upx;
  505. color: #ccc;
  506. }
  507. .rules {
  508. margin-top: 50upx;
  509. padding: 30upx;
  510. background: #ffffff;
  511. border-radius: 20upx;
  512. }
  513. .rules .b-tit {
  514. color: #da5650;
  515. font-size: 30upx;
  516. }
  517. .rules .b-content {
  518. margin-top: 20upx;
  519. display: block;
  520. color: #383838;
  521. font-size: 24upx;
  522. line-height: 40upx;
  523. }
  524. .user-list {
  525. padding: 40upx 40upx 20upx 10upx;
  526. }
  527. .user-list .b-item {
  528. margin-bottom: 50upx;
  529. height: 100upx;
  530. display: flex;
  531. align-items: center;
  532. justify-content: space-between;
  533. }
  534. .user-list .b-item:last-child {
  535. margin-bottom: 0;
  536. }
  537. .user-list .b-item .b-sort {
  538. width: 100upx;
  539. display: flex;
  540. justify-content: center;
  541. align-items: center;
  542. }
  543. .user-list .b-item .b-sort text {
  544. font-size: 36upx;
  545. color: #808080;
  546. }
  547. .user-list .b-item .b-sort image {
  548. width: 60upx;
  549. height: 60upx;
  550. }
  551. .user-list .b-item .b-avatar {
  552. width: 100upx;
  553. height: 100upx;
  554. }
  555. .user-list .b-item .b-avatar image {
  556. width: 100upx;
  557. height: 100upx;
  558. border-radius: 50%;
  559. }
  560. .user-list .b-item .b-user {
  561. margin-left: 20upx;
  562. flex: 1;
  563. display: flex;
  564. flex-direction: column;
  565. }
  566. .user-list .b-item .b-user .s-name {
  567. font-size: 32upx;
  568. }
  569. .user-list .b-item .b-user .s-org {
  570. margin-top: 10upx;
  571. font-size: 26upx;
  572. color: #a6a6a6;
  573. }
  574. .user-list .b-item .b-data {
  575. display: flex;
  576. flex-direction: column;
  577. align-items: flex-end;
  578. }
  579. .user-list .b-item .b-data .s-score {
  580. color: #ffc300;
  581. font-size: 40upx;
  582. }
  583. .user-list .b-item .b-data .s-time {
  584. margin-top: 10upx;
  585. color: #a6a6a6;
  586. font-size: 24upx;
  587. }
  588. button::after {
  589. border: none;
  590. }
  591. </style>