index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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="item.detail.episode.cover_img" 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: [],
  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. getHistory() {
  89. this.$api.user.episode.record().then(res => {
  90. this.history = res.data
  91. })
  92. },
  93. handleMenu(menu) {
  94. if (menu.href) {
  95. this.$u.route(menu.href)
  96. }
  97. },
  98. handleGetUserInfo() {
  99. this.$loading('数据刷新中...')
  100. uni.getUserProfile({
  101. success: res => {
  102. const params = {
  103. encryptedData: res.encryptedData,
  104. iv: res.iv,
  105. signature: res.signature
  106. }
  107. this.$api.user.update(params).then(res => {
  108. this.$hideLoading()
  109. this.$store.dispatch('user/info', res.data)
  110. })
  111. }
  112. })
  113. }
  114. },
  115. onLoad() {
  116. this.getHistory()
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .container {
  122. padding: 20px 20rpx 0;
  123. font-size: 30rpx;
  124. >.header{
  125. .user-box{
  126. .head-img{
  127. image{
  128. width: 100rpx;
  129. height: 100rpx;
  130. border-radius: 50%;
  131. }
  132. }
  133. .nickname{
  134. color: $primary-color;
  135. margin-left: 30rpx;
  136. }
  137. }
  138. .refresh{
  139. background: $primary-color;
  140. color: #fff;
  141. border-radius: 30rpx;
  142. padding: 10rpx 0;
  143. width: 140rpx;
  144. text-align: center;
  145. letter-spacing: .1rem;
  146. line-height: initial;
  147. }
  148. }
  149. .recharge{
  150. background: url("/static/image/my-recharge-bg.png") no-repeat center;
  151. background-size: 100%;
  152. height: 200rpx;
  153. margin-top: 20rpx;
  154. margin-bottom: 10rpx;
  155. .static-box{
  156. margin-left: 30rpx;
  157. .icon{
  158. border-radius: 20rpx;
  159. image{
  160. width: 100rpx;
  161. height: 100rpx;
  162. }
  163. }
  164. .overage{
  165. font-weight: 800;
  166. margin-left: 20rpx;
  167. font-size: 32rpx;
  168. }
  169. }
  170. .recharge-btn{
  171. border: 1rpx solid #fff;
  172. padding: 10rpx 0 ;
  173. text-align: center;
  174. width: 140rpx;
  175. margin-right: 20rpx;
  176. border-radius: 30rpx;
  177. color: #ffffff;
  178. }
  179. }
  180. .history{
  181. background: #1B203C;
  182. height: 300rpx;
  183. border-radius: 15rpx;
  184. padding: 20rpx 30rpx;
  185. margin-bottom: 40rpx;
  186. >.header{
  187. text{
  188. color: $info-color;
  189. font-weight: 600;
  190. }
  191. }
  192. .content{
  193. margin-top: 20rpx;
  194. .episode{
  195. flex: 1;
  196. margin-left: 20rpx;
  197. &:first-child{
  198. margin-left: 0;
  199. }
  200. .cover-image{
  201. image{
  202. width: calc(100%/4);
  203. height: 200rpx;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. .menu-group{
  210. .menu-item{
  211. padding: 20rpx 0;
  212. background: transparent;
  213. border: none;
  214. text-align: unset;
  215. width: 100%;
  216. line-height: initial;
  217. font-size: initial;
  218. justify-content: space-between;
  219. &:after{
  220. content: unset;
  221. }
  222. .left-box{
  223. flex: 1;
  224. .icon{
  225. transform: translateY(4rpx);
  226. image{
  227. width: 55rpx;
  228. height: 55rpx;
  229. }
  230. }
  231. text{
  232. color: #fff;
  233. margin-left: 10rpx;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>