signUp.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <view class="image-container" @click="selectShow = true">
  4. <block v-if="$u.test.isEmpty(data.urls)">
  5. <view class="cuIcon-roundaddfill theme-color" style="font-size: 80upx;padding: 100upx 0 30upx 0;"></view>
  6. <view class="text-black text-bold text-sm">添加图片或视频</view>
  7. <view class="text-sm text-gray margin-top-xs">建议上传横排照片或者视频</view>
  8. </block>
  9. <block v-else>
  10. <block v-if="data.urlsType == 0">
  11. <image :src="data.urls" style="height: 400upx;" mode="aspectFit" @click.stop="preViewImg(data.urls)"></image>
  12. </block>
  13. <block v-else>
  14. <video :src="data.urls" style="height: 400upx;"></video>
  15. </block>
  16. </block>
  17. </view>
  18. <view class="image-container" @click="chooseAvatar" v-if="data.urlsType == 1">
  19. <block v-if="$u.test.isEmpty(data.cover)">
  20. <view class="cuIcon-roundaddfill theme-color" style="font-size: 80upx;padding: 100upx 0 30upx 0;"></view>
  21. <view class="text-black text-bold text-sm">请上传作品封面</view>
  22. </block>
  23. <block v-else>
  24. <image :src="data.cover" style="height: 400upx;" mode="aspectFit" @click.stop="preViewImg(data.cover)"></image>
  25. </block>
  26. </view>
  27. <u-action-sheet :list="list" @click="upload" v-model="selectShow"></u-action-sheet>
  28. <view class="basic-container">
  29. <view class="padding-sm">
  30. <text class="cuIcon-titles theme-color" style="font-size: 36upx;"></text>
  31. <text class="text-black text-bold text-lg">基本信息</text>
  32. </view>
  33. <view class="padding-sm flex justify-around align-center">
  34. <block v-for="(item, index) in classification" :key="index">
  35. <view class="tags" :class="current == index ? 'theme-bg-color text-white' : ''" @click="select(index,item)">{{item}}</view>
  36. </block>
  37. </view>
  38. <view class="padding-sm">
  39. <text class="text-black text-bold text-lg padding-left-sm">{{detail.personTitle}}</text>
  40. <view style="padding: 30upx 20upx;">
  41. <u-input v-model="data.personName" :placeholder="'请输入' + detail.personTitle" />
  42. </view>
  43. <view style="padding: 0 20upx 40upx 20upx;">
  44. <u-line color="#e3e3e3" />
  45. </view>
  46. <text class="text-black text-bold text-lg padding-left-sm">{{detail.productionTitle}}</text>
  47. <view style="padding: 30upx 20upx;">
  48. <u-input v-model="data.title" :placeholder="'请输入' + detail.productionTitle" />
  49. </view>
  50. <view style="padding: 0 20upx 40upx 20upx;">
  51. <u-line color="#e3e3e3" />
  52. </view>
  53. <text class="text-black text-bold text-lg padding-left-sm">{{detail.introductionTitle}}</text>
  54. <view style="padding: 30upx 20upx 0 20upx;">
  55. <u-input v-model="data.introduce" type="textarea" :clearable="false" height="140" :autoHeight="false" maxlength="60" :placeholder="'请输入' + detail.introductionTitle" />
  56. </view>
  57. <view class="flex justify-end padding-right-sm padding-bottom-sm text-gray">{{data.introduce.length}} / 60</view>
  58. <view style="padding: 0 20upx 40upx 20upx;">
  59. <u-line color="#e3e3e3" />
  60. </view>
  61. <view style="margin: 30upx 0 40upx 0;">
  62. <u-button class="custom-style" shape="circle" @click="navWithParam">确定提交</u-button>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="homeBtn" @click="home">
  67. <image src="/static/home.png" style="width: 40upx;height: 40upx;" />
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. detail:{},
  76. selectShow: false,
  77. list: [{
  78. text: '上传图片'
  79. }, {
  80. text: '上传视频'
  81. }],
  82. current: 0,
  83. classification: [],
  84. data: {
  85. userId: '',
  86. urlsType: 0,
  87. urls: '',
  88. cover: '',
  89. title: '',
  90. personName: '',
  91. personType: '',
  92. introduce: '',
  93. activityId: '',
  94. }
  95. }
  96. },
  97. onLoad(options) {
  98. this.getActivityDetail(options.activityId);
  99. this.data.activityId = options.activityId;
  100. this.data.userId = uni.getStorageSync("userId");
  101. },
  102. created() {
  103. uni.$on('uAvatarCropper', path => {
  104. // 可以在此上传到服务端
  105. uni.uploadFile({
  106. url: `https://music.nanyue6688.com/ldt/api/putObject`, //仅为示例,非真实的接口地址
  107. filePath: path,
  108. name: 'file',
  109. success: (uploadFileRes) => {
  110. this.data.urls = JSON.parse(uploadFileRes.data).data;
  111. this.data.cover = JSON.parse(uploadFileRes.data).data;
  112. }
  113. });
  114. })
  115. },
  116. methods: {
  117. async upload(index) {
  118. console.log(index);
  119. let res;
  120. this.data.urlsType = index
  121. if (index == 0) {
  122. //上传图片
  123. // res = await this.$mpi.uploadFile()
  124. this.chooseAvatar();
  125. } else {
  126. //上传视频
  127. res = await this.$mpi.uploadVideo()
  128. }
  129. let obj = JSON.parse(res);
  130. this.data.urls = obj.data
  131. },
  132. async uploadCover() {
  133. let res = await this.$mpi.uploadFile()
  134. this.data.cover = JSON.parse(res).data;
  135. },
  136. home() {
  137. uni.navigateTo({
  138. url: "/pages/activityList/home/home?activityId=" + this.data.activityId,
  139. })
  140. },
  141. getActivityDetail(id) {
  142. this.$u.api.activity.detail({id: id}).then(res => {
  143. this.detail = res
  144. this.classification = res.classification.split(',');
  145. this.data.personType = this.classification[0];
  146. })
  147. },
  148. preViewImg(url){
  149. uni.previewImage({
  150. urls: [url]
  151. });
  152. },
  153. select(index, item) {
  154. this.current = index;
  155. this.data.personType = item;
  156. },
  157. chooseAvatar() {
  158. // 此为uView的跳转方法,详见"文档-JS"部分,也可以用uni的uni.navigateTo
  159. this.$u.route({
  160. // 关于此路径,请见下方"注意事项"
  161. url: '/uview-ui/components/u-avatar-cropper/u-avatar-cropper',
  162. // 内部已设置以下默认参数值,可不传这些参数
  163. params: {
  164. // 输出图片宽度,高等于宽,单位px
  165. destWidth: 300,
  166. // 裁剪框宽度,高等于宽,单位px
  167. rectWidth: 300,
  168. // 输出的图片类型,如果'png'类型发现裁剪的图片太大,改成"jpg"即可
  169. fileType: 'jpg',
  170. }
  171. })
  172. },
  173. navWithParam() {
  174. console.log(this.data);
  175. if (this.$u.test.isEmpty(this.data.userId)) {
  176. uni.showToast({
  177. icon: "none",
  178. title: "请登录后再操作"
  179. })
  180. return;
  181. }
  182. if (this.$u.test.isEmpty(this.data.urls)) {
  183. uni.showToast({
  184. icon: "none",
  185. title: "请上传作品"
  186. })
  187. return;
  188. }
  189. if (this.data.urlsType == 1 && this.$u.test.isEmpty(this.data.cover)) {
  190. uni.showToast({
  191. icon: "none",
  192. title: "请上传作品封面"
  193. })
  194. return;
  195. }
  196. if (this.$u.test.isEmpty(this.data.personName)) {
  197. uni.showToast({
  198. icon: "none",
  199. title: "请填写个人名称"
  200. })
  201. return;
  202. }
  203. if (this.$u.test.isEmpty(this.data.title)) {
  204. uni.showToast({
  205. icon: "none",
  206. title: "请填写" + this.detail.productionTitle
  207. })
  208. return;
  209. }
  210. if (this.$u.test.isEmpty(this.data.introduce)) {
  211. uni.showToast({
  212. icon: "none",
  213. title: "请填写个人介绍"
  214. })
  215. return;
  216. } else {
  217. this.$u.api.activity.signUp(this.data).then(res => {
  218. uni.showToast({
  219. icon: "none",
  220. title: "提交成功",
  221. duration: 3000,
  222. success: () => {
  223. uni.redirectTo({
  224. url: '/pages/activityList/mine/introduction?id=' + res.id
  225. })
  226. }
  227. })
  228. })
  229. }
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .image-container {
  236. text-align: center;
  237. background-color: #FFFFFF;
  238. height: 400upx;
  239. margin: 30upx;
  240. border-radius: 30upx;
  241. }
  242. .basic-container {
  243. background-color: #FFFFFF;
  244. margin: 20upx;
  245. border-radius: 30upx;
  246. }
  247. .tags {
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. width: 30%;
  252. height: 70upx;
  253. border: #4f4f4f 1px solid;
  254. border-radius: 28upx;
  255. }
  256. .custom-style {
  257. background-color: #5a3ee8;
  258. color: #FFFFFF;
  259. width: 400rpx;
  260. }
  261. </style>