userinfo.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="userinfo">
  3. <view class="user-head u-flex u-row-between">
  4. <text>头像</text>
  5. <image :src="userinfo.avatar" mode="aspectFill" @click="uploadimg"></image>
  6. </view>
  7. <view class="user-item" @click="tochangename">
  8. <view class="item-name">
  9. 真实姓名
  10. </view>
  11. <view class="item-input u-flex">
  12. <input type="text" placeholder="请输入真实姓名" :disabled="true" v-model="userinfo.name">
  13. </view>
  14. </view>
  15. <view class="user-item" @click="sexshow = true">
  16. <view class="item-name">
  17. 性别
  18. </view>
  19. <view class="item-input u-flex">
  20. <input type="text" placeholder="请选择性别" :disabled="true" v-model="userinfo.sex_text">
  21. <u-icon name="arrow-right"></u-icon>
  22. </view>
  23. </view>
  24. <view class="user-item" @click="changehangye">
  25. <view class="item-name">
  26. 猎头行业
  27. </view>
  28. <view class="item-input u-flex">
  29. <input type="text" placeholder="请选择猎头行业" :disabled="true" v-model="userinfo.industry_name">
  30. <u-icon name="arrow-right"></u-icon>
  31. </view>
  32. </view>
  33. <view class="user-item" @click="jingyanshow = true">
  34. <view class="item-name">
  35. 经验
  36. </view>
  37. <view class="item-input u-flex">
  38. <input type="text" placeholder="请选择经验" :disabled="true" v-model="userinfo.experience_name">
  39. <u-icon name="arrow-right"></u-icon>
  40. </view>
  41. </view>
  42. <view class="user-item" @click="workshow = true">
  43. <view class="item-name">
  44. 就职状态
  45. </view>
  46. <view class="item-input u-flex">
  47. <input type="text" placeholder="请选择就职状态" :disabled="true" :value="userinfo.work_status == 'soho' ? 'soho猎头' : '就职猎头'">
  48. <u-icon name="arrow-right"></u-icon>
  49. </view>
  50. </view>
  51. <view class="user-item" @click="cityshow = true">
  52. <view class="item-name">
  53. 工作地址
  54. </view>
  55. <view class="item-input u-flex">
  56. <input type="text" placeholder="请选择工作地址" :disabled="true" v-model="userinfo.work_address">
  57. <u-icon name="arrow-right"></u-icon>
  58. </view>
  59. </view>
  60. <view style="height: 150rpx;"></view>
  61. <view class="safe-area-inset-bottom"></view>
  62. <view class="user-down">
  63. <view class="down-btn u-flex">
  64. <text @click="save">保存</text>
  65. </view>
  66. <view class="safe-area-inset-bottom"></view>
  67. </view>
  68. <!-- <u-select v-model="sexshow" :list="sexlist" @confirm="changsex"></u-select>
  69. <u-select v-model="cityshow" :list="citylist" mode="mutil-column-auto" value-name="id" label-name="name" child-name="childlist" @confirm="changecity"></u-select>
  70. <u-select v-model="jingyanshow" :list="jingyanlist" value-name="id" label-name="name" @confirm="changejingyan"></u-select>
  71. <u-select v-model="workshow" :list="worklist" @confirm="changework"></u-select> -->
  72. </view>
  73. </template>
  74. <script>
  75. import fuxing from "../common/fuxing.js"
  76. export default {
  77. data() {
  78. return {
  79. userinfo: {},
  80. sexlist: [],
  81. sexshow: false,
  82. citylist: [],
  83. cityshow: false,
  84. qiye: '',
  85. jingyanlist: [],
  86. jingyanshow: false,
  87. workshow: false,
  88. worklist: [{
  89. label: 'soho猎头',
  90. value: 'soho'
  91. }, {
  92. label: '就职猎头',
  93. value: 'job'
  94. }]
  95. }
  96. },
  97. onLoad() {
  98. this.getuser()
  99. this.getconfig()
  100. },
  101. methods: {
  102. changework(e) {
  103. this.userinfo.work_status = e[0].value
  104. },
  105. changejingyan(e) {
  106. this.userinfo.experience_id = e[0].value
  107. this.userinfo.experience_name = e[0].label
  108. },
  109. changehangye() {
  110. uni.navigateTo({
  111. url: "/pagesA/change-hangye1",
  112. events: {
  113. changehangye: (res) => {
  114. this.userinfo.industry_first = res[0].id
  115. this.userinfo.industry_id = res[1].id
  116. this.userinfo.industry_name = res[1].name
  117. }
  118. }
  119. })
  120. },
  121. save() {
  122. if (!this.userinfo.avatar) {
  123. this.$u.toast("请上传头像")
  124. return
  125. }
  126. if (!this.userinfo.name) {
  127. this.$u.toast("请输入真实名字")
  128. return
  129. }
  130. if (!this.userinfo.sex) {
  131. this.$u.toast("请选择性别")
  132. return
  133. }
  134. if (!this.userinfo.industry_name) {
  135. this.$u.toast("请选择猎头行业")
  136. return
  137. }
  138. if (!this.userinfo.experience_name) {
  139. this.$u.toast("请选择经验")
  140. return
  141. }
  142. if (!this.userinfo.work_status) {
  143. this.$u.toast("请选择就职状态")
  144. return
  145. }
  146. if (!this.userinfo.work_address) {
  147. this.$u.toast("请选择工作地址")
  148. return
  149. }
  150. uni.showLoading({
  151. mask: true,
  152. title: "请稍后"
  153. })
  154. this.$u.post('/api/headhunter.user/profile', {
  155. avatar: this.userinfo.avatar,
  156. name: this.userinfo.name,
  157. industry_first: this.userinfo.industry_first,
  158. industry_id: this.userinfo.industry_id,
  159. experience_id: this.userinfo.experience_id,
  160. work_status: this.userinfo.work_status,
  161. work_address: this.userinfo.work_address,
  162. realname: this.userinfo.virtual_name,
  163. }).then(res => {
  164. if (res.code == 1) {
  165. this.$u.toast("修改成功")
  166. setTimeout(() => {
  167. uni.navigateBack()
  168. }, 800)
  169. }else{
  170. this.$u.toast(res.msg)
  171. }
  172. })
  173. },
  174. changecity(e) {
  175. this.userinfo.work_address = `${e[0].label} ${e[1].label}`
  176. },
  177. changsex(e) {
  178. this.userinfo.sex_text = e[0].label
  179. this.userinfo.sex = e[0].value
  180. if (this.userinfo.name != this.userinfo.virtual_name && this.userinfo.virtual_name) {
  181. if (this.userinfo.name.length == 3) {
  182. this.userinfo.name = this.userinfo.virtual_name[0] + (this.userinfo.sex == 'female' ? '女士' : '先生')
  183. } else {
  184. this.userinfo.name = this.userinfo.virtual_name[0] + this.userinfo.virtual_name[1] + (this.userinfo.sex == 'female' ? '女士' : '先生')
  185. }
  186. }
  187. },
  188. getconfig() {
  189. this.$u.post('/api/commons/get_sex').then(res => {
  190. for (var key in res.data) {
  191. this.sexlist.push({
  192. label: res.data[key],
  193. value: key
  194. })
  195. }
  196. })
  197. this.$u.post('/api/commons/get_area_city').then(res => {
  198. this.citylist = res.data
  199. })
  200. this.$u.post('/api/commons/get_experience').then(res => {
  201. this.jingyanlist = res.data
  202. })
  203. },
  204. uploadimg() {
  205. uni.chooseImage({
  206. count: 1,
  207. success: (img) => {
  208. uni.showLoading({
  209. mask: true,
  210. title: "请稍后"
  211. })
  212. uni.uploadFile({
  213. url: this.$url + '/api/common/upload',
  214. filePath: img.tempFilePaths[0],
  215. name: 'file',
  216. success: (res) => {
  217. uni.hideLoading()
  218. if (JSON.parse(res.data).code == 1) {
  219. this.userinfo.avatar = JSON.parse(res.data).data.fullurl
  220. } else {
  221. this.$u.toast(JSON.parse(res.data).msg)
  222. }
  223. },
  224. fail: (e) => {
  225. console.log(e);
  226. }
  227. })
  228. }
  229. })
  230. },
  231. getuser() {
  232. this.$u.post('/api/headhunter.user/index').then(res => {
  233. this.userinfo = res.data.group_info
  234. this.userinfo.sex_text = {
  235. 'male': '男',
  236. 'female': '女',
  237. 'secret': '保密'
  238. } [this.userinfo.sex]
  239. })
  240. },
  241. tochangename() {
  242. uni.navigateTo({
  243. url: "/pagesD/change-name?name=" + JSON.stringify({ name: this.userinfo.name, virtual_name: this.userinfo.realname }),
  244. events: {
  245. getname: (res) => {
  246. if (res.name) {
  247. this.userinfo.name = res.name
  248. } else {
  249. var name = ''
  250. fuxing.forEach(val => {
  251. if (res.virtual_name.indexOf(val) > -1) {
  252. name = res.virtual_name[0] + res.virtual_name[1] + (this.userinfo.sex == 'female' ? '女士' : '先生')
  253. }
  254. })
  255. if (!name) {
  256. name = res.virtual_name[0] + (this.userinfo.sex == 'female' ? '女士' : '先生')
  257. }
  258. this.userinfo.name = name
  259. }
  260. this.userinfo.realname = res.virtual_name
  261. }
  262. }
  263. })
  264. }
  265. }
  266. }
  267. </script>
  268. <style lang="scss">
  269. .userinfo {
  270. padding: 0 32rpx;
  271. .user-down {
  272. position: fixed;
  273. bottom: 0;
  274. left: 0;
  275. z-index: 99;
  276. width: 750rpx;
  277. background-color: #fff;
  278. .down-btn {
  279. padding: 8rpx 32rpx;
  280. text {
  281. line-height: 88rpx;
  282. background: #0C66C2;
  283. border-radius: 12rpx;
  284. width: 100%;
  285. font-size: 32rpx;
  286. font-family: PingFangSC-Medium, PingFang SC;
  287. font-weight: 500;
  288. color: #FFFFFF;
  289. text-align: center;
  290. }
  291. }
  292. }
  293. .user-item {
  294. padding-top: 30rpx;
  295. border-bottom: 2rpx solid #F0F0F0;
  296. .item-input {
  297. height: 100rpx;
  298. input {
  299. height: 100rpx;
  300. flex: 1;
  301. }
  302. }
  303. .item-name {
  304. font-size: 26rpx;
  305. font-family: PingFangSC-Regular, PingFang SC;
  306. font-weight: 400;
  307. color: #888888;
  308. }
  309. }
  310. .user-head {
  311. padding: 32rpx 0;
  312. border-bottom: 2rpx solid #F0F0F0;
  313. text {
  314. font-size: 32rpx;
  315. font-family: PingFangSC-Regular, PingFang SC;
  316. font-weight: 400;
  317. color: #222222;
  318. }
  319. image {
  320. border-radius: 100%;
  321. width: 120rpx;
  322. height: 120rpx;
  323. }
  324. }
  325. }
  326. </style>