signUp.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. </block>
  8. <block v-else>
  9. <block v-if="data.urlsType == 0">
  10. <image :src="data.urls" style="height: 400upx;" @click="preViewImg(data.urls)"></image>
  11. </block>
  12. <block v-else>
  13. <video :src="data.urls" style="height: 400upx;"></video>
  14. </block>
  15. </block>
  16. </view>
  17. <view class="image-container" @click="uploadCover" v-if="data.urlsType == 1">
  18. <block v-if="$u.test.isEmpty(data.cover)">
  19. <view class="cuIcon-roundaddfill theme-color" style="font-size: 80upx;padding: 100upx 0 30upx 0;"></view>
  20. <view class="text-black text-bold text-sm">请上传作品封面</view>
  21. </block>
  22. <block v-else>
  23. <image :src="data.cover" style="height: 400upx;" @click="preViewImg(data.cover)"></image>
  24. </block>
  25. </view>
  26. <u-action-sheet :list="list" @click="upload" v-model="selectShow"></u-action-sheet>
  27. <view class="basic-container">
  28. <view class="padding-sm">
  29. <text class="cuIcon-titles theme-color" style="font-size: 36upx;"></text>
  30. <text class="text-black text-bold text-lg">基本信息</text>
  31. </view>
  32. <view class="padding-sm flex justify-around align-center">
  33. <block v-for="(item, index) in classification" :key="index">
  34. <view class="tags" :class="current == index ? 'theme-bg-color text-white' : ''" @click="select(index,item)">{{item}}</view>
  35. </block>
  36. </view>
  37. <view class="padding-sm">
  38. <text class="text-black text-bold text-lg padding-left-sm">{{detail.personTitle}}</text>
  39. <view style="padding: 30upx 20upx;">
  40. <u-input v-model="data.personName" :placeholder="'请输入' + detail.personTitle" />
  41. </view>
  42. <view style="padding: 0 20upx 40upx 20upx;">
  43. <u-line color="#e3e3e3" />
  44. </view>
  45. <text class="text-black text-bold text-lg padding-left-sm">{{detail.productionTitle}}</text>
  46. <view style="padding: 30upx 20upx;">
  47. <u-input v-model="data.title" :placeholder="'请输入' + detail.productionTitle" />
  48. </view>
  49. <view style="padding: 0 20upx 40upx 20upx;">
  50. <u-line color="#e3e3e3" />
  51. </view>
  52. <text class="text-black text-bold text-lg padding-left-sm">{{detail.introductionTitle}}</text>
  53. <view style="padding: 30upx 20upx 0 20upx;">
  54. <u-input v-model="data.introduce" type="textarea" :clearable="false" height="140" :autoHeight="false" maxlength="60" :placeholder="'请输入' + detail.productionTitle" />
  55. </view>
  56. <view class="flex justify-end padding-right-sm padding-bottom-sm text-gray">{{data.introduce.length}} / 60</view>
  57. <view style="padding: 0 20upx 40upx 20upx;">
  58. <u-line color="#e3e3e3" />
  59. </view>
  60. <view style="margin: 30upx 0 40upx 0;">
  61. <u-button class="custom-style" shape="circle" @click="navWithParam">确定提交</u-button>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. detail:{},
  72. selectShow: false,
  73. list: [{
  74. text: '上传图片'
  75. }, {
  76. text: '上传视频'
  77. }],
  78. current: 0,
  79. classification: [],
  80. data: {
  81. userId: '',
  82. urlsType: 0,
  83. urls: '',
  84. cover: '',
  85. title: '',
  86. personName: '',
  87. personType: '',
  88. introduce: '',
  89. activityId: '',
  90. }
  91. }
  92. },
  93. onLoad(options) {
  94. this.getActivityDetail(options.activityId);
  95. this.data.activityId = options.activityId;
  96. this.data.userId = uni.getStorageSync("userId");
  97. },
  98. methods: {
  99. async upload(index) {
  100. console.log(index);
  101. let res;
  102. this.data.urlsType = index
  103. if (index == 0) {
  104. //上传图片
  105. res = await this.$mpi.uploadFile()
  106. } else {
  107. //上传视频
  108. res = await this.$mpi.uploadVideo()
  109. }
  110. let obj = JSON.parse(res);
  111. this.data.urls = obj.data
  112. },
  113. async uploadCover() {
  114. let res = await this.$mpi.uploadFile()
  115. this.data.cover = JSON.parse(res).data;
  116. },
  117. getActivityDetail(id) {
  118. this.$u.api.activity.detail({id: id}).then(res => {
  119. this.detail = res
  120. this.classification = res.classification.split(',');
  121. this.data.personType = this.classification[0];
  122. })
  123. },
  124. preViewImg(url){
  125. uni.previewImage({
  126. urls: [url]
  127. });
  128. },
  129. select(index, item) {
  130. this.current = index;
  131. this.data.personType = item;
  132. },
  133. navWithParam() {
  134. console.log(this.data);
  135. if (this.$u.test.isEmpty(this.data.urls)) {
  136. uni.showToast({
  137. icon: "none",
  138. title: "请上传作品"
  139. })
  140. return;
  141. }
  142. if (this.data.urlsType == 1 && this.$u.test.isEmpty(this.data.cover)) {
  143. uni.showToast({
  144. icon: "none",
  145. title: "请上传作品封面"
  146. })
  147. return;
  148. }
  149. if (this.$u.test.isEmpty(this.data.personName)) {
  150. uni.showToast({
  151. icon: "none",
  152. title: "请填写个人名称"
  153. })
  154. return;
  155. }
  156. if (this.$u.test.isEmpty(this.data.title)) {
  157. uni.showToast({
  158. icon: "none",
  159. title: "请填写" + this.detail.productionTitle
  160. })
  161. return;
  162. }
  163. if (this.$u.test.isEmpty(this.data.introduce)) {
  164. uni.showToast({
  165. icon: "none",
  166. title: "请填写个人介绍"
  167. })
  168. return;
  169. } else {
  170. this.$u.api.activity.signUp(this.data).then(res => {
  171. uni.showToast({
  172. icon: "none",
  173. title: "提交成功",
  174. duration: 3000,
  175. success: () => {
  176. uni.redirectTo({
  177. url: '/pages/activityList/mine/introduction?id=' + res.id
  178. })
  179. }
  180. })
  181. })
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .image-container {
  189. text-align: center;
  190. background-color: #FFFFFF;
  191. height: 400upx;
  192. margin: 30upx;
  193. border-radius: 30upx;
  194. }
  195. .basic-container {
  196. background-color: #FFFFFF;
  197. margin: 20upx;
  198. border-radius: 30upx;
  199. }
  200. .tags {
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. width: 30%;
  205. height: 70upx;
  206. border: #4f4f4f 1px solid;
  207. border-radius: 28upx;
  208. }
  209. .custom-style {
  210. background-color: #5a3ee8;
  211. color: #FFFFFF;
  212. width: 400rpx;
  213. }
  214. </style>