userInfo.vue 14 KB

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