index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 dir-left-nowrap 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. }).catch(err => {
  111. this.$hideLoading()
  112. })
  113. }
  114. })
  115. }
  116. },
  117. onLoad() {
  118. this.getHistory()
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .container {
  124. padding: 20px 20rpx 0;
  125. font-size: 30rpx;
  126. >.header{
  127. .user-box{
  128. .head-img{
  129. image{
  130. width: 100rpx;
  131. height: 100rpx;
  132. border-radius: 50%;
  133. }
  134. }
  135. .nickname{
  136. color: $primary-color;
  137. margin-left: 30rpx;
  138. }
  139. }
  140. .refresh{
  141. background: $primary-color;
  142. color: #fff;
  143. border-radius: 30rpx;
  144. padding: 10rpx 0;
  145. width: 140rpx;
  146. text-align: center;
  147. letter-spacing: .1rem;
  148. line-height: initial;
  149. }
  150. }
  151. .recharge{
  152. background: url("/static/image/my-recharge-bg.png") no-repeat center;
  153. background-size: 100%;
  154. height: 200rpx;
  155. margin-top: 20rpx;
  156. margin-bottom: 10rpx;
  157. .static-box{
  158. margin-left: 30rpx;
  159. .icon{
  160. border-radius: 20rpx;
  161. image{
  162. width: 100rpx;
  163. height: 100rpx;
  164. }
  165. }
  166. .overage{
  167. font-weight: 800;
  168. margin-left: 20rpx;
  169. font-size: 32rpx;
  170. }
  171. }
  172. .recharge-btn{
  173. border: 1rpx solid #fff;
  174. padding: 10rpx 0 ;
  175. text-align: center;
  176. width: 140rpx;
  177. margin-right: 20rpx;
  178. border-radius: 30rpx;
  179. color: #ffffff;
  180. }
  181. }
  182. .history{
  183. background: #1B203C;
  184. height: 300rpx;
  185. border-radius: 15rpx;
  186. padding: 20rpx 30rpx;
  187. margin-bottom: 40rpx;
  188. >.header{
  189. text{
  190. color: $info-color;
  191. font-weight: 600;
  192. }
  193. }
  194. .content{
  195. margin-top: 20rpx;
  196. .episode{
  197. width: calc(100%/4);
  198. margin-left: 20rpx;
  199. &:first-child{
  200. margin-left: 0;
  201. }
  202. .cover-image{
  203. image{
  204. width: 100%;
  205. height: 200rpx;
  206. }
  207. }
  208. }
  209. }
  210. }
  211. .menu-group{
  212. .menu-item{
  213. padding: 20rpx 0;
  214. background: transparent;
  215. border: none;
  216. text-align: unset;
  217. width: 100%;
  218. line-height: initial;
  219. font-size: initial;
  220. justify-content: space-between;
  221. &:after{
  222. content: unset;
  223. }
  224. .left-box{
  225. flex: 1;
  226. .icon{
  227. transform: translateY(4rpx);
  228. image{
  229. width: 55rpx;
  230. height: 55rpx;
  231. }
  232. }
  233. text{
  234. color: #fff;
  235. margin-left: 10rpx;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </style>