self.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="self">
  3. <custom-nav :title="pageTitle"></custom-nav>
  4. <view class="content">
  5. <view class="showInfo" v-if="userServerInfo.status === 2 || userServerInfo.status === 3 || userServerInfo.status === 5 && (innerType === 2 || userServerInfo.signuped)">
  6. <view class="content">
  7. <view class="top">
  8. <!-- <open-data class="user-pic" type="userAvatarUrl"></open-data> -->
  9. <image :src="soldInfo.avatar" class="user-pic">
  10. <image v-if="soldInfo.score >= 300" class="hat" src="../../static/icon/hat.png" mode="scaleToFill"></image>
  11. <view class="user-info">
  12. <view class="name-grade-level">
  13. <!-- <open-data type="userNickName" class="name"></open-data> -->
  14. <view class="name">{{ soldInfo.name }}</view>
  15. <view class="grade">{{ soldInfo.grade || '' }}</view>
  16. <!-- 隐藏级别 -->
  17. <!-- <view class="level">
  18. <image src="../../static/icon/level.png" mode="scaleToFill"></image>
  19. <text>{{ soldInfo.level_name || '' }}</text>
  20. </view> -->
  21. </view>
  22. <view class="progress">
  23. 距离 {{ soldInfo.score | willDeg(userServerInfo.max_score) }} 还差 {{ soldInfo.score | lessScore(userServerInfo.max_score) }} 学分
  24. </view>
  25. </view>
  26. </view>
  27. <view class="line"></view>
  28. <view class="chart">
  29. <ucharts-line v-if="soldInfo.sold_data" :chartData="soldInfo.sold_data"></ucharts-line>
  30. </view>
  31. <view class="sold-info" style="text-align: center;">
  32. 总学分: <text style="color: #FA6342;">&nbsp;{{ soldInfo.score || 0 }}分</text>
  33. </view>
  34. <view class="sold-info">
  35. <view class="sold-info-left">今日学分:<text>{{ soldInfo.score_today || 0 }}分</text></view>
  36. <view class="sold-info-right">昨日学分:<text>{{ soldInfo.score_yes || 0 }}分</text></view>
  37. </view>
  38. <view class="sold-info">
  39. <view class="sold-info-left">昨日奖励学分:<text>{{ soldInfo.score_send_yes || 0 }}分</text></view>
  40. <view class="sold-info-right">总奖励学分:<text>{{ soldInfo.score_send || 0 }}分</text></view>
  41. </view>
  42. <view class="sold-info">
  43. <view class="sold-info-left">销售产品总量:<text>{{ soldInfo.sold_total || 0 }}套</text></view>
  44. <view class="sold-info-right">销售产品总额:<text>{{ soldInfo.sales || 0 }}元</text></view>
  45. </view>
  46. <button open-type="share" v-if="innerType === 1" class="share">
  47. <text class="cuIcon-forwardfill"></text>
  48. </button>
  49. <view class="tohistory" @tap="tohisrace" v-if="innerType !== 3">
  50. 历史赛季 <text class="cuIcon-right"></text>
  51. </view>
  52. </view>
  53. </view>
  54. <image v-else class="nosignup" src="../../static/icon/nosignup.png" mode="scaleToFill"></image>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import { api_getPersonalSoldInfo } from '../../api.js'
  60. import uchartsLine from '../../components/ucharts-line.vue'
  61. export default {
  62. onShareAppMessage: function (res) {
  63. uni.showLoading({ title: '加载中', mask: true }) //显示loading
  64. console.log(JSON.stringify(this.soldInfo))
  65. if (res.from === 'button') {
  66. return {
  67. title: '我的卖货数据',
  68. path: `/pages/self/self?from=share&data=${JSON.stringify(this.soldInfo)}`
  69. }
  70. }
  71. return {
  72. title: '大卫博士商学院卖货争霸',
  73. path: '/pages/index/index'
  74. }
  75. },
  76. components: {
  77. uchartsLine
  78. },
  79. data() {
  80. return {
  81. pageTitle: '个人数据',
  82. soldInfo: {}, //当前页面数据
  83. innerType: 1, //判断用户是从哪个页面进入的 1 表示自己从首页或数据统计进入的 2 批发商或者客服从排行榜进入的 3 表示用户是从分享的页面进入的
  84. userId: ''
  85. };
  86. },
  87. computed: {
  88. userServerInfo () { //用户服务器信息
  89. return this.$store.state.userServerInfo
  90. }
  91. },
  92. methods: {
  93. tohisrace () { //去历史赛季页面 带着 innerType 属性是为了区分进入历史赛季页面的用户类型
  94. uni.navigateTo({
  95. url: `../hisrace/hisrace?from=self&innerType=${this.innerType}&id=${this.userId}`
  96. })
  97. },
  98. getUserinfo (opt) { //发送请求获取用户卖货数据
  99. // console.log(222)
  100. // let n = Date.now()
  101. // console.log(n)
  102. // let { start_time, end_time } = this.userServerInfo
  103. // if(n > start_time && n < end_time) {
  104. // console.log(333)
  105. uni.showLoading({ title: '加载中', mask: true }) //显示loading
  106. this.userId = opt.id
  107. this.$ajax.get(`${api_getPersonalSoldInfo}?id=${opt.id}&season=${this.userServerInfo.season}`).then(([ , { data: res }]) => {
  108. this.$hideLoading() //异步操作结束,停止 loading
  109. res.data.sold_data.categories.push('') //对折线图数据进行一些处理
  110. res.data.sold_data.categories.unshift('') //对折线图数据进行一些处理
  111. res.data.sold_data.series[0].data.push(null) //对折线图数据进行一些处理
  112. res.data.sold_data.series[0].data.unshift(null) //对折线图数据进行一些处理
  113. this.soldInfo = res.data
  114. }).catch(e => {
  115. uni.showModal({
  116. content: "获取个人数据失败",
  117. showCancel: false
  118. })
  119. })
  120. // }
  121. }
  122. },
  123. onLoad(opt) { //根据路由传过来的参数展示不同的内容
  124. if (opt.from === 'index') { //表示自己从首页或数据统计进入的
  125. if (this.userServerInfo.signuped) { //只有报名的用户才展示数据
  126. this.getUserinfo(opt) //发送请求获取用户卖货数据
  127. }
  128. } else if (opt.from === 'ranking') { //表示批发商或者客服从排行榜进入的
  129. this.innerType = 2
  130. if (opt.id) {
  131. this.getUserinfo(opt) //发送请求获取用户卖货数据
  132. console.log(this.innerType)
  133. }
  134. } else if (opt.from === 'share') { //表示用户是从分享的页面进入的
  135. this.innerType = 3
  136. uni.hideLoading() //停止 loading
  137. this.soldInfo = JSON.parse(opt.data)
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .self {
  144. @include page();
  145. .content {
  146. .showInfo {
  147. height: 100%;
  148. background: #FE531B;
  149. position: relative;
  150. .content {
  151. position: absolute;
  152. width: 656rpx;
  153. height: auto;
  154. top: 31rpx;
  155. left: 47rpx;
  156. bottom: 67rpx;
  157. border-radius: 8rpx;
  158. background: #FFFFFF;
  159. box-sizing: border-box;
  160. padding: 42rpx 44rpx 0;
  161. .top {
  162. height: 80rpx;
  163. display: flex;
  164. align-items: center;
  165. position: relative;
  166. .user-pic {
  167. height: 100%;
  168. width: 80rpx;
  169. border-radius: 50%;
  170. overflow: hidden;
  171. }
  172. .hat {
  173. position: absolute;
  174. top: -40rpx;
  175. left: 0px;
  176. width: 80rpx;
  177. height: 69.873rpx;
  178. }
  179. .user-info {
  180. flex: 1;
  181. display: flex;
  182. flex-direction: column;
  183. height: 100%;
  184. margin-left: 16rpx;
  185. .progress {
  186. color: #FA6342;
  187. font-size: 26rpx;
  188. }
  189. .name-grade-level {
  190. height: 50%;
  191. width: 100%;
  192. display: flex;
  193. align-items: flex-end;
  194. vertical-align: bottom;
  195. .name {
  196. font-size: 30rpx;
  197. color: #FA6342;
  198. max-width: 38%;
  199. overflow: hidden;
  200. white-space: nowrap;
  201. text-overflow: ellipsis;
  202. }
  203. .grade {
  204. font-size: 24rpx;
  205. color: #FA6342;
  206. margin-left: 16rpx;
  207. vertical-align: baseline;
  208. }
  209. .level {
  210. margin-left: 18rpx;
  211. width: 142rpx;
  212. height: 30rpx;
  213. padding-right: 12rpx;
  214. border-radius: 15rpx;
  215. font-size: 24rpx;
  216. background: #FA6342;
  217. color: #FFFFFF;
  218. text {
  219. float: right;
  220. line-height: 35rpx;
  221. }
  222. image {
  223. width: 30rpx;
  224. height: 30rpx;
  225. float: left;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .line {
  232. height: 1rpx;
  233. background: rgba(238,238,238,1);
  234. margin: 30rpx 0;
  235. }
  236. .chart {
  237. height: 600rpx;
  238. border-bottom: 1rpx solid rgba(238,238,238,1);
  239. box-sizing: border-box;
  240. padding-top: 52rpx;
  241. }
  242. .sold-info {
  243. height: 63rpx;
  244. line-height: 63rpx;
  245. border-bottom: 1rpx solid rgba(238,238,238,1);
  246. view {
  247. box-sizing: border-box;
  248. width: 50%;
  249. height: 100%;
  250. font-size: 24rpx;
  251. color: rgba(42,42,42,1);
  252. padding-left: 8rpx;
  253. float: right;
  254. &.sold-info-left {
  255. float: left;
  256. border-right: 1rpx solid rgba(238,238,238,1);
  257. }
  258. &.sold-info-right {
  259. float: right;
  260. }
  261. text {
  262. color: #FA6342;
  263. }
  264. }
  265. }
  266. .share {
  267. position: absolute;
  268. width: 72rpx;
  269. height: 72rpx;
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. border-radius: 50%;
  274. background: #FFFFFF;
  275. border: 8rpx solid #FE531B;
  276. left: 50%;
  277. font-size: 36rpx;
  278. bottom: -36rpx;
  279. color: #FE531B;
  280. transform: translateX(-50%);
  281. padding: 0;
  282. }
  283. .tohistory {
  284. position: absolute;
  285. right: 37rpx;
  286. bottom: 26rpx;
  287. color: #FA6342;
  288. }
  289. }
  290. }
  291. .nosignup {
  292. display: block;
  293. width: 374rpx;
  294. height: 374rpx;
  295. margin: 320rpx auto;
  296. }
  297. }
  298. }
  299. </style>