self.vue 9.0 KB

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