signUp.vue 7.8 KB

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