鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
6.3 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view>
  3. <uv-popup ref="popup" mode="bottom" bgColor="none" >
  4. <view class="popup__view">
  5. <view class="flex header">
  6. <view class="title">标记有我</view>
  7. <button class="btn" @click="close">关闭</button>
  8. </view>
  9. <view class="form">
  10. <uv-form
  11. ref="form"
  12. :model="form"
  13. :rules="rules"
  14. errorType="toast"
  15. >
  16. <view class="form-item">
  17. <uv-form-item prop="imagePath" :customStyle="formItemStyle">
  18. <view class="form-item-label">
  19. <image class="icon" src="@/pages_order/static/icon-require.png" mode="widthFix"></image>
  20. 上传本人照片
  21. </view>
  22. <view class="form-item-content">
  23. <button class="flex btn btn-avatar" @click="onUpload">
  24. <view v-if="form.imagePath" class="avatar">
  25. <image class="img" :src="form.imagePath" mode="aspectFill"></image>
  26. <view class="flex mask">
  27. <image class="icon" src="@/pages_order/static/icon-change.png" mode="widthFix" />
  28. </view>
  29. </view>
  30. <view v-else class="flex avatar is-empty">
  31. <image class="icon" src="@/static/image/icon-plus.png" mode="widthFix" />
  32. </view>
  33. </button>
  34. </view>
  35. </uv-form-item>
  36. </view>
  37. </uv-form>
  38. </view>
  39. <view class="flex footer">
  40. <button class="flex btn btn-palin" @click="jumpToGrowing">成长档案</button>
  41. <button class="flex btn btn-primary" @click="onSubmit">开始标记</button>
  42. </view>
  43. </view>
  44. </uv-popup>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. activityId: null,
  52. form: {
  53. imagePath: null,
  54. },
  55. rules: {
  56. 'imagePath': {
  57. type: 'string',
  58. required: true,
  59. message: '请上传图片',
  60. },
  61. },
  62. formItemStyle: { padding: 0 },
  63. }
  64. },
  65. methods: {
  66. open(activityId) {
  67. this.activityId = activityId
  68. this.$refs.popup.open();
  69. },
  70. close() {
  71. this.$refs.popup.close();
  72. },
  73. onUpload() {
  74. uni.chooseImage({
  75. count: 1,
  76. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  77. success: res => {
  78. let image = res.tempFilePaths[0] // 将选择的图片赋值给我们定义的cover
  79. this.$Oss.ossUpload(image)
  80. .then(url => {
  81. this.form.imagePath = url
  82. })
  83. }
  84. });
  85. },
  86. async onSubmit() {
  87. try {
  88. await this.$refs.form.validate()
  89. const {
  90. imagePath,
  91. } = this.form
  92. const params = {
  93. activityId: this.activityId,
  94. imagePath,
  95. }
  96. const result = await this.$fetch('queryMarkmeList', params)
  97. uni.showToast({
  98. icon: 'success',
  99. title: '标记成功',
  100. });
  101. this.$emit('submitted', result)
  102. this.$store.commit('setMarkmeList', result)
  103. uni.navigateTo({
  104. url: '/pages_order/growing/activity/markList',
  105. success: () => {
  106. this.close()
  107. }
  108. })
  109. } catch (err) {
  110. console.log('onSave err', err)
  111. }
  112. },
  113. jumpToGrowing(id) {
  114. // todo
  115. this.$utils.navigateTo(`/pages/index/growing`)
  116. },
  117. },
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .popup__view {
  122. width: 100vw;
  123. display: flex;
  124. flex-direction: column;
  125. box-sizing: border-box;
  126. background: #FFFFFF;
  127. border-top-left-radius: 32rpx;
  128. border-top-right-radius: 32rpx;
  129. }
  130. .header {
  131. position: relative;
  132. width: 100%;
  133. padding: 24rpx 0;
  134. box-sizing: border-box;
  135. border-bottom: 2rpx solid #EEEEEE;
  136. .title {
  137. font-family: PingFang SC;
  138. font-weight: 500;
  139. font-size: 34rpx;
  140. line-height: 1.4;
  141. color: #181818;
  142. }
  143. .btn {
  144. font-family: PingFang SC;
  145. font-weight: 500;
  146. font-size: 32rpx;
  147. line-height: 1.4;
  148. color: #8B8B8B;
  149. position: absolute;
  150. top: 26rpx;
  151. left: 40rpx;
  152. }
  153. }
  154. .form {
  155. max-height: 75vh;
  156. padding: 32rpx 40rpx;
  157. box-sizing: border-box;
  158. overflow-y: auto;
  159. &-item {
  160. padding: 8rpx 0 6rpx 0;
  161. & + & {
  162. padding-top: 24rpx;
  163. border-top: 2rpx solid #EEEEEE;
  164. }
  165. &-label {
  166. margin-bottom: 14rpx;
  167. display: flex;
  168. align-items: center;
  169. font-family: PingFang SC;
  170. font-weight: 400;
  171. font-size: 26rpx;
  172. line-height: 1.4;
  173. color: #181818;
  174. .icon {
  175. margin-right: 8rpx;
  176. width: 16rpx;
  177. height: auto;
  178. }
  179. }
  180. &-content {
  181. .text {
  182. padding: 2rpx 0;
  183. font-family: PingFang SC;
  184. font-weight: 400;
  185. font-size: 32rpx;
  186. line-height: 1.4;
  187. &.placeholder {
  188. color: #C6C6C6;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. .footer {
  195. column-gap: 32rpx;
  196. width: 100%;
  197. padding: 32rpx 40rpx;
  198. box-sizing: border-box;
  199. border-top: 2rpx solid #F1F1F1;
  200. .btn {
  201. flex: 1;
  202. padding: 14rpx 0;
  203. box-sizing: border-box;
  204. font-family: PingFang SC;
  205. font-weight: 500;
  206. font-size: 36rpx;
  207. line-height: 1.4;
  208. border-radius: 41rpx;
  209. &-palin {
  210. color: #252545;
  211. border: 2rpx solid #252545;
  212. }
  213. &-primary {
  214. color: #FFFFFF;
  215. background: linear-gradient(to right, #21FEEC, #019AF9);
  216. border: 2rpx solid #00A9FF;
  217. }
  218. }
  219. }
  220. .btn-avatar {
  221. display: inline-flex;
  222. }
  223. .avatar {
  224. position: relative;
  225. width: 200rpx;
  226. height: 200rpx;
  227. border-radius: 24rpx;
  228. overflow: hidden;
  229. .img {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. .mask {
  234. position: absolute;
  235. top: 0;
  236. left: 0;
  237. width: 100%;
  238. height: 100%;
  239. background: #00000080;
  240. border-radius: 24rpx;
  241. .icon {
  242. width: 64rpx;
  243. height: 64rpx;
  244. }
  245. }
  246. &.is-empty {
  247. background: #F7F8FA;
  248. .icon {
  249. width: 61rpx;
  250. height: auto;
  251. }
  252. }
  253. }
  254. </style>