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

276 lines
5.7 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="绑定申请" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <view class="card">
  6. <view class="card-header">绑定申请</view>
  7. <view class="form">
  8. <uv-form
  9. ref="form"
  10. :model="form"
  11. :rules="rules"
  12. errorType="toast"
  13. >
  14. <view class="form-item">
  15. <uv-form-item prop="bindId" :customStyle="formItemStyle">
  16. <view class="form-item-label">绑定人ID</view>
  17. <view class="form-item-content">
  18. <view class="flex search">
  19. <uv-search
  20. v-model="keyword"
  21. placeholder="请输入"
  22. color="#181818"
  23. bgColor="transparent"
  24. :showAction="true"
  25. @custom="search"
  26. @search="search"
  27. >
  28. </uv-search>
  29. </view>
  30. </view>
  31. </uv-form-item>
  32. </view>
  33. <view class="form-item" v-for="item in list" :key="item.id">
  34. <view
  35. :class="['flex', 'list-item', item.id === form.bindId ? 'is-active' : '']"
  36. @click="onSelect(item.id)"
  37. >
  38. <view class="avatar">
  39. <image class="img" :src="item.headImage" mode="scaleToFill"></image>
  40. </view>
  41. <view>
  42. <view class="title">{{ item.nickName }}</view>
  43. <view class="desc">{{ `ID:${item.id}` }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </uv-form>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="bottom">
  52. <button class="btn" @click="onSubmit">申请</button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import formInput from '@/pages_order/components/formInput.vue'
  58. export default {
  59. components: {
  60. formInput,
  61. },
  62. data() {
  63. return {
  64. keyword: '',
  65. list: [],
  66. form: {
  67. bindId: null,
  68. },
  69. rules: {
  70. 'bindId': {
  71. type: 'string',
  72. required: true,
  73. message: '请选择绑定人',
  74. },
  75. },
  76. formItemStyle: { padding: 0 },
  77. }
  78. },
  79. methods: {
  80. async search() {
  81. try {
  82. const result = await this.$fetch('queryBindUser', { bindUserId: this.keyword })
  83. this.list = [result]
  84. this.form.bindId = result.id
  85. } catch (err) {
  86. }
  87. },
  88. onSelect(bindId) {
  89. this.form.bindId = bindId
  90. },
  91. async onSubmit() {
  92. try {
  93. await this.$refs.form.validate()
  94. const {
  95. bindId,
  96. } = this.form
  97. const params = {
  98. bindId,
  99. // userId: this.userInfo.id,
  100. }
  101. await this.$fetch('addBind', params)
  102. uni.showToast({
  103. icon: 'success',
  104. title: '提交成功',
  105. });
  106. setTimeout(() => {
  107. this.$utils.navigateBack()
  108. }, 800)
  109. } catch (err) {
  110. console.log('onSave err', err)
  111. }
  112. },
  113. },
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .page__view {
  118. width: 100vw;
  119. min-height: 100vh;
  120. background: $uni-bg-color;
  121. position: relative;
  122. /deep/ .nav-bar__view {
  123. position: fixed;
  124. top: 0;
  125. left: 0;
  126. }
  127. }
  128. .main {
  129. padding: calc(var(--status-bar-height) + 160rpx) 32rpx calc(env(safe-area-inset-bottom) + 198rpx) 32rpx;
  130. }
  131. .card {
  132. min-height: calc(100vh - (var(--status-bar-height) + 160rpx) - calc(env(safe-area-inset-bottom) + 198rpx));
  133. padding: 40rpx 32rpx;
  134. box-sizing: border-box;
  135. background: #FFFFFF;
  136. border: 2rpx solid #FFFFFF;
  137. border-radius: 32rpx;
  138. &-header {
  139. font-family: PingFang SC;
  140. font-weight: 500;
  141. font-size: 36rpx;
  142. line-height: 1.4;
  143. color: #252545;
  144. }
  145. }
  146. .form {
  147. padding: 8rpx 0 0 0;
  148. &-item {
  149. margin-top: 40rpx;
  150. border-bottom: 2rpx solid #EEEEEE;
  151. &:last-child {
  152. border: none;
  153. }
  154. &-label {
  155. font-family: PingFang SC;
  156. font-weight: 400;
  157. font-size: 26rpx;
  158. line-height: 1.4;
  159. color: #181818;
  160. }
  161. &-content {
  162. }
  163. }
  164. }
  165. .search {
  166. padding: 16rpx 0 8rpx 0;
  167. border-bottom: 2rpx solid #EEEEEE;
  168. /deep/ .uv-search__content {
  169. padding: 0;
  170. }
  171. /deep/ .uv-search__content__icon {
  172. display: none;
  173. }
  174. /deep/ .uv-search__content__input {
  175. margin: 0;
  176. }
  177. /deep/ .uv-search__action {
  178. color: #00A9FF;
  179. }
  180. }
  181. .list-item {
  182. justify-content: flex-start;
  183. column-gap: 24rpx;
  184. padding: 10rpx;
  185. border: 2rpx solid #EEEEEE;
  186. border-radius: 24rpx;
  187. .avatar {
  188. width: 96rpx;
  189. height: 96rpx;
  190. border-radius: 50%;
  191. .img {
  192. width: 100%;
  193. height: 100%;
  194. }
  195. }
  196. .title {
  197. font-size: 32rpx;
  198. font-weight: 600;
  199. color: #000000;
  200. }
  201. .desc {
  202. margin-top: 8rpx;
  203. font-size: 24rpx;
  204. color: #939393;
  205. }
  206. &.is-active {
  207. background: #E9F8FF;
  208. border-color: #00A9FF;
  209. }
  210. }
  211. .bottom {
  212. position: fixed;
  213. left: 0;
  214. bottom: 0;
  215. width: 100vw;
  216. // height: 200rpx;
  217. padding: 32rpx 40rpx;
  218. padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
  219. background: #FFFFFF;
  220. box-sizing: border-box;
  221. .btn {
  222. width: 100%;
  223. padding: 14rpx 0;
  224. box-sizing: border-box;
  225. font-family: PingFang SC;
  226. font-weight: 500;
  227. font-size: 36rpx;
  228. line-height: 1.4;
  229. color: #FFFFFF;
  230. background: linear-gradient(to right, #21FEEC, #019AF9);
  231. border: 2rpx solid #00A9FF;
  232. border-radius: 41rpx;
  233. }
  234. }
  235. </style>