myMusic.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view>
  3. <view v-if="data.cover" class="bg-img flex align-center" :style="[{backgroundImage:'url('+ data.cover +')'}]" style="height: 450upx;" @click="selectShow = true"></view>
  4. <view v-else class="flex justify-center align-center" style="height: 450upx;background-color: #5a3ee8;">
  5. <view class="text-white" @click="chooseAvatar">
  6. <text class="cuIcon-add " style="font-size: 120rpx;"></text>
  7. <view>上传封面</view>
  8. </view>
  9. </view>
  10. <u-action-sheet :list="list1" @click="changeCover" v-model="selectShow"></u-action-sheet>
  11. <view class="head">
  12. <view class="cu-avatar avatar round" :style="[{backgroundImage:'url('+ data.avatar +')'}]"></view>
  13. <view style="margin: 0 30upx 30upx 70upx;">
  14. <view class="flex align-center">
  15. <view class="text-black text-bold text-xl padding-right">{{data.nickName}}</view>
  16. <image src="/static/icon-vip.png" style="width: 30upx;height: 34upx;"></image>
  17. </view>
  18. <view class="padding-tb-sm">
  19. </view>
  20. <view class="flex align-center">
  21. <view>
  22. <text class="text-sm">共获热力</text>
  23. <text class="cuIcon-hotfill padding-lr-xs"></text>
  24. <text class="text-lg text-bold">{{data.totalHot}}</text>
  25. </view>
  26. <view style="height: 20upx;border: #dadada 1px solid; margin: 0 30upx;"></view>
  27. <view>
  28. <text class="text-sm">总值</text>
  29. <text class="padding-left-xs">¥</text>
  30. <text class="text-lg text-bold">{{data.totalCost}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="margin-top bg-white">
  36. <view class="padding-sm flex justify-between align-center">
  37. <view class="margin-left-sm text-lg text-black text-bold">我的作品</view>
  38. <button class="cu-btn theme-bg-color round text-white margin-right" @click="onTap">添加作品</button>
  39. </view>
  40. </view>
  41. <block v-for="(item, index) in list" :key="index">
  42. <view class="flex bg-white" style="padding: 10upx 70upx 30upx 70upx;" @click="detail(item.id)">
  43. <image v-if="item.urlsType==0" :src="item.urls" style="width: 120upx;height: 120upx;margin-right: 20upx;"></image>
  44. <image v-if="item.urlsType==1" :src="item.cover" style="width: 120upx;height: 120upx;margin-right: 20upx;"></image>
  45. <view style="width: 75%;">
  46. <view class="flex justify-between">
  47. <view class="music">
  48. <view class="name">{{item.title}}</view>
  49. <view class="author">{{item.personName}}[{{item.personType}}]</view>
  50. </view>
  51. <view>
  52. <view class="text-black">
  53. <text class="cuIcon-hotfill padding-right-xs"></text>
  54. <text class="text-lg text-bold">{{item.hotValue}}</text>
  55. </view>
  56. <view class="music-rank">NO.{{item.loginWebVO.rank}}</view>
  57. </view>
  58. </view>
  59. <view class="margin-top-sm"><u-line color="#cacaca"></u-line> </view>
  60. </view>
  61. </view>
  62. </block>
  63. <u-loadmore :status="status" v-if="list.length>4"/>
  64. <view class="padding-top">
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. activityId: '',
  73. userId:'',
  74. applyEndTime: '',
  75. data:{},
  76. list:[],
  77. status: 'loadmore',
  78. current:1,
  79. selectShow: false,
  80. list1: [{
  81. text: '查看原图'
  82. }, {
  83. text: '更换封面'
  84. }],
  85. }
  86. },
  87. onLoad(options) {
  88. this.activityId = options.activityId
  89. this.getActivityDetail(options.activityId);
  90. this.userId = uni.getStorageSync("userId");
  91. if (!this.userId) {
  92. this.$u.toast('用户未登录')
  93. return
  94. }
  95. this.init()
  96. },
  97. onReachBottom() {
  98. if (!this.userId) {
  99. this.$u.toast('用户未登录')
  100. return
  101. }
  102. if(this.list.length<this.current*10){
  103. this.status = 'nomore';
  104. return
  105. }else{
  106. this.status = 'loading';
  107. this.current = ++ this.current;
  108. this.fetchList()
  109. }
  110. },
  111. created() {
  112. uni.$on('uAvatarCropper', path => {
  113. // 可以在此上传到服务端
  114. uni.uploadFile({
  115. url: `https://yyzs.nanyue6688.com/ldt/api/putObject`, //仅为示例,非真实的接口地址
  116. filePath: path,
  117. name: 'file',
  118. success: (uploadFileRes) => {
  119. this.data.cover = JSON.parse(uploadFileRes.data).data;
  120. this.$u.api.user.submit({
  121. id: uni.getStorageSync("userId"),
  122. cover: JSON.parse(uploadFileRes.data).data
  123. }).then(res=>{
  124. this.fetchMineData()
  125. })
  126. }
  127. });
  128. })
  129. },
  130. methods: {
  131. init(){
  132. if (!this.userId) {
  133. this.$u.toast('用户未登录')
  134. return
  135. }
  136. this.fetchMineData()
  137. this.fetchList()
  138. },
  139. fetchList() {
  140. let params={
  141. userId:this.userId,
  142. current:this.current
  143. }
  144. this.$u.api.production.list(params).then(res=>{
  145. this.list = [...this.list,...res.records]
  146. })
  147. },
  148. fetchMineData() {
  149. this.$u.api.user.mineData({userId:this.userId}).then(res=>{
  150. this.data=res
  151. })
  152. },
  153. chooseAvatar() {
  154. console.log("触发裁剪方法");
  155. // 此为uView的跳转方法,详见"文档-JS"部分,也可以用uni的uni.navigateTo
  156. this.$u.route({
  157. // 关于此路径,请见下方"注意事项"
  158. url: '/uview-ui/components/u-avatar-cropper/u-avatar-cropper',
  159. // 内部已设置以下默认参数值,可不传这些参数
  160. params: {
  161. // 输出图片宽度,高等于宽,单位px
  162. destWidth: 300,
  163. // 裁剪框宽度,高等于宽,单位px
  164. rectWidth: 300,
  165. // 输出的图片类型,如果'png'类型发现裁剪的图片太大,改成"jpg"即可
  166. fileType: 'jpg',
  167. }
  168. })
  169. },
  170. uploadCover() {
  171. this.$mpi.uploadFile().then(res=>{
  172. let obj = JSON.parse(res)
  173. let params = {
  174. id:this.userId,
  175. cover:obj.data
  176. }
  177. this.$u.api.user.submit(params).then(res=>{
  178. this.fetchMineData()
  179. })
  180. })
  181. },
  182. getActivityDetail(id) {
  183. this.$u.api.activity.detail({id: id}).then(res => {
  184. this.applyEndTime = res.applyEndTime;
  185. })
  186. },
  187. onTap() {
  188. let changeTime = new Date() - Date.parse(this.applyEndTime.replace(/-/g, '/'));//时间戳差值
  189. if (changeTime > 0) { //检查活动是否已经停止报名
  190. uni.showToast({
  191. icon: "none",
  192. title: "报名已结束"
  193. })
  194. return;
  195. } else {
  196. uni.navigateTo({
  197. url: "/pages/activityList/activity/signUp?activityId=" + this.activityId
  198. })
  199. }
  200. },
  201. detail(id) {
  202. uni.navigateTo({
  203. url: "/pages/activityList/mine/introduction?id=" + id
  204. })
  205. },
  206. changeCover(index) {
  207. if (index == 0) {
  208. uni.previewImage({
  209. urls: [this.data.cover]
  210. })
  211. } else {
  212. this.chooseAvatar();
  213. }
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .head {
  220. background-color: #ffffff;
  221. margin-top: -26upx;
  222. height: 280upx;
  223. border-radius: 26upx 26upx 0 0;
  224. }
  225. .avatar {
  226. width: 130upx;
  227. height: 130upx;
  228. margin: -60upx 0 30upx 80upx;
  229. }
  230. .rank {
  231. display: flex;
  232. justify-content: center;
  233. background-color: #583be6;
  234. width: 40%;
  235. color: #ffffff;
  236. border-radius: 16upx;
  237. line-height: 60upx;
  238. }
  239. .music {
  240. .name {
  241. font-size: 28upx;
  242. font-family: PingFang SC;
  243. font-weight: 400;
  244. color: #000000;
  245. padding-bottom: 20upx;
  246. }
  247. .author {
  248. font-size: 28upx;
  249. font-family: PingFang SC;
  250. font-weight: 400;
  251. color: #9A9A9A;
  252. }
  253. }
  254. .music-rank {
  255. display: flex;
  256. margin-top: 18upx;
  257. line-height: 40upx;
  258. justify-content: center;
  259. border: #9d9d9d 1px solid;
  260. color: #9d9d9d;
  261. border-radius: 50upx;
  262. font-style: italic;
  263. }
  264. </style>