人民医院前端

c-userinfo.vue 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="container">
  3. <view class="ui-all">
  4. <view class="avatar" @tap="avatarChoose">
  5. <text v-if="avater">修改头像</text>
  6. <view class="imgAvatar">
  7. <view class="iavatar" :style="'background: url('+avater+') no-repeat center/cover #eeeeee;'"></view>
  8. </view>
  9. </view>
  10. <view class="ui-list">
  11. <text>姓名</text>
  12. <input type="text" :placeholder="value" :value="nickName" @input="bindnickName" placeholder-class="place" />
  13. </view>
  14. <view class="ui-list right">
  15. <text>性别</text>
  16. <picker @change="bindPickerChange" mode='selector' range-key="name" :value="index" :range="sex">
  17. <view class="picker">
  18. {{sex[index].name}}
  19. </view>
  20. </picker>
  21. </view>
  22. <view class="ui-list right">
  23. <text>单位</text>
  24. <picker @change="bindRegionChange">
  25. <view class="picker">
  26. {{region[0]}} {{region[1]}} {{region[2]}}
  27. </view>
  28. </picker>
  29. </view>
  30. <view class="ui-list right">
  31. <text>部门</text>
  32. <picker mode="date" :value="date" @change="bindDateChange">
  33. <view class="picker">
  34. {{date}}
  35. </view>
  36. </picker>
  37. </view>
  38. <view class="ui-list">
  39. <text>职务</text>
  40. <input type="text" :placeholder="value" :value="nickName" @input="bindnickName" placeholder-class="place" />
  41. </view>
  42. <view class="ui-list">
  43. <text>手机号</text>
  44. <input type="text" :placeholder="value" :value="nickName" @input="bindnickName" placeholder-class="place" />
  45. </view>
  46. <view class="ui-list">
  47. <text>签名</text>
  48. <textarea :placeholder="value" placeholder-class="place" :value="description" @input="binddescription"></textarea>
  49. </view>
  50. <button class="save" @tap="savaInfo">保 存 修 改</button>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. value: '请填写',
  59. sex: [{
  60. id: 1,
  61. name: '男'
  62. }, {
  63. id: 2,
  64. name: '女'
  65. }],
  66. index: 0,
  67. region: ['请填写'],
  68. date: '请填写',
  69. avater: '/static/person.png',
  70. description: '',
  71. url: '',
  72. nickName: '',
  73. mobile: '',
  74. headimg: ''
  75. }
  76. },
  77. methods: {
  78. bindPickerChange(e) {
  79. this.index = e.detail.value;
  80. },
  81. bindRegionChange(e) {
  82. this.region = e.detail.value;
  83. },
  84. bindDateChange(e) {
  85. this.date = e.detail.value;
  86. },
  87. bindnickName(e) {
  88. this.nickName = e.detail.value;
  89. },
  90. bindmobile(e) {
  91. this.mobile = e.detail.value;
  92. },
  93. binddescription(e) {
  94. this.description = e.detail.value;
  95. },
  96. avatarChoose() {
  97. let that = this;
  98. uni.chooseImage({
  99. count: 1,
  100. sizeType: ['original', 'compressed'],
  101. sourceType: ['album', 'camera'],
  102. success(res) {
  103. // tempFilePath可以作为img标签的src属性显示图片
  104. that.imgUpload(res.tempFilePaths);
  105. const tempFilePaths = res.tempFilePaths;
  106. }
  107. });
  108. },
  109. getUserInfo () {
  110. uni.getUserProfile({
  111. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  112. success: (res) => {
  113. console.log(res);
  114. uni.showToast({
  115. title: '已授权',
  116. icon: 'none',
  117. duration: 2000
  118. })
  119. }
  120. })
  121. } ,
  122. getphonenumber(e){
  123. if(e.detail.iv){
  124. console.log(e.detail.iv) //传后台解密换取手机号
  125. uni.showToast({
  126. title: '已授权',
  127. icon: 'none',
  128. duration: 2000
  129. })
  130. }
  131. },
  132. savaInfo() {
  133. let that = this;
  134. let nickname = that.nickName;
  135. let headimg = that.headimg;
  136. let gender = that.index + 1;
  137. let mobile = that.mobile;
  138. let region = that.region;
  139. let birthday = that.date;
  140. let description = that.description;
  141. let updata = {};
  142. if (!nickname) {
  143. uni.showToast({
  144. title: '请填写昵称',
  145. icon: 'none',
  146. duration: 2000
  147. });
  148. return;
  149. }
  150. updata.nickname = nickname;
  151. if (!headimg) {
  152. headimg = that.avater;
  153. }
  154. updata.headimg = headimg;
  155. updata.gender = gender;
  156. if (that.isPoneAvailable(mobile)) {
  157. updata.mobile = mobile;
  158. } else {
  159. uni.showToast({
  160. title: '手机号码有误,请重填',
  161. icon: 'none',
  162. duration: 2000
  163. });
  164. return;
  165. }
  166. if (region.length == 1) {
  167. uni.showToast({
  168. title: '请选择常住地',
  169. icon: 'none',
  170. duration: 2000
  171. });
  172. return;
  173. } else {
  174. updata.province = region[0];
  175. updata.city = region[1];
  176. updata.area = region[2];
  177. }
  178. if (birthday == "0000-00-00") {
  179. uni.showToast({
  180. title: '请选择生日',
  181. icon: 'none',
  182. duration: 2000
  183. });
  184. return;
  185. }
  186. updata.birthday = birthday;
  187. updata.description = description;
  188. that.updata(updata);
  189. },
  190. isPoneAvailable(poneInput) {
  191. var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
  192. if (!myreg.test(poneInput)) {
  193. return false;
  194. } else {
  195. return true;
  196. }
  197. },
  198. async updata(datas) {
  199. //传后台
  200. },
  201. imgUpload(file) {
  202. let that = this;
  203. uni.uploadFile({
  204. header: {
  205. Authorization: uni.getStorageSync('token')
  206. },
  207. url:'/api/upload/image', //需传后台图片上传接口
  208. filePath: file[0],
  209. name: 'file',
  210. formData: {
  211. type: 'user_headimg'
  212. },
  213. success: function(res) {
  214. var data = JSON.parse(res.data);
  215. data = data.data;
  216. that.avater = that.url + data.img;
  217. that.headimg = that.url + data.img;
  218. },
  219. fail: function(error) {
  220. console.log(error);
  221. }
  222. });
  223. },
  224. },
  225. onLoad() {
  226. }
  227. }
  228. </script>
  229. <style lang="less">
  230. .container {
  231. background: #ffffff;
  232. display: block;
  233. }
  234. .ui-all {
  235. padding: 20rpx 40rpx;
  236. .avatar {
  237. width: 100%;
  238. text-align: left;
  239. padding: 20rpx 0;
  240. border-bottom: solid 1px #f2f2f2;
  241. position: relative;
  242. .imgAvatar {
  243. width: 140rpx;
  244. height: 140rpx;
  245. border-radius: 50%;
  246. display: inline-block;
  247. vertical-align: middle;
  248. overflow: hidden;
  249. .iavatar {
  250. width: 100%;
  251. height: 100%;
  252. display: block;
  253. }
  254. }
  255. text {
  256. display: inline-block;
  257. vertical-align: middle;
  258. color: #8e8e93;
  259. font-size: 28rpx;
  260. margin-left: 40rpx;
  261. }
  262. &:after {
  263. content: ' ';
  264. width: 20rpx;
  265. height: 20rpx;
  266. border-top: solid 1px #030303;
  267. border-right: solid 1px #030303;
  268. transform: rotate(45deg);
  269. -ms-transform: rotate(45deg);
  270. /* IE 9 */
  271. -moz-transform: rotate(45deg);
  272. /* Firefox */
  273. -webkit-transform: rotate(45deg);
  274. /* Safari 和 Chrome */
  275. -o-transform: rotate(45deg);
  276. position: absolute;
  277. top: 85rpx;
  278. right: 0;
  279. }
  280. }
  281. .ui-list {
  282. width: 100%;
  283. text-align: left;
  284. padding: 20rpx 0;
  285. border-bottom: solid 1px #f2f2f2;
  286. position: relative;
  287. text {
  288. color: #4a4a4a;
  289. font-size: 28rpx;
  290. display: inline-block;
  291. vertical-align: middle;
  292. min-width: 150rpx;
  293. }
  294. input {
  295. color: #030303;
  296. font-size: 30rpx;
  297. display: inline-block;
  298. vertical-align: middle;
  299. }
  300. button{
  301. color: #030303;
  302. font-size: 30rpx;
  303. display: inline-block;
  304. vertical-align: middle;
  305. background: none;
  306. margin: 0;
  307. padding: 0;
  308. &::after{
  309. display: none;
  310. }
  311. }
  312. picker {
  313. width: 90%;
  314. color: #030303;
  315. font-size: 30rpx;
  316. display: inline-block;
  317. vertical-align: middle;
  318. position: absolute;
  319. top: 30rpx;
  320. left: 150rpx;
  321. }
  322. textarea {
  323. color: #030303;
  324. font-size: 30rpx;
  325. vertical-align: middle;
  326. height: 150rpx;
  327. width: 100%;
  328. margin-top: 50rpx;
  329. }
  330. .place {
  331. color: #999999;
  332. font-size: 28rpx;
  333. }
  334. }
  335. .right:after {
  336. content: ' ';
  337. width: 20rpx;
  338. height: 20rpx;
  339. border-top: solid 1px #030303;
  340. border-right: solid 1px #030303;
  341. transform: rotate(45deg);
  342. -ms-transform: rotate(45deg);
  343. /* IE 9 */
  344. -moz-transform: rotate(45deg);
  345. /* Firefox */
  346. -webkit-transform: rotate(45deg);
  347. /* Safari 和 Chrome */
  348. -o-transform: rotate(45deg);
  349. position: absolute;
  350. top: 40rpx;
  351. right: 0;
  352. }
  353. .save {
  354. background: #030303;
  355. border: none;
  356. color: #ffffff;
  357. margin-top: 40rpx;
  358. font-size: 28rpx;
  359. }
  360. }
  361. </style>