mineEdit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view>
  3. <statusBar :item="navBarData"></statusBar>
  4. <view class="editBox">
  5. <view class="edit_avatar">
  6. <view class="edit_title">
  7. <text>头像</text>
  8. </view>
  9. <view class="userAvatar">
  10. <image :src="userData.avatar"></image>
  11. </view>
  12. </view>
  13. <view class="setName">
  14. <view class="edit_title">
  15. <text>姓名</text>
  16. </view>
  17. <view class="input_details">
  18. <view class="nickname">
  19. <input type="text" style=" text-align: right;" maxlength="10" placeholder="请输入昵称"
  20. placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);"
  21. v-model="userData.username" />
  22. </view>
  23. </view>
  24. </view>
  25. <view class="setPicker">
  26. <picker mode="selector" :range="genderList" :value="userData.sex" @change="handelGender">
  27. <view class="content">
  28. <view class="edit_title">
  29. <text>性别</text>
  30. </view>
  31. <view class="input_details">
  32. <view class="details">
  33. <view class="uni-input text">{{genderList[userData.sex]}}</view>
  34. </view>
  35. <view class="arrow">
  36. <image
  37. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  38. mode="aspectFill"></image>
  39. </view>
  40. </view>
  41. </view>
  42. </picker>
  43. </view>
  44. <view class="setPicker">
  45. <picker mode="selector" :range="schoolList" :value="userData.school" @change="handelSchool">
  46. <view class="content">
  47. <view class="edit_title">
  48. <text>学校</text>
  49. </view>
  50. <view class="input_details">
  51. <view class="details">
  52. <view class="uni-input text">{{userData.school}}</view>
  53. </view>
  54. <view class="arrow">
  55. <image
  56. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  57. mode="aspectFill"></image>
  58. </view>
  59. </view>
  60. </view>
  61. </picker>
  62. </view>
  63. <view class="setPicker">
  64. <picker mode="selector" :range="speList" :value="userData.spe" @change="handelspe">
  65. <view class="content">
  66. <view class="edit_title">
  67. <text>专业</text>
  68. </view>
  69. <view class="input_details">
  70. <view class="details">
  71. <view class="uni-input text">{{userData.spe}}</view>
  72. </view>
  73. <view class="arrow">
  74. <image
  75. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  76. mode="aspectFill"></image>
  77. </view>
  78. </view>
  79. </view>
  80. </picker>
  81. </view>
  82. <view class="setPicker">
  83. <picker mode="selector" :range="rankList" :value="userData.rankl" @change="handelrank">
  84. <view class="content">
  85. <view class="edit_title">
  86. <text>职称</text>
  87. </view>
  88. <view class="input_details">
  89. <view class="details">
  90. <view class="uni-input text">{{userData.rankl}}</view>
  91. </view>
  92. <view class="arrow">
  93. <image
  94. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  95. mode="aspectFill"></image>
  96. </view>
  97. </view>
  98. </view>
  99. </picker>
  100. </view>
  101. <!-- <view class="setPicker">
  102. <picker mode="date" :value="userData.birthday" :start="startDate" :end="endDate" @change="bindDateChange">
  103. <view class="content">
  104. <view class="edit_title">
  105. <text>生日</text>
  106. </view>
  107. <view class="input_details">
  108. <view class="details">
  109. <view class="uni-input text">{{userData.birthday=='null'?" ":userData.birthday}}</view>
  110. </view>
  111. <view class="arrow">
  112. <image
  113. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  114. mode="aspectFill"></image>
  115. </view>
  116. </view>
  117. </view>
  118. </picker>
  119. </view> -->
  120. <!-- <view class="setPicker">
  121. <picker mode="selector" :range="hobbyList" :value="userData.tag" @change="handelHobby">
  122. <view class="content">
  123. <view class="edit_title">
  124. <text>兴趣标签</text>
  125. </view>
  126. <view class="input_details">
  127. <view class="details">
  128. <view class="uni-input text">{{hobbyList[userData.tag]}}</view>
  129. </view>
  130. <view class="arrow">
  131. <image
  132. src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right_gray.png"
  133. mode="aspectFill"></image>
  134. </view>
  135. </view>
  136. </view>
  137. </picker>
  138. </view> -->
  139. <view class="setIntro">
  140. <view class="edit_title">
  141. <text>简介</text>
  142. </view>
  143. <view class="input_details">
  144. <view class="selfdomIntro">
  145. <textarea type="text" placeholder="请输入你的个性签名" maxlength="75"
  146. placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);" style="color: black;" v-model="userData.brief" />
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. <view class="btnBox">
  152. <view class="btn">
  153. <button @click="saveInfo">保存修改</button>
  154. <button @click="gotoLogin">退出登录</button>
  155. </view>
  156. </view>
  157. <!-- 弹窗 -->
  158. <view>
  159. <view class="mask" v-show="showPopup" @click="closePopup"></view>
  160. <view class="popup-container" v-show="showPopup">
  161. <view class="popup">
  162. <view class="header">
  163. <text>确认修改</text>
  164. </view>
  165. <view class="footer">
  166. <view class="cancel-btn" @click="closePopup">取消</view>
  167. <view class="confirm-btn" @click="conf">确认</view>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <view>
  173. <view class="popup-container" style="height: 175px;" v-show="showPopupConfirm">
  174. <view class="popup">
  175. <view class="header" style="margin-top: 15px;">
  176. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//gou1.png" mode="aspectFill">
  177. </image>
  178. <text style="margin-bottom: 24px;">修改成功</text>
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </template>
  185. <script>
  186. export default {
  187. data() {
  188. // const currentDate = this.getDate({
  189. // format: true
  190. // })
  191. return {
  192. navBarData: {
  193. title: '个人资料',
  194. btn: 1
  195. },
  196. // 相别选项
  197. genderList: ['男', '女'],
  198. //学校选项
  199. schoolList: ['深圳信息XX学院', '深圳XX学院', '深圳XX学院'],
  200. //专业选项
  201. speList: ['互联网', '网络通信', '航空', '汽修', '珠宝', '文秘', '设计'],
  202. //职称选项
  203. rankList: ['xx', 'xx', 'xx'],
  204. // 兴趣选项
  205. hobbyList: ['篮球','编程','钢琴','美术','摄影'],
  206. gender: '男',
  207. school: 'xx学院',
  208. //控制弹窗
  209. showPopup: false,
  210. //修改成功弹窗
  211. showPopupConfirm: false,
  212. // isFirstShow: true,
  213. // 用户信息数据
  214. userData: {
  215. oid:'',
  216. avatar: '', //头像
  217. username: '', //用户名
  218. sex:'', //用户性别
  219. school:'',//学校
  220. spe:'',//专业
  221. rankl:'',//职称
  222. brief: '', //用户简介
  223. }
  224. };
  225. },
  226. // computed: {
  227. // startDate() {
  228. // return this.getDate('start');
  229. // },
  230. // endDate() {
  231. // return this.getDate('end');
  232. // }
  233. // },
  234. methods: {
  235. // 获取渲染数据
  236. getData(){
  237. const value = this.$store.state.user.openid;
  238. if (value == '') return
  239. console.log('????', this.$store.state.user.openid);
  240. this.$request('/selectUserInfo', "POST", {openid: this.$store.state.user.openid}).then(res => {
  241. console.log('获取渲染数据',res[0][0]);
  242. this.userData=res[0][0]
  243. })
  244. },
  245. // 取消操作
  246. closePopup() {
  247. this.showPopup = false;
  248. // this.showPopupConfirm = false;
  249. },
  250. // 确认操作
  251. conf() {
  252. this.showPopup = false;
  253. this.showPopupConfirm=true
  254. console.log('要上传修改的数据',this.userData);
  255. this.$request('/updateUserInfo', "POST", this.userData).then(res => {
  256. console.log('修改的数据',res);
  257. console.log('this',this);
  258. this.$request('/selectUserInfo', 'POST', {
  259. oId: this.$store.state.user.openid
  260. }).then(res => {
  261. console.log('获取', res[0][0]);
  262. this.$store.dispatch('asyncUpdateUser', res[0][0])
  263. })
  264. setTimeout(()=>{
  265. this.showPopupConfirm=false
  266. this.getData()
  267. },1500)
  268. })
  269. },
  270. // 点击保存修改
  271. saveInfo() {
  272. const value = this.$store.state.user.openid;
  273. if (value == '') return uni.showToast({title:'未登录',icon:'none'})
  274. if(!this.userData.username){
  275. return uni.showToast({title:'昵称不能为空',icon:'none'})
  276. }
  277. this.showPopup = true
  278. },
  279. // 选择用户性别
  280. handelGender(e) {
  281. console.log(e);
  282. this.userData.sex = e.detail.value
  283. },
  284. // handelHobby(e){
  285. // this.userData.tag = e.detail.value
  286. // },
  287. // // 生日
  288. // bindDateChange(e) {
  289. // this.userData.birthday = e.detail.value
  290. // },
  291. // handelGender(e) {
  292. // this.gender = this.genderList[e.detail.value]
  293. // },
  294. // 学校
  295. handelSchool(e) {
  296. console.log(e);
  297. this.userData.school = this.schoolList[e.detail.value]
  298. },
  299. // 专业
  300. handelspe(e) {
  301. console.log('handelspe',e);
  302. this.userData.spe = this.speList[e.detail.value]
  303. console.log('???',this.userData.spe );
  304. },
  305. // 职位
  306. handelrank(e) {
  307. console.log(e);
  308. this.userData.rankl = this.rankList[e.detail.value]
  309. },
  310. // 兴趣
  311. handeHobby(e) {
  312. this.userData.tag = e.detail.value
  313. },
  314. // 清除vuex的数据
  315. gotoLogin() {
  316. let user = {
  317. openid:'',
  318. avatar: '', //头像
  319. username: '', //用户名
  320. sex:'', //用户性别
  321. school:'',//学校
  322. spe:'',//专业
  323. rankl:'',//职称
  324. // birthday: '',//生日
  325. // tag:null, //兴趣标签
  326. brief: '', //用户简介
  327. }
  328. this.$store.dispatch('asyncUpdateUser', user)
  329. uni.navigateTo({
  330. url: '/pages/login_Wechat/login_Wechat'
  331. })
  332. // 清除本页面数据
  333. this.userData={}
  334. },
  335. },
  336. onReady() {
  337. console.log(this.$store.state);
  338. this.getData()
  339. }
  340. }
  341. </script>
  342. <style lang="scss">
  343. .mask {
  344. position: fixed;
  345. top: 0;
  346. left: 0;
  347. width: 100%;
  348. height: 100%;
  349. background-color: rgba(0, 0, 0, 0.3);
  350. z-index: 999;
  351. overflow: hidden;
  352. // display: none;
  353. }
  354. .popup-container {
  355. position: fixed;
  356. top: 50%;
  357. left: 50%;
  358. transform: translate(-50%, -50%);
  359. width: 520rpx;
  360. height: 260rpx;
  361. z-index: 1000;
  362. // display: none;
  363. .popup {
  364. width: 100%;
  365. height: 100%;
  366. display: flex;
  367. flex-direction: column;
  368. background-color: #fff;
  369. border-radius: 16rpx;
  370. overflow: hidden;
  371. .header {
  372. flex: 1;
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. flex-direction: column;
  377. margin-top: 24px;
  378. font-size: 34rpx;
  379. font-weight: 600;
  380. image {
  381. width: 150rpx;
  382. height: 150rpx;
  383. margin-top: 15px;
  384. margin-bottom: 15px;
  385. }
  386. }
  387. .footer {
  388. width: 100%;
  389. display: flex;
  390. overflow: hidden;
  391. .cancel-btn {
  392. width: 50%;
  393. height: 100rpx;
  394. background-color: #F7F7F7;
  395. color: #000;
  396. font-size: 34rpx;
  397. text-align: center;
  398. border-bottom-left-radius: 16rpx;
  399. line-height: 50px;
  400. }
  401. .confirm-btn {
  402. width: 50%;
  403. height: 100rpx;
  404. background-color: #0081FE;
  405. color: #fff;
  406. font-size: 34rpx;
  407. text-align: center;
  408. line-height: 50px;
  409. }
  410. }
  411. }
  412. }
  413. .edit_title {
  414. display: flex;
  415. align-items: center;
  416. font-size: 32rpx;
  417. }
  418. .editBox {
  419. width: 100%;
  420. // height: 800rpx;
  421. display: flex;
  422. flex-direction: column;
  423. background-color: #fff;
  424. border-top: 1px solid #E7E7E7;
  425. padding: 0 18px;
  426. .edit_avatar {
  427. height: 164rpx;
  428. display: flex;
  429. justify-content: space-between;
  430. .userAvatar {
  431. display: flex;
  432. align-items: center;
  433. image {
  434. width: 120rpx;
  435. height: 120rpx;
  436. }
  437. }
  438. }
  439. .setName {
  440. display: flex;
  441. justify-content: space-between;
  442. height: 92rpx;
  443. border-top: 1px solid #E7E7E7;
  444. .input_details {
  445. display: flex;
  446. align-items: center;
  447. flex-direction: row;
  448. .nickname {
  449. width: 350rpx;
  450. text-align: end;
  451. // padding-right: 10rpx;
  452. // margin-right: 10rpx;
  453. font-size: 28rpx;
  454. color: rgb(153, 153, 153);
  455. }
  456. }
  457. }
  458. .setPicker {
  459. height: 92rpx;
  460. border-top: 1px solid #E7E7E7;
  461. .content {
  462. height: 92rpx;
  463. display: flex;
  464. align-items: center;
  465. justify-content: space-between;
  466. .input_details {
  467. display: flex;
  468. align-items: center;
  469. .details {
  470. display: flex;
  471. flex-direction: row;
  472. .text {
  473. font-size: 28rpx;
  474. color: rgb(153, 153, 153);
  475. }
  476. }
  477. .arrow {
  478. display: flex;
  479. image {
  480. width: 32rpx;
  481. height: 32rpx;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. .setIntro {
  488. display: flex;
  489. flex-direction: column;
  490. justify-content: space-evenly;
  491. height: 230rpx;
  492. border-top: 1px solid #E7E7E7;
  493. .input_details {
  494. display: flex;
  495. align-items: center;
  496. .selfdomIntro {
  497. width: 100%;
  498. height: 120rpx;
  499. textarea {
  500. width: 100%;
  501. height: 120rpx;
  502. font-size: 28rpx;
  503. color: rgb(153, 153, 153);
  504. }
  505. }
  506. }
  507. }
  508. }
  509. .btnBox {
  510. position: absolute;
  511. margin: 0 85rpx;
  512. bottom: 40px;
  513. .btn {
  514. button {
  515. width: 580rpx;
  516. height: 88rpx;
  517. border: none;
  518. border-radius: 100rpx;
  519. border: 1px solid lightgray;
  520. font-size: 36rpx;
  521. display: flex;
  522. justify-content: center;
  523. align-items: center;
  524. color: #545454;
  525. text-align: center;
  526. &:first-child {
  527. background-color: rgb(0, 86, 168);
  528. color: white;
  529. margin-bottom: 24rpx;
  530. }
  531. &::after {
  532. border: none;
  533. }
  534. }
  535. }
  536. }
  537. </style>