耀实惠小程序
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.

589 lines
13 KiB

  1. <template>
  2. <view class="pages" v-if="upgrade_list.length>0">
  3. <view class="top">
  4. <image :src="userInfo.headUrl" mode=""></image>
  5. <view class="user_info">
  6. <view :class="userInfo.level == 0? 'user_row m-t-32': 'user_row'">
  7. <text class="user_name">{{userInfo.nickName}}</text>
  8. <view class="lv" v-if="userInfo.level ==0">
  9. <image :src="img_url+'vip/0.png'" mode=""></image>
  10. </view>
  11. <view class="lv" v-if="userInfo.level ==1">
  12. <image :src="img_url+'vip/1.png'" mode=""></image>
  13. </view>
  14. <view class="lv" v-if="userInfo.level ==2">
  15. <image :src="img_url+'vip/2.png'" mode=""></image>
  16. </view>
  17. <view class="lv" v-if="userInfo.level ==3">
  18. <image :src="img_url+'vip/3.png'" mode=""></image>
  19. </view>
  20. <view class="lv" v-if="userInfo.level ==4">
  21. <image :src="img_url+'vip/4.png'" mode=""></image>
  22. </view>
  23. </view>
  24. <text class="expire_time" v-if="userInfo.level !==0 && userInfo.levelTime" >到期时间{{userInfo.levelTime}}</text>
  25. </view>
  26. </view>
  27. <view class="card">
  28. <view class="title">
  29. <image :src="img_url+'member/min.png'" mode=""></image>
  30. <text>耀实惠 等级越高实惠更多</text>
  31. </view>
  32. <view class="select_pic_video">
  33. <u-subsection mode="subsection" :list="listPicVideo" fontSize="36" height="64" :current="curNow"
  34. @change="sectionChange"></u-subsection>
  35. </view>
  36. <!-- 升级 -->
  37. <view v-if="curNow == 0">
  38. <view class="upgrade">
  39. <view class="item" v-for="(item,index) in upgrade_list" :key="index">
  40. <view :class="index== status? 'item select_item ': 'item'" @click="changeStatus(index)">
  41. <text class="title">{{item.title}}</text>
  42. <view class="momey_box">
  43. <text class="icons"></text>
  44. <text class="price">{{item.money}}</text>
  45. </view>
  46. <view class="old_money">
  47. <text>原价</text>
  48. <text class="through">¥{{item.oldMoney}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 权益 -->
  54. <view class="equities">
  55. <view class="title">
  56. <image :src="img_url+'member/max.png'" mode=""></image>
  57. <text>{{upgrade_list[status].name}}</text>
  58. </view>
  59. <view class="item">
  60. <rich-text :nodes="upgrade_list[status].concert"></rich-text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 续费 -->
  65. <view v-if="curNow == 1">
  66. <view class="select">
  67. <view class="item" v-for="(item,index) in select_list" :key="index">
  68. <view :class="index== status_tow? 'item select_item ': 'item'" @click="changeStatus(index)">
  69. <text class="title">{{item.name}}</text>
  70. <text class="price" v-if="index == 0">{{item.money}}/{{item.overdue}}{{ item.overdueType==0?'':'h'}}</text>
  71. <text class="price" v-else>{{item.money}}/</text>
  72. <view class="old_money">
  73. <text>原价</text>
  74. <text class="through">¥{{item.oldMoney}}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 权益 -->
  80. <view class="equities">
  81. <view class="title">
  82. <image :src="img_url+'member/max.png'" mode=""></image>
  83. <text v-if="curNow == 0">{{upgrade_list[status].title}}</text>
  84. <text v-else>{{select_list[status_tow].title}}</text>
  85. </view>
  86. <rich-text v-if="curNow == 0"> :nodes="upgrade_list[status].concert"></rich-text>
  87. <rich-text v-else :nodes="select_list[status_tow].concert"></rich-text>
  88. <!-- <view class="item" v-for="(item,index) in select_list[status].equitiesList" :key="index">
  89. <image :src="img_url+'member/dot.png'" mode=""></image>
  90. <text>{{item}}</text>
  91. </view> -->
  92. </view>
  93. </view>
  94. <!-- 按钮 -->
  95. <view class="btn">
  96. <view class="left">
  97. <text class="icons"></text>
  98. <text class="num" v-if="curNow == 0">{{upgrade_list[status].money}}</text>
  99. <text class="num" v-else>{{select_list[status_tow].money}}</text>
  100. <!-- <text class="info_text">开通即享特权</text> -->
  101. </view>
  102. <text v-if="curNow == 0" class="right" @click="toDredge">升级</text>
  103. <text v-else class="right" @click="toDredge">续费</text>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import config_img from "@/utils/js/config.js"
  110. export default {
  111. data() {
  112. return {
  113. img_url: config_img.img_url,
  114. status: 0,
  115. status_tow: 0,
  116. listPicVideo: ['升级', '续费'],
  117. curNow: 0,
  118. upgrade_list: [],
  119. select_list: [],
  120. userInfo: {},
  121. url: null, //从哪里来
  122. }
  123. },
  124. onUnload() {
  125. uni.navigateBack({
  126. delta: 3
  127. })
  128. },
  129. onLoad() {
  130. this.userInfo = uni.getStorageSync("__user_info");
  131. this.getVipRoleList();
  132. },
  133. methods: {
  134. // 刷新用户个人信息
  135. getUserInfo () {
  136. uni.showLoading();
  137. this.$api('getUserInfo')
  138. .then(res => {
  139. let { code, result, message } = res
  140. uni.hideLoading();
  141. if (code === 200) {
  142. const userInfo = {...result.userInfo,...result.account}
  143. this.$storage.setStorage("__user_info",userInfo)
  144. console.log(userInfo)
  145. } else {
  146. this.$Toast(message)
  147. }
  148. })
  149. .catch(err => {
  150. this.$Toast(err.message)
  151. uni.hideLoading();
  152. })
  153. },
  154. sectionChange(index) {
  155. console.log(index)
  156. this.curNow = index
  157. if(index == 0) {
  158. // 升级
  159. this.getVipRoleList();
  160. }else {
  161. // 续费
  162. this.getVipList();
  163. }
  164. // this.rightList[index].show_pic_video = !this.rightList[index].show_pic_video
  165. // if(index == 0) {
  166. // this.show_pic_video = true
  167. // }else {
  168. // this.show_pic_video = false
  169. // }
  170. // this.curNow = index;
  171. },
  172. getVipList() {
  173. // 续费
  174. uni.showLoading();
  175. this.$api('getVipList').then(res => {
  176. let { code, result, message } = res;
  177. uni.hideLoading();
  178. if(code == 200) {
  179. console.log(result)
  180. this.select_list = result.records
  181. }else {
  182. this.$Toast(message);
  183. }
  184. }).catch(err => {
  185. uni.hideLoading();
  186. this.$Toast(err.message);
  187. })
  188. },
  189. getVipRoleList() {
  190. // 升级
  191. uni.showLoading();
  192. this.$api('getVipRoleList').then(res => {
  193. let { code, result, message } = res;
  194. uni.hideLoading();
  195. if(code == 200) {
  196. console.log(result)
  197. this.upgrade_list = result.records
  198. }else {
  199. this.$Toast(message);
  200. }
  201. }).catch(err => {
  202. uni.hideLoading();
  203. this.$Toast(err.message);
  204. })
  205. },
  206. changeStatus(index) {
  207. console.log(index,this.curNow)
  208. if(this.curNow == 0) {
  209. this.status = index
  210. } else {
  211. this.status_tow = index
  212. }
  213. },
  214. toDredge() {
  215. if(this.curNow == 0) {
  216. // 升级 0
  217. const id = this.upgrade_list[this.status].id;
  218. if(this.userInfo.cardType == 0) {
  219. uni.navigateTo({
  220. url: "./../dredge/index?type=0&id="+id
  221. })
  222. }else{
  223. this.toUpgradesRenewals(0,id)
  224. }
  225. } else {
  226. // 续费 1
  227. const id = this.select_list[this.status_tow].id;
  228. if(this.userInfo.cardType == 0) {
  229. uni.navigateTo({
  230. url: "../dredge/index?type=1&id="+id
  231. })
  232. }else{
  233. this.toUpgradesRenewals(1,id)
  234. }
  235. }
  236. },
  237. toUpgradesRenewals(type,id) {
  238. let url = type == 0 ? 'vipRolePay': 'vipPay'
  239. this.$api(url,{id}).then(res =>{
  240. const { code, result, message } = res
  241. console.log(res)
  242. if (code == 200) {
  243. uni.requestPayment({
  244. provider: 'wxpay',
  245. timeStamp: result.timeStamp,
  246. nonceStr: result.nonceStr,
  247. package: result.packageValue,
  248. signType: result.signType,
  249. paySign: result.paySign,
  250. success: res => {
  251. this.$Toast('支付成功');
  252. // 刷新用户数据
  253. this.getUserInfo();
  254. setTimeout(() => {
  255. this.$tools.navigateTo({
  256. url: './../upgrades_renewals/index'
  257. })
  258. },1500)
  259. },
  260. fail:error=>{
  261. this.$Toast('取消支付')
  262. }
  263. })
  264. } else{
  265. this.$Toast(message)
  266. }
  267. })
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .pages {
  274. position: relative;
  275. .top {
  276. background-color: #000;
  277. height: 404rpx;
  278. display: flex;
  279. align-items: flex-start;
  280. border-bottom-left-radius: 49rpx;
  281. border-bottom-right-radius: 49rpx;
  282. image {
  283. width: 160rpx;
  284. height: 160rpx;
  285. border-radius: 50%;
  286. margin-top: 31rpx;
  287. margin-left: 45rpx;
  288. }
  289. .user_info {
  290. display: flex;
  291. padding-left: 17rpx;
  292. flex-direction: column;
  293. .user_row {
  294. padding-top: 53rpx;
  295. display: flex;
  296. align-items: center;
  297. color: #fff;
  298. .user_name {
  299. font-size: 38rpx;
  300. }
  301. .lv {
  302. position: relative;
  303. margin-left: 20rpx;
  304. width: 144rpx;
  305. height: 42rpx;
  306. image {
  307. position: absolute;
  308. width: 144rpx;
  309. height: 42rpx;
  310. border-radius: 0;
  311. margin: 0;
  312. padding: 0;
  313. }
  314. text {
  315. position: absolute;
  316. display: inline-block;
  317. width: 144rpx;
  318. padding-top: 10rpx;
  319. padding-left: 45rpx;
  320. box-sizing: border-box;
  321. font-size: 20rpx;
  322. top: 0;
  323. left: 0;
  324. }
  325. }
  326. }
  327. .expire_time {
  328. padding-top: 20rpx;
  329. font-size: 32rpx;
  330. }
  331. }
  332. text {
  333. color: #fff;
  334. }
  335. }
  336. .card {
  337. position: absolute;
  338. top: 224rpx;
  339. left: 12rpx;
  340. right: 12rpx;
  341. width: 729rpx;
  342. border-top-left-radius: 70rpx;
  343. border-top-right-radius: 70rpx;
  344. background-color: #fff;
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. .title {
  349. margin-top: 42rpx;
  350. margin-bottom: 42rpx;
  351. image {
  352. width: 55rpx;
  353. height: 40rpx;
  354. margin-right: 10rpx;
  355. }
  356. text {
  357. font-size: 36rpx;
  358. font-weight: bold;
  359. color: #000;
  360. }
  361. }
  362. .select_pic_video {
  363. background-color: #fff;
  364. border-radius: 25rpx;
  365. width: 693rpx;
  366. height: 64rpx;
  367. margin: 0 auto;
  368. background-color: #F5F5F5;
  369. font-size: 32rpx;
  370. /deep/ .u-subsection {
  371. border-radius: 25rpx !important;
  372. width: 700rpx !important;
  373. .u-item {
  374. width: 346rpx !important;
  375. border: none !important;
  376. }
  377. .u-item-bg {
  378. width: 350rpx !important;
  379. background-color: #F6D27F !important;
  380. border-radius: 25rpx !important;
  381. color: #FFF;
  382. }
  383. }
  384. }
  385. .upgrade {
  386. margin-top: 51rpx;
  387. display: flex;
  388. // justify-content: space-between;
  389. .item {
  390. width: 200rpx;
  391. // height: 224rpx;
  392. margin: 0 15rpx;
  393. background-color: #F5F5F5;
  394. display: flex;
  395. flex-direction: column;
  396. align-items: center;
  397. border-radius: 15rpx;
  398. // padding-bottom: 20rpx;
  399. .title {
  400. margin-top: 31rpx;
  401. margin-bottom: 0;
  402. color: #8B5B13;
  403. font-size: 36rpx;
  404. font-weight: bold;
  405. }
  406. .momey_box {
  407. margin-top: 20rpx;
  408. margin-bottom: 22rpx;
  409. .icons {
  410. font-size: 36rpx;
  411. }
  412. .price {
  413. font-size: 49rpx;
  414. }
  415. }
  416. .old_money {
  417. margin-bottom: 35rpx;
  418. font-size: 25rpx;
  419. .through {
  420. text-decoration: line-through;
  421. }
  422. }
  423. }
  424. .select_item {
  425. background-color: #FFEDCF;
  426. color: #8B5B13;
  427. }
  428. }
  429. .select {
  430. width: 605rpx;
  431. margin: 0 auto;
  432. display: flex;
  433. flex-wrap: wrap;
  434. justify-content: space-between;
  435. .item {
  436. background-color: #F5F5F5;
  437. margin-top: 33rpx;
  438. color: #000000;
  439. width: 285rpx;
  440. display: flex;
  441. flex-direction: column;
  442. align-items: center;
  443. border-radius: 15rpx;
  444. .title {
  445. margin-top: 0rpx;
  446. margin-bottom: 0;
  447. font-size: 36rpx;
  448. font-weight: bold;
  449. }
  450. .price {
  451. font-size: 40rpx;
  452. margin-top: 20rpx;
  453. margin-bottom: 22rpx;
  454. }
  455. .old_money {
  456. margin-bottom: 35rpx;
  457. font-size: 25rpx;
  458. .through {
  459. text-decoration: line-through;
  460. }
  461. }
  462. }
  463. .select_item {
  464. background-color: #FFEDCF;
  465. margin: 0;
  466. padding-top: 32rpx;
  467. color: #8B5B13;
  468. }
  469. }
  470. .equities {
  471. margin-top: 57rpx;
  472. margin-left: 65rpx;
  473. width: 596rpx;
  474. .title {
  475. margin-top: 0;
  476. margin-bottom: 0;
  477. image {
  478. width: 61rpx;
  479. height: 41rpx;
  480. }
  481. text {
  482. font-size: 36rpx;
  483. font-weight: bold;
  484. color: #000;
  485. }
  486. }
  487. image {
  488. width: 31rpx;
  489. height: 35rpx;
  490. margin-top: 8rpx;
  491. margin-right: 17rpx;
  492. }
  493. font-size: 32rpx;
  494. }
  495. .btn {
  496. width: 642rpx;
  497. height: 93rpx;
  498. border-radius: 47rpx;
  499. overflow: hidden;
  500. margin-top: 140rpx;
  501. margin-bottom: 47rpx;
  502. display: flex;
  503. .left {
  504. width: 309rpx;
  505. background-color: #302F2D;
  506. display: flex;
  507. justify-content: center;
  508. align-items: center;
  509. .icons {
  510. font-size: 24rpx;
  511. padding-top: 10rpx;
  512. color: #FFDA85;
  513. }
  514. .num {
  515. font-size: 43rpx;
  516. color: #FFDA85;
  517. }
  518. .info_text {
  519. font-size: 14rpx;
  520. padding-left: 10rpx;
  521. padding-top: 20rpx;
  522. color: #C2B09A;
  523. }
  524. }
  525. .right {
  526. flex: 1;
  527. display: flex;
  528. justify-content: center;
  529. align-items: center;
  530. font-size: 38rpx;
  531. font-weight: bold;
  532. color: #6F4920;
  533. background-color: #F6D27F;
  534. }
  535. }
  536. }
  537. }
  538. </style>