鸿宇研学生前端代码
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.

287 lines
6.1 KiB

  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">
  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. id: 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(id) {
  67. this.id = id
  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. imagePath,
  94. }
  95. // todo: check
  96. await this.$fetch('queryMarkmeList', params)
  97. uni.showToast({
  98. icon: 'success',
  99. title: '提交成功',
  100. });
  101. this.$emit('submitted')
  102. this.close()
  103. this.$utils.navigateTo(`/pages_order/growing/activity/markList`)
  104. } catch (err) {
  105. console.log('onSave err', err)
  106. }
  107. },
  108. jumpToGrowing(id) {
  109. // todo
  110. this.$utils.navigateTo(`/pages/index/growing`)
  111. },
  112. },
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .popup__view {
  117. width: 100vw;
  118. display: flex;
  119. flex-direction: column;
  120. box-sizing: border-box;
  121. background: #FFFFFF;
  122. border-top-left-radius: 32rpx;
  123. border-top-right-radius: 32rpx;
  124. }
  125. .header {
  126. position: relative;
  127. width: 100%;
  128. padding: 24rpx 0;
  129. box-sizing: border-box;
  130. border-bottom: 2rpx solid #EEEEEE;
  131. .title {
  132. font-family: PingFang SC;
  133. font-weight: 500;
  134. font-size: 34rpx;
  135. line-height: 1.4;
  136. color: #181818;
  137. }
  138. .btn {
  139. font-family: PingFang SC;
  140. font-weight: 500;
  141. font-size: 32rpx;
  142. line-height: 1.4;
  143. color: #8B8B8B;
  144. position: absolute;
  145. top: 26rpx;
  146. left: 40rpx;
  147. }
  148. }
  149. .form {
  150. max-height: 75vh;
  151. padding: 32rpx 40rpx;
  152. box-sizing: border-box;
  153. overflow-y: auto;
  154. &-item {
  155. padding: 8rpx 0 6rpx 0;
  156. & + & {
  157. padding-top: 24rpx;
  158. border-top: 2rpx solid #EEEEEE;
  159. }
  160. &-label {
  161. margin-bottom: 14rpx;
  162. display: flex;
  163. align-items: center;
  164. font-family: PingFang SC;
  165. font-weight: 400;
  166. font-size: 26rpx;
  167. line-height: 1.4;
  168. color: #181818;
  169. .icon {
  170. margin-right: 8rpx;
  171. width: 16rpx;
  172. height: auto;
  173. }
  174. }
  175. &-content {
  176. .text {
  177. padding: 2rpx 0;
  178. font-family: PingFang SC;
  179. font-weight: 400;
  180. font-size: 32rpx;
  181. line-height: 1.4;
  182. &.placeholder {
  183. color: #C6C6C6;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. .footer {
  190. column-gap: 32rpx;
  191. width: 100%;
  192. padding: 32rpx 40rpx;
  193. box-sizing: border-box;
  194. border-top: 2rpx solid #F1F1F1;
  195. .btn {
  196. flex: 1;
  197. padding: 14rpx 0;
  198. box-sizing: border-box;
  199. font-family: PingFang SC;
  200. font-weight: 500;
  201. font-size: 36rpx;
  202. line-height: 1.4;
  203. border-radius: 41rpx;
  204. &-palin {
  205. color: #252545;
  206. border: 2rpx solid #252545;
  207. }
  208. &-primary {
  209. color: #FFFFFF;
  210. background: linear-gradient(to right, #21FEEC, #019AF9);
  211. border: 2rpx solid #00A9FF;
  212. }
  213. }
  214. }
  215. .btn-avatar {
  216. display: inline-block;
  217. width: auto;
  218. border: none;
  219. }
  220. .avatar {
  221. position: relative;
  222. width: 200rpx;
  223. height: 200rpx;
  224. border-radius: 24rpx;
  225. overflow: hidden;
  226. .img {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. .mask {
  231. position: absolute;
  232. top: 0;
  233. left: 0;
  234. width: 100%;
  235. height: 100%;
  236. background: #00000080;
  237. border-radius: 24rpx;
  238. .icon {
  239. width: 64rpx;
  240. height: 64rpx;
  241. }
  242. }
  243. &.is-empty {
  244. background: #F3F2F7;
  245. .icon {
  246. width: 61rpx;
  247. height: auto;
  248. }
  249. }
  250. }
  251. </style>