eb2f54e484e9a8e5fca9603752b1b231e6497515.svn-base 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div style="height:100vh">
  3. <yd-navbar title="个人资料" color="#fff">
  4. <router-link :to="{path: '/PersonalCenter' }" slot="left">
  5. <yd-navbar-back-icon style="color: #fff"></yd-navbar-back-icon>
  6. </router-link>
  7. </yd-navbar>
  8. <div class="tips">
  9. 请完善您的个人资料,以便尽情享受我们网站提供的所有服务。
  10. </div>
  11. <div class="form">
  12. <ul>
  13. <li>
  14. <label for="user">账号</label>
  15. <input class="disabled" id="user" type="text" placeholder="账号不能修改" disabled="disabled">
  16. </li>
  17. <li>
  18. <label for="password">密码</label>
  19. <input class="disabled" id="password" type="text" placeholder="****" disabled="disabled">
  20. </li>
  21. <li>
  22. <label for="photo">头像</label>
  23. <img class="photo" v-if="imgSrc" :src="imgSrc" alt="">
  24. <yd-button id="photo" @click.native="showImgs = true">上传图片</yd-button>
  25. </li>
  26. <li>
  27. <label for="name">昵称</label>
  28. <input @blur='sureinfor(102)' v-model="name" class="nodisabled" id="name" type="text" placeholder="请输入昵称">
  29. </li>
  30. <li>
  31. <label for="qq">QQ号</label>
  32. <input @blur='sureinfor(100)' v-model="QQ" class="nodisabled" id="qq" type="text" placeholder="请输入QQ号">
  33. </li>
  34. <li>
  35. <label for="phone">手机号</label>
  36. <input @blur='sureinfor(1)' v-model="phone" class="nodisabled" id="phone" type="text" placeholder="请输入手机号">
  37. </li>
  38. <li>
  39. <label for="email">邮箱地址</label>
  40. <input @blur='sureinfor(10)' v-model="eMail" class="nodisabled" id="email" type="text" placeholder="请输入邮箱">
  41. </li>
  42. </ul>
  43. </div>
  44. <yd-tabbar slot="tabbar">
  45. <yd-button @click.native="onSubmit" size="large" type="primary">完善资料</yd-button>
  46. </yd-tabbar>
  47. <yd-popup v-model="showImgs" position="bottom" height="60%">
  48. <div class="closed">
  49. <yd-button @click.native="showImgs = false">关闭</yd-button>
  50. </div>
  51. <div class="imgBox">
  52. <ul>
  53. <li v-for="(item,index) in list" :key="index">
  54. <img @click="isImg(item,index)" :class="idx==index?'hover':''" :src="item.src" alt=""></li>
  55. </ul>
  56. </div>
  57. </yd-popup>
  58. </div>
  59. </template>
  60. <script>
  61. export default {
  62. name: "PersonInfo",
  63. data() {
  64. return {
  65. idx:0,
  66. name: '',
  67. photo:"",
  68. phone: '',
  69. eMail: '',
  70. QQ: "",
  71. imgSrc: '',
  72. showImgs:false,
  73. list: [
  74. {src:require("../../../assets/st-imges/1.jpg"),id:0},
  75. {src:require("../../../assets/st-imges/2.jpg"),id:1},
  76. {src:require("../../../assets/st-imges/3.jpg"),id:2}
  77. ]
  78. }
  79. },
  80. mounted(){
  81. },
  82. methods: {
  83. // 上传图片
  84. isImg(item,index){
  85. this.imgSrc = item.src;
  86. this.imgSrcid = item.id;
  87. this.idx = index;
  88. },
  89. // 失去焦点时验证
  90. sureinfor(type) {
  91. if (type == 1) {
  92. if (!/^1[34578]\d{9}$/.test(this.phone)) {
  93. this.$dialog.alert({mes: '手机格式不正确!' });
  94. this.phone = '';
  95. }
  96. } else if (type == 10) {
  97. if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.eMail)) {
  98. this.$dialog.alert({mes: '邮箱格式不正确!' });
  99. this.eMail = '';
  100. }
  101. } else if (type == 100) {
  102. if (!(/^[0-9]+$/.test(this.QQ))) {
  103. this.$dialog.alert({mes: 'QQ格式不正确!' });
  104. this.QQ = '';
  105. }
  106. }else if (type == 102){
  107. if (this.name == '') {
  108. this.$dialog.alert({mes: '昵称不能为空!' });
  109. this.name = '';
  110. }
  111. }
  112. },
  113. onSubmit(){
  114. if (this.name == '') {
  115. this.$dialog.alert({mes: '请填写昵称'});
  116. } else if (this.phone == '') {
  117. this.$dialog.alert({mes: '请填写手机号!'});
  118. } else if(this.eMail == '') {
  119. this.$dialog.alert({mes: '请填写邮箱!'});
  120. }else if (this.imgSrc == ''){
  121. this.$dialog.alert({mes: '请上传头像!'});
  122. }else {
  123. this.$http.post(this.$ports.login.updateUserInfo, {
  124. token: localStorage.getItem('token'),
  125. email: this.eMail,
  126. phone: this.phone,
  127. img_id:this.imgSrcid,
  128. name: this.name
  129. }).then(res => {
  130. if(res.data.status == 1){
  131. console.log("ok")
  132. this.$dialog.alert({mes: '修改成功!'});
  133. }else {
  134. console.log(res)
  135. }
  136. })
  137. }
  138. }
  139. }
  140. }
  141. </script>
  142. <style scoped>
  143. .yd-btn-block {
  144. margin-top: 0.6rem;
  145. }
  146. .yd-navbar {
  147. background-image: linear-gradient(0deg, #565656 0%, #999999 100%);
  148. }
  149. .tips {
  150. text-align: center;
  151. color: #FF6600;
  152. height: 0.8rem;
  153. line-height: 0.8rem;
  154. background: rgba(255, 235, 196, 1);
  155. }
  156. .form {
  157. background: #E4E4E4;
  158. border-radius: 10px;
  159. padding: 0.3rem;
  160. }
  161. .form ul {
  162. padding: 0.3rem;
  163. background: #EFEFEF;
  164. border-radius: 10px;
  165. }
  166. .form ul li {
  167. height: 0.8rem;
  168. line-height: 0.8rem;
  169. margin-bottom: 0.2rem;
  170. }
  171. .form ul li label {
  172. width: 1.2rem;
  173. display: inline-block;
  174. }
  175. .form ul li input.disabled {
  176. width: 70%;
  177. height: 0.8rem;
  178. line-height: 0.8rem;
  179. border: none;
  180. outline: none;
  181. background: rgba(228, 228, 228, 1);
  182. border: 1px solid rgba(228, 228, 228, 1);
  183. padding-left: 0.2rem;
  184. }
  185. .form ul li input.nodisabled {
  186. width: 70%;
  187. height: 0.8rem;
  188. line-height: 0.8rem;
  189. border: none;
  190. outline: none;
  191. background: #fff;
  192. border: 1px solid rgba(228, 228, 228, 1);
  193. padding-left: 0.2rem;
  194. }
  195. .yd-tabbar {
  196. margin: 0 auto;
  197. width: 80%;
  198. background-color: transparent !important;
  199. }
  200. .yd-btn-block {
  201. margin-top: 0;
  202. border-radius: 10px;
  203. background: linear-gradient(0deg, rgba(90, 90, 90, 1) 0%, rgba(138, 138, 138, 1) 100%);
  204. }
  205. .yd-btn-block:hover {
  206. background: #0bb20c;
  207. }
  208. #photo {
  209. padding:0 10px;
  210. height:.8rem;
  211. border:.01rem solid #ddd;
  212. border-radius: .1rem;
  213. color:#fff;
  214. text-align: center;
  215. background:linear-gradient(0deg,rgba(90,90,90,1) 0%,rgba(138,138,138,1) 100%);
  216. }
  217. .files {
  218. height:.8rem;
  219. border:.01rem solid #ddd;
  220. border-radius: .1rem;
  221. color:#fff;
  222. text-align: center;
  223. background:linear-gradient(0deg,rgba(90,90,90,1) 0%,rgba(138,138,138,1) 100%);
  224. }
  225. .photo {
  226. width: 0.6rem;
  227. height: 0.6rem;
  228. border-radius: 50%;
  229. vertical-align: middle;
  230. }
  231. .listImg {
  232. width: 2rem;
  233. }
  234. .closed {
  235. padding-top: 10px;
  236. height: 20px;
  237. text-align: right;
  238. }
  239. .imgBox {
  240. margin-top: 0.5rem;
  241. }
  242. .imgBox ul {
  243. display: flex;
  244. flex-wrap: wrap-reverse;
  245. justify-content: flex-start;
  246. }
  247. .imgBox ul li img{
  248. width: 1rem;
  249. height: 1rem;
  250. margin: 0 0.2rem 0.2rem 0.2rem;
  251. }
  252. .imgBox ul li img.hover{
  253. border: 1px solid red;
  254. }
  255. </style>