user_info.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. {extend name="public/container"}
  2. {block name="title"}{$userInfo.nickname} - 个人资料{/block}
  3. {block name="head_top"}
  4. <style>
  5. body{
  6. background-color: #f5f5f5;
  7. }
  8. .user-info .avatar {
  9. display: -webkit-box;
  10. display: -webkit-flex;
  11. display: flex;
  12. -webkit-box-align: center;
  13. -webkit-align-items: center;
  14. align-items: center;
  15. padding: .3rem;
  16. background-color: #fff;
  17. }
  18. .user-info .avatar .name {
  19. -webkit-box-flex: 1;
  20. -webkit-flex: 1;
  21. flex: 1;
  22. font-weight: 500;
  23. font-size: .3rem;
  24. color: #333;
  25. }
  26. .user-info .avatar .image {
  27. width: .9rem;
  28. height: .9rem;
  29. border-radius: 50%;
  30. overflow: hidden;
  31. }
  32. .user-info .avatar .img {
  33. display: block;
  34. width: 100%;
  35. height: 100%;
  36. object-fit: cover;
  37. }
  38. .user-info .avatar .knowledge {
  39. margin-left: .3rem;
  40. font-size: .24rem;
  41. color: #999;
  42. }
  43. .user-info .avatar .input {
  44. display: none;
  45. }
  46. .user-info .list {
  47. margin-top: .3rem;
  48. background-color: #fff;
  49. }
  50. .user-info .list .item {
  51. display: -webkit-box;
  52. display: -webkit-flex;
  53. display: flex;
  54. -webkit-box-align: center;
  55. -webkit-align-items: center;
  56. align-items: center;
  57. height: .98rem;
  58. padding-right: .3rem;
  59. padding-left: .3rem;
  60. }
  61. .user-info .list .item~.item{
  62. border-top: 1px solid #f5f5f5;
  63. }
  64. .user-info .list .item .name {
  65. -webkit-box-flex: 1;
  66. -webkit-flex: 1;
  67. flex: 1;
  68. font-weight: 500;
  69. font-size: .3rem;
  70. color: #333;
  71. }
  72. .user-info .list .item .value {
  73. font-size: .3rem;
  74. color: #666;
  75. }
  76. .user-info .list .item .knowledge{
  77. margin-left: .3rem;
  78. font-size: .24rem;
  79. color: #999;
  80. }
  81. .user-info .list .item .input {
  82. font-family: inherit;
  83. text-align: right;
  84. }
  85. .user-info .group{
  86. padding: .3rem;
  87. margin-top: .5rem;
  88. }
  89. .user-info .group .button {
  90. display: block;
  91. width: 100%;
  92. height: .86rem;
  93. border-radius: .43rem;
  94. background-color: #539dfd;
  95. font-weight: 500;
  96. font-size: .3rem;
  97. color: #fff;
  98. }
  99. .user-info .group .link {
  100. display: block;
  101. width: 100%;
  102. height: .86rem;
  103. border: 1px solid #ccc;
  104. border-radius: .43rem;
  105. margin-top: .3rem;
  106. font-weight: 500;
  107. font-size: .3rem;
  108. line-height: .82rem;
  109. text-align: center;
  110. color: #999;
  111. }
  112. </style>
  113. {/block}
  114. {block name="content"}
  115. <div v-cloak id="app">
  116. <div class="user-info">
  117. <label class="avatar">
  118. <div class="name">头像</div>
  119. <div class="image">
  120. <img class="img" :src="userInfo.avatar">
  121. </div>
  122. <div class="knowledge iconxiangyou"></div>
  123. <input ref="avatar" class="input" type="file" accept="image/*">
  124. </label>
  125. <div class="list">
  126. <label class="item">
  127. <span class="name">昵称</span>
  128. <input v-model="userInfo.nickname" class="value input" type="text">
  129. </label>
  130. <a class="item" href="{:Url('save_phone')}">
  131. <span class="name">手机号</span>
  132. <span class="value">{{ userInfo.phone }}</span>
  133. <span class="knowledge iconxiangyou"></span>
  134. </a>
  135. </div>
  136. <div class="group">
  137. <button class="button" type="button" @click="save_user_info">保存</button>
  138. <a class="link" href="/wap/my/index.html">返回</a>
  139. </div>
  140. </div>
  141. <shortcut></shortcut>
  142. </div>
  143. {/block}
  144. {block name='foot'}
  145. <script>
  146. var userInfo = {:json_encode($userInfo)}, isWechat = {$isWechat? 'true': 'false'};
  147. require(['vue', 'helper', 'store', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, $h, app) {
  148. new Vue({
  149. el: '#app',
  150. data: {
  151. userInfo: userInfo
  152. },
  153. watch: {
  154. 'userInfo.nickname': function (n) {
  155. document.title = n + ' - 个人资料';
  156. }
  157. },
  158. mounted: function () {
  159. var that = this;
  160. $(this.$refs.avatar).change(function (e) {
  161. var formdata = new FormData();
  162. if (e.target.files[0]) {
  163. formdata.append('file', e.target.files[0]);
  164. app.basePost($h.U({ c: 'index', a: 'upload' }), formdata, function (res) {
  165. that.userInfo.avatar = res.data.data.url;
  166. })
  167. }
  168. })
  169. },
  170. methods: {
  171. upload: function () {
  172. var that = this;
  173. if (!isWechat) {
  174. return;
  175. }
  176. mapleWx($jssdk(), function () {
  177. app.wechatUploadImg(this, 1, function (res) {
  178. that.userInfo.avatar = res[0];
  179. });
  180. });
  181. },
  182. save_user_info: function () {
  183. var that = this;
  184. app.basePost($h.U({ c: 'my', a: 'save_user_info' }), {
  185. avatar: that.userInfo.avatar,
  186. nickname: that.userInfo.nickname
  187. }, function (res) {
  188. $h.pushMsgOnce(res.data.msg)
  189. })
  190. }
  191. }
  192. });
  193. })
  194. </script>
  195. {/block}