index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="container">
  3. <!--用户信息-->
  4. <view class="header main-between cross-center">
  5. <view class="user-box main-left cross-center">
  6. <view class="head-img">
  7. <image :src="userInfo.avatar?userInfo.avatar:'@/static/image/default-head-img.png'" />
  8. </view>
  9. <view v-if="!userInfo.nickname" class="nickname cross-center" @click="handleGetUserInfo">未授权登陆</view>
  10. <view v-if="userInfo.nickname" class="nickname cross-center" @click="handleGetUserInfo">{{ userInfo.nickname }}</view>
  11. </view>
  12. <button open-type="getUserInfo" class="refresh" @click="handleGetUserInfo">刷新</button>
  13. </view>
  14. <!--充值-->
  15. <view class="recharge main-between cross-center">
  16. <view class="static-box main-left cross-center">
  17. <view class="icon">
  18. <image src="/static/image/gold-bag.png" mode="aspectFill" />
  19. </view>
  20. <view class="overage">3金币</view>
  21. </view>
  22. <view class="recharge-btn">充值</view>
  23. </view>
  24. <!--历史-->
  25. <view class="history" @click="$u.route('/pages/my/history')">
  26. <view class="header main-between cross-center">
  27. <text>历史观看记录</text>
  28. <u-icon name="arrow-right" :color="$colors.infoColor" bold />
  29. </view>
  30. <view class="content main-between cross-center">
  31. <view
  32. v-for="(item,index) in history"
  33. :key="index"
  34. class="episode"
  35. >
  36. <view class="cover-image">
  37. <image src="@/static/image/default-movie.png" mode="aspectFill" />
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!--菜单-->
  43. <view class="menu-group">
  44. <button
  45. v-for="(menu,index) in menus"
  46. :key="index"
  47. class="menu-item main-between cross-center"
  48. :open-type="menu.type ? menu.type : ''"
  49. @click="handleMenu(menu)"
  50. >
  51. <view class="left-box dir-left-nowrap cross-center">
  52. <view class="icon">
  53. <image :src="menu.icon" />
  54. </view>
  55. <text>{{ menu.name }}</text>
  56. </view>
  57. <u-icon name="arrow-right" :color="$colors.infoColor" bold />
  58. </button>
  59. <vedio se />
  60. </view>
  61. <!--tab bar-->
  62. <tab-bar />
  63. </view>
  64. </template>
  65. <script>
  66. import TabBar from '../../components/TabBar/index'
  67. import { mapState } from 'vuex'
  68. export default {
  69. name: 'My',
  70. components: { TabBar },
  71. data() {
  72. return {
  73. history: [1, 2, 3, 4],
  74. menus: [
  75. { icon: '/static/image/my-page/order.png', name: '消费记录', href: '/pages/my/consume' },
  76. { icon: '/static/image/my-page/recharge.png', name: '充值记录', href: '/pages/my/recharge' },
  77. { icon: '/static/image/my-page/share.png', name: '分享好友', type: 'share' },
  78. { icon: '/static/image/my-page/contact.png', name: '联系客服', type: 'contact' },
  79. { icon: '/static/image/my-page/protocol.png', name: '用户协议', href: '/pages/my/protocol' }
  80. ]
  81. }
  82. },
  83. computed: {
  84. ...mapState({
  85. userInfo: seate => seate.user.info
  86. })
  87. },
  88. methods: {
  89. handleMenu(menu) {
  90. if (menu.href) {
  91. this.$u.route(menu.href)
  92. }
  93. },
  94. handleGetUserInfo() {
  95. this.$loading('数据刷新中...')
  96. uni.getUserProfile({
  97. success: res => {
  98. const params = {
  99. encryptedData: res.encryptedData,
  100. iv: res.iv,
  101. signature: res.signature
  102. }
  103. this.$api.user.update(params).then(res => {
  104. this.$hideLoading()
  105. this.$store.dispatch('user/info', res.data)
  106. })
  107. }
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .container {
  115. padding: 20px 20rpx 0;
  116. font-size: 30rpx;
  117. >.header{
  118. .user-box{
  119. .head-img{
  120. image{
  121. width: 100rpx;
  122. height: 100rpx;
  123. border-radius: 50%;
  124. }
  125. }
  126. .nickname{
  127. color: $primary-color;
  128. margin-left: 30rpx;
  129. }
  130. }
  131. .refresh{
  132. background: $primary-color;
  133. color: #fff;
  134. border-radius: 30rpx;
  135. padding: 10rpx 0;
  136. width: 140rpx;
  137. text-align: center;
  138. letter-spacing: .1rem;
  139. line-height: initial;
  140. }
  141. }
  142. .recharge{
  143. background: url("/static/image/my-recharge-bg.png") no-repeat center;
  144. background-size: 100%;
  145. height: 200rpx;
  146. margin-top: 20rpx;
  147. margin-bottom: 10rpx;
  148. .static-box{
  149. margin-left: 30rpx;
  150. .icon{
  151. border-radius: 20rpx;
  152. image{
  153. width: 100rpx;
  154. height: 100rpx;
  155. }
  156. }
  157. .overage{
  158. font-weight: 800;
  159. margin-left: 20rpx;
  160. font-size: 32rpx;
  161. }
  162. }
  163. .recharge-btn{
  164. border: 1rpx solid #fff;
  165. padding: 10rpx 0 ;
  166. text-align: center;
  167. width: 140rpx;
  168. margin-right: 20rpx;
  169. border-radius: 30rpx;
  170. color: #ffffff;
  171. }
  172. }
  173. .history{
  174. background: #1B203C;
  175. height: 300rpx;
  176. border-radius: 15rpx;
  177. padding: 20rpx 30rpx;
  178. margin-bottom: 40rpx;
  179. >.header{
  180. text{
  181. color: $info-color;
  182. font-weight: 600;
  183. }
  184. }
  185. .content{
  186. margin-top: 20rpx;
  187. .episode{
  188. flex: 1;
  189. margin-left: 20rpx;
  190. &:first-child{
  191. margin-left: 0;
  192. }
  193. .cover-image{
  194. image{
  195. width: 100%;
  196. height: 200rpx;
  197. }
  198. }
  199. }
  200. }
  201. }
  202. .menu-group{
  203. .menu-item{
  204. padding: 20rpx 0;
  205. background: transparent;
  206. border: none;
  207. text-align: unset;
  208. width: 100%;
  209. line-height: initial;
  210. font-size: initial;
  211. justify-content: space-between;
  212. &:after{
  213. content: unset;
  214. }
  215. .left-box{
  216. flex: 1;
  217. .icon{
  218. transform: translateY(4rpx);
  219. image{
  220. width: 55rpx;
  221. height: 55rpx;
  222. }
  223. }
  224. text{
  225. color: #fff;
  226. margin-left: 10rpx;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. </style>