grzl.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="container">
  3. <view class="list-cell b-b avatar" hover-class="cell-hover" :hover-stay-time="50" @click="clk(0)">
  4. <text class="cell-tit">头像</text>
  5. <image :src="urls" mode="aspectFill"></image>
  6. <!-- <image mode="aspectFit" style="width: 30upx; height: 30upx; margin-left: 10upx;" :src="staticUrl + 'fh2.png'"> -->
  7. </view>
  8. <view class="list-cell" @click="navTo('../../set/grzl/nc/nc?ty=nickname&name=呢称&v='+listgrzl.nickname)" hover-class="cell-hover" :hover-stay-time="50">
  9. <text class="cell-tit">真实姓名</text>
  10. <text class="cell-tip">{{listgrzl.nickname}}</text>
  11. <image mode="aspectFit" style="width: 30upx; height: 30upx; margin-left: 10upx;" :src="staticUrl + 'fh2.png'">
  12. </view>
  13. <view class="list-cell m-t b-b" @tap="sex" hover-class="cell-hover" :hover-stay-time="50">
  14. <text class="cell-tit">性别</text>
  15. <text class="cell-tip">{{sexType}}</text>
  16. <image mode="aspectFit" style="width: 30upx; height: 30upx; margin-left: 10upx;" :src="staticUrl + 'fh2.png'">
  17. </view>
  18. <view class="list-cell" @click="navTo('../../set/grzl/nc/nc?ty=org&name=生日&v='+listgrzl.birthday)" hover-class="cell-hover" :hover-stay-time="50">
  19. <text class="cell-tit">生日</text>
  20. <text class="cell-tip">{{listgrzl.birthday}}</text>
  21. <image mode="aspectFit" style="width: 30upx; height: 30upx; margin-left: 10upx;" :src="staticUrl + 'fh2.png'">
  22. </view>
  23. <view class="list-cell">
  24. <text class="cell-tit">手机号</text>
  25. <text class="cell-tip">{{listgrzl.mobile}}</text>
  26. </view>
  27. <!--
  28. <view class="list-cell b-b" @click="navTo('../../set/grzl/nc/nc?ty=sg&name=身高&v='+listgrzl.sg)">
  29. <text class="cell-tit">身份证号</text>
  30. <text class="cell-tip">{{listgrzl.sg}}</text>
  31. <image mode="aspectFit" style="width: 30upx; height: 30upx;" :src="staticUrl + 'fh2.png'">
  32. </view> -->
  33. <avatar @upload="doUpload" @avtinit="doBefore" quality="1" ref="avatar"></avatar>
  34. </view>
  35. </template>
  36. <script>
  37. import avatar from "../../../components/yq-avatar/yq-avatar.vue";
  38. let sex = ['女', '男'];
  39. import { mapMutations} from 'vuex';
  40. export default {
  41. data() {
  42. return {
  43. urls:'',
  44. sexsi:'',
  45. array: [],
  46. ageid: 0,
  47. listgrzl:[],
  48. msg:false,
  49. staticUrl:this.$config.staticUrl,
  50. imgUrl:this.configs.imgUrl
  51. };
  52. },
  53. computed: {
  54. sexType() {
  55. return sex[this.sexsi];
  56. },
  57. },
  58. onShow(){
  59. this.ongrzlTap();
  60. if(this.msg){
  61. uni.showToast({ title: '保存成功',icon:"none" });
  62. this.msg=false;
  63. }
  64. },
  65. methods:{
  66. ...mapMutations(['logout']),
  67. ...mapMutations(['login']),
  68. //跳转
  69. async ongrzlTap(){
  70. let _this=this;
  71. let [err,res] = await this.$httpas.get('/api/user/index',{},{token:true});
  72. if (!this.$httpas.errorCheck(err,res)) return;
  73. if(res.data.code === 1){
  74. this.listgrzl=res.data.data;
  75. this.sexsi=res.data.data.gender;
  76. var str = res.data.data.avatar;
  77. if(str.indexOf("http") != -1){
  78. this.urls=res.data.data.avatar;
  79. }else{
  80. this.urls=this.configs.imgUrl+res.data.data.avatar;
  81. }
  82. }else{
  83. uni.showToast({title:res.data.msg})
  84. this.logining = false;
  85. }
  86. },
  87. navTo(url){
  88. uni.navigateTo({
  89. url:url,
  90. animationType: 'slide-in-bottom',
  91. })
  92. },
  93. navsTo(url){
  94. uni.navigateTo({
  95. url:url
  96. })
  97. },
  98. //退出登录
  99. toLogout(){
  100. uni.showModal({
  101. content: '确定要退出登录么',
  102. success: (e)=>{
  103. if(e.confirm){
  104. uni.clearStorageSync();
  105. setTimeout(()=>{
  106. uni.navigateBack();
  107. }, 200)
  108. }
  109. }
  110. });
  111. },
  112. //选择性别
  113. sex() {
  114. uni.showActionSheet({
  115. itemList:sex,
  116. success: (res)=> {
  117. this.sexgender(res);
  118. }
  119. });
  120. },
  121. async sexgender(ress) {
  122. let _this=this;
  123. let [err,res] = await this.$httpas.post('/api/user/edituser',{sex:ress.tapIndex},{token:true});
  124. if (!this.$httpas.errorCheck(err,res)) return;
  125. if(res.data.code === 1){
  126. this.sexsi = ress.tapIndex,
  127. uni.showToast({
  128. title:"保存成功"
  129. })
  130. }else{
  131. uni.showToast({title:res.data.msg})
  132. this.logining = false;
  133. }
  134. },
  135. doBefore() {
  136. console.log('doBefore');
  137. },
  138. clk(index) {
  139. this.$refs.avatar.fChooseImg(index,{
  140. selWidth: '350upx', selHeight: '350upx',
  141. expWidth: '400upx', expHeight: '400upx',
  142. inner: index ? 'true' : 'false',
  143. canRotate:false,
  144. quality:1,
  145. });
  146. },
  147. doUpload(rsp) {
  148. uni.showLoading({
  149. title: '加载中'
  150. });
  151. uni.uploadFile({
  152. url: this.configs.webUrl+'/api/user/avatar?token='+uni.getStorageSync("userinfo").token, //仅为示例,非真实的接口地址
  153. filePath: rsp.path,
  154. name: "file",
  155. dataType:"json",
  156. formData: {
  157. 'token': uni.getStorageSync("userinfo").token,
  158. 'uid': uni.getStorageSync("userinfo").id,
  159. // #ifdef H5
  160. 'base64':rsp.base64, //h5上传base64
  161. // #endif
  162. },
  163. success: (uploadFileRes) => {
  164. var dataarr=JSON.parse(uploadFileRes.data);
  165. if(dataarr.code==1){
  166. console.log(dataarr.data.url)
  167. this.urls=this.configs.imgUrl+dataarr.data.url;
  168. uni.showToast({
  169. title:"修改成功"
  170. })
  171. }else{
  172. uni.showToast({
  173. title:dataarr.msg
  174. })
  175. }
  176. },
  177. complete(res) {
  178. uni.hideLoading();
  179. console.log(res)
  180. }
  181. });
  182. }
  183. },
  184. components: {
  185. avatar
  186. }
  187. }
  188. </script>
  189. <style lang='scss'>
  190. page{
  191. background: $page-color-base;
  192. }
  193. .yyt-ellipsis{
  194. display: inline-block;
  195. overflow:hidden; //超出的文本隐藏
  196. text-overflow:ellipsis; //溢出用省略号显示
  197. white-space:nowrap; //溢出不换
  198. }
  199. .avatar{
  200. padding-top: 40upx!important;
  201. padding-bottom: 40upx!important;
  202. }
  203. .agess{
  204. position: absolute;
  205. z-index: 2;
  206. top: 0px;
  207. right: 0px;
  208. height: 100%;
  209. line-height: 38px;
  210. padding-left: 200px;
  211. padding-right: 36px!important;
  212. background: transparent;
  213. }
  214. .avatar .cell-tit{
  215. font-weight: bold!important;
  216. }
  217. .avatar image{
  218. position: absolute;
  219. top: 50%;
  220. right: 36px;
  221. width: 88upx;
  222. height: 88upx;
  223. border-radius: 50%;
  224. margin-top: -44upx;
  225. z-index: 1
  226. }
  227. .list-cell{
  228. display:flex;
  229. align-items:baseline;
  230. padding: 20upx $page-row-spacing;
  231. line-height:60upx;
  232. position:relative;
  233. background: #fff;
  234. justify-content: center;
  235. align-items: center;
  236. &.log-out-btn{
  237. margin-top: 40upx;
  238. .cell-tit{
  239. color: $uni-color-primary;
  240. text-align: center;
  241. margin-right: 0;
  242. }
  243. }
  244. &.cell-hover{
  245. background:#fafafa;
  246. }
  247. &.b-b:after{
  248. left: 30upx;
  249. }
  250. &.m-t{
  251. margin-top: 16upx;
  252. }
  253. .cell-more{
  254. align-self: baseline;
  255. font-size:$font-lg;
  256. color:$font-color-light;
  257. margin-left:10upx;
  258. }
  259. .cell-tit{
  260. flex: 1;
  261. font-size: $font-base + 2upx;
  262. color: $font-color-dark;
  263. margin-right:10upx;
  264. }
  265. .cell-tip{
  266. font-size: $font-base;
  267. color: $font-color-light;
  268. }
  269. switch{
  270. transform: translateX(16upx) scale(.84);
  271. }
  272. }
  273. </style>