signUp.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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="uploadCover" 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. methods: {
  103. async upload(index) {
  104. console.log(index);
  105. let res;
  106. this.data.urlsType = index
  107. if (index == 0) {
  108. //上传图片
  109. res = await this.$mpi.uploadFile()
  110. } else {
  111. //上传视频
  112. res = await this.$mpi.uploadVideo()
  113. }
  114. let obj = JSON.parse(res);
  115. this.data.urls = obj.data
  116. },
  117. async uploadCover() {
  118. let res = await this.$mpi.uploadFile()
  119. this.data.cover = JSON.parse(res).data;
  120. },
  121. home() {
  122. uni.navigateTo({
  123. url: "/pages/activityList/home/home?activityId=" + this.data.activityId,
  124. })
  125. },
  126. getActivityDetail(id) {
  127. this.$u.api.activity.detail({id: id}).then(res => {
  128. this.detail = res
  129. this.classification = res.classification.split(',');
  130. this.data.personType = this.classification[0];
  131. })
  132. },
  133. preViewImg(url){
  134. uni.previewImage({
  135. urls: [url]
  136. });
  137. },
  138. select(index, item) {
  139. this.current = index;
  140. this.data.personType = item;
  141. },
  142. navWithParam() {
  143. console.log(this.data);
  144. if (this.$u.test.isEmpty(this.data.userId)) {
  145. uni.showToast({
  146. icon: "none",
  147. title: "请登录后再操作"
  148. })
  149. return;
  150. }
  151. if (this.$u.test.isEmpty(this.data.urls)) {
  152. uni.showToast({
  153. icon: "none",
  154. title: "请上传作品"
  155. })
  156. return;
  157. }
  158. if (this.data.urlsType == 1 && this.$u.test.isEmpty(this.data.cover)) {
  159. uni.showToast({
  160. icon: "none",
  161. title: "请上传作品封面"
  162. })
  163. return;
  164. }
  165. if (this.$u.test.isEmpty(this.data.personName)) {
  166. uni.showToast({
  167. icon: "none",
  168. title: "请填写个人名称"
  169. })
  170. return;
  171. }
  172. if (this.$u.test.isEmpty(this.data.title)) {
  173. uni.showToast({
  174. icon: "none",
  175. title: "请填写" + this.detail.productionTitle
  176. })
  177. return;
  178. }
  179. if (this.$u.test.isEmpty(this.data.introduce)) {
  180. uni.showToast({
  181. icon: "none",
  182. title: "请填写个人介绍"
  183. })
  184. return;
  185. } else {
  186. this.$u.api.activity.signUp(this.data).then(res => {
  187. uni.showToast({
  188. icon: "none",
  189. title: "提交成功",
  190. duration: 3000,
  191. success: () => {
  192. uni.redirectTo({
  193. url: '/pages/activityList/mine/introduction?id=' + res.id
  194. })
  195. }
  196. })
  197. })
  198. }
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .image-container {
  205. text-align: center;
  206. background-color: #FFFFFF;
  207. height: 400upx;
  208. margin: 30upx;
  209. border-radius: 30upx;
  210. }
  211. .basic-container {
  212. background-color: #FFFFFF;
  213. margin: 20upx;
  214. border-radius: 30upx;
  215. }
  216. .tags {
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. width: 30%;
  221. height: 70upx;
  222. border: #4f4f4f 1px solid;
  223. border-radius: 28upx;
  224. }
  225. .custom-style {
  226. background-color: #5a3ee8;
  227. color: #FFFFFF;
  228. width: 400rpx;
  229. }
  230. </style>