user_info.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container"}
  11. {block name="title"}{$userInfo.nickname} - 个人资料{/block}
  12. {block name="head_top"}
  13. <script src="{__WAP_PATH}zsff/js/md5.js"></script>
  14. <style>
  15. body{
  16. background-color: #f5f5f5;
  17. }
  18. .user-info .avatar {
  19. display: -webkit-box;
  20. display: -webkit-flex;
  21. display: flex;
  22. -webkit-box-align: center;
  23. -webkit-align-items: center;
  24. align-items: center;
  25. padding: .3rem;
  26. background-color: #fff;
  27. }
  28. .user-info .avatar .name {
  29. -webkit-box-flex: 1;
  30. -webkit-flex: 1;
  31. flex: 1;
  32. font-weight: 500;
  33. font-size: .3rem;
  34. color: #333;
  35. }
  36. .user-info .avatar .image {
  37. width: .9rem;
  38. height: .9rem;
  39. border-radius: 50%;
  40. overflow: hidden;
  41. }
  42. .user-info .avatar .img {
  43. display: block;
  44. width: 100%;
  45. height: 100%;
  46. object-fit: cover;
  47. }
  48. .user-info .avatar .iconfont {
  49. margin-left: .3rem;
  50. font-size: .24rem;
  51. color: #999;
  52. }
  53. .user-info .avatar .input {
  54. display: none;
  55. }
  56. .user-info .list {
  57. margin-top: .3rem;
  58. background-color: #fff;
  59. }
  60. .user-info .list .item {
  61. display: -webkit-box;
  62. display: -webkit-flex;
  63. display: flex;
  64. -webkit-box-align: center;
  65. -webkit-align-items: center;
  66. align-items: center;
  67. height: .98rem;
  68. padding-right: .3rem;
  69. padding-left: .3rem;
  70. }
  71. .user-info .list .item~.item{
  72. border-top: 1px solid #f5f5f5;
  73. }
  74. .user-info .list .item .name {
  75. -webkit-box-flex: 1;
  76. -webkit-flex: 1;
  77. flex: 1;
  78. font-weight: 500;
  79. font-size: .3rem;
  80. color: #333;
  81. }
  82. .user-info .list .item .value {
  83. font-size: .3rem;
  84. color: #666;
  85. }
  86. .user-info .list .item .iconfont{
  87. margin-left: .3rem;
  88. font-size: .24rem;
  89. color: #999;
  90. }
  91. .user-info .list .item .input {
  92. font-family: inherit;
  93. text-align: right;
  94. }
  95. .user-info .btn-group {
  96. padding: .8rem .3rem 0;
  97. }
  98. .user-info .btn-group .btn {
  99. width: 100%;
  100. height: .9rem;
  101. border-radius: .45rem;
  102. margin-bottom: .3rem;
  103. background-color: #191C6E;
  104. font-size: .32rem;
  105. color: #FFFFFF;
  106. }
  107. .user-info .btn-group .btn:last-child {
  108. margin-bottom: 0;
  109. }
  110. .user-info .btn-group .out-btn {
  111. border: 1px solid #191C6E;
  112. background-color: #FFFFFF;
  113. color: #191C6E;
  114. }
  115. .user-info .group .link {
  116. display: block;
  117. width: 100%;
  118. height: .86rem;
  119. border: 1px solid #ccc;
  120. border-radius: .43rem;
  121. margin-top: .3rem;
  122. font-weight: 500;
  123. font-size: .3rem;
  124. line-height: .82rem;
  125. text-align: center;
  126. color: #999;
  127. }
  128. .user-info .list .item.password {
  129. justify-content: space-between;
  130. }
  131. .popup {
  132. position: fixed;
  133. right: 0;
  134. bottom: 0;
  135. left: 0;
  136. z-index: 60;
  137. border-radius: .2rem .2rem 0 0;
  138. background: #FFFFFF;
  139. transform: translateY(100%);
  140. transition: 0.3s;
  141. }
  142. .popup.on {
  143. transform: translateY(0);
  144. }
  145. .popup > a {
  146. position: absolute;
  147. top: .3rem;
  148. right: .3rem;
  149. z-index: 2;
  150. }
  151. .popup a .iconfont {
  152. font-size: .27rem;
  153. color: #8A8A8A;
  154. }
  155. .popup > div:nth-child(2) {
  156. padding: .4rem 0 .34rem;
  157. font-weight: bold;
  158. font-size: .36rem;
  159. line-height: .5rem;
  160. text-align: center;
  161. color: #282828;
  162. }
  163. .popup > div:nth-child(3) {
  164. padding: 0 .3rem .3rem;
  165. }
  166. .popup .item {
  167. position: relative;
  168. display: flex;
  169. align-items: center;
  170. height: 1.19rem;
  171. padding: 0 .15rem;
  172. }
  173. .popup .item::after {
  174. content: "";
  175. position: absolute;
  176. right: .15rem;
  177. bottom: 0;
  178. left: .15rem;
  179. z-index: 2;
  180. height: 1px;
  181. border-bottom: 1px solid #CCCCCC;
  182. }
  183. .popup .item .iconfont {
  184. font-size: .4rem;
  185. }
  186. .popup .item input {
  187. flex: 1;
  188. min-width: 0;
  189. margin-left: .25rem;
  190. }
  191. .popup .item:nth-child(2) {
  192. padding-right: 0;
  193. }
  194. .popup .item:nth-child(2) label {
  195. flex: 1;
  196. display: flex;
  197. align-items: center;
  198. min-width: 0;
  199. }
  200. .popup .item button {
  201. width: 2rem;
  202. font-size: .26rem;
  203. color: #191C6E;
  204. }
  205. .popup > div > button {
  206. width: 100%;
  207. height: .86rem;
  208. border-radius: .43rem;
  209. margin-top: .5rem;
  210. background: #191C6E;
  211. font-size: .3rem;
  212. color: #FFFFFF;
  213. }
  214. </style>
  215. {/block}
  216. {block name="content"}
  217. <div v-cloak id="app">
  218. <div class="user-info">
  219. <label class="avatar">
  220. <div class="name">头像</div>
  221. <div class="image">
  222. <img class="img" :src="userInfo.avatar">
  223. </div>
  224. <div class="iconfont iconxiangyou"></div>
  225. <input ref="avatar" class="input" type="file" accept="image/png,image/jpeg">
  226. </label>
  227. <div class="list">
  228. <label class="item">
  229. <span class="name">ID</span>
  230. <input v-model="userInfo.uid" class="value input" type="text" disabled>
  231. </label>
  232. <label class="item">
  233. <span class="name">昵称</span>
  234. <input v-model="userInfo.nickname" class="value input" type="text">
  235. </label>
  236. <label class="item">
  237. <span class="name">姓名</span>
  238. <input v-model="userInfo.realname" class="value input" type="text">
  239. </label>
  240. <a v-if="userInfo.phone" class="item" href="{:Url('save_phone')}">
  241. <span class="name">手机号</span>
  242. <span class="value">{{ userInfo.phone }}</span>
  243. <span class="iconfont iconxiangyou"></span>
  244. </a>
  245. <div v-if="userInfo.phone" class="item password" @click="popupShow = true">
  246. <div>密码</div>
  247. <div>******</div>
  248. </div>
  249. <label class="item">
  250. <span class="name">备注</span>
  251. <input v-model="userInfo.comment" class="value input" type="text">
  252. </label>
  253. </div>
  254. <div class="btn-group">
  255. <button class="btn" type="button" @click="save_user_info">保存修改</button>
  256. <button v-if="!isWechat && phone" class="btn out-btn" type="button" @click="logout">退出登录</button>
  257. </div>
  258. </div>
  259. <div :class="{ mask: popupShow }" @click="popupShow = false"></div>
  260. <div :class="{ on: popupShow }" class="popup">
  261. <a href="javascript:" @click="popupShow = false">
  262. <i class="iconfont iconguanbi"></i>
  263. </a>
  264. <div>修改密码</div>
  265. <div>
  266. <label class="item">
  267. <i class="iconfont iconshouji"></i>
  268. <input :value="userInfo.phone" type="text" readonly>
  269. </label>
  270. <div class="item">
  271. <label>
  272. <i class="iconfont iconyanzhengma"></i>
  273. <input v-model.trim="code" type="text" placeholder="请填写验证码">
  274. </label>
  275. <button :disabled="count >= 0" type="button" @click="getCode">{{ count < 0 ? '获取验证码' : '重新获取(' + count + 's)' }}</button>
  276. </div>
  277. <label class="item">
  278. <i class="iconfont iconmima"></i>
  279. <input v-model.trim="pwd" type="password" placeholder="请填写8-16位字母加数字组合密码">
  280. </label>
  281. <button type="button" @click="submitPassword">确认</button>
  282. </div>
  283. </div>
  284. <quick-menu></quick-menu>
  285. </div>
  286. {/block}
  287. {block name='foot'}
  288. <script>
  289. var userInfo = {:json_encode($userInfo)}, isWechat = {$isWechat? 'true': 'false'}, phone = '{$phone}';
  290. require(['vue', 'helper', 'store', 'layer', '{__WAP_PATH}zsff/js/quick.js'], function (Vue, $h, app) {
  291. new Vue({
  292. el: '#app',
  293. data: {
  294. userInfo: userInfo,
  295. popupShow: false,
  296. count: -1,
  297. COUNT_TIME: 60,
  298. code: '',
  299. pwd: '',
  300. isWechat: isWechat,
  301. phone: phone
  302. },
  303. watch: {
  304. 'userInfo.nickname': function (n) {
  305. document.title = n + ' - 个人资料';
  306. }
  307. },
  308. mounted: function () {
  309. var that = this;
  310. $(this.$refs.avatar).change(function (e) {
  311. var formdata = new FormData();
  312. if (e.target.files[0]) {
  313. formdata.append('file', e.target.files[0]);
  314. app.basePost($h.U({ c: 'auth_api', a: 'upload' }), formdata, function (res) {
  315. that.userInfo.avatar = res.data.data.url;
  316. })
  317. }
  318. })
  319. },
  320. methods: {
  321. upload: function () {
  322. var that = this;
  323. if (!isWechat) {
  324. return;
  325. }
  326. mapleWx($jssdk(), function () {
  327. app.wechatUploadImg(this, 1, function (res) {
  328. that.userInfo.avatar = res[0];
  329. });
  330. });
  331. },
  332. save_user_info: function () {
  333. var that = this;
  334. app.basePost($h.U({ c: 'my', a: 'save_user_info' }), {
  335. avatar: that.userInfo.avatar,
  336. nickname: that.userInfo.nickname,
  337. realname: that.userInfo.realname,
  338. comment: that.userInfo.comment,
  339. }, function (res) {
  340. $h.pushMsgOnce(res.data.msg)
  341. })
  342. },
  343. getCode: function () {
  344. var vm = this;
  345. vm.count = vm.COUNT_TIME;
  346. vm.timer = setInterval(function () {
  347. vm.count--;
  348. if (vm.count < 0) {
  349. clearInterval(vm.timer);
  350. vm.timer = null;
  351. }
  352. }, 1000);
  353. app.baseGet($h.U({
  354. c: 'auth_api',
  355. a: 'code',
  356. p: {
  357. phone: vm.userInfo.phone
  358. }
  359. }), function (res) {
  360. $h.pushMsg(res.data.msg);
  361. }, function (err) {
  362. $h.pushMsg(err.data.msg, function () {
  363. clearInterval(vm.timer);
  364. vm.timer = null;
  365. vm.count = -1;
  366. });
  367. });
  368. },
  369. // 点击密码弹窗确认按钮
  370. submitPassword: function () {
  371. var vm = this;
  372. if (!vm.code) {
  373. $h.pushMsg('请填写验证码');
  374. return;
  375. }
  376. if (!vm.pwd) {
  377. $h.pushMsg('请填写新密码');
  378. return;
  379. }
  380. if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/.test(vm.pwd)) {
  381. $h.pushMsg('请填写8-16位字母加数字组合密码');
  382. return;
  383. }
  384. app.basePost($h.U({
  385. c: 'login',
  386. a: 'register'
  387. }), {
  388. account: vm.userInfo.phone,
  389. pwd: hex_md5(vm.pwd),
  390. code: vm.code,
  391. type: 2
  392. }, function () {
  393. vm.popupShow = false;
  394. vm.code = '';
  395. vm.pwd = '';
  396. layer.alert('密码修改成功!<br>请确定去个人中心重新登陆。', {
  397. title: false,
  398. closeBtn: false
  399. }, function (index) {
  400. app.baseGet($h.U({
  401. c: 'my',
  402. a: 'logout'
  403. }), function () {
  404. window.location.replace($h.U({
  405. c: 'my',
  406. a: 'index'
  407. }));
  408. });
  409. layer.close(index);
  410. });
  411. }, function () {
  412. vm.count = -1;
  413. });
  414. },
  415. // 退出登录
  416. logout: function () {
  417. layer.confirm('确定退出登录?', {
  418. title: false,
  419. closeBtn: false
  420. }, function () {
  421. app.baseGet($h.U({
  422. c: 'my',
  423. a: 'logout'
  424. }), function (res) {
  425. layer.msg(res.data.msg, {
  426. anim: 0
  427. },function () {
  428. window.history.back();
  429. });
  430. });
  431. });
  432. }
  433. }
  434. });
  435. })
  436. </script>
  437. {/block}