index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. </view>
  60. <!--tab bar-->
  61. <tab-bar />
  62. </view>
  63. </template>
  64. <script>
  65. import TabBar from '../../components/TabBar/index'
  66. import { mapState } from 'vuex'
  67. export default {
  68. name: 'My',
  69. components: { TabBar },
  70. data() {
  71. return {
  72. history: [1, 2, 3, 4],
  73. menus: [
  74. { icon: '/static/image/my-page/order.png', name: '消费记录', href: '/pages/my/consume' },
  75. { icon: '/static/image/my-page/recharge.png', name: '充值记录', href: '/pages/my/recharge' },
  76. { icon: '/static/image/my-page/share.png', name: '分享好友', type: 'share' },
  77. { icon: '/static/image/my-page/contact.png', name: '联系客服', type: 'contact' },
  78. { icon: '/static/image/my-page/protocol.png', name: '用户协议', href: '/pages/my/protocol' }
  79. ]
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. userInfo: seate => seate.user.info
  85. })
  86. },
  87. methods: {
  88. handleMenu(menu) {
  89. if (menu.href) {
  90. this.$u.route(menu.href)
  91. }
  92. },
  93. handleGetUserInfo() {
  94. this.$loading('数据刷新中...')
  95. uni.getUserProfile({
  96. success: res => {
  97. const params = {
  98. encryptedData: res.encryptedData,
  99. iv: res.iv,
  100. signature: res.signature
  101. }
  102. this.$api.user.update(params).then(res => {
  103. this.$hideLoading()
  104. this.$store.dispatch('user/info', res.data)
  105. })
  106. }
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .container {
  114. padding: 20px 20rpx 0;
  115. font-size: 30rpx;
  116. >.header{
  117. .user-box{
  118. .head-img{
  119. image{
  120. width: 100rpx;
  121. height: 100rpx;
  122. border-radius: 50%;
  123. }
  124. }
  125. .nickname{
  126. color: $primary-color;
  127. margin-left: 30rpx;
  128. }
  129. }
  130. .refresh{
  131. background: $primary-color;
  132. color: #fff;
  133. border-radius: 30rpx;
  134. padding: 10rpx 0;
  135. width: 140rpx;
  136. text-align: center;
  137. letter-spacing: .1rem;
  138. line-height: initial;
  139. }
  140. }
  141. .recharge{
  142. background: url("/static/image/my-recharge-bg.png") no-repeat center;
  143. background-size: 100%;
  144. height: 200rpx;
  145. margin-top: 20rpx;
  146. margin-bottom: 10rpx;
  147. .static-box{
  148. margin-left: 30rpx;
  149. .icon{
  150. border-radius: 20rpx;
  151. image{
  152. width: 100rpx;
  153. height: 100rpx;
  154. }
  155. }
  156. .overage{
  157. font-weight: 800;
  158. margin-left: 20rpx;
  159. font-size: 32rpx;
  160. }
  161. }
  162. .recharge-btn{
  163. border: 1rpx solid #fff;
  164. padding: 10rpx 0 ;
  165. text-align: center;
  166. width: 140rpx;
  167. margin-right: 20rpx;
  168. border-radius: 30rpx;
  169. color: #ffffff;
  170. }
  171. }
  172. .history{
  173. background: #1B203C;
  174. height: 300rpx;
  175. border-radius: 15rpx;
  176. padding: 20rpx 30rpx;
  177. margin-bottom: 40rpx;
  178. >.header{
  179. text{
  180. color: $info-color;
  181. font-weight: 600;
  182. }
  183. }
  184. .content{
  185. margin-top: 20rpx;
  186. .episode{
  187. flex: 1;
  188. margin-left: 20rpx;
  189. &:first-child{
  190. margin-left: 0;
  191. }
  192. .cover-image{
  193. image{
  194. width: 100%;
  195. height: 200rpx;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. .menu-group{
  202. .menu-item{
  203. padding: 20rpx 0;
  204. background: transparent;
  205. border: none;
  206. text-align: unset;
  207. width: 100%;
  208. line-height: initial;
  209. font-size: initial;
  210. justify-content: space-between;
  211. &:after{
  212. content: unset;
  213. }
  214. .left-box{
  215. flex: 1;
  216. .icon{
  217. transform: translateY(4rpx);
  218. image{
  219. width: 55rpx;
  220. height: 55rpx;
  221. }
  222. }
  223. text{
  224. color: #fff;
  225. margin-left: 10rpx;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. </style>