index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view class="user-info-wrap">
  3. <view class="nav-bar">
  4. <view class="nav-content">
  5. <view class="nav-info">
  6. <view class="nav-desc">
  7. <view class="nav-name">
  8. <view class="">头像</view>
  9. </view>
  10. </view>
  11. <view @click="uploadImg1(1)" class="arrow-right">
  12. <view class="head-img">
  13. <image :src="userInfo.facePhotoUrl || '/static/me/ud4.png'" mode="aspectFill"></image>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="custom-line"></view>
  19. <view class="cotent-from">
  20. <u--form
  21. labelPosition="left"
  22. :model="userInfo"
  23. :rules="rules"
  24. ref="form1"
  25. >
  26. <u-form-item
  27. label="昵称"
  28. prop="nickName"
  29. labelWidth="auto"
  30. labelAlign="right"
  31. >
  32. <u--input
  33. v-model="userInfo.nickName"
  34. placeholder="请输入昵称"
  35. border="bottom"
  36. maxlength="20"
  37. type="text"
  38. ></u--input>
  39. </u-form-item>
  40. <u-form-item
  41. labelWidth="auto"
  42. labelAlign="right"
  43. label="关系"
  44. prop="blood"
  45. width="120"
  46. >
  47. <u--input
  48. maxlength="20"
  49. v-model="userInfo.blood"
  50. placeholder="请输入关系"
  51. border="bottom"
  52. type="text"
  53. ></u--input>
  54. </u-form-item>
  55. <u-form-item
  56. labelWidth="auto"
  57. labelAlign="right"
  58. label="备注"
  59. prop="remark"
  60. width="120"
  61. >
  62. <u--input
  63. maxlength="20"
  64. v-model="userInfo.remark"
  65. placeholder="请输入备注"
  66. border="bottom"
  67. type="text"
  68. ></u--input>
  69. </u-form-item>
  70. </u--form>
  71. </view>
  72. </view>
  73. <view @click="saveUserInfo()" class="sure-btn">
  74. <view class="btn">确认</view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. requestStatus:false,
  83. userInfo: {
  84. auth: true,
  85. nickName: '',
  86. facePhoto: '',
  87. blood: '',
  88. remark: '',
  89. id: ''
  90. },
  91. genderShow: false,
  92. value1: '2023-12-12',
  93. imgUrl1: '',
  94. rules:[]
  95. };
  96. },
  97. mounted() {
  98. },
  99. onShow(){
  100. if (this.userInfo.facePhoto){
  101. this.getImgUrlByOssId(this.userInfo.facePhoto)
  102. }
  103. },
  104. onLoad(option) {
  105. console.log('++++++++++++++++option+++++++++++++++',option)
  106. if(option.data){
  107. this.userInfo = JSON.parse(option.data);
  108. if (this.userInfo.facePhoto){
  109. this.getImgUrlByOssId(this.userInfo.facePhoto)
  110. }
  111. }
  112. },
  113. methods: {
  114. getImgUrlByOssId(Id){
  115. if (Id) {
  116. this.$api.getImage(Id).then(res=>{
  117. this.userInfo.facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  118. this.$set(this.userInfo)
  119. });
  120. }
  121. },
  122. // 保存用户信息
  123. saveUserInfo(){
  124. if(!this.userInfo.nickName){
  125. uni.showToast({
  126. title: "请填写昵称"
  127. })
  128. return;
  129. }
  130. if(!this.userInfo.blood){
  131. uni.showToast({
  132. title: "请填写关系"
  133. })
  134. return;
  135. }
  136. if(this.requestStatus){
  137. return;
  138. }
  139. this.requestStatus=true
  140. this.userInfo.auth = true;
  141. if(this.userInfo.opType == '1'){ // 绑定
  142. // 保存数据
  143. this.$api.bindServiceObject(this.userInfo).then((res)=>{
  144. if (res.data.code === 500){
  145. uni.showToast({
  146. title: res.data.msg
  147. })
  148. }else {
  149. uni.showToast({
  150. title: "绑定成功"
  151. })
  152. }
  153. // 去服务对象列表页
  154. setTimeout(()=>{
  155. this.requestStatus=false
  156. uni.redirectTo({
  157. url: '/myPages/ServiceObjectManagement/index',
  158. })
  159. },3000)
  160. }).catch(()=>{
  161. this.requestStatus=false
  162. })
  163. }else if(this.userInfo.opType == '2'){ // 修改
  164. // 修改数据
  165. this.$api.updateServiceObject(this.userInfo).then((res)=>{
  166. uni.showToast({
  167. title: "修改成功"
  168. })
  169. // 去服务对象列表页
  170. setTimeout(()=>{
  171. this.requestStatus=false
  172. uni.redirectTo({
  173. url: '/myPages/ServiceObjectManagement/index',
  174. })
  175. },3000)
  176. }).catch(()=>{
  177. this.requestStatus=false
  178. })
  179. }
  180. },
  181. //头像上传
  182. uploadImg1(imgIndex) {
  183. return //关闭头像上传
  184. let that = this;
  185. uni.chooseImage({
  186. count: 1,
  187. success: (chooseImageRes) => {
  188. const tempFilePaths = chooseImageRes.tempFilePaths;
  189. uni.uploadFile({
  190. url: that.$baseUrl + '/resource/oss/upload', //仅为示例,非真实的接口地址
  191. filePath: tempFilePaths[0],
  192. name: 'file',
  193. header: {
  194. 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
  195. },
  196. success: (uploadFileRes) => {
  197. console.log('uploadFileRes=>',uploadFileRes)
  198. let res = JSON.parse(uploadFileRes.data)
  199. that.userInfo.facePhotoUrl = res.data.url.replace(/^http:/, "https:");
  200. that.userInfo.facePhoto = res.data.ossId
  201. }
  202. });
  203. }
  204. });
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss">
  210. .user-info-wrap{
  211. margin-left: 12px;
  212. margin-right: 12px;
  213. /* 导航菜单 */
  214. .nav-bar{
  215. background: #fff;
  216. border-radius: 10px;
  217. margin-top: 12px;
  218. .cotent-from{
  219. padding-right: 12px;
  220. padding-left: 12px;
  221. }
  222. /* 商店信息 */
  223. .nav-content{
  224. padding-right: 6px;
  225. padding-top: 10px;
  226. padding-bottom: 6px;
  227. .nav-info{
  228. display: flex;
  229. justify-content: space-between;
  230. padding-left: 10px;
  231. align-items: center;
  232. .logo {
  233. width: 12%;
  234. text-align: center;
  235. image{
  236. width: 24px;
  237. height: 24px;
  238. }
  239. }
  240. .nav-desc{
  241. width: 46%;
  242. display: flex;
  243. line-height: 30px;
  244. font-family: PingFangSC-Regular, PingFang SC;
  245. font-weight: 400;
  246. align-items: center;
  247. .custom-input{
  248. font-size: 12px;
  249. }
  250. .nav-name{
  251. width: 60%;
  252. font-size: 14px;
  253. color: #333333;
  254. line-height: 22px;
  255. }
  256. .change-store{
  257. text-align: right;
  258. width: 40%;
  259. font-size: 12px;
  260. color: #333333;
  261. line-height: 22px;
  262. }
  263. }
  264. .arrow-right{
  265. width: 50px;
  266. height: 50px;
  267. display: flex;
  268. justify-content: flex-end;
  269. .head-img {
  270. width: 50px;
  271. height: 50px;
  272. border-radius: 25px;
  273. image{
  274. width: 50px;
  275. height: 50px;
  276. border-radius: 25px;
  277. }
  278. }
  279. .change-store{
  280. font-size: 14px;
  281. color: #999;
  282. line-height: 22px;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .sure-btn{
  289. margin-top: 20px;
  290. width: 100%;
  291. .btn{
  292. text-align: center;
  293. height: 42px;
  294. background: #FFE05C;
  295. border-radius: 27px;
  296. color: #333333;
  297. line-height: 42px;
  298. margin-top: 12px;
  299. font-size: 14px;
  300. }
  301. }
  302. }
  303. </style>