index.jsx 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import { Component } from 'react'
  2. import { View, Text, Button, Image, scrollView, Input } from '@tarojs/components'
  3. import * as api from '../../service/index'
  4. import tool from '../../common/tool'
  5. import Taro, { } from '@tarojs/taro'
  6. import './index.less'
  7. export default class collection extends Component {
  8. state = {
  9. userInfo: {},
  10. pageList: [
  11. {
  12. title: '阅读记录',
  13. icon: 'https://video-img.fyshark.com/1683703300058shsho.png',
  14. url: '/pages/mine/subpages/history/index',
  15. isOpen: true
  16. },
  17. {
  18. title: '我的收益',
  19. icon: 'https://video-img.fyshark.com/1683703315275akljs.png',
  20. url: '/pages/mine/subpages/makeMoney/index',
  21. isOpen: true
  22. },
  23. {
  24. title: '赚钱计划',
  25. icon: 'https://video-img.fyshark.com/1683703340452dnkhfgo.png',
  26. url: '/pages/mine/subpages/moneyPlay/index',
  27. isOpen: true
  28. },
  29. {
  30. title: '我的团队',
  31. icon: 'https://video-img.fyshark.com/1685065866448dslajd.png',
  32. url: '/pages/mine/subpages/team/index',
  33. isOpen: true
  34. },
  35. {
  36. title: '通知公告',
  37. icon: 'https://video-img.fyshark.com/1683703331018dhjldj.png',
  38. url: '',
  39. isOpen: false
  40. }
  41. ],
  42. adUnitId: '',
  43. ad_status: ''
  44. }
  45. componentWillMount () {
  46. tt.getUserInfo({
  47. withCredentials: true,
  48. success (res) {
  49. console.log(`getUserInfo 调用成功 ${res.userInfo}`, res);
  50. },
  51. fail (res) {
  52. console.log(`getUserInfo 调用失败`);
  53. },
  54. });
  55. this.getAppConfig()
  56. }
  57. componentDidShow () {
  58. Taro.showLoading({
  59. title: '加载中',
  60. })
  61. if (!Taro.getStorageSync('session_key')) {
  62. setTimeout(() => {
  63. this.getUserInfo()
  64. }, 1000)
  65. } else {
  66. this.getUserInfo()
  67. }
  68. }
  69. getAppConfig () {
  70. api.getAppConfig().then(res => {
  71. if (res.code == 200) {
  72. this.setState({
  73. // adUnitId: res.data.adUnitId,
  74. ad_status: res.data.ad_status
  75. })
  76. }
  77. })
  78. }
  79. getUserInfo () {
  80. let that = this
  81. api.getUserInfo().then(res => {
  82. Taro.hideLoading()
  83. if (res.code == 200) {
  84. tt.getUserInfo({
  85. withCredentials: true,
  86. success (item) {
  87. res.data.head_img = item.userInfo.avatarUrl
  88. res.data.user_name = item.userInfo.nickName
  89. that.setState({
  90. userInfo: res.data
  91. })
  92. },
  93. fail (item) {
  94. console.log(res.data,'res.data');
  95. that.setState({
  96. userInfo: res.data
  97. })
  98. console.log(`getUserInfo 调用失败`);
  99. },
  100. });
  101. }
  102. })
  103. }
  104. toVipDetial () {
  105. Taro.navigateTo({
  106. url: '/pages/mine/subpages/vipDetail/index'
  107. })
  108. }
  109. toDetial (item, index) {
  110. if (!item.isOpen) {
  111. Taro.showToast({ title: '敬请期待', icon: 'none' })
  112. return
  113. }
  114. Taro.navigateTo({
  115. url: item.url
  116. })
  117. }
  118. onShareAppMessage (res) {
  119. if (res.from === 'button') {
  120. // 来自页面内转发按钮
  121. console.log(res.target)
  122. }
  123. return {
  124. channel: "video",
  125. title: "测试分享视频",
  126. desc: "测试描述",
  127. extra: {
  128. videoTopics: ["hello", "hi"],
  129. withVideoId: true,
  130. },
  131. success (res) {
  132. /* res结构:{errMsg: string, videoId: string } */
  133. console.log(res.videoId);
  134. tt.navigateToVideoView({
  135. videoId: res.videoId,
  136. success: (res) => {
  137. /* res结构: {errMsg: string } */
  138. console.log("done");
  139. },
  140. fail: (err) => {
  141. if (err.errCode === 1006) {
  142. tt.showToast({
  143. title: "something wrong with your network",
  144. });
  145. }
  146. },
  147. });
  148. },
  149. }
  150. }
  151. render () {
  152. return (
  153. <View className='mine'>
  154. <View className='user-info'>
  155. <View className='info-left'>
  156. <Image className='user-img' src={this.state.userInfo.head_img}></Image>
  157. </View>
  158. <View className='info-right'>
  159. <View className='user-name'>{this.state.userInfo.user_name}
  160. {
  161. this.state.userInfo.is_vip == 1 &&
  162. <Image className='vip-img' src='https://video-img.fyshark.com/1683860337987f-vip3.png'></Image>
  163. }
  164. </View>
  165. <View className='user-id'>用户ID:{this.state.userInfo.id}</View>
  166. </View>
  167. </View>
  168. {
  169. this.state.userInfo.is_vip == 0 ?
  170. <View className='user-vip-banner' onClick={e => (this.toVipDetial())}>
  171. <Image className='banner-img' mode='widthFix' src='https://video-img.fyshark.com/1683705427196VIP.png'></Image>
  172. </View>
  173. :
  174. <View className='user-vip-banner-have'>
  175. <View className='vip-banner-have-left'>
  176. <Image className='vip-banner-img' src='https://video-img.fyshark.com/1683860337987f-vip3.png'></Image>
  177. <View className='vip-banner-tips'>已开通会员,有效期至:{tool.formattedDate(this.state.userInfo.time_is_vip)}</View>
  178. </View>
  179. <View className='vip-banner-have-right' onClick={e => (this.toVipDetial())}>
  180. 续费
  181. </View>
  182. </View>
  183. }
  184. <View className='user-page'>
  185. {
  186. this.state.pageList.map((item, index) => (
  187. <View className='page-info' key={index} onClick={e => (this.toDetial(item, index))}>
  188. <View className='page-left'>
  189. <Image className='page-icon' src={item.icon}></Image>
  190. <View className='page-title'>{item.title}</View>
  191. </View>
  192. <Image className='page-next' src='https://video-img.fyshark.com/1683703470907shkls.png'></Image>
  193. </View>
  194. ))
  195. }
  196. <Button className=' button'
  197. plain type='default' open-type='contact'>
  198. <View className='page-info'>
  199. <View className='page-left'>
  200. <Image className='page-icon' src='https://video-img.fyshark.com/1683703284336shkdj.png'></Image>
  201. <View className='page-title'>联系客服</View>
  202. </View>
  203. <Image className='page-next' src='https://video-img.fyshark.com/1683703470907shkls.png'></Image>
  204. </View>
  205. </Button>
  206. {/* <Button className=' button'
  207. plain type='default' open-type='share'>
  208. <View className='page-info'>
  209. <View className='page-left'>
  210. <Image className='page-icon' src='https://video-img.fyshark.com/1683703284336shkdj.png'></Image>
  211. <View className='page-title'>转发</View>
  212. </View>
  213. <Image className='page-next' src='https://video-img.fyshark.com/1683703470907shkls.png'></Image>
  214. </View>
  215. </Button> */}
  216. </View>
  217. </View>
  218. )
  219. }
  220. }