index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. </view>
  5. <view class="u-i">
  6. <view class="user">
  7. <image class="avatar" :src="userInfo.avatar" mode="" v-if="userInfo.avatar"
  8. @click="navTo('/pages/set/userinfo')"></image>
  9. <view class="info">
  10. <view class="user-name clamp2">{{ userInfo.nickname || '游客'}}</view>
  11. <view class="user-id" v-if="userInfo && userInfo.uid">
  12. UID: {{userInfo.uid}}
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="bn1-wrap">
  18. <image src="/static/user/bn1.png" mode="" class="bn1"></image>
  19. </view>
  20. <view class="card-wrap flex">
  21. <view class="card" v-for="(item,index) in list" :class="{'action': checked.id == item.id}"
  22. @click="choose(item)">
  23. <view class="tit">
  24. {{item.name}}
  25. </view>
  26. <view class="price">{{(item.price*1).toFixed(0)}}</view>
  27. <view class="zs">
  28. 赠送¥{{(item.gift_amount*1).toFixed(0)}}
  29. </view>
  30. <view class="zs" style="padding-top: 10rpx;">
  31. 有效期:{{(item.valid_date*1).toFixed(0)}}天
  32. </view>
  33. </view>
  34. </view>
  35. <!-- <input type="text" v-model="authCode" placeholder="请输入吗" /> -->
  36. <view class="btn flex" @click="createLevel()">
  37. 立即开通
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState,
  44. mapMutations
  45. } from 'vuex';
  46. import {
  47. getLevelLists,
  48. createLevel,
  49. paylevel
  50. } from '@/api/user.js'
  51. export default {
  52. data() {
  53. return {
  54. list: [],
  55. checked: {},
  56. loading: false,
  57. authCode: ''
  58. }
  59. },
  60. computed: {
  61. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  62. },
  63. methods: {
  64. getLevelList() {
  65. getLevelLists().then(res => {
  66. this.list = res.data
  67. this.checked = res.data[0]
  68. }).catch(err => {
  69. console.log(err);
  70. })
  71. },
  72. choose(item) {
  73. this.checked = item
  74. },
  75. goPay(orderId, payType) {
  76. if (this.loading) return;
  77. this.loading = true
  78. paylevel({
  79. order_id: orderId,
  80. pay_type: 'HuifuCode',
  81. authCode: this.authCode
  82. }).then(res => {
  83. this.loading = false
  84. }).catch(err => {
  85. this.loading = false
  86. })
  87. },
  88. createLevel() {
  89. if (this.loading) return;
  90. this.loading = true
  91. createLevel({
  92. level: this.checked.id,
  93. pay_type: 'huifu'
  94. }).then(res => {
  95. this.loading = false
  96. this.goPay(res.data.order_id, 'huifu')
  97. }).catch(err => {
  98. this.loading = false
  99. })
  100. }
  101. },
  102. onLoad() {
  103. this.getLevelList()
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .card-wrap {
  109. background-color: #fff;
  110. padding: 47rpx;
  111. }
  112. .card {
  113. width: 204rpx;
  114. height: 315rpx;
  115. padding-top: 47rpx;
  116. background: #F5F5F5;
  117. border-radius: 20rpx;
  118. text-align: center;
  119. color: #854E13;
  120. .tit {
  121. font-weight: 500;
  122. font-size: 33rpx;
  123. color: #644931;
  124. }
  125. .price {
  126. padding: 20rpx 0;
  127. font-weight: bold;
  128. font-size: 66rpx;
  129. &::before {
  130. content: '¥';
  131. font-size: 44rpx;
  132. }
  133. }
  134. .zs {
  135. font-size: 26rpx;
  136. }
  137. }
  138. .action {
  139. background: #FFF2DF;
  140. border: 1px solid #FF861B;
  141. .price {
  142. color: #FF502F;
  143. }
  144. }
  145. .btn {
  146. width: 647rpx;
  147. height: 94rpx;
  148. background: linear-gradient(-90deg, #FDC358 0%, #FADDA3 100%);
  149. border-radius: 47rpx;
  150. justify-content: center;
  151. margin: 54rpx auto;
  152. font-weight: 400;
  153. font-size: 38rpx;
  154. color: #773B00;
  155. }
  156. .u-i {
  157. width: 100%;
  158. height: 342rpx;
  159. padding: 52rpx 0;
  160. margin: -250rpx 0 0;
  161. // .bg {
  162. // width: 100%;
  163. // height: 100%;
  164. // }
  165. background-image: url('/static/user/hy-c.png');
  166. background-size: 100% 100%;
  167. // background-repeat: no-repeat;
  168. }
  169. .user {
  170. width: 100%;
  171. height: 120rpx;
  172. padding: 0 72rpx;
  173. display: flex;
  174. align-items: center;
  175. }
  176. .info {
  177. padding: 10rpx 0;
  178. height: 100%;
  179. display: flex;
  180. flex-direction: column;
  181. margin-right: auto;
  182. }
  183. .user-name {
  184. font-weight: bold;
  185. font-size: 36rpx;
  186. color: #773B00;
  187. margin-bottom: auto;
  188. }
  189. .user-id {
  190. font-weight: 500;
  191. font-size: 24rpx;
  192. color: #773B00;
  193. }
  194. .avatar {
  195. width: 120rpx;
  196. height: 120rpx;
  197. border-radius: 50%;
  198. margin-right: 20rpx;
  199. }
  200. .bn1-wrap {
  201. width: 100%;
  202. background-color: #fff;
  203. // padding: 20rpx auto;
  204. }
  205. .bn1 {
  206. display: block;
  207. width: 420rpx;
  208. height: 38rpx;
  209. margin: auto;
  210. }
  211. .top {
  212. width: 100%;
  213. height: 300rpx;
  214. background-color: #ff6602;
  215. }
  216. </style>