signUp.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.productionTitle" />
  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>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. detail:{},
  73. selectShow: false,
  74. list: [{
  75. text: '上传图片'
  76. }, {
  77. text: '上传视频'
  78. }],
  79. current: 0,
  80. classification: [],
  81. data: {
  82. userId: '',
  83. urlsType: 0,
  84. urls: '',
  85. cover: '',
  86. title: '',
  87. personName: '',
  88. personType: '',
  89. introduce: '',
  90. activityId: '',
  91. }
  92. }
  93. },
  94. onLoad(options) {
  95. this.getActivityDetail(options.activityId);
  96. this.data.activityId = options.activityId;
  97. this.data.userId = uni.getStorageSync("userId");
  98. },
  99. methods: {
  100. async upload(index) {
  101. console.log(index);
  102. let res;
  103. this.data.urlsType = index
  104. if (index == 0) {
  105. //上传图片
  106. res = await this.$mpi.uploadFile()
  107. } else {
  108. //上传视频
  109. res = await this.$mpi.uploadVideo()
  110. }
  111. let obj = JSON.parse(res);
  112. this.data.urls = obj.data
  113. },
  114. async uploadCover() {
  115. let res = await this.$mpi.uploadFile()
  116. this.data.cover = JSON.parse(res).data;
  117. },
  118. getActivityDetail(id) {
  119. this.$u.api.activity.detail({id: id}).then(res => {
  120. this.detail = res
  121. this.classification = res.classification.split(',');
  122. this.data.personType = this.classification[0];
  123. })
  124. },
  125. preViewImg(url){
  126. uni.previewImage({
  127. urls: [url]
  128. });
  129. },
  130. select(index, item) {
  131. this.current = index;
  132. this.data.personType = item;
  133. },
  134. navWithParam() {
  135. console.log(this.data);
  136. if (this.$u.test.isEmpty(this.data.urls)) {
  137. uni.showToast({
  138. icon: "none",
  139. title: "请上传作品"
  140. })
  141. return;
  142. }
  143. if (this.data.urlsType == 1 && this.$u.test.isEmpty(this.data.cover)) {
  144. uni.showToast({
  145. icon: "none",
  146. title: "请上传作品封面"
  147. })
  148. return;
  149. }
  150. if (this.$u.test.isEmpty(this.data.personName)) {
  151. uni.showToast({
  152. icon: "none",
  153. title: "请填写个人名称"
  154. })
  155. return;
  156. }
  157. if (this.$u.test.isEmpty(this.data.title)) {
  158. uni.showToast({
  159. icon: "none",
  160. title: "请填写" + this.detail.productionTitle
  161. })
  162. return;
  163. }
  164. if (this.$u.test.isEmpty(this.data.introduce)) {
  165. uni.showToast({
  166. icon: "none",
  167. title: "请填写个人介绍"
  168. })
  169. return;
  170. } else {
  171. this.$u.api.activity.signUp(this.data).then(res => {
  172. uni.showToast({
  173. icon: "none",
  174. title: "提交成功",
  175. duration: 3000,
  176. success: () => {
  177. uni.redirectTo({
  178. url: '/pages/activityList/mine/introduction?id=' + res.id
  179. })
  180. }
  181. })
  182. })
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .image-container {
  190. text-align: center;
  191. background-color: #FFFFFF;
  192. height: 400upx;
  193. margin: 30upx;
  194. border-radius: 30upx;
  195. }
  196. .basic-container {
  197. background-color: #FFFFFF;
  198. margin: 20upx;
  199. border-radius: 30upx;
  200. }
  201. .tags {
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. width: 30%;
  206. height: 70upx;
  207. border: #4f4f4f 1px solid;
  208. border-radius: 28upx;
  209. }
  210. .custom-style {
  211. background-color: #5a3ee8;
  212. color: #FFFFFF;
  213. width: 400rpx;
  214. }
  215. </style>