signUp.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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;" @click="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;" @click="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://yyzs.nanyue6688.com/ldt/api/putObject`, //仅为示例,非真实的接口地址
  107. filePath: path,
  108. name: 'file',
  109. success: (uploadFileRes) => {
  110. this.data.cover = JSON.parse(uploadFileRes.data).data;
  111. }
  112. });
  113. })
  114. },
  115. methods: {
  116. async upload(index) {
  117. console.log(index);
  118. let res;
  119. this.data.urlsType = index
  120. if (index == 0) {
  121. //上传图片
  122. res = await this.$mpi.uploadFile()
  123. } else {
  124. //上传视频
  125. res = await this.$mpi.uploadVideo()
  126. }
  127. let obj = JSON.parse(res);
  128. this.data.urls = obj.data
  129. },
  130. async uploadCover() {
  131. let res = await this.$mpi.uploadFile()
  132. this.data.cover = JSON.parse(res).data;
  133. },
  134. home() {
  135. uni.navigateTo({
  136. url: "/pages/activityList/home/home?activityId=" + this.data.activityId,
  137. })
  138. },
  139. getActivityDetail(id) {
  140. this.$u.api.activity.detail({id: id}).then(res => {
  141. this.detail = res
  142. this.classification = res.classification.split(',');
  143. this.data.personType = this.classification[0];
  144. })
  145. },
  146. preViewImg(url){
  147. uni.previewImage({
  148. urls: [url]
  149. });
  150. },
  151. select(index, item) {
  152. this.current = index;
  153. this.data.personType = item;
  154. },
  155. chooseAvatar() {
  156. // 此为uView的跳转方法,详见"文档-JS"部分,也可以用uni的uni.navigateTo
  157. this.$u.route({
  158. // 关于此路径,请见下方"注意事项"
  159. url: '/uview-ui/components/u-avatar-cropper/u-avatar-cropper',
  160. // 内部已设置以下默认参数值,可不传这些参数
  161. params: {
  162. // 输出图片宽度,高等于宽,单位px
  163. destWidth: 300,
  164. // 裁剪框宽度,高等于宽,单位px
  165. rectWidth: 280,
  166. // 输出的图片类型,如果'png'类型发现裁剪的图片太大,改成"jpg"即可
  167. fileType: 'jpg',
  168. }
  169. })
  170. },
  171. navWithParam() {
  172. console.log(this.data);
  173. if (this.$u.test.isEmpty(this.data.userId)) {
  174. uni.showToast({
  175. icon: "none",
  176. title: "请登录后再操作"
  177. })
  178. return;
  179. }
  180. if (this.$u.test.isEmpty(this.data.urls)) {
  181. uni.showToast({
  182. icon: "none",
  183. title: "请上传作品"
  184. })
  185. return;
  186. }
  187. if (this.data.urlsType == 1 && this.$u.test.isEmpty(this.data.cover)) {
  188. uni.showToast({
  189. icon: "none",
  190. title: "请上传作品封面"
  191. })
  192. return;
  193. }
  194. if (this.$u.test.isEmpty(this.data.personName)) {
  195. uni.showToast({
  196. icon: "none",
  197. title: "请填写个人名称"
  198. })
  199. return;
  200. }
  201. if (this.$u.test.isEmpty(this.data.title)) {
  202. uni.showToast({
  203. icon: "none",
  204. title: "请填写" + this.detail.productionTitle
  205. })
  206. return;
  207. }
  208. if (this.$u.test.isEmpty(this.data.introduce)) {
  209. uni.showToast({
  210. icon: "none",
  211. title: "请填写个人介绍"
  212. })
  213. return;
  214. } else {
  215. this.$u.api.activity.signUp(this.data).then(res => {
  216. uni.showToast({
  217. icon: "none",
  218. title: "提交成功",
  219. duration: 3000,
  220. success: () => {
  221. uni.redirectTo({
  222. url: '/pages/activityList/mine/introduction?id=' + res.id
  223. })
  224. }
  225. })
  226. })
  227. }
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. .image-container {
  234. text-align: center;
  235. background-color: #FFFFFF;
  236. height: 400upx;
  237. margin: 30upx;
  238. border-radius: 30upx;
  239. }
  240. .basic-container {
  241. background-color: #FFFFFF;
  242. margin: 20upx;
  243. border-radius: 30upx;
  244. }
  245. .tags {
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. width: 30%;
  250. height: 70upx;
  251. border: #4f4f4f 1px solid;
  252. border-radius: 28upx;
  253. }
  254. .custom-style {
  255. background-color: #5a3ee8;
  256. color: #FFFFFF;
  257. width: 400rpx;
  258. }
  259. </style>