userInfo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view class="container">
  3. <view class="contentBox">
  4. <view class="btoomBg"></view>
  5. <view class="topBg">
  6. <image class="topImg" src="../../static/img/img08.png" mode="widthFix"></image>
  7. <view class="tpConent">
  8. <view class="titleUser">
  9. <text>{{chargeUserItem.sub_id}}号</text>
  10. <test style='margin-left: 0.5em;'></test>
  11. <text>{{chargeUserItem.name}}</text>
  12. </view>
  13. <view class="userType flex">
  14. <image class="typeIcon" src="../../static/img/userinfoLeft.png" mode="widthFix"></image>
  15. <view class="typeItem">
  16. {{chargeUserItem.job}}
  17. </view>
  18. <image class="typeIcon" src="../../static/img/userinfoRight.png" mode="widthFix"></image>
  19. </view>
  20. <view class="tip">
  21. 正在参加:2022年度明星母婴工作者</br>
  22. 颍川杯海选赛</br>
  23. 诚邀您来投票
  24. </view>
  25. <view class="tjContent borderV flex">
  26. <view class="tjItem">
  27. <view class="topText">
  28. {{ chargeUserItem.vote }}
  29. <text class="iconTip"></text>
  30. </view>
  31. <view class="bottomText">投票</view>
  32. </view>
  33. <view class="tjItem">
  34. <view class="topText">
  35. {{ chargeUserItem.rank }}
  36. <text class="iconTip"></text>
  37. </view>
  38. <view class="bottomText">排名</view>
  39. </view>
  40. </view>
  41. <view class="userImg">
  42. <view class="imgBox">
  43. <image class="img" :src="chargeUserItem.avatar" mode="widthFix"></image>
  44. <view class="company clamp" v-if="chargeUserItem.type==2">
  45. {{chargeUserItem.company}}
  46. </view>
  47. </view>
  48. </view>
  49. <view class="detail borderV">
  50. 个人介绍
  51. </view>
  52. <view class="detailText">
  53. {{chargeUserItem.detail}}
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="alertAddBox flex">
  59. <view class="textAlertBox">
  60. <view class="psBox">
  61. <image class="psImgIcon" src="../../static/img/alertPIcon.png" mode="widthFix"></image>
  62. <text>{{ myVote }}</text>
  63. </view>
  64. <view>剩余票数</view>
  65. </view>
  66. <view class="addUser" @click="chargeConfirm">给TA投票</view>
  67. </view>
  68. <u-popup border-radius="20" v-model="showCharge" mode="bottom">
  69. <view class="alertChargeBox">
  70. <view class="alertCharge flex">
  71. <view class="chargeItem" :class="{ actionCharge: ind == moneyIndex }" v-for="(ls, ind) in voteNumList" @click="moneyIndex = ind">
  72. <view class="chargeImgIcon">{{ ls.num }}票</view>
  73. <view class="chargeImgBox"><image class="chargeImg" :src="'../../static/img/chargeIcon' + (ind + 1) + '.png'" mode="widthFix"></image></view>
  74. <view class="chargeTextBox flex">
  75. <image class="chargeIcon" src="../../static/img/moneyIcon.png" mode="scaleToFill"></image>
  76. <text>{{ ls.num }}</text>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="flex chargeButtom">
  81. <view class="left flex">
  82. <image class="chargeIcon" src="../../static/img/moneyIcon.png" mode="scaleToFill"></image>
  83. <text class="num">¥{{ payMoneyNum }}</text>
  84. <text class="tip">可为选手加{{ voteNumList[moneyIndex].num }}票</text>
  85. </view>
  86. <view class="right" @click="payLoding ? false : commitCharge()">赠送</view>
  87. </view>
  88. </view>
  89. </u-popup>
  90. </view>
  91. </template>
  92. <script>
  93. import { ptDetail, rechargeWechat, getItemInfo,ptPush } from '@/api/tp.js';
  94. import weixinObj from '@/plugin/jweixin-module/index.js';
  95. import { shareLoad } from '@/utils/wxAuthorized.js';
  96. import { share } from '@/api/wx';
  97. export default {
  98. data() {
  99. return {
  100. // 投票数列表
  101. voteNumList: [
  102. {
  103. num: 1
  104. },
  105. {
  106. num: 3
  107. },
  108. {
  109. num: 5
  110. },
  111. {
  112. num: 10
  113. },
  114. {
  115. num: 20
  116. },
  117. {
  118. num: 50
  119. },
  120. {
  121. num: 100
  122. },
  123. {
  124. num: 200
  125. }
  126. ],
  127. moneyIndex: 0, //当前选中的投票对象
  128. showCharge: false, //显示投票弹窗
  129. priceBl: 1, //默认1票对应金额投票比例
  130. chargeUserItem: {}, //当前选中的投票对象
  131. dayFree: '', //可投票数
  132. dayFreeVote: '', //已投票数
  133. payLoding: false, //是否微信充值
  134. activtyName: '', //活动标题
  135. erweima: '', //首页分享二维码
  136. uid: ''
  137. };
  138. },
  139. computed: {
  140. // 我剩余可投票数
  141. myVote() {
  142. return this.dayFree - this.dayFreeVote;
  143. },
  144. // 需要支付的金额
  145. payMoneyNum() {
  146. return this.voteNumList[this.moneyIndex].num * this.priceBl;
  147. }
  148. },
  149. onLoad(res) {
  150. // 保存当前用户信息
  151. this.uid = res.id;
  152. // 获取参赛用户信息
  153. this.getItemInfo();
  154. },
  155. onShow() {
  156. this.init();
  157. },
  158. methods: {
  159. loadShare() {
  160. // 请求获取默认数据
  161. shareLoad({
  162. link: window.location.href, // 分享链接
  163. imgUrl: this.chargeUserItem.avatar,
  164. desc:this.chargeUserItem.detail,
  165. title: this.chargeUserItem.name+'需要您的助力!',
  166. });
  167. },
  168. init() {
  169. this.ptDetail();
  170. },
  171. getItemInfo() {
  172. // 获取用户信息
  173. getItemInfo({}, this.uid)
  174. .then(e => {
  175. this.chargeUserItem = e.data.data;
  176. this.loadShare();
  177. console.log(e);
  178. })
  179. .catch(e => {
  180. console.log(e);
  181. });
  182. },
  183. //开始投票
  184. async commitCharge() {
  185. // 创建对象
  186. let payType, num;
  187. // 判断是否有剩余投票次数
  188. if (this.myVote > 0) {
  189. payType = 'free';
  190. num = 1;
  191. } else {
  192. payType = 'yue';
  193. num = this.voteNumList[this.moneyIndex].num;
  194. await this.payMoney();
  195. }
  196. uni.showLoading({
  197. title: '投票中',
  198. mask: true
  199. });
  200. ptPush(
  201. {
  202. num,
  203. payType
  204. },
  205. this.chargeUserItem.id
  206. )
  207. .then(e => {
  208. uni.hideLoading();
  209. if (e.msg == '余额支付成功' || e.msg == '投票成功') {
  210. uni.showToast({
  211. title: '投票成功!'
  212. });
  213. // 修改当前用户获得的票数
  214. this.chargeUserItem.vote += num;
  215. if (e.msg == '投票成功') {
  216. // 修改当前可投票数
  217. this.dayFree -= num;
  218. }
  219. } else {
  220. this.showCharge = false;
  221. uni.showModal({
  222. title: '错误',
  223. content: '余额不足请充值',
  224. success: res => {
  225. if (res.confirm) {
  226. uni.navigateTo({
  227. url: '/pages/recharge/pay'
  228. });
  229. }
  230. },
  231. fail: () => {},
  232. complete: () => {}
  233. });
  234. }
  235. })
  236. .catch(e => {
  237. uni.hideLoading();
  238. });
  239. },
  240. // 调用微信支付
  241. payMoney() {
  242. let obj = this;
  243. return new Promise((ok, err) => {
  244. if (obj.payLoding) {
  245. return;
  246. }
  247. obj.payLoding = true;
  248. rechargeWechat({ price: this.payMoneyNum, from: 'weixin' })
  249. .then(e => {
  250. let da = e.data.data;
  251. console.log(da);
  252. console.log(weixinObj, 'weixinObj');
  253. try {
  254. weixinObj.ready(() => {
  255. weixinObj.chooseWXPay({
  256. timestamp: da.timestamp,
  257. nonceStr: da.nonceStr,
  258. package: da.package,
  259. signType: da.signType,
  260. paySign: da.paySign,
  261. success: function(res) {
  262. console.log(res);
  263. ok(true);
  264. },
  265. fail: function(res) {
  266. console.log(res);
  267. err(false);
  268. }
  269. });
  270. });
  271. } catch (e) {
  272. console.log(e);
  273. }
  274. obj.payLoding = false;
  275. })
  276. .catch(e => {
  277. obj.payLoding = false;
  278. });
  279. });
  280. },
  281. // 投票弹窗
  282. chargeConfirm() {
  283. // 判断是否还有剩余投票次数
  284. if (this.myVote <= 0) {
  285. uni.showToast({
  286. title: '已无免费票数'
  287. });
  288. // this.showCharge = true;
  289. } else {
  290. this.commitCharge();
  291. }
  292. },
  293. // 请求返回项目数据
  294. ptDetail() {
  295. ptDetail()
  296. .then(e => {
  297. const data = e.data;
  298. this.priceBl = +data.price;
  299. this.dayFree = data.day_free; //可投免费票数
  300. this.dayFreeVote = data.today_free_vote_num; //已投免费 票数
  301. this.activtyName = data.title;
  302. })
  303. .catch(e => {
  304. console.log();
  305. });
  306. },
  307. // 页面跳转
  308. nextTo(url) {
  309. console.log(url, '跳转地址');
  310. uni.navigateTo({
  311. url,
  312. fail: e => {
  313. console.log(e);
  314. }
  315. });
  316. }
  317. }
  318. };
  319. </script>
  320. <style lang="scss">
  321. page,
  322. .container {
  323. height: auto;
  324. min-height: 100%;
  325. background-color: #ff9ba7;
  326. }
  327. .container {
  328. padding-top: 50rpx;
  329. padding-bottom: 130rpx;
  330. position: relative;
  331. }
  332. .alertChargeBox {
  333. .alertCharge {
  334. justify-content: flex-start;
  335. flex-wrap: wrap;
  336. padding: 30rpx;
  337. .chargeItem {
  338. width: 25%;
  339. text-align: center;
  340. position: relative;
  341. height: 180rpx;
  342. padding: 40rpx;
  343. margin: 20rpx 0;
  344. &.actionCharge {
  345. border: 1px solid #d7272b;
  346. border-radius: 10rpx;
  347. }
  348. .chargeImgIcon {
  349. position: absolute;
  350. top: 10rpx;
  351. right: 10rpx;
  352. font-size: 18rpx;
  353. font-weight: bold;
  354. color: #ffffff;
  355. border-top-right-radius: 90rpx;
  356. border-top-left-radius: 90rpx;
  357. border-bottom-right-radius: 90rpx;
  358. padding: 5rpx 15rpx;
  359. background-color: #d7272b;
  360. }
  361. .chargeTextBox {
  362. position: absolute;
  363. bottom: 10rpx;
  364. right: 0;
  365. left: 0;
  366. justify-content: center;
  367. color: #223438;
  368. font-size: 24rpx;
  369. text-align: center;
  370. .chargeIcon {
  371. width: 35rpx;
  372. height: 35rpx;
  373. margin-right: 10rpx;
  374. }
  375. }
  376. .chargeImgBox {
  377. .chargeImg {
  378. width: 77rpx;
  379. }
  380. }
  381. }
  382. }
  383. .chargeButtom {
  384. padding: 30rpx;
  385. background-color: #fff6f6;
  386. .left {
  387. font-weight: bold;
  388. flex-grow: 1;
  389. justify-content: flex-start;
  390. .chargeIcon {
  391. width: 40rpx;
  392. height: 40rpx;
  393. }
  394. .num {
  395. margin-left: 10rpx;
  396. color: #16363a;
  397. font-size: 30rpx;
  398. }
  399. .tip {
  400. margin-left: 10rpx;
  401. color: #d82a2e;
  402. font-size: 24rpx;
  403. }
  404. }
  405. .right {
  406. background-color: #d7272b;
  407. color: #ffffff;
  408. border-radius: 99rpx;
  409. padding: 5rpx 40rpx;
  410. font-size: 26rpx;
  411. }
  412. }
  413. }
  414. .alertAddBox {
  415. background: #ff9ba7;
  416. position: fixed;
  417. bottom: 0;
  418. left: 0;
  419. right: 0;
  420. padding: 20rpx 30rpx;
  421. z-index: 1;
  422. .textAlertBox {
  423. flex-shrink: 0;
  424. text-align: center;
  425. font-size: 28rpx;
  426. color: #ffffff;
  427. padding-right: 20rpx;
  428. .psBox {
  429. font-size: 40rpx;
  430. font-weight: bold;
  431. .psImgIcon {
  432. margin-right: 10rpx;
  433. width: 30rpx;
  434. }
  435. }
  436. }
  437. .addUser {
  438. flex-grow: 1;
  439. background: #d7272b;
  440. border: 1px solid #170911;
  441. border-radius: 7px;
  442. line-height: 1;
  443. font-size: 31rpx;
  444. font-weight: bold;
  445. color: #ffffff;
  446. text-align: center;
  447. padding: 30rpx;
  448. line-height: 24rpx;
  449. }
  450. }
  451. .topImg {
  452. width: 100%;
  453. }
  454. .contentBox {
  455. position: relative;
  456. width: 0px;
  457. min-width: 100%;
  458. margin-bottom: 32rpx;
  459. .btoomBg {
  460. background-color: #ffffff;
  461. min-height: 50vh;
  462. height: 100%;
  463. position: absolute;
  464. top: 32rpx;
  465. right: 30rpx;
  466. left: 42rpx;
  467. }
  468. .topBg {
  469. position: relative;
  470. margin-left: 30rpx;
  471. margin-right: 42rpx;
  472. box-shadow: 3px 5rpx 3rpx 0rpx rgba(4, 0, 0, 0.15);
  473. line-height: 0;
  474. min-height: 100%;
  475. .leftIcon {
  476. position: absolute;
  477. top: 30rpx;
  478. left: -30rpx;
  479. width: 100rpx;
  480. }
  481. .tpConent {
  482. background: #ffffff;
  483. line-height: 1;
  484. min-height: 50vh;
  485. padding-top: 15px;
  486. padding-bottom: 11px;
  487. .detail{
  488. color: #333333;
  489. font-size: 32rpx;
  490. text-align: center;
  491. font-weight: bold;
  492. padding: 30rpx 0;
  493. }
  494. .detailText{
  495. line-height: 1.5;
  496. padding: 30rpx;
  497. color: #666666;
  498. }
  499. .userImg{
  500. padding: 40rpx 30rpx;
  501. text-align: center;
  502. .imgBox{
  503. position: relative;
  504. width: 100%;
  505. height: 100%;
  506. // padding-top: 100%;
  507. .img{
  508. // position: absolute;
  509. // top: 0;
  510. // left: 0;
  511. width: 100%;
  512. height: 100%;
  513. }
  514. .company{
  515. position: absolute;
  516. bottom: 0;
  517. left: 0;
  518. right: 0;
  519. background: #262626;
  520. opacity: 0.6;
  521. color: #ffffff;
  522. font-size: 30rpx;
  523. padding: 10rpx 0;
  524. text-align: center;
  525. line-height: 1.5;
  526. }
  527. }
  528. }
  529. .tip{
  530. color: rgb(1, 9, 172);
  531. text-align: center;
  532. font-size: 26rpx;
  533. font-weight: bold;
  534. padding:30rpx ;
  535. line-height: 1.5;
  536. }
  537. .userType{
  538. color:#FFC103 ;
  539. font-weight: bold;
  540. padding-top: 32rpx;
  541. justify-content: center;
  542. .typeIcon{
  543. width:120rpx ;
  544. }
  545. .typeItem{
  546. padding: 0 1em;
  547. }
  548. }
  549. .titleUser{
  550. padding-top: 50rpx;
  551. color:#d7272b;
  552. font-size: 50rpx;
  553. font-weight: bold;
  554. text-align: center;
  555. }
  556. .borderV{
  557. border-top: 1px solid #f3f3f3;
  558. border-bottom: 1px solid #f3f3f3;
  559. }
  560. .tjContent {
  561. margin-top: 10rpx;
  562. padding-top: 30rpx;
  563. padding-bottom: 30rpx;
  564. justify-content: space-around;
  565. text-align: center;
  566. .tjItem {
  567. .topText {
  568. font-size: 50rpx;
  569. font-weight: bold;
  570. color: #d7272b;
  571. .iconTip {
  572. font-size: 20rpx;
  573. }
  574. }
  575. .bottomText {
  576. margin-top: 10rpx;
  577. font-size: 24rpx;
  578. font-family: PingFang SC;
  579. font-weight: 500;
  580. color: #333333;
  581. }
  582. }
  583. }
  584. }
  585. }
  586. }
  587. /deep/ .u-countdown-item {
  588. padding: 10rpx;
  589. border-radius: 8rpx;
  590. overflow: hidden;
  591. }
  592. .alertBox {
  593. padding-bottom: 40rpx;
  594. .titleImg {
  595. width: 100%;
  596. z-index: -1;
  597. }
  598. .title {
  599. text-align: center;
  600. font-size: 36rpx;
  601. font-weight: bold;
  602. color: #333333;
  603. margin-top: -80rpx;
  604. }
  605. .titleTip {
  606. text-align: center;
  607. font-size: 24rpx;
  608. font-weight: bold;
  609. color: #808080;
  610. }
  611. .lxTtem {
  612. margin: 0 40rpx;
  613. padding: 30rpx 0;
  614. border-bottom: 1px solid #ebebeb;
  615. .leftTitle {
  616. justify-content: start;
  617. width: 43rpx;
  618. flex-grow: 1;
  619. color: #333333;
  620. font-size: 28rpx;
  621. .leftImgTip {
  622. flex-shrink: 0;
  623. // width: 30rpx;
  624. height: 30rpx;
  625. margin-right: 20rpx;
  626. }
  627. }
  628. .rightTip {
  629. border: 1px solid #d7272b;
  630. opacity: 0.5;
  631. border-radius: 50%;
  632. width: 32rpx;
  633. height: 32rpx;
  634. justify-content: center;
  635. .xzTip {
  636. width: 20rpx;
  637. height: 20rpx;
  638. border-radius: 99rpx;
  639. background-color: #d7272b;
  640. }
  641. }
  642. }
  643. .pushtyle {
  644. background: #d7272b;
  645. box-shadow: 0px 16rpx 16rpx 0px rgba(215, 39, 43, 0.5);
  646. border-radius: 10rpx;
  647. color: #ffffff;
  648. font-size: 28rpx;
  649. font-weight: bold;
  650. text-align: center;
  651. padding: 20rpx 0;
  652. margin: 0 40rpx;
  653. margin-top: 40rpx;
  654. }
  655. }
  656. </style>