特易招,招聘小程序
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.

318 lines
6.5 KiB

5 months ago
  1. <template>
  2. <view class="login">
  3. <view class="bg1"></view>
  4. <view class="title">
  5. 定制自己的形象
  6. </view>
  7. <view
  8. v-if="back"
  9. @click="$utils.navigateBack"
  10. style="position: absolute;top: 120rpx;left: 20rpx;">
  11. <uv-icon
  12. size="30rpx"
  13. color="#000"
  14. name="arrow-left"></uv-icon>
  15. </view>
  16. <button class="chooseAvatar"
  17. open-type="chooseAvatar"
  18. @chooseavatar="onChooseAvatar">
  19. <image :src="form.headImage"
  20. mode="aspectFill"></image>
  21. </button>
  22. <input type="nickname"
  23. placeholder="给自己起一个响亮的名字"
  24. class="nickname" id="nickName"
  25. v-model="form.nickName" />
  26. <!-- <view class="sexSelect">
  27. <view
  28. @click="sexClick(item)"
  29. v-for="(item, index) in sexList"
  30. :key="index"
  31. :style="{color : form.sex == item.value ? item.actColor : '#333'}">
  32. <uv-icon
  33. size="30rpx"
  34. :color="form.sex == item.value ? item.actColor : '#333'"
  35. :name="item.icon"></uv-icon>
  36. {{ item.value }}
  37. </view>
  38. </view> -->
  39. <!-- <view class="address"
  40. @click="$refs.datetimePicker.open()">
  41. 您出生于{{ $dayjs(form.yearDate).format("YYYY") }}
  42. </view>
  43. <view class="address"
  44. @click="$refs.picker.open()">
  45. {{ form.address || '请选择居住地址'}}
  46. </view> -->
  47. <uv-datetime-picker
  48. ref="datetimePicker"
  49. v-model="form.yearDate"
  50. mode="year"
  51. :minDate="minDate"
  52. :maxDate="maxDate">
  53. </uv-datetime-picker>
  54. <uv-picker ref="picker"
  55. :columns="columns"
  56. keyName="name"
  57. @confirm="confirmAddress"></uv-picker>
  58. <view class="btn" @click="submit">
  59. 确认
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import { mapState } from 'vuex'
  65. export default {
  66. data() {
  67. return {
  68. form: {
  69. headImage: '',
  70. nickName: '',
  71. sex : '男',
  72. yearDate : this.$dayjs().add(-18, 'y').valueOf(),//默认满18岁
  73. address : '',
  74. },
  75. maxDate : this.$dayjs().valueOf(),
  76. minDate : this.$dayjs().add(-100, 'y').valueOf(),
  77. sex : {
  78. : {
  79. name : 'man',
  80. color : '#5baaff',
  81. },
  82. : {
  83. name : 'woman',
  84. color : '#ff50b3',
  85. },
  86. },
  87. sexList : [
  88. {
  89. value : '男',
  90. icon : 'man',
  91. actColor : '#5baaff',
  92. },
  93. {
  94. value : '女',
  95. icon : 'woman',
  96. actColor : '#ff50b3',
  97. },
  98. ],
  99. columns : [],
  100. back : '',
  101. };
  102. },
  103. computed: {
  104. ...mapState(['cityList', 'userInfo']),
  105. },
  106. onLoad({back}) {
  107. this.back = back
  108. // this.$nextTick(() => {
  109. // this.form.headImage = this.userInfo.headImage || this.form.headImage
  110. // this.form.nickName = this.userInfo.nickName || this.form.nickName
  111. // this.form.sex = this.userInfo.sex || this.form.sex
  112. // this.form.yearDate = this.userInfo.yearDate || this.form.yearDate
  113. // this.form.address = this.userInfo.address || this.form.address
  114. // })
  115. },
  116. onShow() {
  117. this.getCityList()
  118. this.getUserInfo()
  119. },
  120. computed: {},
  121. methods: {
  122. onChooseAvatar(res) {
  123. let self = this
  124. self.$Oss.ossUpload(res.target.avatarUrl)
  125. .then(url => {
  126. self.form.headImage = url
  127. })
  128. },
  129. sexClick(item){
  130. this.form.sex = item.value
  131. },
  132. confirmAddress(e){
  133. this.form.address = e.value[0].name
  134. },
  135. // 获取城市
  136. getCityList(){
  137. this.$api('getCityList', res => {
  138. if(res.code == 200){
  139. this.columns = [
  140. res.result
  141. ]
  142. }
  143. })
  144. },
  145. getUserInfo(){
  146. this.$api('getInfo', res => {
  147. if(res.code == 200){
  148. this.form.headImage = res.result.headImage || this.form.headImage
  149. this.form.nickName = res.result.nickName || this.form.nickName
  150. this.form.sex = res.result.sex || this.form.sex
  151. this.form.yearDate = res.result.yearDate &&
  152. this.$dayjs(res.result.yearDate + '-01-01').valueOf() || this.form.yearDate
  153. this.form.address = res.result.address || this.form.address
  154. }
  155. })
  156. },
  157. submit() {
  158. let self = this
  159. uni.createSelectorQuery().in(this)
  160. .select("#nickName")
  161. .fields({
  162. properties: ["value"],
  163. })
  164. .exec((res) => {
  165. const nickName = res?.[0]?.value
  166. self.form.nickName = nickName
  167. if (self.$utils.verificationAll(self.form, {
  168. headImage: '请选择头像',
  169. nickName: '请填写昵称',
  170. // address: '请选择居住地址',
  171. })) {
  172. return
  173. }
  174. let data = {
  175. ...self.form,
  176. // yearDate : this.$dayjs(self.form.yearDate).format("YYYY")
  177. }
  178. self.$api('updateInfo', data, res => {
  179. if (res.code == 200) {
  180. uni.reLaunch({
  181. url:'/pages/index/index'
  182. })
  183. }
  184. })
  185. })
  186. },
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .login {
  192. display: flex;
  193. flex-direction: column;
  194. justify-content: center;
  195. align-items: center;
  196. height: 100vh;
  197. background-color: #fff;
  198. overflow: hidden;
  199. .bg1{
  200. width: 700rpx;
  201. height: 700rpx;
  202. border-radius: 50%;
  203. background-color: #ffc0b333;
  204. position: absolute;
  205. right: -300rpx;
  206. top: -300rpx;
  207. }
  208. .title {
  209. line-height: 45rpx;
  210. font-weight: 900;
  211. padding-bottom: 100rpx;
  212. font-size: 40rpx;
  213. }
  214. .chooseAvatar {
  215. width: 100%;
  216. padding: 0 !important;
  217. margin: 0 !important;
  218. border: none;
  219. background-color: #fff !important;
  220. width: 220rpx;
  221. height: 220rpx;
  222. border-radius: 50%;
  223. image{
  224. width: 200rpx;
  225. height: 200rpx;
  226. border-radius: 50%;
  227. box-shadow: 0 0 10rpx 10rpx #00000012;
  228. margin: 10rpx;
  229. }
  230. }
  231. .chooseAvatar::after{
  232. border: none;
  233. padding: 0 !important;
  234. margin: 0 !important;
  235. }
  236. .nickname{
  237. background-color: #f7f7f7;
  238. width: 600rpx;
  239. height: 80rpx;
  240. text-align: center;
  241. border-radius: 40rpx;
  242. margin-top: 30rpx;
  243. }
  244. .sexSelect{
  245. background-color: #f7f7f7;
  246. width: 600rpx;
  247. height: 80rpx;
  248. text-align: center;
  249. border-radius: 40rpx;
  250. margin-top: 30rpx;
  251. display: flex;
  252. align-items: center;
  253. font-size: 26rpx;
  254. line-height: 80rpx;
  255. overflow: hidden;
  256. &>view{
  257. flex: 1;
  258. display: flex;
  259. justify-content: center;
  260. align-content: center;
  261. height: 100%;
  262. }
  263. &>view:nth-child(1){
  264. border-right: 1px solid #000;
  265. }
  266. }
  267. .address{
  268. background-color: #f7f7f7;
  269. width: 600rpx;
  270. height: 80rpx;
  271. text-align: center;
  272. border-radius: 40rpx;
  273. margin-top: 30rpx;
  274. line-height: 80rpx;
  275. color: #555;
  276. }
  277. .btn {
  278. // background: $uni-linear-gradient-btn-color;
  279. background: $uni-color;
  280. color: #fff;
  281. width: 80%;
  282. padding: 20rpx 0;
  283. text-align: center;
  284. border-radius: 15rpx;
  285. margin-top: 10vh;
  286. }
  287. }
  288. </style>