耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

563 lines
12 KiB

  1. <template>
  2. <view class="pages">
  3. <!-- 头部标题 -->
  4. <view class="title">
  5. <text class="title_text">充值</text>
  6. <view class="icon" @click="toDetale">
  7. <text>充值明细</text>
  8. <u-icon name="arrow-right"></u-icon>
  9. </view>
  10. </view>
  11. <!-- 选择区域 -->
  12. <view class="card">
  13. <view v-for="(item,index) in list" :key="index" class="item_box">
  14. <view :class="index == status? 'item select_item ': 'item' " @click="selectItem(index)"
  15. v-if="item.role == -1">
  16. <u-icon v-show="index == status" size='20' name="checkmark-circle-fill"></u-icon>
  17. <view class="position_text">
  18. <image class="image_img" :src="IMG_URL +'special_bg.png'" mode=""></image>
  19. <text v-if="item.wallet !== null"
  20. class=" text-center m-t-10 position_t">{{item.title? item.title:"今日充值特惠"}}</text>
  21. </view>
  22. <!-- <text v-if="item.wallet !== null" class="font-36 text-center m-t-10 position_text" >{{item.title? item.title:"今日充值特惠"}}</text> -->
  23. <view class=" up m-t-30">
  24. <text class="text_up"></text>
  25. <text class="num">{{item.wallet}}</text>
  26. <text class="text_give"></text>
  27. <text class="num">{{item.getMoney+ item.getInteger}}</text>
  28. </view>
  29. <!-- <view class="give">
  30. <text class="text_give"></text>
  31. <text class="num">{{item.getMoney+ item.getInteger}}</text>
  32. </view> -->
  33. <text class="alt">{{'('+item.getMoney+'消费金+'+item.getInteger +'兑购金)'}}</text>
  34. <view class="time" v-if="item.endTime !== null && item.type == 1">
  35. <text>活动结束时间</text>
  36. <text>{{item.endTime}}</text>
  37. </view>
  38. </view>
  39. <view :class="index == status? 'item select_item ': 'item' " @click="selectItem(index)"
  40. v-if="userInfo.level == item.role">
  41. <u-icon v-show="index == status" size='20' name="checkmark-circle-fill"></u-icon>
  42. <text v-if="item.endTime !== null"
  43. class="font-36 text-center m-t-10 position_text">{{item.title? item.title:"今日充值特惠"}}</text>
  44. <view class="up m-t-30">
  45. <text class="text_up"></text>
  46. <text class="num">{{item.wallet}}</text>
  47. <text class="text_give"> </text>
  48. <text class="num">{{item.getMoney+ item.getInteger}}</text>
  49. </view>
  50. <!-- <view class="give">
  51. <text class="text_give"></text>
  52. <text class="num">{{item.getMoney+ item.getInteger}}</text>
  53. </view> -->
  54. <text class="alt">{{'('+item.getMoney+'消费金+'+item.getInteger +'兑购金)'}}</text>
  55. <view class="time" v-if="item.endTime !== null && item.type == 1">
  56. <text>活动结束时间</text>
  57. <text>{{item.endTime}}</text>
  58. </view>
  59. <text
  60. class="alt text-red">多得实惠{{ (item.getMoney+ item.getInteger - item.wallet).toFixed(2)}}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 充值说明 -->
  65. <view class="explain">
  66. <text class="explain_title">{{agreementInfo.title}}</text>
  67. <rich-text :nodes="agreementInfo.content"></rich-text>
  68. <!-- <text >1{{}}</text> -->
  69. </view>
  70. <!-- 充值福利 -->
  71. <!-- <view class="welfare">
  72. <view class="welfare_title">
  73. <text></text>
  74. <text></text>
  75. <text></text>
  76. <text></text>
  77. </view>
  78. <view :class="'item bg'+index" v-for="(item,index) in welfareList" :key="index">
  79. <view class="title_box">
  80. <u-icon name="play-right-fill"></u-icon>
  81. <text class="item_title">{{item.title}}</text>
  82. </view>
  83. <text>{{item.textlist[0]}}</text>
  84. <text>{{item.textlist[1]}}</text>
  85. <text>{{item.textlist[2]}}</text>
  86. </view>
  87. </view>
  88. -->
  89. <!-- 按钮 -->
  90. <view class="btn_box">
  91. <button class="up_btn btn" @click="toPay">确认充值</button>
  92. <button class="pass_btn btn" @click="toUpMenber">去升级会员实惠更多</button>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import dataList from "./config.js"
  98. import {
  99. IMG_URL
  100. } from '@/env.js'
  101. export default {
  102. data() {
  103. return {
  104. IMG_URL,
  105. list: [],
  106. welfareList: dataList.welfareList,
  107. status: 0,
  108. userInfo: {},
  109. rechargeId: null,
  110. agreementInfo: {}, // 充值说明
  111. }
  112. },
  113. onLoad() {
  114. uni.showLoading();
  115. this.getUserInfo();
  116. this.getRechargeList();
  117. this.getRechargeInfo();
  118. uni.hideLoading();
  119. },
  120. methods: {
  121. getRechargeInfo() {
  122. // 获取充值说明
  123. this.$api('getAgreement', {
  124. type: 2
  125. }).then(res => {
  126. let {
  127. code,
  128. result,
  129. message
  130. } = res;
  131. if (code == 200) {
  132. console.log(result);
  133. this.agreementInfo = result;
  134. } else {
  135. this.$Toast(message)
  136. }
  137. }).catch(err => {
  138. this,
  139. $Toast(err.message);
  140. })
  141. },
  142. getRechargeList() {
  143. // 获取充值列表
  144. this.$api('rechargeList', {
  145. pageSize: 999
  146. }).then(res => {
  147. let {
  148. code,
  149. result,
  150. message
  151. } = res;
  152. if (code == 200) {
  153. console.log(result);
  154. let newList = []
  155. result.records.forEach((item, index) => {
  156. if (item.type == 1) {
  157. if (item.endTime !== null) {
  158. newList.push(item)
  159. }
  160. result.records[index].endTime = item.endTime.substring(5);
  161. }
  162. })
  163. console.log(result.records, newList)
  164. this.list = [...new Set([...newList, ...result.records])]
  165. this.rechargeId = this.list[0].id
  166. } else {
  167. this.$Toast(message)
  168. }
  169. }).catch(err => {
  170. this.$Toast(err.message);
  171. })
  172. },
  173. // 获取用户信息
  174. getUserInfo() {
  175. uni.showLoading();
  176. this.$api('getUserInfo')
  177. .then(res => {
  178. let {
  179. code,
  180. result,
  181. message
  182. } = res
  183. uni.hideLoading();
  184. if (code === 200) {
  185. this.userInfo = {
  186. ...result.userInfo,
  187. ...result.account
  188. }
  189. this.$storage.setStorage("__user_info", this.userInfo)
  190. console.log(this.userInfo)
  191. } else {
  192. this.$Toast(message)
  193. }
  194. })
  195. .catch(err => {
  196. this.$Toast(err.message)
  197. uni.hideLoading();
  198. })
  199. },
  200. toDetale() {
  201. // 去充值明细
  202. this.$tools.navigateTo({
  203. url: "/pagesB/homeGridList/topUp/detale/detale"
  204. })
  205. },
  206. // 选择的那个
  207. selectItem(index) {
  208. this.status = index;
  209. this.rechargeId = this.list[index].id
  210. },
  211. // 去升级会员
  212. toUpMenber() {
  213. uni.navigateTo({
  214. url: "/pagesC/member/upgrades_renewals/index"
  215. })
  216. },
  217. toPay() {
  218. const that = this;
  219. // 创建支付订单
  220. const params = {
  221. id: this.rechargeId
  222. }
  223. console.log(this.rechargeId)
  224. this.$api('rechargePay', params).then(res => {
  225. const {
  226. code,
  227. result,
  228. message
  229. } = res
  230. console.log(res)
  231. if (code == 200) {
  232. uni.requestPayment({
  233. provider: 'wxpay',
  234. timeStamp: result.timeStamp,
  235. nonceStr: result.nonceStr,
  236. package: result.packageValue,
  237. signType: result.signType,
  238. paySign: result.paySign,
  239. success: res => {
  240. that.$Toast('支付成功');
  241. alert('支付成功')
  242. // 刷新用户数据
  243. that.getUserInfo();
  244. },
  245. fail: error => {
  246. alert('取消支付')
  247. that.$Toast('取消支付')
  248. }
  249. })
  250. } else {
  251. that.$Toast(message)
  252. }
  253. })
  254. // .catch(err => {
  255. // console.log(err.message)
  256. // this.$Toast(err.message)
  257. // })
  258. },
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .title {
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. margin-top: 54rpx;
  268. margin-left: 36rpx;
  269. margin-right: 40rpx;
  270. .title_text {
  271. font-size: 66rpx;
  272. font-weight: bold;
  273. color: #000;
  274. }
  275. .icon {
  276. font-size: 38rpx;
  277. color: #01AEEA;
  278. }
  279. }
  280. .card {
  281. display: flex;
  282. flex-wrap: wrap;
  283. margin: 0 auto;
  284. margin-top: 7rpx;
  285. width: 717rpx;
  286. justify-content: space-between;
  287. display: flex;
  288. .item_box {
  289. width: 47%;
  290. margin: 0 10rpx;
  291. position: relative;
  292. .position_text {
  293. right: 260rpx;
  294. .image_img {
  295. width: 206rpx;
  296. height: 50rpx;
  297. position: absolute;
  298. }
  299. position: absolute;
  300. top: 15rpx;
  301. padding: 0 10rpx;
  302. .position_t {
  303. position: absolute;
  304. width: 206rpx;
  305. color: #FF3030;
  306. z-index: 22;
  307. }
  308. // background-color: #fff;
  309. }
  310. }
  311. .item {
  312. margin: 0 10rpx;
  313. width: 100%;
  314. min-height: 286rpx;
  315. border-radius: 23rpx;
  316. border: 1px solid #707070;
  317. box-shadow: 0 3rpx 6rpx 0 rgba(0, 0, 0, 0.16);
  318. color: #707070;
  319. background-color: #F3F3F3;
  320. margin-top: 40rpx;
  321. display: flex;
  322. align-items: center;
  323. flex-direction: column;
  324. &:nth-child(3n-2) {
  325. margin-left: 0;
  326. }
  327. &:nth-child(3n) {
  328. margin-right: 0;
  329. }
  330. .up {
  331. font-size: 36rpx;
  332. .text_up {
  333. font-size: 36rpx;
  334. margin-right: 12rpx;
  335. }
  336. .num {
  337. // font-size: 42rpx;
  338. }
  339. }
  340. .text_give {
  341. padding: 0 6rpx;
  342. }
  343. .alt {
  344. margin-top: 10rpx;
  345. margin-bottom: 25rpx;
  346. text-align: center;
  347. font-size: 30rpx;
  348. }
  349. .time {
  350. font-size: 30rpx;
  351. color: #FF0000;
  352. margin-bottom: 20rpx;
  353. display: flex;
  354. flex-direction: column;
  355. }
  356. }
  357. .select_item {
  358. width: 100%;
  359. color: #01AEEA;
  360. border-color: #01AEEA;
  361. position: relative;
  362. .position_text {
  363. position: absolute;
  364. top: -28rpx;
  365. right: 259rpx;
  366. padding: 0 10rpx;
  367. .image_img {
  368. width: 206rpx;
  369. height: 50rpx;
  370. position: absolute;
  371. }
  372. .position_t {
  373. position: absolute;
  374. width: 206rpx;
  375. color: #FF3030;
  376. z-index: 22;
  377. }
  378. // background-color: #fff;
  379. }
  380. /deep/ .u-icon {
  381. position: absolute;
  382. background-color: #fff;
  383. transform: translate(50%, 50%);
  384. top: 44%;
  385. right: 0;
  386. .u-icon__icon {
  387. color: #01AEEA;
  388. }
  389. }
  390. }
  391. }
  392. // 充值说明
  393. .explain {
  394. width: 674rpx;
  395. margin-left: 60rpx;
  396. display: flex;
  397. flex-direction: column;
  398. text {
  399. font-size: 26rpx;
  400. color: #000;
  401. margin-top: 14rpx;
  402. }
  403. .explain_title {
  404. font-size: 32rpx;
  405. font-weight: bold;
  406. margin-top: 40rpx;
  407. }
  408. }
  409. // 充值福利
  410. .welfare {
  411. width: 654rpx;
  412. margin: 94rpx auto 0;
  413. border: 3px solid #F6CB86;
  414. position: relative;
  415. .welfare_title {
  416. position: absolute;
  417. top: -88rpx;
  418. left: -20rpx;
  419. transform: translate(50%, 50%);
  420. display: flex;
  421. text {
  422. width: 83rpx;
  423. height: 83rpx;
  424. text-align: center;
  425. line-height: 83rpx;
  426. border-radius: 50%;
  427. margin-right: 5rpx;
  428. font-size: 43rpx;
  429. font-weight: bold;
  430. color: #A12527;
  431. background-color: #F6CB86;
  432. }
  433. }
  434. .bg0 {
  435. background-color: #01AEEA;
  436. margin-top: 74rpx !important;
  437. }
  438. .bg1 {
  439. background-color: #59E5A3;
  440. }
  441. .bg2 {
  442. background-color: #FAB875;
  443. }
  444. .bg3 {
  445. background-color: #F33D3D;
  446. }
  447. .bg4 {
  448. background-color: #000000;
  449. margin-bottom: 35rpx !important;
  450. }
  451. .item {
  452. width: 532rpx;
  453. margin: 0 auto 15rpx;
  454. display: flex;
  455. color: #fff;
  456. flex-direction: column;
  457. border-radius: 10rpx;
  458. padding-left: 20rpx;
  459. box-sizing: border-box;
  460. padding-bottom: 20rpx;
  461. .title_box {
  462. margin-top: 20rpx;
  463. display: flex;
  464. align-items: center;
  465. .item_title {
  466. margin-left: 10rpx;
  467. padding: 0;
  468. }
  469. }
  470. text {
  471. padding-top: 20rpx;
  472. font-size: 21rpx;
  473. }
  474. }
  475. }
  476. .btn {
  477. height: 94rpx;
  478. border-radius: 46rpx;
  479. font-size: 30rpx;
  480. font-weight: bold;
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. }
  485. .up_btn {
  486. margin-top: 50rpx;
  487. width: 569rpx;
  488. border: 3px solid #01AEEA;
  489. background-color: #fff;
  490. color: #01AEEA;
  491. }
  492. .pass_btn {
  493. margin-top: 42rpx;
  494. margin-bottom: 59rpx;
  495. width: 637rpx;
  496. background-color: #01AEEA;
  497. color: #fff;
  498. }
  499. .btn_box {
  500. position: fixed;
  501. bottom: 0;
  502. width: 100%;
  503. background-color: #fff;
  504. }
  505. .pages {
  506. padding-bottom: 370rpx;
  507. }
  508. </style>