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

285 lines
6.0 KiB

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